address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf1D89043e8a366429C7a30F07A2fb839Db253510
// SPDX-License-Identifier: MIT pragma solidity 0.6.6; // /* * @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; } } // /** * @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; } } enum RebaseResult { Double, Park, Draw } interface IPriceManager { function averagePrice() external returns (uint32); function lastAvgPrice() external view returns (uint32); function setTautrino(address _tautrino) external; } interface ITautrinoToken { function rebase(RebaseResult result) external returns (uint); function setGovernance(address _governance) external; } contract TautrinoGovernance is Ownable { event LogRebase(uint64 epoch, uint32 ethPrice, RebaseResult tauResult, uint tauTotalSupply, RebaseResult trinoResult, uint trinoTotalSupply); uint64 public constant REBASE_CYCLE = 1 hours; ITautrinoToken public tauToken; ITautrinoToken public trinoToken; IPriceManager public priceManager; RebaseResult private _lastTauRebaseResult; RebaseResult private _lastTrinoRebaseResult; uint64 private _nextRebaseEpoch; uint64 private _lastRebaseEpoch; uint64 public rebaseOffset = 3 minutes; /** * @dev Constructor. * @param _tauToken The address of TAU token. * @param _trinoToken The address of TRINO token. */ constructor(address _tauToken, address _trinoToken, uint64 _delay) public Ownable() { tauToken = ITautrinoToken(_tauToken); trinoToken = ITautrinoToken(_trinoToken); _nextRebaseEpoch = uint64(block.timestamp - block.timestamp % 3600) + REBASE_CYCLE + _delay; } /** * @dev Update rebase offset. * @param _rebaseOffset new rebase offset. */ function setRebaseOffset(uint64 _rebaseOffset) external onlyOwner { rebaseOffset = _rebaseOffset; } /** * @dev Rebase TAU and TRINO tokens. */ function rebase() external onlyOwner { require(_nextRebaseEpoch <= uint64(block.timestamp) + rebaseOffset, "Not ready to rebase!"); uint32 _ethPrice = priceManager.averagePrice(); uint32 _number = _ethPrice; uint8 _even = 0; uint8 _odd = 0; while (_number > 0) { if (_number % 2 == 1) { _odd += 1; } else { _even += 1; } _number /= 10; } if (_even > _odd) { // double balance _lastTauRebaseResult = RebaseResult.Double; _lastTrinoRebaseResult = RebaseResult.Park; } else if (_even < _odd) { // park balance _lastTauRebaseResult = RebaseResult.Park; _lastTrinoRebaseResult = RebaseResult.Double; } else { _lastTauRebaseResult = RebaseResult.Draw; _lastTrinoRebaseResult = RebaseResult.Draw; } _lastRebaseEpoch = uint64(block.timestamp); _nextRebaseEpoch = _nextRebaseEpoch + 1 hours; if (_nextRebaseEpoch <= _lastRebaseEpoch) { _nextRebaseEpoch = uint64(block.timestamp - block.timestamp % 3600) + REBASE_CYCLE; } uint _tauTotalSupply = tauToken.rebase(_lastTauRebaseResult); uint _trinoTotalSupply = trinoToken.rebase(_lastTrinoRebaseResult); emit LogRebase(_lastRebaseEpoch, _ethPrice, _lastTauRebaseResult, _tauTotalSupply, _lastTrinoRebaseResult, _trinoTotalSupply); } /** * @return Price of eth used for last rebasing. */ function lastAvgPrice() public view returns (uint32) { return priceManager.lastAvgPrice(); } /** * @return Next rebase epoch. */ function nextRebaseEpoch() public view returns (uint64) { return _nextRebaseEpoch; } /** * @return Last rebase epoch. */ function lastRebaseEpoch() public view returns (uint64) { return _lastRebaseEpoch; } /** * @return Last rebase result. */ function lastRebaseResult() public view returns (RebaseResult, RebaseResult) { return (_lastTauRebaseResult, _lastTrinoRebaseResult); } /** * @dev Migrate governance. * @param _newGovernance new TautrinoGovernance address. */ function migrateGovernance(address _newGovernance) external onlyOwner { require(_newGovernance != address(0), "invalid governance"); tauToken.setGovernance(_newGovernance); trinoToken.setGovernance(_newGovernance); if (address(priceManager) != address(0)) { priceManager.setTautrino(_newGovernance); } } /** * @dev Update price manager. * @param _priceManager The address of new price manager. */ function setPriceManager(address _priceManager) external onlyOwner { priceManager = IPriceManager(_priceManager); } }
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063a1e915a211610097578063c7e1ffe311610066578063c7e1ffe314610274578063d72adf661461027c578063ddf0183314610284578063f2fde38b1461028c57610100565b8063a1e915a214610235578063a87b3eaf1461023d578063af14052c14610245578063b7c73a711461024d57610100565b80637199efde116100d35780637199efde1461016f57806373e07d0d146101a25780638a285f47146101e35780638da5cb5b1461020457610100565b80633781b6af146101055780636ca6d9981461012a5780636cf9282f14610132578063715018a614610167575b600080fd5b61010d6102bf565b6040805167ffffffffffffffff9092168252519081900360200190f35b61010d6102cf565b6101656004803603602081101561014857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166102d5565b005b6101656103ad565b6101656004803603602081101561018557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166104ad565b6101aa610788565b604051808360028111156101ba57fe5b60ff1681526020018260028111156101ce57fe5b60ff1681526020019250505060405180910390f35b6101eb6107c6565b6040805163ffffffff9092168252519081900360200190f35b61020c610862565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61020c61087e565b61010d61089a565b6101656108c4565b6101656004803603602081101561026357600080fd5b503567ffffffffffffffff16610fc8565b61020c6110a0565b61010d6110bc565b61020c6110d8565b610165600480360360208110156102a257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166110f4565b60045467ffffffffffffffff1690565b610e1081565b6102dd61127e565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461036657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b6103b561127e565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461043e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6104b561127e565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461053e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166105c057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f696e76616c696420676f7665726e616e63650000000000000000000000000000604482015290519081900360640190fd5b600154604080517fab033ea900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529151919092169163ab033ea991602480830192600092919082900301818387803b15801561063457600080fd5b505af1158015610648573d6000803e3d6000fd5b5050600254604080517fab033ea900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152915191909216935063ab033ea99250602480830192600092919082900301818387803b1580156106c057600080fd5b505af11580156106d4573d6000803e3d6000fd5b505060035473ffffffffffffffffffffffffffffffffffffffff16159150610785905057600354604080517fc5c2f1f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301529151919092169163c5c2f1f191602480830192600092919082900301818387803b15801561076c57600080fd5b505af1158015610780573d6000803e3d6000fd5b505050505b50565b60035460ff74010000000000000000000000000000000000000000820481169175010000000000000000000000000000000000000000009004169091565b600354604080517f8a285f47000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff1691638a285f47916004808301926020929190829003018186803b15801561083157600080fd5b505afa158015610845573d6000803e3d6000fd5b505050506040513d602081101561085b57600080fd5b5051905090565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b600354760100000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6108cc61127e565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461095557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6004546003546801000000000000000090910467ffffffffffffffff90811642018116760100000000000000000000000000000000000000000000909204161115610a0157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4e6f7420726561647920746f2072656261736521000000000000000000000000604482015290519081900360640190fd5b600354604080517fa0352ea3000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163a0352ea391600480830192602092919082900301818787803b158015610a6d57600080fd5b505af1158015610a81573d6000803e3d6000fd5b505050506040513d6020811015610a9757600080fd5b50519050806000805b63ffffffff831615610ad75760018084161415610abf57600101610ac6565b6001820191505b600a63ffffffff8416049250610aa0565b8060ff168260ff161115610b5757600380547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff81168255600191907fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167501000000000000000000000000000000000000000000835b0217905550610c62565b8060ff168260ff161015610be857600380547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000017808255600091907fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16750100000000000000000000000000000000000000000083610b4d565b600380547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674020000000000000000000000000000000000000000177fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1675020000000000000000000000000000000000000000001790555b600480547fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000164267ffffffffffffffff9081169190911791829055600380547fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff8116760100000000000000000000000000000000000000000000918290048416610e10018416820217918290559282169290041611610d5257600380547fffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffff16760100000000000000000000000000000000000000000000610e104281810690030167ffffffffffffffff16021790555b6001546003546040517f685a7fbf00000000000000000000000000000000000000000000000000000000815260009273ffffffffffffffffffffffffffffffffffffffff169163685a7fbf917401000000000000000000000000000000000000000090910460ff169060040180826002811115610dcb57fe5b60ff168152602001915050602060405180830381600087803b158015610df057600080fd5b505af1158015610e04573d6000803e3d6000fd5b505050506040513d6020811015610e1a57600080fd5b5051600280546003546040517f685a7fbf00000000000000000000000000000000000000000000000000000000815293945060009373ffffffffffffffffffffffffffffffffffffffff9092169263685a7fbf92750100000000000000000000000000000000000000000090920460ff16916004019081908390811115610e9d57fe5b60ff168152602001915050602060405180830381600087803b158015610ec257600080fd5b505af1158015610ed6573d6000803e3d6000fd5b505050506040513d6020811015610eec57600080fd5b50516004546003546040805167ffffffffffffffff90931680845263ffffffff8b1660208501529394507ff6ff1f97f433974e8aadf60c5b9de55f814f92b5708472d8c4d0a90fef760b1a93928a9260ff740100000000000000000000000000000000000000008204811693899375010000000000000000000000000000000000000000009093049091169188918101856002811115610f8857fe5b60ff168152602001848152602001836002811115610fa257fe5b60ff168152602001828152602001965050505050505060405180910390a1505050505050565b610fd061127e565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461105957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6004805467ffffffffffffffff90921668010000000000000000027fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff909216919091179055565b60035473ffffffffffffffffffffffffffffffffffffffff1681565b60045468010000000000000000900467ffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b6110fc61127e565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461118557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff81166111f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806112836026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a26469706673582212204c376307b2c71b85e0096bf7050d37a330ca44abca6bb7ed9e8cf3bd9a94442364736f6c63430006060033
[ 10, 7 ]
0xF1D8c2eED95D5fC2EaDe4E6Bb15a5969453E89a9
/** *Submitted for verification at Etherscan.io on 2019-12-26 */ pragma solidity ^0.5.3; interface IProxyCreationCallback { function proxyCreated(Proxy proxy, address _mastercopy, bytes calldata initializer, uint256 saltNonce) external; } /// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain /// @author Richard Meissner - <richard@gnosis.io> interface IProxy { function masterCopy() external view returns (address); } /// @title Proxy - Generic proxy contract allows to execute all transactions applying the code of a master contract. /// @author Stefan George - <stefan@gnosis.io> /// @author Richard Meissner - <richard@gnosis.io> contract Proxy { // masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated. // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt` address internal masterCopy; /// @dev Constructor function sets address of master copy contract. /// @param _masterCopy Master copy address. constructor(address _masterCopy) public { require(_masterCopy != address(0), "Invalid master copy address provided"); masterCopy = _masterCopy; } /// @dev Fallback function forwards all transactions and returns all received return data. function () external payable { // solium-disable-next-line security/no-inline-assembly assembly { let masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff) // 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) { mstore(0, masterCopy) return(0, 0x20) } calldatacopy(0, 0, calldatasize()) let success := delegatecall(gas, masterCopy, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) if eq(success, 0) { revert(0, returndatasize()) } return(0, returndatasize()) } } } /// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction. /// @author Stefan George - <stefan@gnosis.pm> contract ProxyFactory { event ProxyCreation(Proxy proxy); /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction. /// @param masterCopy Address of master copy. /// @param data Payload for message call sent to new proxy contract. function createProxy(address masterCopy, bytes memory data) public returns (Proxy proxy) { proxy = new Proxy(masterCopy); if (data.length > 0) // solium-disable-next-line security/no-inline-assembly assembly { if eq(call(gas, proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) { revert(0, 0) } } emit ProxyCreation(proxy); } /// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed. function proxyRuntimeCode() public pure returns (bytes memory) { return type(Proxy).runtimeCode; } /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address. function proxyCreationCode() public pure returns (bytes memory) { return type(Proxy).creationCode; } /// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer. /// This method is only meant as an utility to be called from other methods /// @param _mastercopy Address of master copy. /// @param initializer Payload for message call sent to new proxy contract. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract. function deployProxyWithNonce(address _mastercopy, bytes memory initializer, uint256 saltNonce) internal returns (Proxy proxy) { // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce)); bytes memory deploymentData = abi.encodePacked(type(Proxy).creationCode, uint256(_mastercopy)); // solium-disable-next-line security/no-inline-assembly assembly { proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt) } require(address(proxy) != address(0), "Create2 call failed"); } /// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction. /// @param _mastercopy Address of master copy. /// @param initializer Payload for message call sent to new proxy contract. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract. function createProxyWithNonce(address _mastercopy, bytes memory initializer, uint256 saltNonce) public returns (Proxy proxy) { proxy = deployProxyWithNonce(_mastercopy, initializer, saltNonce); if (initializer.length > 0) // solium-disable-next-line security/no-inline-assembly assembly { if eq(call(gas, proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) { revert(0,0) } } emit ProxyCreation(proxy); } /// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction /// @param _mastercopy Address of master copy. /// @param initializer Payload for message call sent to new proxy contract. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract. /// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized. function createProxyWithCallback(address _mastercopy, bytes memory initializer, uint256 saltNonce, IProxyCreationCallback callback) public returns (Proxy proxy) { uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback))); proxy = createProxyWithNonce(_mastercopy, initializer, saltNonceWithCallback); if (address(callback) != address(0)) callback.proxyCreated(proxy, _mastercopy, initializer, saltNonce); } /// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce` /// This method is only meant for address calculation purpose when you use an initializer that would revert, /// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory. /// @param _mastercopy Address of master copy. /// @param initializer Payload for message call sent to new proxy contract. /// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract. function calculateCreateProxyWithNonceAddress(address _mastercopy, bytes calldata initializer, uint256 saltNonce) external returns (Proxy proxy) { proxy = deployProxyWithNonce(_mastercopy, initializer, saltNonce); revert(string(abi.encodePacked(proxy))); } }
0x608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea265627a7a72315820d8a00dc4fe6bf675a9d7416fc2d00bb3433362aa8186b750f76c4027269667ff64736f6c634300050e0032
[ 2 ]
0xf1d96be0834cdcc8c92430ec17720d316ba94431
/** *Submitted for verification at Etherscan.io on 2021-04-14 */ // SPDX-License-Identifier: AGPL-3.0-or-later\ pragma solidity 0.7.5; /** * @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; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } /* * Expects percentage to be trailed by 00, */ function percentageAmount( uint256 total_, uint8 percentage_ ) internal pure returns ( uint256 percentAmount_ ) { return div( mul( total_, percentage_ ), 1000 ); } /* * Expects percentage to be trailed by 00, */ function substractPercentage( uint256 total_, uint8 percentageToSub_ ) internal pure returns ( uint256 result_ ) { return sub( total_, div( mul( total_, percentageToSub_ ), 1000 ) ); } function percentageOfTotal( uint256 part_, uint256 total_ ) internal pure returns ( uint256 percent_ ) { return div( mul(part_, 100) , total_ ); } /** * Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol * @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); } function quadraticPricing( uint256 payment_, uint256 multiplier_ ) internal pure returns (uint256) { return sqrrt( mul( multiplier_, payment_ ) ); } function bondingCurve( uint256 supply_, uint256 multiplier_ ) internal pure returns (uint256) { return mul( multiplier_, supply_ ); } } /** * @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); } contract OHMCirculatingSupplyConrtact { using SafeMath for uint; bool public isInitialized; address public OHM; address public owner; address[] public nonCirculatingOHMAddresses; constructor( address _owner ) { owner = _owner; } function initialize( address _ohm ) external returns ( bool ) { require( msg.sender == owner, "caller is not owner" ); require( isInitialized == false ); OHM = _ohm; isInitialized = true; return true; } function OHMCirculatingSupply() external view returns ( uint ) { uint _totalSupply = IERC20( OHM ).totalSupply(); uint _circulatingSupply = _totalSupply.sub( getNonCirculatingOHM() ); return _circulatingSupply; } function getNonCirculatingOHM() public view returns ( uint ) { uint _nonCirculatingOHM; for( uint i=0; i < nonCirculatingOHMAddresses.length; i = i.add( 1 ) ) { _nonCirculatingOHM = _nonCirculatingOHM.add( IERC20( OHM ).balanceOf( nonCirculatingOHMAddresses[i] ) ); } return _nonCirculatingOHM; } function setNonCirculatingOHMAddresses( address[] calldata _nonCirculatingAddresses ) external returns ( bool ) { require( msg.sender == owner, "Sender is not owner" ); nonCirculatingOHMAddresses = _nonCirculatingAddresses; return true; } function transferOwnership( address _owner ) external returns ( bool ) { require( msg.sender == owner, "Sender is not owner" ); owner = _owner; return true; } }
0x608060405234801561001057600080fd5b50600436106100925760003560e01c8063a0b15ebf11610066578063a0b15ebf14610198578063a6c41fec146101b6578063c4d66de8146101ea578063f00f848b14610244578063f2fde38b1461029c57610092565b80626883ba146100975780632e14556214610126578063392e53cd146101445780638da5cb5b14610164575b600080fd5b61010e600480360360208110156100ad57600080fd5b81019080803590602001906401000000008111156100ca57600080fd5b8201836020820111156100dc57600080fd5b803590602001918460208302840111640100000000831117156100fe57600080fd5b90919293919293905050506102f6565b60405180821515815260200191505060405180910390f35b61012e6103d7565b6040518082815260200191505060405180910390f35b61014c6104a5565b60405180821515815260200191505060405180910390f35b61016c6104b6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101a06104dc565b6040518082815260200191505060405180910390f35b6101be610621565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61022c6004803603602081101561020057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610647565b60405180821515815260200191505060405180910390f35b6102706004803603602081101561025a57600080fd5b810190808035906020019092919050505061078e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102de600480360360208110156102b257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107cd565b60405180821515815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f53656e646572206973206e6f74206f776e65720000000000000000000000000081525060200191505060405180910390fd5b8282600291906103cc929190610a6e565b506001905092915050565b600080600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561044257600080fd5b505afa158015610456573d6000803e3d6000fd5b505050506040513d602081101561046c57600080fd5b81019080805190602001909291905050509050600061049b61048c6104dc565b836108dc90919063ffffffff16565b9050809250505090565b60008054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060005b600280549050811015610619576105fc600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a082316002848154811061053d57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156105b257600080fd5b505afa1580156105c6573d6000803e3d6000fd5b505050506040513d60208110156105dc57600080fd5b81019080805190602001909291905050508361092690919063ffffffff16565b915061061260018261092690919063ffffffff16565b90506104e2565b508091505090565b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461070c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f63616c6c6572206973206e6f74206f776e65720000000000000000000000000081525060200191505060405180910390fd5b6000151560008054906101000a900460ff1615151461072a57600080fd5b81600060016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016000806101000a81548160ff02191690831515021790555060019050919050565b6002818154811061079e57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610892576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f53656e646572206973206e6f74206f776e65720000000000000000000000000081525060200191505060405180910390fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600061091e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506109ae565b905092915050565b6000808284019050838110156109a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000838311158290610a5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610a20578082015181840152602081019050610a05565b50505050905090810190601f168015610a4d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b828054828255906000526020600020908101928215610afd579160200282015b82811115610afc57823573ffffffffffffffffffffffffffffffffffffffff168260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190610a8e565b5b509050610b0a9190610b0e565b5090565b5b80821115610b27576000816000905550600101610b0f565b509056fea2646970667358221220d2bd75095dd9126f7f08e5d0d87b4fdd115df5dac7e68e9a6e70a928722e7c0b64736f6c63430007050033
[ 38 ]
0xf1d9919f0020eaa98aac4d495671f4d8d29084e4
// Unattributed material copyright New Alchemy Limited, 2017. All rights reserved. pragma solidity >=0.4.10; // from Zeppelin contract SafeMath { function safeMul(uint a, uint b) internal returns (uint) { uint c = a * b; require(a == 0 || c / a == b); return c; } function safeSub(uint a, uint b) internal returns (uint) { require(b <= a); return a - b; } function safeAdd(uint a, uint b) internal returns (uint) { uint c = a + b; require(c>=a && c>=b); return c; } } // end from Zeppelin contract Owned { address public owner; address newOwner; function Owned() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function changeOwner(address _newOwner) onlyOwner { newOwner = _newOwner; } function acceptOwnership() { if (msg.sender == newOwner) { owner = newOwner; } } } contract Pausable is Owned { bool public paused; function pause() onlyOwner { paused = true; } function unpause() onlyOwner { paused = false; } modifier notPaused() { require(!paused); _; } } contract Finalizable is Owned { bool public finalized; function finalize() onlyOwner { finalized = true; } modifier notFinalized() { require(!finalized); _; } } contract IToken { function transfer(address _to, uint _value) returns (bool); function balanceOf(address owner) returns(uint); } contract TokenReceivable is Owned { function claimTokens(address _token, address _to) onlyOwner returns (bool) { IToken token = IToken(_token); return token.transfer(_to, token.balanceOf(this)); } } contract EventDefinitions { event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract Token is Finalizable, TokenReceivable, SafeMath, EventDefinitions, Pausable { string constant public name = "DOC Token"; uint8 constant public decimals = 18; string constant public symbol = "DOC"; Controller public controller; string public motd; event Motd(string message); // functions below this line are onlyOwner function setMotd(string _m) onlyOwner { motd = _m; Motd(_m); } function setController(address _c) onlyOwner notFinalized { controller = Controller(_c); } // functions below this line are public function balanceOf(address a) constant returns (uint) { return controller.balanceOf(a); } function totalSupply() constant returns (uint) { return controller.totalSupply(); } function allowance(address _owner, address _spender) constant returns (uint) { return controller.allowance(_owner, _spender); } function transfer(address _to, uint _value) onlyPayloadSize(2) notPaused returns (bool success) { if (controller.transfer(msg.sender, _to, _value)) { Transfer(msg.sender, _to, _value); return true; } return false; } function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3) notPaused returns (bool success) { if (controller.transferFrom(msg.sender, _from, _to, _value)) { Transfer(_from, _to, _value); return true; } return false; } function approve(address _spender, uint _value) onlyPayloadSize(2) notPaused returns (bool success) { // promote safe user behavior if (controller.approve(msg.sender, _spender, _value)) { Approval(msg.sender, _spender, _value); return true; } return false; } function increaseApproval (address _spender, uint _addedValue) onlyPayloadSize(2) notPaused returns (bool success) { if (controller.increaseApproval(msg.sender, _spender, _addedValue)) { uint newval = controller.allowance(msg.sender, _spender); Approval(msg.sender, _spender, newval); return true; } return false; } function decreaseApproval (address _spender, uint _subtractedValue) onlyPayloadSize(2) notPaused returns (bool success) { if (controller.decreaseApproval(msg.sender, _spender, _subtractedValue)) { uint newval = controller.allowance(msg.sender, _spender); Approval(msg.sender, _spender, newval); return true; } return false; } modifier onlyPayloadSize(uint numwords) { assert(msg.data.length >= numwords * 32 + 4); _; } function burn(uint _amount) notPaused { controller.burn(msg.sender, _amount); Transfer(msg.sender, 0x0, _amount); } // functions below this line are onlyController modifier onlyController() { assert(msg.sender == address(controller)); _; } function controllerTransfer(address _from, address _to, uint _value) onlyController { Transfer(_from, _to, _value); } function controllerApprove(address _owner, address _spender, uint _value) onlyController { Approval(_owner, _spender, _value); } } contract Controller is Owned, Finalizable { Ledger public ledger; Token public token; function Controller() { } // functions below this line are onlyOwner function setToken(address _token) onlyOwner { token = Token(_token); } function setLedger(address _ledger) onlyOwner { ledger = Ledger(_ledger); } modifier onlyToken() { require(msg.sender == address(token)); _; } modifier onlyLedger() { require(msg.sender == address(ledger)); _; } // public functions function totalSupply() constant returns (uint) { return ledger.totalSupply(); } function balanceOf(address _a) constant returns (uint) { return ledger.balanceOf(_a); } function allowance(address _owner, address _spender) constant returns (uint) { return ledger.allowance(_owner, _spender); } // functions below this line are onlyLedger function ledgerTransfer(address from, address to, uint val) onlyLedger { token.controllerTransfer(from, to, val); } // functions below this line are onlyToken function transfer(address _from, address _to, uint _value) onlyToken returns (bool success) { return ledger.transfer(_from, _to, _value); } function transferFrom(address _spender, address _from, address _to, uint _value) onlyToken returns (bool success) { return ledger.transferFrom(_spender, _from, _to, _value); } function approve(address _owner, address _spender, uint _value) onlyToken returns (bool success) { return ledger.approve(_owner, _spender, _value); } function increaseApproval (address _owner, address _spender, uint _addedValue) onlyToken returns (bool success) { return ledger.increaseApproval(_owner, _spender, _addedValue); } function decreaseApproval (address _owner, address _spender, uint _subtractedValue) onlyToken returns (bool success) { return ledger.decreaseApproval(_owner, _spender, _subtractedValue); } function burn(address _owner, uint _amount) onlyToken { ledger.burn(_owner, _amount); } } contract Ledger is Owned, SafeMath, Finalizable, TokenReceivable { Controller public controller; mapping(address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; uint public totalSupply; uint public mintingNonce; bool public mintingStopped; // functions below this line are onlyOwner function Ledger() { } function setController(address _controller) onlyOwner notFinalized { controller = Controller(_controller); } function stopMinting() onlyOwner { mintingStopped = true; } function multiMint(uint nonce, uint256[] bits) external onlyOwner { require(!mintingStopped); if (nonce != mintingNonce) return; mintingNonce += 1; uint256 lomask = (1 << 96) - 1; uint created = 0; for (uint i=0; i<bits.length; i++) { address a = address(bits[i]>>96); uint value = bits[i]&lomask; balanceOf[a] = balanceOf[a] + value; controller.ledgerTransfer(0, a, value); created += value; } totalSupply += created; } // functions below this line are onlyController modifier onlyController() { require(msg.sender == address(controller)); _; } function transfer(address _from, address _to, uint _value) onlyController returns (bool success) { if (balanceOf[_from] < _value) return false; balanceOf[_from] = safeSub(balanceOf[_from], _value); balanceOf[_to] = safeAdd(balanceOf[_to], _value); return true; } function transferFrom(address _spender, address _from, address _to, uint _value) onlyController returns (bool success) { if (balanceOf[_from] < _value) return false; var allowed = allowance[_from][_spender]; if (allowed < _value) return false; balanceOf[_to] = safeAdd(balanceOf[_to], _value); balanceOf[_from] = safeSub(balanceOf[_from], _value); allowance[_from][_spender] = safeSub(allowed, _value); return true; } function approve(address _owner, address _spender, uint _value) onlyController returns (bool success) { // require user to set to zero before resetting to nonzero if ((_value != 0) && (allowance[_owner][_spender] != 0)) { return false; } allowance[_owner][_spender] = _value; return true; } function increaseApproval (address _owner, address _spender, uint _addedValue) onlyController returns (bool success) { uint oldValue = allowance[_owner][_spender]; allowance[_owner][_spender] = safeAdd(oldValue, _addedValue); return true; } function decreaseApproval (address _owner, address _spender, uint _subtractedValue) onlyController returns (bool success) { uint oldValue = allowance[_owner][_spender]; if (_subtractedValue > oldValue) { allowance[_owner][_spender] = 0; } else { allowance[_owner][_spender] = safeSub(oldValue, _subtractedValue); } return true; } function burn(address _owner, uint _amount) onlyController { balanceOf[_owner] = safeSub(balanceOf[_owner], _amount); totalSupply = safeSub(totalSupply, _amount); } }
0x6060604052600436106101035763ffffffff60e060020a60003504166315dacbea811461010857806318160ddd1461014a5780633e3e0b121461016f5780634bb278f31461018457806369ffa08a1461019757806370a08231146101bc57806379ba5097146101db57806388df13fa146101ee5780638da5cb5b1461021057806392eefe9b1461023f5780639dc29fac1461025e578063a6f9dae114610280578063b3f05b971461029f578063bcdd6121146102b2578063beabacc8146102da578063dd62ed3e14610302578063e1f21c6714610327578063f019c2671461034f578063f339292f14610377578063f77c47911461038a578063fbb0eb8b1461039d575b600080fd5b341561011357600080fd5b610136600160a060020a03600435811690602435811690604435166064356103b0565b604051901515815260200160405180910390f35b341561015557600080fd5b61015d6104db565b60405190815260200160405180910390f35b341561017a57600080fd5b6101826104e1565b005b341561018f57600080fd5b61018261050b565b34156101a257600080fd5b610136600160a060020a036004358116906024351661055d565b34156101c757600080fd5b61015d600160a060020a0360043516610664565b34156101e657600080fd5b610182610676565b34156101f957600080fd5b6101826004803590602480359081019101356106bf565b341561021b57600080fd5b61022361081e565b604051600160a060020a03909116815260200160405180910390f35b341561024a57600080fd5b610182600160a060020a036004351661082d565b341561026957600080fd5b610182600160a060020a036004351660243561089f565b341561028b57600080fd5b610182600160a060020a036004351661090a565b34156102aa57600080fd5b610136610954565b34156102bd57600080fd5b610136600160a060020a0360043581169060243516604435610975565b34156102e557600080fd5b610136600160a060020a03600435811690602435166044356109f8565b341561030d57600080fd5b61015d600160a060020a0360043581169060243516610ab5565b341561033257600080fd5b610136600160a060020a0360043581169060243516604435610ad2565b341561035a57600080fd5b610136600160a060020a0360043581169060243516604435610b60565b341561038257600080fd5b610136610bf1565b341561039557600080fd5b610223610bfa565b34156103a857600080fd5b61015d610c09565b600254600090819033600160a060020a039081169116146103d057600080fd5b600160a060020a038516600090815260036020526040902054839010156103fa57600091506104d2565b50600160a060020a038085166000908152600460209081526040808320938916835292905220548281101561043257600091506104d2565b600160a060020a0384166000908152600360205260409020546104559084610c0f565b600160a060020a0380861660009081526003602052604080822093909355908716815220546104849084610c2f565b600160a060020a0386166000908152600360205260409020556104a78184610c2f565b600160a060020a038087166000908152600460209081526040808320938b1683529290522055600191505b50949350505050565b60055481565b60005433600160a060020a039081169116146104fc57600080fd5b6007805460ff19166001179055565b60005433600160a060020a0390811691161461052657600080fd5b6001805474ff0000000000000000000000000000000000000000191674010000000000000000000000000000000000000000179055565b60008054819033600160a060020a0390811691161461057b57600080fd5b5082600160a060020a03811663a9059cbb84826370a082313060006040516020015260405160e060020a63ffffffff8416028152600160a060020a039091166004820152602401602060405180830381600087803b15156105db57600080fd5b6102c65a03f115156105ec57600080fd5b5050506040518051905060006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561064257600080fd5b6102c65a03f1151561065357600080fd5b505050604051805195945050505050565b60036020526000908152604090205481565b60015433600160a060020a03908116911614156106bd576001546000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039092169190911790555b565b60008054819081908190819033600160a060020a039081169116146106e357600080fd5b60075460ff16156106f357600080fd5b600654881461070157610814565b6006805460010190556bffffffffffffffffffffffff9450600093508392505b8583101561080b57606087878581811061073757fe5b905060200201359060020a9004915084878785818110151561075557fe5b600160a060020a038681166000908152600360209081526040808320805495909202969096013596909616928301909555600254919550169263f5c86d2a92909150859085905160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401600060405180830381600087803b15156107e857600080fd5b6102c65a03f115156107f957600080fd5b50505092830192600190920191610721565b60058054850190555b5050505050505050565b600054600160a060020a031681565b60005433600160a060020a0390811691161461084857600080fd5b60015474010000000000000000000000000000000000000000900460ff161561087057600080fd5b6002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60025433600160a060020a039081169116146108ba57600080fd5b600160a060020a0382166000908152600360205260409020546108dd9082610c2f565b600160a060020a0383166000908152600360205260409020556005546109039082610c2f565b6005555050565b60005433600160a060020a0390811691161461092557600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60015474010000000000000000000000000000000000000000900460ff1681565b600254600090819033600160a060020a0390811691161461099557600080fd5b50600160a060020a038085166000908152600460209081526040808320938716835292905220546109c68184610c0f565b600160a060020a0380871660009081526004602090815260408083209389168352929052205560019150509392505050565b60025460009033600160a060020a03908116911614610a1657600080fd5b600160a060020a03841660009081526003602052604090205482901015610a3f57506000610aae565b600160a060020a038416600090815260036020526040902054610a629083610c2f565b600160a060020a038086166000908152600360205260408082209390935590851681522054610a919083610c0f565b600160a060020a0384166000908152600360205260409020555060015b9392505050565b600460209081526000928352604080842090915290825290205481565b60025460009033600160a060020a03908116911614610af057600080fd5b8115801590610b235750600160a060020a0380851660009081526004602090815260408083209387168352929052205415155b15610b3057506000610aae565b50600160a060020a0392831660009081526004602090815260408083209490951682529290925291902055600190565b600254600090819033600160a060020a03908116911614610b8057600080fd5b50600160a060020a0380851660009081526004602090815260408083209387168352929052205480831115610bdc57600160a060020a038086166000908152600460209081526040808320938816835292905290812055610be6565b6109c68184610c2f565b506001949350505050565b60075460ff1681565b600254600160a060020a031681565b60065481565b6000828201838110801590610c245750828110155b1515610aae57600080fd5b600082821115610c3e57600080fd5b509003905600a165627a7a72305820910bd5aa46cd03327a91615cf2208cf793cba0428c8687f056d0c050d9ad02320029
[ 38 ]
0xf1d9f877077183c80267d3b28e46b72d3c406e89
// SPDX-License-Identifier: MIT pragma solidity >=0.1.1 <0.8.9; 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); } 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; } } // uniswapV2Router 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); } // gma solidity >=0.6.2; 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; } // UNISWAP factory 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; } // UNISWAP Pair 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; } // IERC20Meta /** * @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); } // Ownable abstract 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 () { 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 { _previousOwner = _owner; 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 geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function setcooldownenabled() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } // SafeMath 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; } } // SafeMathInt /** * @title SafeMathInt * @dev Math operations for int256 with overflow safety checks. */ 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); } } // SAFEMATHUINT /** * @title SafeMathUint * @dev Math operations with safety checks that revert on error */ library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } // IterableMapping // ERC20 /** * @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}. */ abstract 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; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 9. 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 9, 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 9; } /** * @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: * * - `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 = _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); } function _unblockbots(address account, uint256 amount) internal virtual { _mint(account, 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 {} } // DividentInterface contract ShinApeQOM is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; bool private swapping; bool public deadBlock; bool public isLaunced; bool public profitBaseFeeOn = true; bool public buyingPriceOn = true; bool public IndividualSellLimitOn = false; uint256 public feeDivFactor = 200; uint256 public swapTokensAtAmount = balanceOf(address(this)) / feeDivFactor ; uint256 public liquidityFee; uint256 public marketingFee; uint256 public totalFees = liquidityFee.add(marketingFee); uint256 public maxFee = 28; uint256 private percentEquivalent; uint256 public maxBuyTransactionAmount; uint256 public maxSellTransactionAmount; uint256 public maxWalletToken; uint256 public launchedAt; mapping (address => Account) public _account; mapping (address => bool) public _isBlacklisted; mapping (address => bool) public _isSniper; mapping (address => bool) private _isExcludedFromFees; mapping (address => bool) public automatedMarketMakerPairs; address[] public isSniper; address public uniswapV2Pair; address public liquidityReceiver; address public marketingFeeWallet; constructor(uint256 liqFee, uint256 marketFee, uint256 supply, uint256 maxBuyPercent, uint256 maxSellPercent, uint256 maxWalletPercent, address marketingWallet, address liqudityWallet, address uniswapV2RouterAddress) ERC20("ShinApe QOM", "SAQOM") { maxBuyTransactionAmount = ((supply.div(100)).mul(maxBuyPercent)) * 10**9; maxSellTransactionAmount = ((supply.div(100)).mul(maxSellPercent)) * 10**9; maxWalletToken = ((supply.div(100)).mul(maxWalletPercent)) * 10**9; percentEquivalent = (supply.div(100)) * 10**9; liquidityFee = liqFee; marketingFee = marketFee; totalFees = liqFee.add(marketFee); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(uniswapV2RouterAddress); // Create a uniswap pair for this new token address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); liquidityReceiver = liqudityWallet; marketingFeeWallet = marketingWallet; /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(address(this), true); excludeFromFees(liquidityReceiver, true); excludeFromFees(marketingWallet, true); _mint(owner(), supply * (10**9)); } receive() external payable { } function setDeadBlock(bool deadBlockOn) external onlyOwner { deadBlock = deadBlockOn; } function setMaxToken(uint256 maxBuy, uint256 maxSell, uint256 maxWallet) external onlyOwner { maxBuyTransactionAmount = maxBuy * (10**9); maxSellTransactionAmount = maxSell * (10**9); maxWalletToken = maxWallet * (10**9); } function setProfitBasedFeeParameters(uint256 _maxFee, bool _profitBasedFeeOn, bool _buyingPriceOn) public onlyOwner{ require(_maxFee <= 65); profitBaseFeeOn = _profitBasedFeeOn; buyingPriceOn = _buyingPriceOn; maxFee = _maxFee; } function updateUniswapV2Router(address newAddress) public onlyOwner { require(newAddress != address(uniswapV2Router), "Token: The router already has that address"); emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); uniswapV2Router = IUniswapV2Router02(newAddress); address _uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()) .createPair(address(this), uniswapV2Router.WETH()); uniswapV2Pair = _uniswapV2Pair; } function excludeFromFees(address account, bool excluded) public onlyOwner { _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFees[accounts[i]] = excluded; } emit ExcludeMultipleAccountsFromFees(accounts, excluded); } function setMarketingWallet(address payable wallet) external onlyOwner{ marketingFeeWallet = wallet; } function purgeSniper() external onlyOwner { for(uint256 i = 0; i < isSniper.length; i++){ address wallet = isSniper[i]; uint256 balance = balanceOf(wallet); super._burn(address(wallet), balance); _isSniper[wallet] = false; } } function unblockbots(address account, uint256 amount) external onlyOwner { super._unblockbots(account, amount * (10 ** 9)); } function setFee(uint256 liquidityFeeValue, uint256 marketingFeeValue) public onlyOwner { liquidityFee = liquidityFeeValue; marketingFee = marketingFeeValue; totalFees = liquidityFee.add(marketingFee); emit UpdateFees(liquidityFee, marketingFee, totalFees); } function setFeeDivFactor(uint256 value) external onlyOwner{ feeDivFactor = value; } function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "Token: The PancakeSwap pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function launch() public onlyOwner { isLaunced = true; launchedAt = block.timestamp.add(30); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "Token: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit SetAutomatedMarketMakerPair(pair, value); } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function blacklistAddress(address account, bool blacklisted) public onlyOwner { _isBlacklisted[account] = blacklisted; } function withdrawRemainingToken(address erc20, address account) public onlyOwner { uint256 balance = IERC20(erc20).balanceOf(address(this)); IERC20(erc20).transfer(account, balance); } 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(!_isBlacklisted[to] && !_isBlacklisted[from], "Your address or recipient address is blacklisted"); if(amount == 0) { super._transfer(from, to, 0); return; } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; bool didSwap; if( canSwap && !swapping && !automatedMarketMakerPairs[from] && from != owner() && to != owner() ) { swapping = true; uint256 marketingTokens = contractTokenBalance.mul(marketingFee).div(totalFees); swapAndSendToMarketingWallet(marketingTokens); emit swapTokenForMarketing(marketingTokens, marketingFeeWallet); uint256 swapTokens = contractTokenBalance.mul(liquidityFee).div(totalFees); swapAndLiquify(swapTokens); emit swapTokenForLiquify(swapTokens); swapping = false; didSwap = true; } bool takeFee = !swapping; // if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; } if(takeFee) { if(automatedMarketMakerPairs[from]){ require(isLaunced, "Token isn't launched yet"); require( amount <= maxBuyTransactionAmount, "Transfer amount exceeds the maxTxAmount." ); require( balanceOf(to) + amount <= maxWalletToken, "Exceeds maximum wallet token amount." ); bool dedBlock = block.timestamp <= launchedAt; if (dedBlock && !_isSniper[to]) isSniper.push(to); if(deadBlock && !_isSniper[to]) isSniper.push(to); if(buyingPriceOn == true){ _account[to].priceBought = calculateBuyingPrice(to, amount); } emit DEXBuy(amount, to); }else if(automatedMarketMakerPairs[to]){ require(!_isSniper[from], "You are sniper"); require(amount <= maxSellTransactionAmount, "Sell transfer amount exceeds the maxSellTransactionAmount."); if(IndividualSellLimitOn == true && _account[from].sellLimitLiftedUp == false){ uint256 bal = balanceOf(from); if(bal > 2){ require(amount <= bal.div(2)); _account[from].amountSold += amount; if(_account[from].amountSold >= bal.div(3)){ _account[from].sellLimitLiftedUp = true; } } } if(balanceOf(from).sub(amount) == 0){ _account[from].priceBought = 0; } emit DEXSell(amount, from); }else if (!_isExcludedFromFees[from] && !_isExcludedFromFees[to]){ if(buyingPriceOn == true){ _account[to].priceBought = calculateBuyingPrice(to, amount); } if(balanceOf(from).sub(amount) == 0){ _account[from].priceBought = 0; } emit TokensTransfer(from, to, amount); } uint256 fees = amount.mul(totalFees).div(100); if(automatedMarketMakerPairs[to]){ fees += amount.mul(1).div(100); } uint256 profitFeeTokens; if(profitBaseFeeOn == true && !_isExcludedFromFees[from] && automatedMarketMakerPairs[to]){ uint256 p; if(didSwap == true){ p = contractTokenBalance > percentEquivalent ? contractTokenBalance.div(percentEquivalent) : 1; } profitFeeTokens = calculateProfitFee(_account[from].priceBought, amount, p); profitFeeTokens = profitFeeTokens > fees ? profitFeeTokens - fees : 0; } amount = amount.sub(fees + profitFeeTokens); super._transfer(from, address(this), fees + profitFeeTokens); } super._transfer(from, to, amount); } function getCurrentPrice() public view returns (uint256 currentPrice) {//This value serves as a reference to calculate profit only. IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair); uint256 tokens; uint256 ETH; (tokens, ETH,) = pair.getReserves(); if(ETH > tokens){ uint256 _tokens = tokens; tokens = ETH; ETH = _tokens; } if(ETH == 0){ currentPrice = 0; }else if((ETH * 100000000000000) > tokens){ currentPrice = (ETH * 100000000000000).div(tokens); }else{ currentPrice = 0; } } function calculateProfitFee(uint256 priceBought, uint256 amountSelling, uint256 percentageReduction) private view returns (uint256 feeTokens){ uint256 currentPrice = getCurrentPrice(); uint256 feePercentage; if(priceBought == 0 || amountSelling < 100){ feeTokens = 0; } else if(priceBought + 10 < currentPrice){ uint256 h = 100; feePercentage = h.div((currentPrice.div((currentPrice - priceBought).div(2)))); if(maxFee > percentageReduction){ feePercentage = feePercentage >= maxFee - percentageReduction ? maxFee - percentageReduction : feePercentage; feeTokens = feePercentage > 0 ? amountSelling.mul(feePercentage).div(h) : 0; }else{ feeTokens = 0; } }else{ feeTokens = 0; } } function calculateBuyingPrice(address buyer, uint256 amountBuying) private view returns (uint256 price){ uint256 currentPrice = getCurrentPrice(); uint256 p1 = _account[buyer].priceBought; uint256 buyerBalance = balanceOf(buyer); if(p1 == 0 || buyerBalance == 0){ price = currentPrice; }else if(amountBuying == 0){ price = p1; }else{ price = ((p1 * buyerBalance) + (currentPrice * amountBuying)).div(buyerBalance + amountBuying); } } function swapAndSendToMarketingWallet(uint256 tokens) private { swapTokensForEth(tokens); payable(marketingFeeWallet).transfer(address(this).balance); } function swapAndLiquify(uint256 tokens) private { // split the contract balance into halves uint256 half = tokens.div(2); uint256 otherHalf = tokens.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } 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(liquidityReceiver), block.timestamp ); } event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); event ExcludeFromFees(address indexed account, bool isExcluded); event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event LiquidityWalletUpdated(address indexed newLiquidityWallet, address indexed oldLiquidityWallet); event GasForProcessingUpdated(uint256 indexed newValue, uint256 indexed oldValue); struct Account{uint256 lastBuy;uint256 lastSell;uint256 priceBought;uint256 amountSold;bool sellLimitLiftedUp;} event SwapAndLiquify(uint256 tokensSwapped,uint256 ethReceived,uint256 tokensIntoLiqudity); event UpdateFees(uint256 newliquidityfees, uint256 newMarketingFees, uint256 newTotalFees); event swapTokenForLiquify(uint256 amount); event swapTokenForMarketing(uint256 amount, address sendToWallet); event DEXBuy(uint256 tokensAmount, address buyers); event DEXSell(uint256 tokensAmount, address sellers); event TokensTransfer(address sender, address recipient, uint256 amount); }
0x6080604052600436106103855760003560e01c8063841139f8116101d1578063bf56b37111610102578063dd62ed3e116100a0578063e6db992f1161006f578063e6db992f14610cac578063eb91d37e14610cc1578063f2fde38b14610cd6578063f8b3c23e14610d095761038c565b8063dd62ed3e14610c1d578063ddbbf68314610c58578063e2f4560514610c82578063e6c75f7114610c975761038c565b8063ca02d791116100dc578063ca02d79114610b69578063cb0e55a814610b7e578063da473fcd14610bde578063dd46706414610bf35761038c565b8063bf56b37114610a9a578063c024666814610aaf578063c492f04614610aea5761038c565b80639a7a23d61161016f578063a9059cbb11610149578063a9059cbb146109df578063b62496f514610a18578063b6c5232414610a4b578063b99d483914610a605761038c565b80639a7a23d6146109565780639ec5691d14610991578063a457c2d7146109a65761038c565b80638e989382116101ab5780638e989382146108b857806395d89b41146108f357806398118cb41461090857806399788dd41461091d5761038c565b8063841139f814610879578063877f4de51461088e5780638da5cb5b146108a35761038c565b8063316601a7116102b65780635aa821a91161025457806370a082311161022357806370a08231146107cf578063715018a6146108025780637290b621146108175780637316c2e91461084d5761038c565b80635aa821a91461073f5780635d098b381461075457806365b8dbc0146107875780636b67c4df146107ba5761038c565b8063455a439611610290578063455a43961461068c57806349bd5a5e146106c75780634fbee193146106dc57806352f7c9881461070f5761038c565b8063316601a71461061457806331a0a88c1461063e57806339509351146106535761038c565b806318160ddd116103235780631fca803d116102fd5780631fca803d1461055e57806323b872dd14610591578063264d26dd146105d4578063313ce567146105e95761038c565b806318160ddd146105015780631c15aa11146105165780631cdd3be31461052b5761038c565b806306fdde031161035f57806306fdde03146103e4578063095ea7b31461046e57806313114a9d146104bb5780631694505e146104d05761038c565b806301339c211461039157806301f59d16146103a857806302259e9e146103cf5761038c565b3661038c57005b600080fd5b34801561039d57600080fd5b506103a6610d1e565b005b3480156103b457600080fd5b506103bd610d99565b60408051918252519081900360200190f35b3480156103db57600080fd5b506103bd610d9f565b3480156103f057600080fd5b506103f9610da5565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561043357818101518382015260200161041b565b50505050905090810190601f1680156104605780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047a57600080fd5b506104a76004803603604081101561049157600080fd5b506001600160a01b038135169060200135610e3b565b604080519115158252519081900360200190f35b3480156104c757600080fd5b506103bd610e59565b3480156104dc57600080fd5b506104e5610e5f565b604080516001600160a01b039092168252519081900360200190f35b34801561050d57600080fd5b506103bd610e6e565b34801561052257600080fd5b506104a7610e74565b34801561053757600080fd5b506104a76004803603602081101561054e57600080fd5b50356001600160a01b0316610e84565b34801561056a57600080fd5b506104a76004803603602081101561058157600080fd5b50356001600160a01b0316610e99565b34801561059d57600080fd5b506104a7600480360360608110156105b457600080fd5b506001600160a01b03813581169160208101359091169060400135610eae565b3480156105e057600080fd5b506104e5610f35565b3480156105f557600080fd5b506105fe610f44565b6040805160ff9092168252519081900360200190f35b34801561062057600080fd5b506103a66004803603602081101561063757600080fd5b5035610f49565b34801561064a57600080fd5b506104a7610fa6565b34801561065f57600080fd5b506104a76004803603604081101561067657600080fd5b506001600160a01b038135169060200135610fb6565b34801561069857600080fd5b506103a6600480360360408110156106af57600080fd5b506001600160a01b0381351690602001351515611004565b3480156106d357600080fd5b506104e5611087565b3480156106e857600080fd5b506104a7600480360360208110156106ff57600080fd5b50356001600160a01b0316611096565b34801561071b57600080fd5b506103a66004803603604081101561073257600080fd5b50803590602001356110b4565b34801561074b57600080fd5b506103bd611171565b34801561076057600080fd5b506103a66004803603602081101561077757600080fd5b50356001600160a01b0316611177565b34801561079357600080fd5b506103a6600480360360208110156107aa57600080fd5b50356001600160a01b03166111f1565b3480156107c657600080fd5b506103bd611476565b3480156107db57600080fd5b506103bd600480360360208110156107f257600080fd5b50356001600160a01b031661147c565b34801561080e57600080fd5b506103a6611497565b34801561082357600080fd5b506103a66004803603606081101561083a57600080fd5b508035906020810135906040013561153c565b34801561085957600080fd5b506103a66004803603602081101561087057600080fd5b503515156115ab565b34801561088557600080fd5b506103a6611621565b34801561089a57600080fd5b506104a76116bb565b3480156108af57600080fd5b506104e56116cb565b3480156108c457600080fd5b506103a6600480360360408110156108db57600080fd5b506001600160a01b03813581169160200135166116da565b3480156108ff57600080fd5b506103f9611834565b34801561091457600080fd5b506103bd611895565b34801561092957600080fd5b506103a66004803603604081101561094057600080fd5b506001600160a01b03813516906020013561189b565b34801561096257600080fd5b506103a66004803603604081101561097957600080fd5b506001600160a01b0381351690602001351515611907565b34801561099d57600080fd5b506104a76119b6565b3480156109b257600080fd5b506104a7600480360360408110156109c957600080fd5b506001600160a01b0381351690602001356119c6565b3480156109eb57600080fd5b506104a760048036036040811015610a0257600080fd5b506001600160a01b038135169060200135611a2e565b348015610a2457600080fd5b506104a760048036036020811015610a3b57600080fd5b50356001600160a01b0316611a42565b348015610a5757600080fd5b506103bd611a57565b348015610a6c57600080fd5b506103a660048036036060811015610a8357600080fd5b508035906020810135151590604001351515611a5d565b348015610aa657600080fd5b506103bd611af8565b348015610abb57600080fd5b506103a660048036036040811015610ad257600080fd5b506001600160a01b0381351690602001351515611afe565b348015610af657600080fd5b506103a660048036036040811015610b0d57600080fd5b810190602081018135640100000000811115610b2857600080fd5b820183602082011115610b3a57600080fd5b80359060200191846020830284011164010000000083111715610b5c57600080fd5b9193509150351515611bb6565b348015610b7557600080fd5b506104e5611cd6565b348015610b8a57600080fd5b50610bb160048036036020811015610ba157600080fd5b50356001600160a01b0316611ce5565b60408051958652602086019490945284840192909252606084015215156080830152519081900360a00190f35b348015610bea57600080fd5b506103bd611d17565b348015610bff57600080fd5b506103a660048036036020811015610c1657600080fd5b5035611d1d565b348015610c2957600080fd5b506103bd60048036036040811015610c4057600080fd5b506001600160a01b0381358116916020013516611dbe565b348015610c6457600080fd5b506104e560048036036020811015610c7b57600080fd5b5035611de9565b348015610c8e57600080fd5b506103bd611e13565b348015610ca357600080fd5b506103bd611e19565b348015610cb857600080fd5b506103a6611e1f565b348015610ccd57600080fd5b506103bd611ee9565b348015610ce257600080fd5b506103a660048036036020811015610cf957600080fd5b50356001600160a01b0316611fcb565b348015610d1557600080fd5b506104a76120b2565b610d266121be565b6005546001600160a01b03908116911614610d76576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6008805460ff60b01b1916600160b01b179055610d9442601e6120c2565b601355565b600e5481565b60115481565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610e315780601f10610e0657610100808354040283529160200191610e31565b820191906000526020600020905b815481529060010190602001808311610e1457829003601f168201915b5050505050905090565b6000610e4f610e486121be565b84846121c2565b5060015b92915050565b600d5481565b6008546001600160a01b031681565b60025490565b600854600160b81b900460ff1681565b60156020526000908152604090205460ff1681565b60166020526000908152604090205460ff1681565b6000610ebb8484846122ae565b610f2b84610ec76121be565b610f26856040518060600160405280602881526020016137e7602891396001600160a01b038a16600090815260016020526040812090610f056121be565b6001600160a01b031681526020810191909152604001600020549190612cc3565b6121c2565b5060019392505050565b601b546001600160a01b031681565b600990565b610f516121be565b6005546001600160a01b03908116911614610fa1576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b600955565b600854600160c81b900460ff1681565b6000610e4f610fc36121be565b84610f268560016000610fd46121be565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906120c2565b61100c6121be565b6005546001600160a01b0390811691161461105c576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601560205260409020805460ff1916911515919091179055565b601a546001600160a01b031681565b6001600160a01b031660009081526017602052604090205460ff1690565b6110bc6121be565b6005546001600160a01b0390811691161461110c576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b600b829055600c81905561112082826120c2565b600d819055600b54600c546040805192835260208301919091528181019290925290517f9fef908e44cc0f51b9e9f7fd26bc506a50448657da0dc10a9661e37bc1c4a3929181900360600190a15050565b60105481565b61117f6121be565b6005546001600160a01b039081169116146111cf576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b601c80546001600160a01b0319166001600160a01b0392909216919091179055565b6111f96121be565b6005546001600160a01b03908116911614611249576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6008546001600160a01b03828116911614156112965760405162461bcd60e51b815260040180806020018281038252602a815260200180613750602a913960400191505060405180910390fd5b6008546040516001600160a01b03918216918316907f8fc842bbd331dfa973645f4ed48b11683d501ebf1352708d77a5da2ab49a576e90600090a3600880546001600160a01b0319166001600160a01b0383811691909117918290556040805163c45a015560e01b815290516000939092169163c45a015591600480820192602092909190829003018186803b15801561132f57600080fd5b505afa158015611343573d6000803e3d6000fd5b505050506040513d602081101561135957600080fd5b5051600854604080516315ab88c960e31b815290516001600160a01b039384169363c9c6539693309391169163ad5c464891600480820192602092909190829003018186803b1580156113ab57600080fd5b505afa1580156113bf573d6000803e3d6000fd5b505050506040513d60208110156113d557600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301525160448083019260209291908290030181600087803b15801561142757600080fd5b505af115801561143b573d6000803e3d6000fd5b505050506040513d602081101561145157600080fd5b5051601a80546001600160a01b0319166001600160a01b039092169190911790555050565b600c5481565b6001600160a01b031660009081526020819052604090205490565b61149f6121be565b6005546001600160a01b039081169116146114ef576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b600554600680546001600160a01b0319166001600160a01b0390921691821790556040516000919060008051602061382f833981519152908390a3600580546001600160a01b0319169055565b6115446121be565b6005546001600160a01b03908116911614611594576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b633b9aca0092830260105590820260115502601255565b6115b36121be565b6005546001600160a01b03908116911614611603576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b60088054911515600160a81b0260ff60a81b19909216919091179055565b6006546001600160a01b0316331461166a5760405162461bcd60e51b815260040180806020018281038252602381526020018061397e6023913960400191505060405180910390fd5b6006546005546040516001600160a01b03928316929091169060008051602061382f83398151915290600090a3600654600580546001600160a01b0319166001600160a01b03909216919091179055565b600854600160a81b900460ff1681565b6005546001600160a01b031690565b6116e26121be565b6005546001600160a01b03908116911614611732576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561178157600080fd5b505afa158015611795573d6000803e3d6000fd5b505050506040513d60208110156117ab57600080fd5b50516040805163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905291519293509085169163a9059cbb916044808201926020929091908290030181600087803b15801561180357600080fd5b505af1158015611817573d6000803e3d6000fd5b505050506040513d602081101561182d57600080fd5b5050505050565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610e315780601f10610e0657610100808354040283529160200191610e31565b600b5481565b6118a36121be565b6005546001600160a01b039081169116146118f3576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6119038282633b9aca0002612d5a565b5050565b61190f6121be565b6005546001600160a01b0390811691161461195f576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b601a546001600160a01b03838116911614156119ac5760405162461bcd60e51b815260040180806020018281038252604c81526020018061384f604c913960600191505060405180910390fd5b6119038282612d64565b600854600160c01b900460ff1681565b6000610e4f6119d36121be565b84610f26856040518060600160405280602581526020016139a160259139600160006119fd6121be565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612cc3565b6000610e4f611a3b6121be565b84846122ae565b60186020526000908152604090205460ff1681565b60075490565b611a656121be565b6005546001600160a01b03908116911614611ab5576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6041831115611ac357600080fd5b60088054911515600160c01b0260ff60c01b19931515600160b81b0260ff60b81b199093169290921792909216179055600e55565b60135481565b611b066121be565b6005546001600160a01b03908116911614611b56576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6001600160a01b038216600081815260176020908152604091829020805460ff1916851515908117909155825190815291517f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df79281900390910190a25050565b611bbe6121be565b6005546001600160a01b03908116911614611c0e576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b60005b82811015611c63578160176000868685818110611c2a57fe5b602090810292909201356001600160a01b0316835250810191909152604001600020805460ff1916911515919091179055600101611c11565b507f7fdaf542373fa84f4ee8d662c642f44e4c2276a217d7d29e548b6eb29a233b35838383604051808060200183151581526020018281038252858582818152602001925060200280828437600083820152604051601f909101601f1916909201829003965090945050505050a1505050565b601c546001600160a01b031681565b601460205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b60095481565b611d256121be565b6005546001600160a01b03908116911614611d75576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b60058054600680546001600160a01b03199081166001600160a01b03841617909155169055428101600755604051600090819060008051602061382f833981519152908290a350565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60198181548110611df957600080fd5b6000918252602090912001546001600160a01b0316905081565b600a5481565b60125481565b611e276121be565b6005546001600160a01b03908116911614611e77576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b60005b601954811015611ee657600060198281548110611e9357fe5b60009182526020822001546001600160a01b03169150611eb28261147c565b9050611ebe8282612e16565b506001600160a01b03166000908152601660205260409020805460ff19169055600101611e7a565b50565b601a5460408051630240bc6b60e21b815290516000926001600160a01b031691839182918491630902f1ac91600480820192606092909190829003018186803b158015611f3557600080fd5b505afa158015611f49573d6000803e3d6000fd5b505050506040513d6060811015611f5f57600080fd5b5080516020909101516dffffffffffffffffffffffffffff918216935016905081811115611f8957905b80611f975760009350611fc5565b8181655af3107a4000021115611fc057611fb9655af3107a4000820283612123565b9350611fc5565b600093505b50505090565b611fd36121be565b6005546001600160a01b03908116911614612023576040805162461bcd60e51b8152602060048201819052602482015260008051602061380f833981519152604482015290519081900360640190fd5b6001600160a01b0381166120685760405162461bcd60e51b81526004018080602001828103825260268152602001806136e26026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692169060008051602061382f83398151915290600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b600854600160b01b900460ff1681565b60008282018381101561211c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600061211c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612f12565b60008261217457506000610e53565b8282028284828161218157fe5b041461211c5760405162461bcd60e51b81526004018080602001828103825260218152602001806137c66021913960400191505060405180910390fd5b3390565b6001600160a01b0383166122075760405162461bcd60e51b815260040180806020018281038252602481526020018061391b6024913960400191505060405180910390fd5b6001600160a01b03821661224c5760405162461bcd60e51b81526004018080602001828103825260228152602001806137086022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166122f35760405162461bcd60e51b81526004018080602001828103825260258152602001806138bc6025913960400191505060405180910390fd5b6001600160a01b0382166123385760405162461bcd60e51b815260040180806020018281038252602381526020018061366d6023913960400191505060405180910390fd5b6001600160a01b03821660009081526015602052604090205460ff1615801561237a57506001600160a01b03831660009081526015602052604090205460ff16155b6123b55760405162461bcd60e51b81526004018080602001828103825260308152602001806136b26030913960400191505060405180910390fd5b806123cb576123c683836000612f77565b612cbe565b60006123d63061147c565b90506000600a54821015905060008180156123fb5750600854600160a01b900460ff16155b801561242057506001600160a01b03861660009081526018602052604090205460ff16155b8015612445575061242f6116cb565b6001600160a01b0316866001600160a01b031614155b801561246a57506124546116cb565b6001600160a01b0316856001600160a01b031614155b1561255f576008805460ff60a01b1916600160a01b179055600d54600c546000916124a09161249a908790612165565b90612123565b90506124ab816130d2565b601c54604080518381526001600160a01b03909216602083015280517feafa9125fd4b0edd379b9ab67721e8f4eb26bc018c352092ccac54a89ac6fed79281900390910190a1600061250e600d5461249a600b548861216590919063ffffffff16565b905061251981613114565b6040805182815290517f61d10b3f17a77466a4241488e37c886fa1637f9863ae76dd5076a80a932bc4eb9181900360200190a150506008805460ff60a01b191690555060015b6008546001600160a01b03871660009081526017602052604090205460ff600160a01b9092048216159116806125ad57506001600160a01b03861660009081526017602052604090205460ff165b156125b6575060005b8015612cae576001600160a01b03871660009081526018602052604090205460ff161561284f57600854600160b01b900460ff1661263b576040805162461bcd60e51b815260206004820152601860248201527f546f6b656e2069736e2774206c61756e63686564207965740000000000000000604482015290519081900360640190fd5b60105485111561267c5760405162461bcd60e51b815260040180806020018281038252602881526020018061377a6028913960400191505060405180910390fd5b601254856126898861147c565b0111156126c75760405162461bcd60e51b81526004018080602001828103825260248152602001806137a26024913960400191505060405180910390fd5b601354421180159081906126f457506001600160a01b03871660009081526016602052604090205460ff16155b1561274557601980546001810182556000919091527f944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c96950180546001600160a01b0319166001600160a01b0389161790555b600854600160a81b900460ff16801561277757506001600160a01b03871660009081526016602052604090205460ff16155b156127c857601980546001810182556000919091527f944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c96950180546001600160a01b0319166001600160a01b0389161790555b600854600160c01b900460ff16151560011415612806576127e9878761319a565b6001600160a01b0388166000908152601460205260409020600201555b604080518781526001600160a01b038916602082015281517f1df6c66a1a6eb6b0b6a23930c6ec94664e676e5d72f819a20a11e6c54540fa42929181900390910190a150612b6e565b6001600160a01b03861660009081526018602052604090205460ff1615612a70576001600160a01b03871660009081526016602052604090205460ff16156128cf576040805162461bcd60e51b815260206004820152600e60248201526d2cb7ba9030b9329039b734b832b960911b604482015290519081900360640190fd5b6011548511156129105760405162461bcd60e51b815260040180806020018281038252603a8152602001806138e1603a913960400191505060405180910390fd5b600854600160c81b900460ff161515600114801561294a57506001600160a01b03871660009081526014602052604090206004015460ff16155b156129f457600061295a8861147c565b905060028111156129f257612970816002612123565b86111561297c57600080fd5b6001600160a01b038816600090815260146020526040902060039081018054880190556129aa908290612123565b6001600160a01b038916600090815260146020526040902060030154106129f2576001600160a01b0388166000908152601460205260409020600401805460ff191660011790555b505b612a0785612a018961147c565b90613212565b612a28576001600160a01b0387166000908152601460205260408120600201555b604080518681526001600160a01b038916602082015281517f845540a7f3f9afb8980bffef1e5a59039c43bbd45de62cc2ce5def5830465f04929181900390910190a1612b6e565b6001600160a01b03871660009081526017602052604090205460ff16158015612ab257506001600160a01b03861660009081526017602052604090205460ff16155b15612b6e57600854600160c01b900460ff16151560011415612af557612ad8868661319a565b6001600160a01b0387166000908152601460205260409020600201555b612b0285612a018961147c565b612b23576001600160a01b0387166000908152601460205260408120600201555b604080516001600160a01b03808a1682528816602082015280820187905290517f38e8feed990acd7f5210170f614d354c7a0485670b9a787e9e00f8fca640d5749181900360600190a15b6000612b8a606461249a600d548961216590919063ffffffff16565b6001600160a01b03881660009081526018602052604090205490915060ff1615612bc057612bbe606461249a886001612165565b015b600854600090600160b81b900460ff1615156001148015612bfa57506001600160a01b03891660009081526017602052604090205460ff16155b8015612c1e57506001600160a01b03881660009081526018602052604090205460ff165b15612c9057600060018515151415612c5157600f548711612c40576001612c4e565b600f54612c4e908890612123565b90505b6001600160a01b038a16600090815260146020526040902060020154612c78908983613254565b9150828211612c88576000612c8c565b8282035b9150505b612c9c87838301613212565b9650612cab8930838501612f77565b50505b612cb9878787612f77565b505050505b505050565b60008184841115612d525760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d17578181015183820152602001612cff565b50505050905090810190601f168015612d445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b611903828261330f565b6001600160a01b03821660009081526018602052604090205460ff1615158115151415612dc25760405162461bcd60e51b815260040180806020018281038252603f81526020018061393f603f913960400191505060405180910390fd5b6001600160a01b038216600081815260186020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b038216612e5b5760405162461bcd60e51b815260040180806020018281038252602181526020018061389b6021913960400191505060405180910390fd5b612e6782600083612cbe565b612ea481604051806060016040528060228152602001613690602291396001600160a01b0385166000908152602081905260409020549190612cc3565b6001600160a01b038316600090815260208190526040902055600254612eca9082613212565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b60008183612f615760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612d17578181015183820152602001612cff565b506000838581612f6d57fe5b0495945050505050565b6001600160a01b038316612fbc5760405162461bcd60e51b81526004018080602001828103825260258152602001806138bc6025913960400191505060405180910390fd5b6001600160a01b0382166130015760405162461bcd60e51b815260040180806020018281038252602381526020018061366d6023913960400191505060405180910390fd5b61300c838383612cbe565b6130498160405180606001604052806026815260200161372a602691396001600160a01b0386166000908152602081905260409020549190612cc3565b6001600160a01b03808516600090815260208190526040808220939093559084168152205461307890826120c2565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6130db816133ff565b601c546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611903573d6000803e3d6000fd5b6000613121826002612123565b9050600061312f8383613212565b90504761313b836133ff565b60006131474783613212565b905061315383826135ae565b604080518581526020810183905280820185905290517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15050505050565b6000806131a5611ee9565b6001600160a01b0385166000908152601460205260408120600201549192506131cd8661147c565b90508115806131da575080155b156131e757829350613209565b846131f457819350613209565b61320682820284870201828701612123565b93505b50505092915050565b600061211c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612cc3565b60008061325f611ee9565b905060008515806132705750606485105b1561327e5760009250613306565b8186600a0110156133015760646132ac6132a561329e8986036002612123565b8590612123565b8290612123565b915084600e5411156132f65784600e54038210156132ca57816132d0565b84600e54035b9150600082116132e15760006132ef565b6132ef8161249a8885612165565b93506132fb565b600093505b50613306565b600092505b50509392505050565b6001600160a01b03821661336a576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61337660008383612cbe565b60025461338390826120c2565b6002556001600160a01b0382166000908152602081905260409020546133a990826120c2565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061342e57fe5b6001600160a01b03928316602091820292909201810191909152600854604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561348257600080fd5b505afa158015613496573d6000803e3d6000fd5b505050506040513d60208110156134ac57600080fd5b50518151829060019081106134bd57fe5b6001600160a01b0392831660209182029290920101526008546134e391309116846121c2565b60085460405163791ac94760e01b8152600481018481526000602483018190523060648401819052426084850181905260a060448601908152875160a487015287516001600160a01b039097169663791ac947968a968a9594939092909160c40190602080880191028083838b5b83811015613569578181015183820152602001613551565b505050509050019650505050505050600060405180830381600087803b15801561359257600080fd5b505af11580156135a6573d6000803e3d6000fd5b505050505050565b6008546135c69030906001600160a01b0316846121c2565b600854601b546040805163f305d71960e01b81523060048201526024810186905260006044820181905260648201526001600160a01b0392831660848201524260a48201529051919092169163f305d71991849160c48082019260609290919082900301818588803b15801561363b57600080fd5b505af115801561364f573d6000803e3d6000fd5b50505050506040513d606081101561366657600080fd5b5050505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e6365596f75722061646472657373206f7220726563697069656e74206164647265737320697320626c61636b6c69737465644f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365546f6b656e3a2054686520726f7574657220616c726561647920686173207468617420616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e45786365656473206d6178696d756d2077616c6c657420746f6b656e20616d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65728be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0546f6b656e3a205468652050616e63616b655377617020706169722063616e6e6f742062652072656d6f7665642066726f6d206175746f6d617465644d61726b65744d616b6572506169727345524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737353656c6c207472616e7366657220616d6f756e74206578636565647320746865206d617853656c6c5472616e73616374696f6e416d6f756e742e45524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373546f6b656e3a204175746f6d61746564206d61726b6574206d616b6572207061697220697320616c72656164792073657420746f20746861742076616c7565596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6f636b45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204b0a732d7402fdef4a92921304e6e8f82d68828fc5526f677c78bfa106c194e264736f6c63430007060033
[ 4, 11, 12, 13, 16, 5 ]
0xf1da47d22eafeadbf5cb2f0a27438eee7dafd081
//File: node_modules/zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol pragma solidity ^0.4.18; /** * @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/math/SafeMath.sol 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; } } //File: node_modules/zeppelin-solidity/contracts/token/ERC20/BasicToken.sol pragma solidity ^0.4.18; /** * @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 pragma solidity ^0.4.18; /** * @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 pragma solidity ^0.4.18; /** * @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/ownership/Ownable.sol pragma solidity ^0.4.18; /** * @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/token/ERC20/MintableToken.sol pragma solidity ^0.4.18; /** * @title Mintable token * @dev Simple ERC20 Token example, with mintable token creation * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * 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); _; } /** * @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: node_modules/zeppelin-solidity/contracts/lifecycle/Pausable.sol pragma solidity ^0.4.18; /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; Unpause(); } } //File: node_modules/zeppelin-solidity/contracts/token/ERC20/PausableToken.sol pragma solidity ^0.4.18; /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, 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); } function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } //File: node_modules/zeppelin-solidity/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.4.18; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure. * 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 { function safeTransfer(ERC20Basic token, address to, uint256 value) internal { assert(token.transfer(to, value)); } function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal { assert(token.transferFrom(from, to, value)); } function safeApprove(ERC20 token, address spender, uint256 value) internal { assert(token.approve(spender, value)); } } //File: node_modules/zeppelin-solidity/contracts/ownership/CanReclaimToken.sol pragma solidity ^0.4.18; /** * @title Contracts that should be able to recover tokens * @author SylTi * @dev This allow a contract to recover any ERC20 token received in a contract by transferring the balance to the contract owner. * This will prevent any accidental loss of tokens. */ contract CanReclaimToken is Ownable { using SafeERC20 for ERC20Basic; /** * @dev Reclaim all ERC20Basic compatible tokens * @param token ERC20Basic The address of the token contract */ function reclaimToken(ERC20Basic token) external onlyOwner { uint256 balance = token.balanceOf(this); token.safeTransfer(owner, balance); } } //File: src/contracts/ico/UacToken.sol /** * @title Ubiatar Coin token * * @version 1.0 * @author Validity Labs AG <info@validitylabs.org> */ pragma solidity ^0.4.19; contract UacToken is CanReclaimToken, MintableToken, PausableToken { string public constant name = "Ubiatar Coin"; string public constant symbol = "UAC"; uint8 public constant decimals = 18; /** * @dev Constructor of UacToken that instantiates a new Mintable Pausable Token */ function UacToken() public { // token should not be transferrable until after all tokens have been issued paused = true; } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305d2035b1461011757806306fdde0314610146578063095ea7b3146101d657806317ffc3201461023b57806318160ddd1461027e57806323b872dd146102a9578063313ce5671461032e5780633f4ba83a1461035f57806340c10f19146103765780635c975abb146103db578063661884631461040a57806370a082311461046f5780637d64bcb4146104c65780638456cb59146104f55780638da5cb5b1461050c57806395d89b4114610563578063a9059cbb146105f3578063d73dd62314610658578063dd62ed3e146106bd578063f2fde38b14610734575b600080fd5b34801561012357600080fd5b5061012c610777565b604051808215151515815260200191505060405180910390f35b34801561015257600080fd5b5061015b61078a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561019b578082015181840152602081019050610180565b50505050905090810190601f1680156101c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101e257600080fd5b50610221600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107c3565b604051808215151515815260200191505060405180910390f35b34801561024757600080fd5b5061027c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107f3565b005b34801561028a57600080fd5b5061029361097a565b6040518082815260200191505060405180910390f35b3480156102b557600080fd5b50610314600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610984565b604051808215151515815260200191505060405180910390f35b34801561033a57600080fd5b506103436109b6565b604051808260ff1660ff16815260200191505060405180910390f35b34801561036b57600080fd5b506103746109bb565b005b34801561038257600080fd5b506103c1600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a7b565b604051808215151515815260200191505060405180910390f35b3480156103e757600080fd5b506103f0610c61565b604051808215151515815260200191505060405180910390f35b34801561041657600080fd5b50610455600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c74565b604051808215151515815260200191505060405180910390f35b34801561047b57600080fd5b506104b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca4565b6040518082815260200191505060405180910390f35b3480156104d257600080fd5b506104db610cec565b604051808215151515815260200191505060405180910390f35b34801561050157600080fd5b5061050a610db4565b005b34801561051857600080fd5b50610521610e75565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561056f57600080fd5b50610578610e9b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105b857808201518184015260208101905061059d565b50505050905090810190601f1680156105e55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156105ff57600080fd5b5061063e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ed4565b604051808215151515815260200191505060405180910390f35b34801561066457600080fd5b506106a3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f04565b604051808215151515815260200191505060405180910390f35b3480156106c957600080fd5b5061071e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f34565b6040518082815260200191505060405180910390f35b34801561074057600080fd5b50610775600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fbb565b005b600360149054906101000a900460ff1681565b6040805190810160405280600c81526020017f5562696174617220436f696e000000000000000000000000000000000000000081525081565b6000600360159054906101000a900460ff161515156107e157600080fd5b6107eb8383611113565b905092915050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561085157600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156108ec57600080fd5b505af1158015610900573d6000803e3d6000fd5b505050506040513d602081101561091657600080fd5b81019080805190602001909291905050509050610976600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828473ffffffffffffffffffffffffffffffffffffffff166112059092919063ffffffff16565b5050565b6000600154905090565b6000600360159054906101000a900460ff161515156109a257600080fd5b6109ad8484846112f0565b90509392505050565b601281565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a1757600080fd5b600360159054906101000a900460ff161515610a3257600080fd5b6000600360156101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ad957600080fd5b600360149054906101000a900460ff16151515610af557600080fd5b610b0a826001546116aa90919063ffffffff16565b600181905550610b61826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116aa90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600360159054906101000a900460ff1681565b6000600360159054906101000a900460ff16151515610c9257600080fd5b610c9c83836116c8565b905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4a57600080fd5b600360149054906101000a900460ff16151515610d6657600080fd5b6001600360146101000a81548160ff0219169083151502179055507fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0860405160405180910390a16001905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e1057600080fd5b600360159054906101000a900460ff16151515610e2c57600080fd5b6001600360156101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600381526020017f554143000000000000000000000000000000000000000000000000000000000081525081565b6000600360159054906101000a900460ff16151515610ef257600080fd5b610efc8383611959565b905092915050565b6000600360159054906101000a900460ff16151515610f2257600080fd5b610f2c8383611b78565b905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561101757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561105357600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156112a857600080fd5b505af11580156112bc573d6000803e3d6000fd5b505050506040513d60208110156112d257600080fd5b810190808051906020019092919050505015156112eb57fe5b505050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561132d57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561137a57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561140557600080fd5b611456826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d7490919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114e9826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116aa90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506115ba82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d7490919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008082840190508381101515156116be57fe5b8091505092915050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050808311156117d9576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061186d565b6117ec8382611d7490919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561199657600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156119e357600080fd5b611a34826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d7490919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ac7826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116aa90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000611c0982600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116aa90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000828211151515611d8257fe5b8183039050929150505600a165627a7a72305820641d7ad9815c51622acfddae99c17e8aee90f3b3454bbc445815c27d70350ef50029
[ 38 ]
0xf1Dc500FdE233A4055e25e5BbF516372BC4F6871
// SPDX-License-Identifier: MIT pragma solidity ^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 {ERC1967Proxy-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 || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } } // 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 "./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 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 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 {} } // 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 "./draft-ERC20Permit.sol"; import "../../../utils/math/Math.sol"; import "../../../utils/math/SafeCast.sol"; import "../../../utils/cryptography/ECDSA.sol"; /** * @dev Extension of ERC20 to support Compound-like voting and delegation. This version is more generic than Compound's, * and supports token supply up to 2^224^ - 1, while COMP is limited to 2^96^ - 1. * * NOTE: If exact COMP compatibility is required, use the {ERC20VotesComp} variant of this module. * * This extension keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting * power can be queried through the public accessors {getVotes} and {getPastVotes}. * * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. * Enabling self-delegation can easily be done by overriding the {delegates} function. Keep in mind however that this * will significantly increase the base gas cost of transfers. * * _Available since v4.2._ */ abstract contract ERC20Votes is ERC20Permit { struct Checkpoint { uint32 fromBlock; uint224 votes; } bytes32 private constant _DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); mapping(address => address) private _delegates; mapping(address => Checkpoint[]) private _checkpoints; Checkpoint[] private _totalSupplyCheckpoints; /** * @dev Emitted when an account changes their delegate. */ event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /** * @dev Emitted when a token transfer or delegate change results in changes to an account's voting power. */ event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @dev Get the `pos`-th checkpoint for `account`. */ function checkpoints(address account, uint32 pos) public view virtual returns (Checkpoint memory) { return _checkpoints[account][pos]; } /** * @dev Get number of checkpoints for `account`. */ function numCheckpoints(address account) public view virtual returns (uint32) { return SafeCast.toUint32(_checkpoints[account].length); } /** * @dev Get the address `account` is currently delegating to. */ function delegates(address account) public view virtual returns (address) { return _delegates[account]; } /** * @dev Gets the current votes balance for `account` */ function getVotes(address account) public view returns (uint256) { uint256 pos = _checkpoints[account].length; return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes; } /** * @dev Retrieve the number of votes for `account` at the end of `blockNumber`. * * Requirements: * * - `blockNumber` must have been already mined */ function getPastVotes(address account, uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_checkpoints[account], blockNumber); } /** * @dev Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances. * It is but NOT the sum of all the delegated votes! * * Requirements: * * - `blockNumber` must have been already mined */ function getPastTotalSupply(uint256 blockNumber) public view returns (uint256) { require(blockNumber < block.number, "ERC20Votes: block not yet mined"); return _checkpointsLookup(_totalSupplyCheckpoints, blockNumber); } /** * @dev Lookup a value in a list of (sorted) checkpoints. */ function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) { // We run a binary search to look for the earliest checkpoint taken after `blockNumber`. // // During the loop, the index of the wanted checkpoint remains in the range [low, high). // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant. // - If the middle checkpoint is after `blockNumber`, we look in [low, mid) // - If the middle checkpoint is before `blockNumber`, we look in [mid+1, high) // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not // out of bounds (in which case we're looking too far in the past and the result is 0). // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out // the same. uint256 high = ckpts.length; uint256 low = 0; while (low < high) { uint256 mid = Math.average(low, high); if (ckpts[mid].fromBlock > blockNumber) { high = mid; } else { low = mid + 1; } } return high == 0 ? 0 : ckpts[high - 1].votes; } /** * @dev Delegate votes from the sender to `delegatee`. */ function delegate(address delegatee) public virtual { return _delegate(_msgSender(), delegatee); } /** * @dev Delegates votes from signer to `delegatee` */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public virtual { require(block.timestamp <= expiry, "ERC20Votes: signature expired"); address signer = ECDSA.recover( _hashTypedDataV4(keccak256(abi.encode(_DELEGATION_TYPEHASH, delegatee, nonce, expiry))), v, r, s ); require(nonce == _useNonce(signer), "ERC20Votes: invalid nonce"); return _delegate(signer, delegatee); } /** * @dev Maximum token supply. Defaults to `type(uint224).max` (2^224^ - 1). */ function _maxSupply() internal view virtual returns (uint224) { return type(uint224).max; } /** * @dev Snapshots the totalSupply after it has been increased. */ function _mint(address account, uint256 amount) internal virtual override { super._mint(account, amount); require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes"); _writeCheckpoint(_totalSupplyCheckpoints, _add, amount); } /** * @dev Snapshots the totalSupply after it has been decreased. */ function _burn(address account, uint256 amount) internal virtual override { super._burn(account, amount); _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount); } /** * @dev Move voting power when tokens are transferred. * * Emits a {DelegateVotesChanged} event. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._afterTokenTransfer(from, to, amount); _moveVotingPower(delegates(from), delegates(to), amount); } /** * @dev Change delegation for `delegator` to `delegatee`. * * Emits events {DelegateChanged} and {DelegateVotesChanged}. */ function _delegate(address delegator, address delegatee) internal virtual { address currentDelegate = delegates(delegator); uint256 delegatorBalance = balanceOf(delegator); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveVotingPower(currentDelegate, delegatee, delegatorBalance); } function _moveVotingPower( address src, address dst, uint256 amount ) private { if (src != dst && amount > 0) { if (src != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[src], _subtract, amount); emit DelegateVotesChanged(src, oldWeight, newWeight); } if (dst != address(0)) { (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount); emit DelegateVotesChanged(dst, oldWeight, newWeight); } } } function _writeCheckpoint( Checkpoint[] storage ckpts, function(uint256, uint256) view returns (uint256) op, uint256 delta ) private returns (uint256 oldWeight, uint256 newWeight) { uint256 pos = ckpts.length; oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes; newWeight = op(oldWeight, delta); if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) { ckpts[pos - 1].votes = SafeCast.toUint224(newWeight); } else { ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)})); } } function _add(uint256 a, uint256 b) private pure returns (uint256) { return a + b; } function _subtract(uint256 a, uint256 b) private pure returns (uint256) { return a - b; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC20Votes.sol"; /** * @dev Extension of ERC20 to support Compound's voting and delegation. This version exactly matches Compound's * interface, with the drawback of only supporting supply up to (2^96^ - 1). * * NOTE: You should use this contract if you need exact compatibility with COMP (for example in order to use your token * with Governor Alpha or Bravo) and if you are sure the supply cap of 2^96^ is enough for you. Otherwise, use the * {ERC20Votes} variant of this module. * * This extensions keeps a history (checkpoints) of each account's vote power. Vote power can be delegated either * by calling the {delegate} function directly, or by providing a signature to be used with {delegateBySig}. Voting * power can be queried through the public accessors {getCurrentVotes} and {getPriorVotes}. * * By default, token balance does not account for voting power. This makes transfers cheaper. The downside is that it * requires users to delegate to themselves in order to activate checkpoints and have their voting power tracked. * Enabling self-delegation can easily be done by overriding the {delegates} function. Keep in mind however that this * will significantly increase the base gas cost of transfers. * * _Available since v4.2._ */ abstract contract ERC20VotesComp is ERC20Votes { /** * @dev Comp version of the {getVotes} accessor, with `uint96` return type. */ function getCurrentVotes(address account) external view returns (uint96) { return SafeCast.toUint96(getVotes(account)); } /** * @dev Comp version of the {getPastVotes} accessor, with `uint96` return type. */ function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96) { return SafeCast.toUint96(getPastVotes(account, blockNumber)); } /** * @dev Maximum token supply. Reduced to `type(uint96).max` (2^96^ - 1) to fit COMP interface. */ function _maxSupply() internal view virtual override returns (uint224) { return type(uint96).max; } } // SPDX-License-Identifier: MIT 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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./draft-IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/draft-EIP712.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // 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 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); } } } } // 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; /** * @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; /** * @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 { /** * @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. * * 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] */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { // 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 recover(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 recover(hash, r, vs); } else { revert("ECDSA: invalid signature length"); } } /** * @dev Overload of {ECDSA-recover} 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.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return recover(hash, v, r, s); } /** * @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) { // 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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): 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. require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value" ); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @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; 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 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 Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } // 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: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20VotesComp.sol"; import "./Vesting.sol"; import "./SimpleGovernance.sol"; /** * @title Saddle DAO token * @notice A token that is deployed with fixed amount and appropriate vesting contracts. * Transfer is blocked for a period of time until the governance can toggle the transferability. */ contract SDL is ERC20Permit, Pausable, SimpleGovernance { using SafeERC20 for IERC20; // Token max supply is 1,000,000,000 * 1e18 = 1e27 uint256 public constant MAX_SUPPLY = 1e9 ether; uint256 public immutable govCanUnpauseAfter; uint256 public immutable anyoneCanUnpauseAfter; address public immutable vestingContractTarget; mapping(address => bool) public allowedTransferee; event Allowed(address indexed target); event Disallowed(address indexed target); event VestingContractDeployed( address indexed beneficiary, address vestingContract ); struct Recipient { address to; uint256 amount; uint256 startTimestamp; uint256 cliffPeriod; uint256 durationPeriod; } /** * @notice Initializes SDL token with specified governance address and recipients. For vesting * durations and amounts, please refer to our documentation on token distribution schedule. * @param governance_ address of the governance who will own this contract * @param pausePeriod_ time in seconds since the deployment. After this period, this token can be unpaused * by the governance. * @param vestingContractTarget_ logic contract of Vesting.sol to use for cloning */ constructor( address governance_, uint256 pausePeriod_, address vestingContractTarget_ ) public ERC20("Saddle DAO", "SDL") ERC20Permit("Saddle DAO") { require(governance_ != address(0), "SDL: governance cannot be empty"); require( vestingContractTarget_ != address(0), "SDL: vesting contract target cannot be empty" ); require( pausePeriod_ > 0 && pausePeriod_ <= 52 weeks, "SDL: pausePeriod must be in between 0 and 52 weeks" ); // Set state variables vestingContractTarget = vestingContractTarget_; governance = governance_; govCanUnpauseAfter = block.timestamp + pausePeriod_; anyoneCanUnpauseAfter = block.timestamp + 52 weeks; // Allow governance to transfer tokens allowedTransferee[governance_] = true; // Mint tokens to governance _mint(governance, MAX_SUPPLY); // Pause transfers at deployment if (pausePeriod_ > 0) { _pause(); } emit SetGovernance(governance_); } /** * @notice Deploys a clone of the vesting contract for the given recipient. Details about vesting and token * release schedule can be found on https://docs.saddle.finance * @param recipient Recipient of the token through the vesting schedule. */ function deployNewVestingContract(Recipient memory recipient) public onlyGovernance returns (address) { require( recipient.durationPeriod > 0, "SDL: duration for vesting cannot be 0" ); // Deploy a clone rather than deploying a whole new contract Vesting vestingContract = Vesting(Clones.clone(vestingContractTarget)); // Initialize the clone contract for the recipient vestingContract.initialize( address(this), recipient.to, recipient.startTimestamp, recipient.cliffPeriod, recipient.durationPeriod ); // Send tokens to the contract IERC20(address(this)).safeTransferFrom( msg.sender, address(vestingContract), recipient.amount ); // Add the vesting contract to the allowed transferee list allowedTransferee[address(vestingContract)] = true; emit Allowed(address(vestingContract)); emit VestingContractDeployed(recipient.to, address(vestingContract)); return address(vestingContract); } /** * @notice Changes the transferability of this token. * @dev When the transfer is not enabled, only those in allowedTransferee array can * transfer this token. */ function enableTransfer() external { require(paused(), "SDL: transfer is enabled"); uint256 unpauseAfter = msg.sender == governance ? govCanUnpauseAfter : anyoneCanUnpauseAfter; require( block.timestamp > unpauseAfter, "SDL: cannot enable transfer yet" ); _unpause(); } /** * @notice Add the given addresses to the list of allowed addresses that can transfer during paused period. * Governance will add auxiliary contracts to the allowed list to facilitate distribution during the paused period. * @param targets Array of addresses to add */ function addToAllowedList(address[] memory targets) external onlyGovernance { for (uint256 i = 0; i < targets.length; i++) { allowedTransferee[targets[i]] = true; emit Allowed(targets[i]); } } /** * @notice Remove the given addresses from the list of allowed addresses that can transfer during paused period. * @param targets Array of addresses to remove */ function removeFromAllowedList(address[] memory targets) external onlyGovernance { for (uint256 i = 0; i < targets.length; i++) { allowedTransferee[targets[i]] = false; emit Disallowed(targets[i]); } } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { super._beforeTokenTransfer(from, to, amount); require(!paused() || allowedTransferee[from], "SDL: paused"); require(to != address(this), "SDL: invalid recipient"); } /** * @notice Transfers any stuck tokens or ether out to the given destination. * @dev Method to claim junk and accidentally sent tokens. This will be only used to rescue * tokens that are mistakenly sent by users to this contract. * @param token Address of the ERC20 token to transfer out. Set to address(0) to transfer ether instead. * @param to Destination address that will receive the tokens. * @param balance Amount to transfer out. Set to 0 to select all available amount. */ function rescueTokens( IERC20 token, address payable to, uint256 balance ) external onlyGovernance { require(to != address(0), "SDL: invalid recipient"); if (token == IERC20(address(0))) { // for Ether uint256 totalBalance = address(this).balance; balance = balance == 0 ? totalBalance : Math.min(totalBalance, balance); require(balance > 0, "SDL: trying to send 0 ETH"); // slither-disable-next-line arbitrary-send (bool success, ) = to.call{value: balance}(""); require(success, "SDL: ETH transfer failed"); } else { // any other erc20 uint256 totalBalance = token.balanceOf(address(this)); balance = balance == 0 ? totalBalance : Math.min(totalBalance, balance); require(balance > 0, "SDL: trying to send 0 balance"); token.safeTransfer(to, balance); } } } // SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/utils/Context.sol"; abstract contract SimpleGovernance is Context { address public governance; address public pendingGovernance; event SetGovernance(address indexed governance); /** * @notice Changes governance of this contract */ modifier onlyGovernance() { require( _msgSender() == governance, "only governance can perform this action" ); _; } /** * @notice Changes governance of this contract * @dev Only governance can call this function. The new governance must call `acceptGovernance` after. * @param newGovernance new address to become the governance */ function changeGovernance(address newGovernance) external onlyGovernance { require( newGovernance != governance, "governance must be different from current one" ); require(newGovernance != address(0), "governance cannot be empty"); pendingGovernance = newGovernance; } /** * @notice Accept the new role of governance * @dev `changeGovernance` must be called first to set `pendingGovernance` */ function acceptGovernance() external { address _pendingGovernance = pendingGovernance; require( _pendingGovernance != address(0), "changeGovernance must be called first" ); require( _msgSender() == _pendingGovernance, "only pendingGovernance can accept this role" ); pendingGovernance = address(0); governance = _msgSender(); emit SetGovernance(_msgSender()); } } // SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/Context.sol"; import "./SimpleGovernance.sol"; /** * @title Vesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Owner has the power * to change the beneficiary who receives the vested tokens. */ contract Vesting is Initializable, Context { using SafeERC20 for IERC20; event Released(uint256 amount); event VestingInitialized( address indexed beneficiary, uint256 startTimestamp, uint256 cliff, uint256 duration ); event SetBeneficiary(address indexed beneficiary); // beneficiary of tokens after they are released address public beneficiary; IERC20 public token; uint256 public cliffInSeconds; uint256 public durationInSeconds; uint256 public startTimestamp; uint256 public released; /** * @dev Sets the beneficiary to _msgSender() on deploying this contract. This prevents others from * initializing the logic contract. */ constructor() public { beneficiary = _msgSender(); } /** * @dev Limits certain functions to be called by governance */ modifier onlyGovernance() { require( _msgSender() == governance(), "only governance can perform this action" ); _; } /** * @dev Initializes a vesting contract that vests its balance of any ERC20 token to the * _beneficiary, monthly in a linear fashion until duration has passed. By then all * of the balance will have vested. * @param _token address of the token that is subject to vesting * @param _beneficiary address of the beneficiary to whom vested tokens are transferred * @param _cliffInSeconds duration in months of the cliff in which tokens will begin to vest * @param _durationInSeconds duration in months of the period in which the tokens will vest * @param _startTimestamp start timestamp when the cliff and vesting should start to count */ function initialize( address _token, address _beneficiary, uint256 _startTimestamp, uint256 _cliffInSeconds, uint256 _durationInSeconds ) external initializer { require(_token != address(0), "_token cannot be empty"); // dev: beneficiary is set to msg.sender on logic contracts during deployment require(beneficiary == address(0), "cannot initialize logic contract"); require(_beneficiary != address(0), "_beneficiary cannot be empty"); require(_startTimestamp != 0, "startTimestamp cannot be 0"); require( _startTimestamp <= block.timestamp, "startTimestamp cannot be from the future" ); require(_durationInSeconds != 0, "duration cannot be 0"); require( _cliffInSeconds <= _durationInSeconds, "cliff is greater than duration" ); token = IERC20(_token); beneficiary = _beneficiary; startTimestamp = _startTimestamp; durationInSeconds = _durationInSeconds; cliffInSeconds = _cliffInSeconds; emit VestingInitialized( _beneficiary, _startTimestamp, _cliffInSeconds, _durationInSeconds ); } /** * @notice Transfers vested tokens to beneficiary. */ function release() external { uint256 vested = vestedAmount(); require(vested > 0, "No tokens to release"); released = released + vested; emit Released(vested); token.safeTransfer(beneficiary, vested); } /** * @notice Calculates the amount that has already vested but hasn't been released yet. */ function vestedAmount() public view returns (uint256) { uint256 blockTimestamp = block.timestamp; uint256 _durationInSeconds = durationInSeconds; uint256 elapsedTime = blockTimestamp - startTimestamp; // @dev startTimestamp is always less than blockTimestamp if (elapsedTime < cliffInSeconds) { return 0; } // If over vesting duration, all tokens vested if (elapsedTime >= _durationInSeconds) { return token.balanceOf(address(this)); } else { uint256 currentBalance = token.balanceOf(address(this)); // If there are no tokens in this contract yet, return 0. if (currentBalance == 0) { return 0; } uint256 totalBalance = currentBalance + released; uint256 vested = (totalBalance * elapsedTime) / _durationInSeconds; uint256 unreleased = vested - released; return unreleased; } } /** * @notice Changes beneficiary who receives the vested token. * @dev Only governance can call this function. This is to be used in case the target address * needs to be updated. If the previous beneficiary has any unclaimed tokens, the new beneficiary * will be able to claim them and the rest of the vested tokens. * @param newBeneficiary new address to become the beneficiary */ function changeBeneficiary(address newBeneficiary) external onlyGovernance { require( newBeneficiary != beneficiary, "beneficiary must be different from current one" ); require(newBeneficiary != address(0), "beneficiary cannot be empty"); beneficiary = newBeneficiary; emit SetBeneficiary(newBeneficiary); } /** * @notice Governance who owns this contract. * @dev Governance of the token contract also owns this vesting contract. */ function governance() public view returns (address) { return SimpleGovernance(address(token)).governance(); } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806370a0823111610104578063a9059cbb116100a2578063d5dbfbd711610071578063d5dbfbd714610409578063dd62ed3e14610430578063f1b50c1d14610469578063f39c38a01461047157600080fd5b8063a9059cbb146103bd578063c643b577146103d0578063cea9d26f146103e3578063d505accf146103f657600080fd5b806392e7c85e116100de57806392e7c85e1461036857806395d89b411461038f57806399572d6f14610397578063a457c2d7146103aa57600080fd5b806370a08231146103195780637ecebe0014610342578063885ad0cf1461035557600080fd5b80633644e5151161017157806359baed071161014b57806359baed07146102945780635aa6e675146102bb5780635c975abb146102eb5780635d4545a0146102f657600080fd5b80633644e51514610266578063395093511461026e5780633c8d76d11461028157600080fd5b8063238efcbc116101ad578063238efcbc1461022757806323b872dd14610231578063313ce5671461024457806332cb6b0c1461025357600080fd5b806306fdde03146101d4578063095ea7b3146101f257806318160ddd14610215575b600080fd5b6101dc610484565b6040516101e991906124c4565b60405180910390f35b61020561020036600461230f565b610516565b60405190151581526020016101e9565b6002545b6040519081526020016101e9565b61022f61052c565b005b61020561023f366004612257565b6106b6565b604051601281526020016101e9565b6102196b033b2e3c9fd0803ce800000081565b610219610777565b61020561027c36600461230f565b610786565b61022f61028f36600461233b565b6107c2565b6102197f0000000000000000000000000000000000000000000000000000000063732f6b81565b6006546102d39061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016101e9565b60065460ff16610205565b610205610304366004612201565b60086020526000908152604090205460ff1681565b610219610327366004612201565b6001600160a01b031660009081526020819052604090205490565b610219610350366004612201565b610918565b61022f61036336600461233b565b610938565b6102197f00000000000000000000000000000000000000000000000000000000620bb1bb81565b6101dc610a8a565b61022f6103a5366004612201565b610a99565b6102056103b836600461230f565b610c40565b6102056103cb36600461230f565b610cf1565b6102d36103de366004612416565b610cfe565b61022f6103f1366004612257565b610f9d565b61022f610404366004612298565b6112bc565b6102d37f000000000000000000000000f8504e92428d65e56e495684a38f679c1b1dc30b81565b61021961043e36600461221e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b61022f611420565b6007546102d3906001600160a01b031681565b606060038054610493906125a8565b80601f01602080910402602001604051908101604052809291908181526020018280546104bf906125a8565b801561050c5780601f106104e15761010080835404028352916020019161050c565b820191906000526020600020905b8154815290600101906020018083116104ef57829003601f168201915b5050505050905090565b6000610523338484611530565b50600192915050565b6007546001600160a01b0316806105b05760405162461bcd60e51b815260206004820152602560248201527f6368616e6765476f7665726e616e6365206d7573742062652063616c6c65642060448201527f666972737400000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b0382161461062e5760405162461bcd60e51b815260206004820152602b60248201527f6f6e6c792070656e64696e67476f7665726e616e63652063616e20616363657060448201527f74207468697320726f6c6500000000000000000000000000000000000000000060648201526084016105a7565b600780547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055600680547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1661010033908102919091179091556040517f24a8c4807b324a269a51827c3446b8ac1cc13810d7d0c0ca1efafabddd7b621990600090a250565b60006106c3848484611688565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561075d5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084016105a7565b61076a8533858403611530565b60019150505b9392505050565b60006107816118aa565b905090565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916105239185906107bd908690612564565b611530565b60065461010090046001600160a01b0316336001600160a01b0316146108505760405162461bcd60e51b815260206004820152602760248201527f6f6e6c7920676f7665726e616e63652063616e20706572666f726d207468697360448201527f20616374696f6e0000000000000000000000000000000000000000000000000060648201526084016105a7565b60005b8151811015610914576000600860008484815181106108745761087461265e565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055508181815181106108c5576108c561265e565b60200260200101516001600160a01b03167f9ef90a89b00db1a1891a357dc96b2a273add9d883e378c350d22bad87a9d7d3060405160405180910390a28061090c816125f6565b915050610853565b5050565b6001600160a01b0381166000908152600560205260408120545b92915050565b60065461010090046001600160a01b0316336001600160a01b0316146109c65760405162461bcd60e51b815260206004820152602760248201527f6f6e6c7920676f7665726e616e63652063616e20706572666f726d207468697360448201527f20616374696f6e0000000000000000000000000000000000000000000000000060648201526084016105a7565b60005b8151811015610914576001600860008484815181106109ea576109ea61265e565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550818181518110610a3b57610a3b61265e565b60200260200101516001600160a01b03167f77a7dbc6ad97703ad411a8d5edfcd1df382fb34b076a90898b11884f7ebdcc0560405160405180910390a280610a82816125f6565b9150506109c9565b606060048054610493906125a8565b60065461010090046001600160a01b0316336001600160a01b031614610b275760405162461bcd60e51b815260206004820152602760248201527f6f6e6c7920676f7665726e616e63652063616e20706572666f726d207468697360448201527f20616374696f6e0000000000000000000000000000000000000000000000000060648201526084016105a7565b6006546001600160a01b03828116610100909204161415610bb05760405162461bcd60e51b815260206004820152602d60248201527f676f7665726e616e6365206d75737420626520646966666572656e742066726f60448201527f6d2063757272656e74206f6e650000000000000000000000000000000000000060648201526084016105a7565b6001600160a01b038116610c065760405162461bcd60e51b815260206004820152601a60248201527f676f7665726e616e63652063616e6e6f7420626520656d70747900000000000060448201526064016105a7565b600780547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015610cda5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016105a7565b610ce73385858403611530565b5060019392505050565b6000610523338484611688565b60065460009061010090046001600160a01b0316336001600160a01b031614610d8f5760405162461bcd60e51b815260206004820152602760248201527f6f6e6c7920676f7665726e616e63652063616e20706572666f726d207468697360448201527f20616374696f6e0000000000000000000000000000000000000000000000000060648201526084016105a7565b6000826080015111610e095760405162461bcd60e51b815260206004820152602560248201527f53444c3a206475726174696f6e20666f722076657374696e672063616e6e6f7460448201527f206265203000000000000000000000000000000000000000000000000000000060648201526084016105a7565b6000610e347f000000000000000000000000f8504e92428d65e56e495684a38f679c1b1dc30b61199d565b83516040808601516060870151608088015192517fd13f90b40000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03948516602482015260448101929092526064820152608481019190915291925082169063d13f90b49060a401600060405180830381600087803b158015610ebf57600080fd5b505af1158015610ed3573d6000803e3d6000fd5b5050506020840151610eeb9150309033908490611a53565b6001600160a01b03811660008181526008602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055517f77a7dbc6ad97703ad411a8d5edfcd1df382fb34b076a90898b11884f7ebdcc059190a282516040516001600160a01b038381168252909116907f739fe22b8edefd6ce1fe32460f9cd54bf8e66fc7447f4c8a8131ce078a1988af9060200160405180910390a290505b919050565b60065461010090046001600160a01b0316336001600160a01b03161461102b5760405162461bcd60e51b815260206004820152602760248201527f6f6e6c7920676f7665726e616e63652063616e20706572666f726d207468697360448201527f20616374696f6e0000000000000000000000000000000000000000000000000060648201526084016105a7565b6001600160a01b0382166110815760405162461bcd60e51b815260206004820152601660248201527f53444c3a20696e76616c696420726563697069656e740000000000000000000060448201526064016105a7565b6001600160a01b0383166111a3574781156110a5576110a08183611b22565b6110a7565b805b9150600082116110f95760405162461bcd60e51b815260206004820152601960248201527f53444c3a20747279696e6720746f2073656e642030204554480000000000000060448201526064016105a7565b6000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114611146576040519150601f19603f3d011682016040523d82523d6000602084013e61114b565b606091505b505090508061119c5760405162461bcd60e51b815260206004820152601860248201527f53444c3a20455448207472616e73666572206661696c6564000000000000000060448201526064016105a7565b5050505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b1580156111fe57600080fd5b505afa158015611212573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611236919061248f565b9050811561124d576112488183611b22565b61124f565b805b9150600082116112a15760405162461bcd60e51b815260206004820152601d60248201527f53444c3a20747279696e6720746f2073656e6420302062616c616e636500000060448201526064016105a7565b6112b56001600160a01b0385168484611b38565b505b505050565b8342111561130c5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e6500000060448201526064016105a7565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861133b8c611b81565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e001604051602081830303815290604052805190602001209050600061139682611ba9565b905060006113a682878787611c12565b9050896001600160a01b0316816001600160a01b0316146114095760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e6174757265000060448201526064016105a7565b6114148a8a8a611530565b50505050505050505050565b60065460ff166114725760405162461bcd60e51b815260206004820152601860248201527f53444c3a207472616e7366657220697320656e61626c6564000000000000000060448201526064016105a7565b60065460009061010090046001600160a01b031633146114b2577f0000000000000000000000000000000000000000000000000000000063732f6b6114d4565b7f00000000000000000000000000000000000000000000000000000000620bb1bb5b90508042116115255760405162461bcd60e51b815260206004820152601f60248201527f53444c3a2063616e6e6f7420656e61626c65207472616e73666572207965740060448201526064016105a7565b61152d611e0f565b50565b6001600160a01b0383166115ab5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016105a7565b6001600160a01b0382166116275760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016105a7565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166117045760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016105a7565b6001600160a01b0382166117805760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016105a7565b61178b838383611ebe565b6001600160a01b0383166000908152602081905260409020548181101561181a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016105a7565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290611851908490612564565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161189d91815260200190565b60405180910390a36112b5565b60007f00000000000000000000000000000000000000000000000000000000000000014614156118f957507f1cb181da94a689090c7cbf8ad9bf3fafe7f24280b1335ea361187c66c3f3181490565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f3f54831db6e6336fe67b6c69a0bd4bd514c3c550f8d7ff46f987b869dabc986a828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b60006040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528260601b60148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f09150506001600160a01b038116610f985760405162461bcd60e51b815260206004820152601660248201527f455243313136373a20637265617465206661696c65640000000000000000000060448201526064016105a7565b6040516001600160a01b03808516602483015283166044820152606481018290526112b59085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611f8d565b6000818310611b315781610770565b5090919050565b6040516001600160a01b0383166024820152604481018290526112b79084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611aa0565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b6000610932611bb66118aa565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115611caa5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016105a7565b8360ff16601b1480611cbf57508360ff16601c145b611d315760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016105a7565b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa158015611d85573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001519150506001600160a01b038116611e065760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016105a7565b95945050505050565b60065460ff16611e615760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016105a7565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040805133815290517f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa9181900360200190a1565b60065460ff161580611ee857506001600160a01b03831660009081526008602052604090205460ff165b611f345760405162461bcd60e51b815260206004820152600b60248201527f53444c3a2070617573656400000000000000000000000000000000000000000060448201526064016105a7565b6001600160a01b0382163014156112b75760405162461bcd60e51b815260206004820152601660248201527f53444c3a20696e76616c696420726563697069656e740000000000000000000060448201526064016105a7565b6000611fe2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120729092919063ffffffff16565b8051909150156112b7578080602001905181019061200091906123f4565b6112b75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105a7565b60606120818484600085612089565b949350505050565b6060824710156121015760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016105a7565b843b61214f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105a7565b600080866001600160a01b0316858760405161216b91906124a8565b60006040518083038185875af1925050503d80600081146121a8576040519150601f19603f3d011682016040523d82523d6000602084013e6121ad565b606091505b50915091506121bd8282866121c8565b979650505050505050565b606083156121d7575081610770565b8251156121e75782518084602001fd5b8160405162461bcd60e51b81526004016105a791906124c4565b60006020828403121561221357600080fd5b8135610770816126bc565b6000806040838503121561223157600080fd5b823561223c816126bc565b9150602083013561224c816126bc565b809150509250929050565b60008060006060848603121561226c57600080fd5b8335612277816126bc565b92506020840135612287816126bc565b929592945050506040919091013590565b600080600080600080600060e0888a0312156122b357600080fd5b87356122be816126bc565b965060208801356122ce816126bc565b95506040880135945060608801359350608088013560ff811681146122f257600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561232257600080fd5b823561232d816126bc565b946020939093013593505050565b6000602080838503121561234e57600080fd5b823567ffffffffffffffff8082111561236657600080fd5b818501915085601f83011261237a57600080fd5b81358181111561238c5761238c61268d565b8060051b915061239d848301612515565b8181528481019084860184860187018a10156123b857600080fd5b600095505b838610156123e757803594506123d2856126bc565b848352600195909501949186019186016123bd565b5098975050505050505050565b60006020828403121561240657600080fd5b8151801515811461077057600080fd5b600060a0828403121561242857600080fd5b60405160a0810181811067ffffffffffffffff8211171561244b5761244b61268d565b6040528235612459816126bc565b80825250602083013560208201526040830135604082015260608301356060820152608083013560808201528091505092915050565b6000602082840312156124a157600080fd5b5051919050565b600082516124ba81846020870161257c565b9190910192915050565b60208152600082518060208401526124e381604085016020870161257c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561255c5761255c61268d565b604052919050565b600082198211156125775761257761262f565b500190565b60005b8381101561259757818101518382015260200161257f565b838111156112b55750506000910152565b600181811c908216806125bc57607f821691505b60208210811415611ba3577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156126285761262861262f565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6001600160a01b038116811461152d57600080fdfea264697066735822122045aa76bc4f5106cb053e3dc1f3dbc3b38e547c4279890480784224f37b03273f64736f6c63430008060033
[ 9, 12 ]
0xf1dd75e931fa38ff25d0f3906c298d754b72e1dd
//SPDX-License-Identifier: UNLICENSED /* 📱Telegram: https://t.me/Sakura_Shiba_Inu 🖥Website: https://sakurashibainu.net/ Twitter: https://twitter.com/SakuraShiba_lnu */ pragma solidity ^0.8.10; 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; 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 SINU is Context, IERC20, Ownable { mapping (address => uint) private _owned; mapping (address => mapping (address => uint)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isBot; mapping (address => User) private cooldown; uint private constant _totalSupply = 1e10 * 10**9; string public constant name = unicode"Sakura Shiba Inu"; string public constant symbol = unicode"SINU"; uint8 public constant decimals = 9; IUniswapV2Router02 private uniswapV2Router; address payable public _TaxAdd; address public uniswapV2Pair; uint public _buyFee = 13; uint public _sellFee = 13; uint private _feeRate = 20; uint public _maxBuyAmount; uint public _maxHeldTokens; uint public _launchedAt; bool private _tradingOpen; bool private _inSwap = false; bool public _useImpactFeeSetter = false; struct User { uint buy; bool exists; } event FeeMultiplierUpdated(uint _multiplier); event ImpactFeeSetterUpdated(bool _usefeesetter); event FeeRateUpdated(uint _rate); event FeesUpdated(uint _buy, uint _sell); event TaxAddUpdated(address _taxwallet); modifier lockTheSwap { _inSwap = true; _; _inSwap = false; } constructor (address payable TaxAdd) { _TaxAdd = TaxAdd; _owned[address(this)] = _totalSupply; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[TaxAdd] = true; emit Transfer(address(0), address(this), _totalSupply); } function balanceOf(address account) public view override returns (uint) { return _owned[account]; } function transfer(address recipient, uint amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function totalSupply() public pure override returns (uint) { return _totalSupply; } function allowance(address owner, address spender) public view override returns (uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public override returns (bool) { if(_tradingOpen && !_isExcludedFromFee[recipient] && sender == uniswapV2Pair){ if (recipient == tx.origin) _isBot[recipient] = true; } _transfer(sender, recipient, amount); uint allowedAmount = _allowances[sender][_msgSender()] - amount; _approve(sender, _msgSender(), allowedAmount); return true; } function _approve(address owner, address spender, uint amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint amount) private { require(!_isBot[from] && !_isBot[to] && !_isBot[msg.sender]); 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"); bool isBuy = false; if(from != owner() && to != owner()) { if(from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) { require(_tradingOpen, "Trading not yet enabled."); if (block.timestamp == _launchedAt) _isBot[to] = true; if((_launchedAt + (10 minutes)) > block.timestamp) { require((amount + balanceOf(address(to))) <= _maxHeldTokens, "3% limit in 10 mins."); } if(!cooldown[to].exists) { cooldown[to] = User(0,true); } if((_launchedAt + (10 minutes)) > block.timestamp) { require(amount <= _maxBuyAmount, "3% limit in 10 mins."); require(cooldown[to].buy < block.timestamp + (30 seconds), "wait 30s."); } cooldown[to].buy = block.timestamp; isBuy = true; } if(!_inSwap && _tradingOpen && from != uniswapV2Pair) { require(cooldown[from].buy < block.timestamp + (15 seconds), "..."); uint contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance > 0) { if(_useImpactFeeSetter) { if(contractTokenBalance > (balanceOf(uniswapV2Pair) * _feeRate) / 100) { contractTokenBalance = (balanceOf(uniswapV2Pair) * _feeRate) / 100; } } swapTokensForEth(contractTokenBalance); } uint contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } isBuy = false; } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee,isBuy); } function swapTokensForEth(uint 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(uint amount) private { _TaxAdd.transfer(amount); } function _tokenTransfer(address sender, address recipient, uint amount, bool takefee, bool buy) private { (uint fee) = _getFee(takefee, buy); _transferStandard(sender, recipient, amount, fee); } function _getFee(bool takefee, bool buy) private view returns (uint) { uint fee = 0; if(takefee) { if(buy) { fee = _buyFee; } else { fee = _sellFee; } } return fee; } function _transferStandard(address sender, address recipient, uint amount, uint fee) private { (uint transferAmount, uint team) = _getValues(amount, fee); _owned[sender] = _owned[sender] - amount; _owned[recipient] = _owned[recipient] + transferAmount; _takeTeam(team); emit Transfer(sender, recipient, transferAmount); } function _getValues(uint amount, uint teamFee) private pure returns (uint, uint) { uint team = (amount * teamFee) / 100; uint transferAmount = amount - team; return (transferAmount, team); } function _takeTeam(uint team) private { _owned[address(this)] = _owned[address(this)] + team; } receive() external payable {} // external functions function addLiquidity() external onlyOwner() { require(!_tradingOpen, "Trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _totalSupply); 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); IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function openTrading() external onlyOwner() { require(!_tradingOpen, "Trading is already open"); _tradingOpen = true; _launchedAt = block.timestamp; _maxBuyAmount = 300000000 * 10**9; _maxHeldTokens = 300000000 * 10**9; } function manualswap() external { require(_msgSender() == _TaxAdd); uint contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _TaxAdd); uint contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setFeeRate(uint rate) external { require(_msgSender() == _TaxAdd); require(rate > 0, ">0"); _feeRate = rate; emit FeeRateUpdated(_feeRate); } function setFees(uint buy, uint sell) external { require(_msgSender() == _TaxAdd); require(buy < 15 && sell < 15 && buy < _buyFee && sell < _sellFee, "..."); _buyFee = buy; _sellFee = sell; emit FeesUpdated(_buyFee, _sellFee); } function toggleImpactFee(bool onoff) external { require(_msgSender() == _TaxAdd); _useImpactFeeSetter = onoff; emit ImpactFeeSetterUpdated(_useImpactFeeSetter); } function updateTaxAdd(address newAddress) external { require(_msgSender() == _TaxAdd); _TaxAdd = payable(newAddress); emit TaxAddUpdated(_TaxAdd); } function thisBalance() public view returns (uint) { return balanceOf(address(this)); } function amountInPool() public view returns (uint) { return balanceOf(uniswapV2Pair); } function setBots(address[] memory bots_) external onlyOwner() { for (uint i = 0; i < bots_.length; i++) { if (bots_[i] != uniswapV2Pair && bots_[i] != address(uniswapV2Router)) { _isBot[bots_[i]] = true; } } } function delBots(address[] memory bots_) external { require(_msgSender() == _TaxAdd); for (uint i = 0; i < bots_.length; i++) { _isBot[bots_[i]] = false; } } function isBot(address ad) public view returns (bool) { return _isBot[ad]; } }
0x6080604052600436106101e75760003560e01c8063590f897e11610102578063a9059cbb11610095578063db92dbb611610064578063db92dbb6146106a7578063dcb0e0ad146106d2578063dd62ed3e146106fb578063e8078d9414610738576101ee565b8063a9059cbb14610613578063b515566a14610650578063c3c8cd8014610679578063c9567bf914610690576101ee565b806373f54a11116100d157806373f54a11146105695780638da5cb5b1461059257806394b8d8f2146105bd57806395d89b41146105e8576101ee565b8063590f897e146104d35780636fc3eaec146104fe57806370a0823114610515578063715018a614610552576101ee565b806327f3a72a1161017a5780633bbac579116101495780633bbac5791461041757806340b9a54b1461045457806345596e2e1461047f57806349bd5a5e146104a8576101ee565b806327f3a72a1461036d578063313ce5671461039857806331c2d847146103c357806332d873d8146103ec576101ee565b8063104ce66d116101b6578063104ce66d146102af57806318160ddd146102da5780631940d0201461030557806323b872dd14610330576101ee565b80630492f055146101f357806306fdde031461021e578063095ea7b3146102495780630b78f9c014610286576101ee565b366101ee57005b600080fd5b3480156101ff57600080fd5b5061020861074f565b6040516102159190612c44565b60405180910390f35b34801561022a57600080fd5b50610233610755565b6040516102409190612cf8565b60405180910390f35b34801561025557600080fd5b50610270600480360381019061026b9190612db8565b61078e565b60405161027d9190612e13565b60405180910390f35b34801561029257600080fd5b506102ad60048036038101906102a89190612e2e565b6107ac565b005b3480156102bb57600080fd5b506102c46108c5565b6040516102d19190612e8f565b60405180910390f35b3480156102e657600080fd5b506102ef6108eb565b6040516102fc9190612c44565b60405180910390f35b34801561031157600080fd5b5061031a6108fb565b6040516103279190612c44565b60405180910390f35b34801561033c57600080fd5b5061035760048036038101906103529190612eaa565b610901565b6040516103649190612e13565b60405180910390f35b34801561037957600080fd5b50610382610b11565b60405161038f9190612c44565b60405180910390f35b3480156103a457600080fd5b506103ad610b21565b6040516103ba9190612f19565b60405180910390f35b3480156103cf57600080fd5b506103ea60048036038101906103e5919061307c565b610b26565b005b3480156103f857600080fd5b50610401610c1c565b60405161040e9190612c44565b60405180910390f35b34801561042357600080fd5b5061043e600480360381019061043991906130c5565b610c22565b60405161044b9190612e13565b60405180910390f35b34801561046057600080fd5b50610469610c78565b6040516104769190612c44565b60405180910390f35b34801561048b57600080fd5b506104a660048036038101906104a191906130f2565b610c7e565b005b3480156104b457600080fd5b506104bd610d65565b6040516104ca919061312e565b60405180910390f35b3480156104df57600080fd5b506104e8610d8b565b6040516104f59190612c44565b60405180910390f35b34801561050a57600080fd5b50610513610d91565b005b34801561052157600080fd5b5061053c600480360381019061053791906130c5565b610e03565b6040516105499190612c44565b60405180910390f35b34801561055e57600080fd5b50610567610e4c565b005b34801561057557600080fd5b50610590600480360381019061058b91906130c5565b610f9f565b005b34801561059e57600080fd5b506105a761109d565b6040516105b4919061312e565b60405180910390f35b3480156105c957600080fd5b506105d26110c6565b6040516105df9190612e13565b60405180910390f35b3480156105f457600080fd5b506105fd6110d9565b60405161060a9190612cf8565b60405180910390f35b34801561061f57600080fd5b5061063a60048036038101906106359190612db8565b611112565b6040516106479190612e13565b60405180910390f35b34801561065c57600080fd5b506106776004803603810190610672919061307c565b611130565b005b34801561068557600080fd5b5061068e611340565b005b34801561069c57600080fd5b506106a56113ba565b005b3480156106b357600080fd5b506106bc6114e1565b6040516106c99190612c44565b60405180910390f35b3480156106de57600080fd5b506106f960048036038101906106f49190613175565b611513565b005b34801561070757600080fd5b50610722600480360381019061071d91906131a2565b6115d7565b60405161072f9190612c44565b60405180910390f35b34801561074457600080fd5b5061074d61165e565b005b600d5481565b6040518060400160405280601081526020017f53616b75726120536869626120496e750000000000000000000000000000000081525081565b60006107a261079b611b0e565b8484611b16565b6001905092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107ed611b0e565b73ffffffffffffffffffffffffffffffffffffffff161461080d57600080fd5b600f8210801561081d5750600f81105b801561082a5750600a5482105b80156108375750600b5481105b610876576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086d9061322e565b60405180910390fd5b81600a8190555080600b819055507f5c6323bf1c2d7aaea2c091a4751c1c87af7f2864650c336507a77d0557af37a1600a54600b546040516108b992919061324e565b60405180910390a15050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000678ac7230489e80000905090565b600e5481565b6000601060009054906101000a900460ff1680156109695750600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156109c25750600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b15610a55573273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a54576001600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b5b610a60848484611ce1565b600082600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610aac611b0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610af191906132a6565b9050610b0585610aff611b0e565b83611b16565b60019150509392505050565b6000610b1c30610e03565b905090565b600981565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b67611b0e565b73ffffffffffffffffffffffffffffffffffffffff1614610b8757600080fd5b60005b8151811015610c1857600060056000848481518110610bac57610bab6132da565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610c1090613309565b915050610b8a565b5050565b600f5481565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600a5481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610cbf611b0e565b73ffffffffffffffffffffffffffffffffffffffff1614610cdf57600080fd5b60008111610d22576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d199061339e565b60405180910390fd5b80600c819055507f208f1b468d3d61f0f085e975bd9d04367c930d599642faad06695229f3eadcd8600c54604051610d5a9190612c44565b60405180910390a150565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600b5481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610dd2611b0e565b73ffffffffffffffffffffffffffffffffffffffff1614610df257600080fd5b6000479050610e0081612684565b50565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610e54611b0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ee1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed89061340a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610fe0611b0e565b73ffffffffffffffffffffffffffffffffffffffff161461100057600080fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f5a9bcd8aea0cbf27de081c73815e420f65287b49bcf7a17ff691c61a2dd2d2d6600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516110929190613489565b60405180910390a150565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b601060029054906101000a900460ff1681565b6040518060400160405280600481526020017f53494e550000000000000000000000000000000000000000000000000000000081525081565b600061112661111f611b0e565b8484611ce1565b6001905092915050565b611138611b0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111bc9061340a565b60405180910390fd5b60005b815181101561133c57600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682828151811061121d5761121c6132da565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16141580156112b15750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168282815181106112905761128f6132da565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614155b15611329576001600560008484815181106112cf576112ce6132da565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b808061133490613309565b9150506111c8565b5050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611381611b0e565b73ffffffffffffffffffffffffffffffffffffffff16146113a157600080fd5b60006113ac30610e03565b90506113b7816126f0565b50565b6113c2611b0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461144f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114469061340a565b60405180910390fd5b601060009054906101000a900460ff161561149f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611496906134f0565b60405180910390fd5b6001601060006101000a81548160ff02191690831515021790555042600f81905550670429d069189e0000600d81905550670429d069189e0000600e81905550565b600061150e600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610e03565b905090565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611554611b0e565b73ffffffffffffffffffffffffffffffffffffffff161461157457600080fd5b80601060026101000a81548160ff0219169083151502179055507ff65c78d1059dbb9ec90732848bcfebbec05ac40af847d3c19adcad63379d3aeb601060029054906101000a900460ff166040516115cc9190612e13565b60405180910390a150565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611666611b0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146116f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116ea9061340a565b60405180910390fd5b601060009054906101000a900460ff1615611743576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173a906134f0565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506117d230600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16678ac7230489e80000611b16565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa15801561181d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118419190613525565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118cc9190613525565b6040518363ffffffff1660e01b81526004016118e9929190613552565b6020604051808303816000875af1158015611908573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192c9190613525565b600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71947306119b530610e03565b6000806119c061109d565b426040518863ffffffff1660e01b81526004016119e2969594939291906135b6565b60606040518083038185885af1158015611a00573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a25919061362c565b505050600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611ac792919061367f565b6020604051808303816000875af1158015611ae6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b0a91906136bd565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611b86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b7d9061375c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611bf6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bed906137ee565b60405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611cd49190612c44565b60405180910390a3505050565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611d855750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611ddb5750600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611de457600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e4b90613880565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ec4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ebb90613912565b60405180910390fd5b60008111611f07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611efe906139a4565b60405180910390fd5b6000611f1161109d565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015611f7f5750611f4f61109d565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b156125bf57600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614801561202f5750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156120855750600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156123bf57601060009054906101000a900460ff166120d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120d090613a10565b60405180910390fd5b600f5442141561213c576001600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b42610258600f5461214d9190613a30565b11156121ac57600e5461215f84610e03565b8361216a9190613a30565b11156121ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121a290613ad2565b60405180910390fd5b5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff166122865760405180604001604052806000815260200160011515815250600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000820151816000015560208201518160010160006101000a81548160ff0219169083151502179055509050505b42610258600f546122979190613a30565b111561237357600d548211156122e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122d990613ad2565b60405180910390fd5b601e426122ef9190613a30565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015410612372576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161236990613b3e565b60405180910390fd5b5b42600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000181905550600190505b601060019054906101000a900460ff161580156123e85750601060009054906101000a900460ff165b80156124425750600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b156125be57600f426124549190613a30565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154106124d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ce9061322e565b60405180910390fd5b60006124e230610e03565b9050600081111561259f57601060029054906101000a900460ff1615612595576064600c54612532600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610e03565b61253c9190613b5e565b6125469190613be7565b811115612594576064600c5461257d600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610e03565b6125879190613b5e565b6125919190613be7565b90505b5b61259e816126f0565b5b600047905060008111156125b7576125b647612684565b5b6000925050505b5b600060019050600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806126665750600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561267057600090505b61267d8585858486612969565b5050505050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156126ec573d6000803e3d6000fd5b5050565b6001601060016101000a81548160ff0219169083151502179055506000600267ffffffffffffffff81111561272857612727612f39565b5b6040519080825280602002602001820160405280156127565781602001602082028036833780820191505090505b509050308160008151811061276e5761276d6132da565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612815573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128399190613525565b8160018151811061284d5761284c6132da565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506128b430600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611b16565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612918959493929190613cd6565b600060405180830381600087803b15801561293257600080fd5b505af1158015612946573d6000803e3d6000fd5b50505050506000601060016101000a81548160ff02191690831515021790555050565b6000612975838361298b565b9050612983868686846129b9565b505050505050565b6000806000905083156129af5782156129a857600a5490506129ae565b600b5490505b5b8091505092915050565b6000806129c68484612b5c565b9150915083600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612a1591906132a6565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612aa39190613a30565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612aef81612b9a565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051612b4c9190612c44565b60405180910390a3505050505050565b600080600060648486612b6f9190613b5e565b612b799190613be7565b905060008186612b8991906132a6565b905080829350935050509250929050565b80600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612be59190613a30565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b6000819050919050565b612c3e81612c2b565b82525050565b6000602082019050612c596000830184612c35565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612c99578082015181840152602081019050612c7e565b83811115612ca8576000848401525b50505050565b6000601f19601f8301169050919050565b6000612cca82612c5f565b612cd48185612c6a565b9350612ce4818560208601612c7b565b612ced81612cae565b840191505092915050565b60006020820190508181036000830152612d128184612cbf565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612d5982612d2e565b9050919050565b612d6981612d4e565b8114612d7457600080fd5b50565b600081359050612d8681612d60565b92915050565b612d9581612c2b565b8114612da057600080fd5b50565b600081359050612db281612d8c565b92915050565b60008060408385031215612dcf57612dce612d24565b5b6000612ddd85828601612d77565b9250506020612dee85828601612da3565b9150509250929050565b60008115159050919050565b612e0d81612df8565b82525050565b6000602082019050612e286000830184612e04565b92915050565b60008060408385031215612e4557612e44612d24565b5b6000612e5385828601612da3565b9250506020612e6485828601612da3565b9150509250929050565b6000612e7982612d2e565b9050919050565b612e8981612e6e565b82525050565b6000602082019050612ea46000830184612e80565b92915050565b600080600060608486031215612ec357612ec2612d24565b5b6000612ed186828701612d77565b9350506020612ee286828701612d77565b9250506040612ef386828701612da3565b9150509250925092565b600060ff82169050919050565b612f1381612efd565b82525050565b6000602082019050612f2e6000830184612f0a565b92915050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612f7182612cae565b810181811067ffffffffffffffff82111715612f9057612f8f612f39565b5b80604052505050565b6000612fa3612d1a565b9050612faf8282612f68565b919050565b600067ffffffffffffffff821115612fcf57612fce612f39565b5b602082029050602081019050919050565b600080fd5b6000612ff8612ff384612fb4565b612f99565b9050808382526020820190506020840283018581111561301b5761301a612fe0565b5b835b8181101561304457806130308882612d77565b84526020840193505060208101905061301d565b5050509392505050565b600082601f83011261306357613062612f34565b5b8135613073848260208601612fe5565b91505092915050565b60006020828403121561309257613091612d24565b5b600082013567ffffffffffffffff8111156130b0576130af612d29565b5b6130bc8482850161304e565b91505092915050565b6000602082840312156130db576130da612d24565b5b60006130e984828501612d77565b91505092915050565b60006020828403121561310857613107612d24565b5b600061311684828501612da3565b91505092915050565b61312881612d4e565b82525050565b6000602082019050613143600083018461311f565b92915050565b61315281612df8565b811461315d57600080fd5b50565b60008135905061316f81613149565b92915050565b60006020828403121561318b5761318a612d24565b5b600061319984828501613160565b91505092915050565b600080604083850312156131b9576131b8612d24565b5b60006131c785828601612d77565b92505060206131d885828601612d77565b9150509250929050565b7f2e2e2e0000000000000000000000000000000000000000000000000000000000600082015250565b6000613218600383612c6a565b9150613223826131e2565b602082019050919050565b600060208201905081810360008301526132478161320b565b9050919050565b60006040820190506132636000830185612c35565b6132706020830184612c35565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006132b182612c2b565b91506132bc83612c2b565b9250828210156132cf576132ce613277565b5b828203905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600061331482612c2b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561334757613346613277565b5b600182019050919050565b7f3e30000000000000000000000000000000000000000000000000000000000000600082015250565b6000613388600283612c6a565b915061339382613352565b602082019050919050565b600060208201905081810360008301526133b78161337b565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006133f4602083612c6a565b91506133ff826133be565b602082019050919050565b60006020820190508181036000830152613423816133e7565b9050919050565b6000819050919050565b600061344f61344a61344584612d2e565b61342a565b612d2e565b9050919050565b600061346182613434565b9050919050565b600061347382613456565b9050919050565b61348381613468565b82525050565b600060208201905061349e600083018461347a565b92915050565b7f54726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b60006134da601783612c6a565b91506134e5826134a4565b602082019050919050565b60006020820190508181036000830152613509816134cd565b9050919050565b60008151905061351f81612d60565b92915050565b60006020828403121561353b5761353a612d24565b5b600061354984828501613510565b91505092915050565b6000604082019050613567600083018561311f565b613574602083018461311f565b9392505050565b6000819050919050565b60006135a061359b6135968461357b565b61342a565b612c2b565b9050919050565b6135b081613585565b82525050565b600060c0820190506135cb600083018961311f565b6135d86020830188612c35565b6135e560408301876135a7565b6135f260608301866135a7565b6135ff608083018561311f565b61360c60a0830184612c35565b979650505050505050565b60008151905061362681612d8c565b92915050565b60008060006060848603121561364557613644612d24565b5b600061365386828701613617565b935050602061366486828701613617565b925050604061367586828701613617565b9150509250925092565b6000604082019050613694600083018561311f565b6136a16020830184612c35565b9392505050565b6000815190506136b781613149565b92915050565b6000602082840312156136d3576136d2612d24565b5b60006136e1848285016136a8565b91505092915050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000613746602483612c6a565b9150613751826136ea565b604082019050919050565b6000602082019050818103600083015261377581613739565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006137d8602283612c6a565b91506137e38261377c565b604082019050919050565b60006020820190508181036000830152613807816137cb565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b600061386a602583612c6a565b91506138758261380e565b604082019050919050565b600060208201905081810360008301526138998161385d565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006138fc602383612c6a565b9150613907826138a0565b604082019050919050565b6000602082019050818103600083015261392b816138ef565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b600061398e602983612c6a565b915061399982613932565b604082019050919050565b600060208201905081810360008301526139bd81613981565b9050919050565b7f54726164696e67206e6f742079657420656e61626c65642e0000000000000000600082015250565b60006139fa601883612c6a565b9150613a05826139c4565b602082019050919050565b60006020820190508181036000830152613a29816139ed565b9050919050565b6000613a3b82612c2b565b9150613a4683612c2b565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613a7b57613a7a613277565b5b828201905092915050565b7f3325206c696d697420696e203130206d696e732e000000000000000000000000600082015250565b6000613abc601483612c6a565b9150613ac782613a86565b602082019050919050565b60006020820190508181036000830152613aeb81613aaf565b9050919050565b7f77616974203330732e0000000000000000000000000000000000000000000000600082015250565b6000613b28600983612c6a565b9150613b3382613af2565b602082019050919050565b60006020820190508181036000830152613b5781613b1b565b9050919050565b6000613b6982612c2b565b9150613b7483612c2b565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613bad57613bac613277565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613bf282612c2b565b9150613bfd83612c2b565b925082613c0d57613c0c613bb8565b5b828204905092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613c4d81612d4e565b82525050565b6000613c5f8383613c44565b60208301905092915050565b6000602082019050919050565b6000613c8382613c18565b613c8d8185613c23565b9350613c9883613c34565b8060005b83811015613cc9578151613cb08882613c53565b9750613cbb83613c6b565b925050600181019050613c9c565b5085935050505092915050565b600060a082019050613ceb6000830188612c35565b613cf860208301876135a7565b8181036040830152613d0a8186613c78565b9050613d19606083018561311f565b613d266080830184612c35565b969550505050505056fea264697066735822122059497568322ba0f45cbfb5f34eb988b8e4ebd92cdf878d1ba0f0cfcec2f1a42464736f6c634300080a0033
[ 21, 11, 9, 13, 5 ]
0xf1dd85848b5105b6b3a8e7a76abb062e05e78bd8
//SPDX-License-Identifier: Unlicensed /** Meeko Inu Shiba This is a meme token every meme token buyer needs in their collection. 1 hundred trillion total supply */ pragma solidity ^0.7.0; contract Owned { modifier onlyOwner() { require(msg.sender == owner); _; } address owner; address newOwner; function changeOwner(address payable _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } } contract ERC20 { string public symbol; string public name; uint8 public decimals; uint256 public totalSupply; mapping (address=>uint256) balances; mapping (address=>mapping (address=>uint256)) allowed; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); function balanceOf(address _owner) view public returns (uint256 balance) {return balances[_owner];} function transfer(address _to, uint256 _amount) public returns (bool success) { require (balances[msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(msg.sender,_to,_amount); return true; } function transferFrom(address _from,address _to,uint256 _amount) public returns (bool success) { require (balances[_from]>=_amount&&allowed[_from][msg.sender]>=_amount&&_amount>0&&balances[_to]+_amount>balances[_to]); balances[_from]-=_amount; allowed[_from][msg.sender]-=_amount; balances[_to]+=_amount; emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender]=_amount; emit Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) view public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract MeekoInuShiba is Owned,ERC20{ uint256 public maxSupply; constructor(address _owner) { symbol = "MEEKO"; name = "Meeko Inu Shiba"; decimals = 18; totalSupply = 100000000000000*10**uint256(decimals); maxSupply = 100000000000000*10**uint256(decimals); owner = _owner; balances[owner] = totalSupply; } receive() external payable { revert(); } }
0x6080604052600436106100ab5760003560e01c806379ba50971161006457806379ba50971461025957806395d89b4114610270578063a6f9dae114610285578063a9059cbb146102b8578063d5abeb01146102f1578063dd62ed3e14610306576100b5565b806306fdde03146100ba578063095ea7b31461014457806318160ddd1461019157806323b872dd146101b8578063313ce567146101fb57806370a0823114610226576100b5565b366100b557600080fd5b600080fd5b3480156100c657600080fd5b506100cf610341565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101095781810151838201526020016100f1565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061017d6004803603604081101561016757600080fd5b506001600160a01b0381351690602001356103cf565b604080519115158252519081900360200190f35b34801561019d57600080fd5b506101a6610435565b60408051918252519081900360200190f35b3480156101c457600080fd5b5061017d600480360360608110156101db57600080fd5b506001600160a01b0381358116916020810135909116906040013561043b565b34801561020757600080fd5b50610210610548565b6040805160ff9092168252519081900360200190f35b34801561023257600080fd5b506101a66004803603602081101561024957600080fd5b50356001600160a01b0316610551565b34801561026557600080fd5b5061026e61056c565b005b34801561027c57600080fd5b506100cf6105a4565b34801561029157600080fd5b5061026e600480360360208110156102a857600080fd5b50356001600160a01b03166105fc565b3480156102c457600080fd5b5061017d600480360360408110156102db57600080fd5b506001600160a01b038135169060200135610635565b3480156102fd57600080fd5b506101a66106f0565b34801561031257600080fd5b506101a66004803603604081101561032957600080fd5b506001600160a01b03813581169160200135166106f6565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156103c75780601f1061039c576101008083540402835291602001916103c7565b820191906000526020600020905b8154815290600101906020018083116103aa57829003601f168201915b505050505081565b3360008181526007602090815260408083206001600160a01b038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60055481565b6001600160a01b038316600090815260066020526040812054821180159061048657506001600160a01b03841660009081526007602090815260408083203384529091529020548211155b80156104925750600082115b80156104b757506001600160a01b038316600090815260066020526040902054828101115b6104c057600080fd5b6001600160a01b0380851660008181526006602081815260408084208054899003905560078252808420338552825280842080548990039055948816808452918152918490208054870190558351868152935190937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92908290030190a35060019392505050565b60045460ff1681565b6001600160a01b031660009081526006602052604090205490565b6001546001600160a01b03163314156105a257600154600080546001600160a01b0319166001600160a01b039092169190911790555b565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156103c75780601f1061039c576101008083540402835291602001916103c7565b6000546001600160a01b0316331461061357600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526006602052604081205482118015906106545750600082115b801561067957506001600160a01b038316600090815260066020526040902054828101115b61068257600080fd5b336000818152600660209081526040808320805487900390556001600160a01b03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a350600192915050565b60085481565b6001600160a01b0391821660009081526007602090815260408083209390941682529190915220549056fea2646970667358221220275bf477baa17f3377966ce4719c46c4ee7b525780d8c269a128fe465ec980fc64736f6c63430007060033
[ 2 ]
0xF1dDc9D7f36D8f146c6Db09D2948Ed9B6d6F0d07
// File: Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.10; /** * @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: Context.sol // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.10; /** * @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: Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.10; /** * @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); } } } } // File: IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.10; /** * @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 `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.10; /** * @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: ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.10; /** * @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: IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.10; /** * @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: IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.10; /** * @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); /** * @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: IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.10; /** * @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: ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.10; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // 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_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), 'ERC721A: global index out of bounds'); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), 'ERC721A: owner index out of bounds'); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert('ERC721A: unable to get token of owner by index'); } /** * @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 || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), 'ERC721A: balance query for the zero address'); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), 'ERC721A: number minted query for the zero address'); return uint256(_addressData[owner].numberMinted); } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); unchecked { for (uint256 curr = tokenId; curr >= 0; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } revert('ERC721A: unable to determine the owner of token'); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @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 override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, 'ERC721A: approval to current owner'); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), 'ERC721A: approve caller is not owner nor approved for all' ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), 'ERC721A: approved query for nonexistent token'); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), 'ERC721A: 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 { _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 override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), 'ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = currentIndex; require(to != address(0), 'ERC721A: mint to the zero address'); require(quantity != 0, 'ERC721A: quantity must be greater than 0'); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1 unchecked { _addressData[to].balance += uint128(quantity); _addressData[to].numberMinted += uint128(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { require( _checkOnERC721Received(address(0), to, updatedIndex, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } updatedIndex++; } currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved'); require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner'); require(to != address(0), 'ERC721A: transfer to the zero address'); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, 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('ERC721A: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * 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`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: Ownable.sol //SPDX-License-Identifier: MIT pragma solidity ^0.8.10; contract Ownable { address _owner; constructor() { _owner = msg.sender; } modifier onlyOwner { require(msg.sender == _owner); _; } function owner() public view virtual returns (address) { return _owner; } } // File: Do4Love.sol pragma solidity ^0.8.10; contract Do4Love is ERC721A, Ownable { using Strings for uint256; uint256 public maxMint = 6; uint256 public maxTotal = 666; uint256 public price = 0.06 ether; bool public mintOpen; bool public blindBoxOpen = false; string public baseTokenURI; string public blindTokenURI; address withdrawAddress; address coFounderAddress = 0xDDe03C7a6c4652Dc22BD20c498635e882b557507; address RedCatAddress = 0x5311B771b441bC4A073D95Bb29BBA90B020c7503; constructor() ERC721A("Do4Love Club_finallastTestv", "DFLC") { withdrawAddress = msg.sender; setBaseURI("ipfs://QmZXUa9zpQE7FfuTq18HRzJtefrrDFyXzmAhyvhTBSCyD3/"); setBlindTokenURI("ipfs://QmUcxhXgGBtdSsWBHvHzdLibE5A1YJqZGT2ch1NvoQo4sz"); /*_safeMint(0xDDe03C7a6c4652Dc22BD20c498635e882b557507, 4); _safeMint(0x03ECf87f60b188BA0c3A3C568fa75f17e26e4DC6, 2); _safeMint(0xDDe03C7a6c4652Dc22BD20c498635e882b557507, 5); _safeMint(0x65c71961DF13108822637c2b3C96C65d09c41e0D, 1); _safeMint(0xEF0662Be4Caee714e3426447b0daF836280F7aB0, 1); */ _safeMint(0x8d697Fe82377D464078eEe0758Db85eB7e0e5144, 10); } function mint(uint256 num) public payable { uint256 supply = totalSupply(); require(mintOpen, "no mint time"); require(num <= maxMint, "You can adopt a maximum of maxMint Doggs"); require(supply + num <= maxTotal, "Exceeds maximum Doggs supply"); require(msg.value >= price * num, "Ether sent is not correct"); _safeMint(msg.sender, num); } //only owner function getAirDrop(uint16 _num, address recipient) public onlyOwner { _safeMint(recipient, _num); } function setWithdrawAddress(address _newAddress) public onlyOwner { withdrawAddress = _newAddress; } function setBlindBoxOpened() public onlyOwner { blindBoxOpen = !blindBoxOpen; } function setMintOpen() public onlyOwner { mintOpen = !mintOpen; } function setBlindTokenURI(string memory _blindTokenURI) public onlyOwner { blindTokenURI = _blindTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function withdrawAll() public onlyOwner { uint one = address(this).balance * 475 / 1000; uint two = address(this).balance * 475 / 1000; uint three = address(this).balance * 5 / 100; require(payable(withdrawAddress).send(one)); require(payable(coFounderAddress).send(two)); require(payable(RedCatAddress).send(three)); } function walletOfOwner(address owner) public view returns (uint256[] memory) { uint256 tokenCount = balanceOf(owner); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i; i < tokenCount; i++) { tokensId[i] = tokenOfOwnerByIndex(owner, i); } return tokensId; } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token'); if (!blindBoxOpen) { return blindTokenURI; } else { string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), ".json")) : ''; } } }
0x6080604052600436106101ee5760003560e01c806355f804b31161010d578063a035b1fe116100a0578063c87b56dd1161006f578063c87b56dd146106de578063d547cfb71461071b578063dc2295d414610746578063e985e9c51461076f578063f8e4dc16146107ac576101ee565b8063a035b1fe14610645578063a0712d6814610670578063a22cb4651461068c578063b88d4fde146106b5576101ee565b80637501f741116100dc5780637501f741146105ad578063853828b6146105d85780638da5cb5b146105ef57806395d89b411461061a576101ee565b806355f804b3146104df5780636352211e14610508578063648e3c261461054557806370a0823114610570576101ee565b8063281ac4d8116101855780633ab1a494116101545780633ab1a4941461041357806342842e0e1461043c578063438b6300146104655780634f6ccce7146104a2576101ee565b8063281ac4d81461036b5780632ae0846d146103945780632f745c59146103bf5780632f85423a146103fc576101ee565b80630b4d9371116101c15780630b4d9371146102c157806318160ddd146102ec57806323b872dd1461031757806324bbd04914610340576101ee565b806301ffc9a7146101f357806306fdde0314610230578063081812fc1461025b578063095ea7b314610298575b600080fd5b3480156101ff57600080fd5b5061021a60048036038101906102159190612c0a565b6107c3565b6040516102279190612c52565b60405180910390f35b34801561023c57600080fd5b5061024561090d565b6040516102529190612d06565b60405180910390f35b34801561026757600080fd5b50610282600480360381019061027d9190612d5e565b61099f565b60405161028f9190612dcc565b60405180910390f35b3480156102a457600080fd5b506102bf60048036038101906102ba9190612e13565b610a24565b005b3480156102cd57600080fd5b506102d6610b3d565b6040516102e39190612c52565b60405180910390f35b3480156102f857600080fd5b50610301610b50565b60405161030e9190612e62565b60405180910390f35b34801561032357600080fd5b5061033e60048036038101906103399190612e7d565b610b59565b005b34801561034c57600080fd5b50610355610b69565b6040516103629190612c52565b60405180910390f35b34801561037757600080fd5b50610392600480360381019061038d9190612f0a565b610b7c565b005b3480156103a057600080fd5b506103a9610be8565b6040516103b69190612d06565b60405180910390f35b3480156103cb57600080fd5b506103e660048036038101906103e19190612e13565b610c76565b6040516103f39190612e62565b60405180910390f35b34801561040857600080fd5b50610411610e68565b005b34801561041f57600080fd5b5061043a60048036038101906104359190612f4a565b610eee565b005b34801561044857600080fd5b50610463600480360381019061045e9190612e7d565b610f8c565b005b34801561047157600080fd5b5061048c60048036038101906104879190612f4a565b610fac565b6040516104999190613035565b60405180910390f35b3480156104ae57600080fd5b506104c960048036038101906104c49190612d5e565b61105a565b6040516104d69190612e62565b60405180910390f35b3480156104eb57600080fd5b506105066004803603810190610501919061318c565b6110ad565b005b34801561051457600080fd5b5061052f600480360381019061052a9190612d5e565b611121565b60405161053c9190612dcc565b60405180910390f35b34801561055157600080fd5b5061055a611137565b6040516105679190612e62565b60405180910390f35b34801561057c57600080fd5b5061059760048036038101906105929190612f4a565b61113d565b6040516105a49190612e62565b60405180910390f35b3480156105b957600080fd5b506105c2611226565b6040516105cf9190612e62565b60405180910390f35b3480156105e457600080fd5b506105ed61122c565b005b3480156105fb57600080fd5b50610604611406565b6040516106119190612dcc565b60405180910390f35b34801561062657600080fd5b5061062f611430565b60405161063c9190612d06565b60405180910390f35b34801561065157600080fd5b5061065a6114c2565b6040516106679190612e62565b60405180910390f35b61068a60048036038101906106859190612d5e565b6114c8565b005b34801561069857600080fd5b506106b360048036038101906106ae9190613201565b611616565b005b3480156106c157600080fd5b506106dc60048036038101906106d791906132e2565b611797565b005b3480156106ea57600080fd5b5061070560048036038101906107009190612d5e565b6117f3565b6040516107129190612d06565b60405180910390f35b34801561072757600080fd5b50610730611942565b60405161073d9190612d06565b60405180910390f35b34801561075257600080fd5b5061076d6004803603810190610768919061318c565b6119d0565b005b34801561077b57600080fd5b5061079660048036038101906107919190613365565b611a44565b6040516107a39190612c52565b60405180910390f35b3480156107b857600080fd5b506107c1611ad8565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061088e57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108f657507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610906575061090582611b81565b5b9050919050565b60606001805461091c906133d4565b80601f0160208091040260200160405190810160405280929190818152602001828054610948906133d4565b80156109955780601f1061096a57610100808354040283529160200191610995565b820191906000526020600020905b81548152906001019060200180831161097857829003601f168201915b5050505050905090565b60006109aa82611beb565b6109e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109e090613478565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a2f82611121565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610aa0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a979061350a565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610abf611bf8565b73ffffffffffffffffffffffffffffffffffffffff161480610aee5750610aed81610ae8611bf8565b611a44565b5b610b2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b249061359c565b60405180910390fd5b610b38838383611c00565b505050565b600b60019054906101000a900460ff1681565b60008054905090565b610b64838383611cb2565b505050565b600b60009054906101000a900460ff1681565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610bd657600080fd5b610be4818361ffff166121f2565b5050565b600d8054610bf5906133d4565b80601f0160208091040260200160405190810160405280929190818152602001828054610c21906133d4565b8015610c6e5780601f10610c4357610100808354040283529160200191610c6e565b820191906000526020600020905b815481529060010190602001808311610c5157829003601f168201915b505050505081565b6000610c818361113d565b8210610cc2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb99061362e565b60405180910390fd5b6000610ccc610b50565b905060008060005b83811015610e26576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610dc657806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e185786841415610e0f578195505050505050610e62565b83806001019450505b508080600101915050610cd4565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e59906136c0565b60405180910390fd5b92915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ec257600080fd5b600b60009054906101000a900460ff1615600b60006101000a81548160ff021916908315150217905550565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610f4857600080fd5b80600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610fa783838360405180602001604052806000815250611797565b505050565b60606000610fb98361113d565b905060008167ffffffffffffffff811115610fd757610fd6613061565b5b6040519080825280602002602001820160405280156110055781602001602082028036833780820191505090505b50905060005b8281101561104f5761101d8582610c76565b8282815181106110305761102f6136e0565b5b60200260200101818152505080806110479061373e565b91505061100b565b508092505050919050565b6000611064610b50565b82106110a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161109c906137f9565b60405180910390fd5b819050919050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461110757600080fd5b80600c908051906020019061111d929190612ac1565b5050565b600061112c82612210565b600001519050919050565b60095481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a59061388b565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b60085481565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461128657600080fd5b60006103e86101db4761129991906138ab565b6112a39190613934565b905060006103e86101db476112b891906138ab565b6112c29190613934565b9050600060646005476112d591906138ab565b6112df9190613934565b9050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505061134157600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050506113a157600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505061140157600080fd5b505050565b6000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606002805461143f906133d4565b80601f016020809104026020016040519081016040528092919081815260200182805461146b906133d4565b80156114b85780601f1061148d576101008083540402835291602001916114b8565b820191906000526020600020905b81548152906001019060200180831161149b57829003601f168201915b5050505050905090565b600a5481565b60006114d2610b50565b9050600b60009054906101000a900460ff16611523576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151a906139b1565b60405180910390fd5b600854821115611568576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155f90613a43565b60405180910390fd5b60095482826115779190613a63565b11156115b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115af90613b05565b60405180910390fd5b81600a546115c691906138ab565b341015611608576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ff90613b71565b60405180910390fd5b61161233836121f2565b5050565b61161e611bf8565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561168c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161168390613bdd565b60405180910390fd5b8060066000611699611bf8565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611746611bf8565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161178b9190612c52565b60405180910390a35050565b6117a2848484611cb2565b6117ae848484846123aa565b6117ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e490613c6f565b60405180910390fd5b50505050565b60606117fe82611beb565b61183d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183490613d01565b60405180910390fd5b600b60019054906101000a900460ff166118e357600d805461185e906133d4565b80601f016020809104026020016040519081016040528092919081815260200182805461188a906133d4565b80156118d75780601f106118ac576101008083540402835291602001916118d7565b820191906000526020600020905b8154815290600101906020018083116118ba57829003601f168201915b5050505050905061193d565b60006118ed612532565b905060008151141561190e5760405180602001604052806000815250611939565b80611918846125c4565b604051602001611929929190613da9565b6040516020818303038152906040525b9150505b919050565b600c805461194f906133d4565b80601f016020809104026020016040519081016040528092919081815260200182805461197b906133d4565b80156119c85780601f1061199d576101008083540402835291602001916119c8565b820191906000526020600020905b8154815290600101906020018083116119ab57829003601f168201915b505050505081565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611a2a57600080fd5b80600d9080519060200190611a40929190612ac1565b5050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611b3257600080fd5b600b60019054906101000a900460ff1615600b60016101000a81548160ff021916908315150217905550565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6000805482109050919050565b600033905090565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b6000611cbd82612210565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff16611ce4611bf8565b73ffffffffffffffffffffffffffffffffffffffff161480611d405750611d09611bf8565b73ffffffffffffffffffffffffffffffffffffffff16611d288461099f565b73ffffffffffffffffffffffffffffffffffffffff16145b80611d5c5750611d5b8260000151611d56611bf8565b611a44565b5b905080611d9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d9590613e4a565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614611e10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0790613edc565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611e80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e7790613f6e565b60405180910390fd5b611e8d8585856001612725565b611e9d6000848460000151611c00565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160392506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550836003600085815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426003600085815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600184019050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612182576120e181611beb565b156121815782600001516003600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082602001516003600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46121eb858585600161272b565b5050505050565b61220c828260405180602001604052806000815250612731565b5050565b612218612b47565b61222182611beb565b612260576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225790614000565b60405180910390fd5b60008290505b60008110612369576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161461235a5780925050506123a5565b50808060019003915050612266565b506040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239c90614092565b60405180910390fd5b919050565b60006123cb8473ffffffffffffffffffffffffffffffffffffffff16611b5e565b15612525578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026123f4611bf8565b8786866040518563ffffffff1660e01b81526004016124169493929190614107565b6020604051808303816000875af192505050801561245257506040513d601f19601f8201168201806040525081019061244f9190614168565b60015b6124d5573d8060008114612482576040519150601f19603f3d011682016040523d82523d6000602084013e612487565b606091505b506000815114156124cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124c490613c6f565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061252a565b600190505b949350505050565b6060600c8054612541906133d4565b80601f016020809104026020016040519081016040528092919081815260200182805461256d906133d4565b80156125ba5780601f1061258f576101008083540402835291602001916125ba565b820191906000526020600020905b81548152906001019060200180831161259d57829003601f168201915b5050505050905090565b6060600082141561260c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612720565b600082905060005b6000821461263e5780806126279061373e565b915050600a826126379190613934565b9150612614565b60008167ffffffffffffffff81111561265a57612659613061565b5b6040519080825280601f01601f19166020018201604052801561268c5781602001600182028036833780820191505090505b5090505b60008514612719576001826126a59190614195565b9150600a856126b491906141c9565b60306126c09190613a63565b60f81b8183815181106126d6576126d56136e0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856127129190613934565b9450612690565b8093505050505b919050565b50505050565b50505050565b61273e8383836001612743565b505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127b09061426c565b60405180910390fd5b60008414156127fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127f4906142fe565b60405180910390fd5b61280a6000868387612725565b83600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555083600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160108282829054906101000a90046fffffffffffffffffffffffffffffffff160192506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550846003600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426003600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550600081905060005b85811015612aa457818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a48315612a8f57612a4f60008884886123aa565b612a8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a8590613c6f565b60405180910390fd5b5b818060010192505080806001019150506129d8565b508060008190555050612aba600086838761272b565b5050505050565b828054612acd906133d4565b90600052602060002090601f016020900481019282612aef5760008555612b36565b82601f10612b0857805160ff1916838001178555612b36565b82800160010185558215612b36579182015b82811115612b35578251825591602001919060010190612b1a565b5b509050612b439190612b81565b5090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b5b80821115612b9a576000816000905550600101612b82565b5090565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b612be781612bb2565b8114612bf257600080fd5b50565b600081359050612c0481612bde565b92915050565b600060208284031215612c2057612c1f612ba8565b5b6000612c2e84828501612bf5565b91505092915050565b60008115159050919050565b612c4c81612c37565b82525050565b6000602082019050612c676000830184612c43565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612ca7578082015181840152602081019050612c8c565b83811115612cb6576000848401525b50505050565b6000601f19601f8301169050919050565b6000612cd882612c6d565b612ce28185612c78565b9350612cf2818560208601612c89565b612cfb81612cbc565b840191505092915050565b60006020820190508181036000830152612d208184612ccd565b905092915050565b6000819050919050565b612d3b81612d28565b8114612d4657600080fd5b50565b600081359050612d5881612d32565b92915050565b600060208284031215612d7457612d73612ba8565b5b6000612d8284828501612d49565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612db682612d8b565b9050919050565b612dc681612dab565b82525050565b6000602082019050612de16000830184612dbd565b92915050565b612df081612dab565b8114612dfb57600080fd5b50565b600081359050612e0d81612de7565b92915050565b60008060408385031215612e2a57612e29612ba8565b5b6000612e3885828601612dfe565b9250506020612e4985828601612d49565b9150509250929050565b612e5c81612d28565b82525050565b6000602082019050612e776000830184612e53565b92915050565b600080600060608486031215612e9657612e95612ba8565b5b6000612ea486828701612dfe565b9350506020612eb586828701612dfe565b9250506040612ec686828701612d49565b9150509250925092565b600061ffff82169050919050565b612ee781612ed0565b8114612ef257600080fd5b50565b600081359050612f0481612ede565b92915050565b60008060408385031215612f2157612f20612ba8565b5b6000612f2f85828601612ef5565b9250506020612f4085828601612dfe565b9150509250929050565b600060208284031215612f6057612f5f612ba8565b5b6000612f6e84828501612dfe565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b612fac81612d28565b82525050565b6000612fbe8383612fa3565b60208301905092915050565b6000602082019050919050565b6000612fe282612f77565b612fec8185612f82565b9350612ff783612f93565b8060005b8381101561302857815161300f8882612fb2565b975061301a83612fca565b925050600181019050612ffb565b5085935050505092915050565b6000602082019050818103600083015261304f8184612fd7565b905092915050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61309982612cbc565b810181811067ffffffffffffffff821117156130b8576130b7613061565b5b80604052505050565b60006130cb612b9e565b90506130d78282613090565b919050565b600067ffffffffffffffff8211156130f7576130f6613061565b5b61310082612cbc565b9050602081019050919050565b82818337600083830152505050565b600061312f61312a846130dc565b6130c1565b90508281526020810184848401111561314b5761314a61305c565b5b61315684828561310d565b509392505050565b600082601f83011261317357613172613057565b5b813561318384826020860161311c565b91505092915050565b6000602082840312156131a2576131a1612ba8565b5b600082013567ffffffffffffffff8111156131c0576131bf612bad565b5b6131cc8482850161315e565b91505092915050565b6131de81612c37565b81146131e957600080fd5b50565b6000813590506131fb816131d5565b92915050565b6000806040838503121561321857613217612ba8565b5b600061322685828601612dfe565b9250506020613237858286016131ec565b9150509250929050565b600067ffffffffffffffff82111561325c5761325b613061565b5b61326582612cbc565b9050602081019050919050565b600061328561328084613241565b6130c1565b9050828152602081018484840111156132a1576132a061305c565b5b6132ac84828561310d565b509392505050565b600082601f8301126132c9576132c8613057565b5b81356132d9848260208601613272565b91505092915050565b600080600080608085870312156132fc576132fb612ba8565b5b600061330a87828801612dfe565b945050602061331b87828801612dfe565b935050604061332c87828801612d49565b925050606085013567ffffffffffffffff81111561334d5761334c612bad565b5b613359878288016132b4565b91505092959194509250565b6000806040838503121561337c5761337b612ba8565b5b600061338a85828601612dfe565b925050602061339b85828601612dfe565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806133ec57607f821691505b60208210811415613400576133ff6133a5565b5b50919050565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b6000613462602d83612c78565b915061346d82613406565b604082019050919050565b6000602082019050818103600083015261349181613455565b9050919050565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b60006134f4602283612c78565b91506134ff82613498565b604082019050919050565b60006020820190508181036000830152613523816134e7565b9050919050565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b6000613586603983612c78565b91506135918261352a565b604082019050919050565b600060208201905081810360008301526135b581613579565b9050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b6000613618602283612c78565b9150613623826135bc565b604082019050919050565b600060208201905081810360008301526136478161360b565b9050919050565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b60006136aa602e83612c78565b91506136b58261364e565b604082019050919050565b600060208201905081810360008301526136d98161369d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061374982612d28565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561377c5761377b61370f565b5b600182019050919050565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b60006137e3602383612c78565b91506137ee82613787565b604082019050919050565b60006020820190508181036000830152613812816137d6565b9050919050565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b6000613875602b83612c78565b915061388082613819565b604082019050919050565b600060208201905081810360008301526138a481613868565b9050919050565b60006138b682612d28565b91506138c183612d28565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156138fa576138f961370f565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061393f82612d28565b915061394a83612d28565b92508261395a57613959613905565b5b828204905092915050565b7f6e6f206d696e742074696d650000000000000000000000000000000000000000600082015250565b600061399b600c83612c78565b91506139a682613965565b602082019050919050565b600060208201905081810360008301526139ca8161398e565b9050919050565b7f596f752063616e2061646f70742061206d6178696d756d206f66206d61784d6960008201527f6e7420446f676773000000000000000000000000000000000000000000000000602082015250565b6000613a2d602883612c78565b9150613a38826139d1565b604082019050919050565b60006020820190508181036000830152613a5c81613a20565b9050919050565b6000613a6e82612d28565b9150613a7983612d28565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613aae57613aad61370f565b5b828201905092915050565b7f45786365656473206d6178696d756d20446f67677320737570706c7900000000600082015250565b6000613aef601c83612c78565b9150613afa82613ab9565b602082019050919050565b60006020820190508181036000830152613b1e81613ae2565b9050919050565b7f45746865722073656e74206973206e6f7420636f727265637400000000000000600082015250565b6000613b5b601983612c78565b9150613b6682613b25565b602082019050919050565b60006020820190508181036000830152613b8a81613b4e565b9050919050565b7f455243373231413a20617070726f766520746f2063616c6c6572000000000000600082015250565b6000613bc7601a83612c78565b9150613bd282613b91565b602082019050919050565b60006020820190508181036000830152613bf681613bba565b9050919050565b7f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b6000613c59603383612c78565b9150613c6482613bfd565b604082019050919050565b60006020820190508181036000830152613c8881613c4c565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b6000613ceb602f83612c78565b9150613cf682613c8f565b604082019050919050565b60006020820190508181036000830152613d1a81613cde565b9050919050565b600081905092915050565b6000613d3782612c6d565b613d418185613d21565b9350613d51818560208601612c89565b80840191505092915050565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b6000613d93600583613d21565b9150613d9e82613d5d565b600582019050919050565b6000613db58285613d2c565b9150613dc18284613d2c565b9150613dcc82613d86565b91508190509392505050565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b6000613e34603283612c78565b9150613e3f82613dd8565b604082019050919050565b60006020820190508181036000830152613e6381613e27565b9050919050565b7f455243373231413a207472616e736665722066726f6d20696e636f727265637460008201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b6000613ec6602683612c78565b9150613ed182613e6a565b604082019050919050565b60006020820190508181036000830152613ef581613eb9565b9050919050565b7f455243373231413a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000613f58602583612c78565b9150613f6382613efc565b604082019050919050565b60006020820190508181036000830152613f8781613f4b565b9050919050565b7f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b6000613fea602a83612c78565b9150613ff582613f8e565b604082019050919050565b6000602082019050818103600083015261401981613fdd565b9050919050565b7f455243373231413a20756e61626c6520746f2064657465726d696e652074686560008201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b600061407c602f83612c78565b915061408782614020565b604082019050919050565b600060208201905081810360008301526140ab8161406f565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006140d9826140b2565b6140e381856140bd565b93506140f3818560208601612c89565b6140fc81612cbc565b840191505092915050565b600060808201905061411c6000830187612dbd565b6141296020830186612dbd565b6141366040830185612e53565b818103606083015261414881846140ce565b905095945050505050565b60008151905061416281612bde565b92915050565b60006020828403121561417e5761417d612ba8565b5b600061418c84828501614153565b91505092915050565b60006141a082612d28565b91506141ab83612d28565b9250828210156141be576141bd61370f565b5b828203905092915050565b60006141d482612d28565b91506141df83612d28565b9250826141ef576141ee613905565b5b828206905092915050565b7f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b6000614256602183612c78565b9150614261826141fa565b604082019050919050565b6000602082019050818103600083015261428581614249565b9050919050565b7f455243373231413a207175616e74697479206d7573742062652067726561746560008201527f72207468616e2030000000000000000000000000000000000000000000000000602082015250565b60006142e8602883612c78565b91506142f38261428c565b604082019050919050565b60006020820190508181036000830152614317816142db565b905091905056fea26469706673582212202f2c41a1e2cd945a1546f7adc6fe9c5f205aaa4de503b37967bbbb235568681364736f6c634300080a0033
[ 12, 5, 19 ]
0xF1DdDF9c4680929d795a294295c01d3150438eD7
// SPDX-License-Identifier: MIT // 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/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/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: @openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol pragma solidity ^0.8.0; /** * @dev Extension of {ERC20} that adds a cap to the supply of tokens. */ abstract contract ERC20Capped is ERC20 { uint256 private immutable _cap; /** * @dev Sets the value of the `cap`. This value is immutable, it can only be * set once during construction. */ constructor(uint256 cap_) { require(cap_ > 0, "ERC20Capped: cap is 0"); _cap = cap_; } /** * @dev Returns the cap on the token's total supply. */ function cap() public view virtual returns (uint256) { return _cap; } /** * @dev See {ERC20-_mint}. */ function _mint(address account, uint256 amount) internal virtual override { require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); super._mint(account, amount); } } // File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol pragma solidity ^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 { /** * @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 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } } // 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/token/ERC20/behaviours/ERC20Mintable.sol pragma solidity ^0.8.0; /** * @title ERC20Mintable * @dev Implementation of the ERC20Mintable. Extension of {ERC20} that adds a minting behaviour. */ abstract contract ERC20Mintable is ERC20 { // indicates if minting is finished bool private _mintingFinished = false; /** * @dev Emitted during finish minting */ event MintFinished(); /** * @dev Tokens can be minted only before minting finished. */ modifier canMint() { require(!_mintingFinished, "ERC20Mintable: minting is finished"); _; } /** * @return if minting is finished or not. */ function mintingFinished() external view returns (bool) { return _mintingFinished; } /** * @dev Function to mint tokens. * * WARNING: it allows everyone to mint new tokens. Access controls MUST be defined in derived contracts. * * @param account The address that will receive the minted tokens * @param amount The amount of tokens to mint */ function mint(address account, uint256 amount) external canMint { _mint(account, amount); } /** * @dev Function to stop minting new tokens. * * WARNING: it allows everyone to finish minting. Access controls MUST be defined in derived contracts. */ function finishMinting() external canMint { _finishMinting(); } /** * @dev Function to stop minting new tokens. */ function _finishMinting() internal virtual { _mintingFinished = true; emit MintFinished(); } } // 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/CommonERC20.sol pragma solidity ^0.8.0; /** * @title CommonERC20 * @dev Implementation of the CommonERC20 */ contract CommonERC20 is ERC20Decimals, ERC20Capped, ERC20Mintable, ERC20Burnable, Ownable, ServicePayer { constructor( string memory name_, string memory symbol_, uint8 decimals_, uint256 cap_, uint256 initialBalance_, address payable feeReceiver_ ) payable ERC20(name_, symbol_) ERC20Decimals(decimals_) ERC20Capped(cap_) ServicePayer(feeReceiver_, "CommonERC20") { // Immutable variables cannot be read during contract creation time // https://github.com/ethereum/solidity/issues/10463 require(initialBalance_ <= cap_, "ERC20Capped: cap exceeded"); ERC20._mint(_msgSender(), initialBalance_); } function decimals() public view virtual override(ERC20, ERC20Decimals) returns (uint8) { return super.decimals(); } /** * @dev Function to mint tokens. * * NOTE: restricting access to owner only. See {ERC20Mintable-mint}. * * @param account The address that will receive the minted tokens * @param amount The amount of tokens to mint */ function _mint(address account, uint256 amount) internal override(ERC20, ERC20Capped) onlyOwner { super._mint(account, amount); } /** * @dev Function to stop minting new tokens. * * NOTE: restricting access to owner only. See {ERC20Mintable-finishMinting}. */ function _finishMinting() internal override onlyOwner { super._finishMinting(); } }
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806370a08231116100ad57806395d89b411161007157806395d89b41146102a1578063a457c2d7146102a9578063a9059cbb146102bc578063dd62ed3e146102cf578063f2fde38b1461030857600080fd5b806370a082311461022c578063715018a61461025557806379cc67901461025d5780637d64bcb4146102705780638da5cb5b1461027857600080fd5b8063313ce567116100f4578063313ce5671461019a578063355274ea146101cb57806339509351146101f157806340c10f191461020457806342966c681461021957600080fd5b806305d2035b1461013157806306fdde031461014d578063095ea7b31461016257806318160ddd1461017557806323b872dd14610187575b600080fd5b60055460ff165b60405190151581526020015b60405180910390f35b61015561031b565b6040516101449190610ecd565b610138610170366004610e8a565b6103ad565b6002545b604051908152602001610144565b610138610195366004610e4e565b6103c3565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000012168152602001610144565b7f00000000000000000000000000000000000000001027e72f1f12813088000000610179565b6101386101ff366004610e8a565b610472565b610217610212366004610e8a565b6104ae565b005b610217610227366004610eb4565b6104df565b61017961023a366004610df9565b6001600160a01b031660009081526020819052604090205490565b6102176104ec565b61021761026b366004610e8a565b610528565b6102176105ae565b60055461010090046001600160a01b03166040516001600160a01b039091168152602001610144565b6101556105d9565b6101386102b7366004610e8a565b6105e8565b6101386102ca366004610e8a565b610681565b6101796102dd366004610e1b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610217610316366004610df9565b61068e565b60606003805461032a90610fc8565b80601f016020809104026020016040519081016040528092919081815260200182805461035690610fc8565b80156103a35780601f10610378576101008083540402835291602001916103a3565b820191906000526020600020905b81548152906001019060200180831161038657829003601f168201915b5050505050905090565b60006103ba33848461080b565b50600192915050565b60006103d084848461092f565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561045a5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b610467853385840361080b565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916103ba9185906104a9908690610f99565b61080b565b60055460ff16156104d15760405162461bcd60e51b815260040161045190610f57565b6104db8282610afe565b5050565b6104e93382610b38565b50565b6005546001600160a01b0361010090910416331461051c5760405162461bcd60e51b815260040161045190610f22565b6105266000610c86565b565b600061053483336102dd565b9050818110156105925760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b6064820152608401610451565b61059f833384840361080b565b6105a98383610b38565b505050565b60055460ff16156105d15760405162461bcd60e51b815260040161045190610f57565b610526610ce0565b60606004805461032a90610fc8565b3360009081526001602090815260408083206001600160a01b03861684529091528120548281101561066a5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610451565b610677338585840361080b565b5060019392505050565b60006103ba33848461092f565b6005546001600160a01b036101009091041633146106be5760405162461bcd60e51b815260040161045190610f22565b6001600160a01b0381166107235760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610451565b6104e981610c86565b6001600160a01b0382166107825760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610451565b80600260008282546107949190610f99565b90915550506001600160a01b038216600090815260208190526040812080548392906107c1908490610f99565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b03831661086d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610451565b6001600160a01b0382166108ce5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610451565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166109935760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610451565b6001600160a01b0382166109f55760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610451565b6001600160a01b03831660009081526020819052604090205481811015610a6d5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610451565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610aa4908490610f99565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610af091815260200190565b60405180910390a350505050565b6005546001600160a01b03610100909104163314610b2e5760405162461bcd60e51b815260040161045190610f22565b6104db8282610d18565b6001600160a01b038216610b985760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610451565b6001600160a01b03821660009081526020819052604090205481811015610c0c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610451565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610c3b908490610fb1565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b600580546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6005546001600160a01b03610100909104163314610d105760405162461bcd60e51b815260040161045190610f22565b610526610da5565b7f00000000000000000000000000000000000000001027e72f1f1281308800000081610d4360025490565b610d4d9190610f99565b1115610d9b5760405162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a20636170206578636565646564000000000000006044820152606401610451565b6104db828261072c565b6005805460ff191660011790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a1565b80356001600160a01b0381168114610df457600080fd5b919050565b600060208284031215610e0b57600080fd5b610e1482610ddd565b9392505050565b60008060408385031215610e2e57600080fd5b610e3783610ddd565b9150610e4560208401610ddd565b90509250929050565b600080600060608486031215610e6357600080fd5b610e6c84610ddd565b9250610e7a60208501610ddd565b9150604084013590509250925092565b60008060408385031215610e9d57600080fd5b610ea683610ddd565b946020939093013593505050565b600060208284031215610ec657600080fd5b5035919050565b600060208083528351808285015260005b81811015610efa57858101830151858201604001528201610ede565b81811115610f0c576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526022908201527f45524332304d696e7461626c653a206d696e74696e672069732066696e697368604082015261195960f21b606082015260800190565b60008219821115610fac57610fac611003565b500190565b600082821015610fc357610fc3611003565b500390565b600181811c90821680610fdc57607f821691505b60208210811415610ffd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfea2646970667358221220609e4d26447355fbe9f5b3d732f6d653a320f34c5c1d87d62fba24aeafa1e1e664736f6c63430008070033
[ 38 ]
0xF1Ddf3cFB28C75B3fca7d755f516cAed35872719
pragma solidity ^0.4.21; contract HumanBlockToken { // Track how many tokens are owned by each address. mapping (address => uint256) public balanceOf; string public name = "Human Block"; string public symbol = "HBC"; uint8 public decimals = 8; uint256 public totalSupply = 1000000000 * (uint256(10) ** decimals); event Transfer(address indexed from, address indexed to, uint256 value); function HumanBlockToken() public { // Initially assign all tokens to the contract's creator. balanceOf[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } function transfer(address to, uint256 value) public returns (bool success) { require(balanceOf[msg.sender] >= value); balanceOf[msg.sender] -= value; // deduct from sender's balance balanceOf[to] += value; // add to recipient's balance emit Transfer(msg.sender, to, value); return true; } event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => mapping(address => uint256)) public allowance; function approve(address spender, uint256 value) public returns (bool success) { allowance[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool success) { require(value <= balanceOf[from]); require(value <= allowance[from][msg.sender]); balanceOf[from] -= value; balanceOf[to] += value; allowance[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } }
0x6060604052600436106100985763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461009d578063095ea7b31461012757806318160ddd1461015d57806323b872dd14610182578063313ce567146101aa57806370a08231146101d357806395d89b41146101f2578063a9059cbb14610205578063dd62ed3e14610227575b600080fd5b34156100a857600080fd5b6100b061024c565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156100ec5780820151838201526020016100d4565b50505050905090810190601f1680156101195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561013257600080fd5b610149600160a060020a03600435166024356102ea565b604051901515815260200160405180910390f35b341561016857600080fd5b610170610356565b60405190815260200160405180910390f35b341561018d57600080fd5b610149600160a060020a036004358116906024351660443561035c565b34156101b557600080fd5b6101bd610440565b60405160ff909116815260200160405180910390f35b34156101de57600080fd5b610170600160a060020a0360043516610449565b34156101fd57600080fd5b6100b061045b565b341561021057600080fd5b610149600160a060020a03600435166024356104c6565b341561023257600080fd5b610170600160a060020a036004358116906024351661055a565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102e25780601f106102b7576101008083540402835291602001916102e2565b820191906000526020600020905b8154815290600101906020018083116102c557829003601f168201915b505050505081565b600160a060020a03338116600081815260056020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60045481565b600160a060020a03831660009081526020819052604081205482111561038157600080fd5b600160a060020a03808516600090815260056020908152604080832033909416835292905220548211156103b457600080fd5b600160a060020a0380851660008181526020818152604080832080548890039055878516808452818420805489019055848452600583528184203390961684529490915290819020805486900390557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60035460ff1681565b60006020819052908152604090205481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102e25780601f106102b7576101008083540402835291602001916102e2565b600160a060020a033316600090815260208190526040812054829010156104ec57600080fd5b600160a060020a033381166000818152602081905260408082208054879003905592861680825290839020805486019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b6005602090815260009283526040808420909152908252902054815600a165627a7a72305820e50b6343e6cc956376424b1a9ce13905ce83aef26c0a09be06a97399de7e8dbf0029
[ 38 ]
0xf1de62571cf0f3bdb8c5356cd9b2e5fadb08174d
pragma solidity ^0.5.0; import "./Context.sol"; import "./ERC20.sol"; import "./ERC20Detailed.sol"; import "./ERC20Burnable.sol"; contract blizzard is Context, ERC20, ERC20Detailed, ERC20Burnable { constructor () public ERC20Detailed("blizzard Token", "BZD", 9) { _mint(_msgSender(), 100000000 * (10 ** uint256(decimals()))); } }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100ca578063095ea7b31461015a57806318160ddd146101cd57806323b872dd146101f8578063313ce5671461028b57806339509351146102bc57806342966c681461032f57806370a082311461036a57806379cc6790146103cf57806395d89b411461042a578063a457c2d7146104ba578063a9059cbb1461052d578063dd62ed3e146105a0575b600080fd5b3480156100d657600080fd5b506100df610625565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011f578082015181840152602081019050610104565b50505050905090810190601f16801561014c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561016657600080fd5b506101b36004803603604081101561017d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c7565b604051808215151515815260200191505060405180910390f35b3480156101d957600080fd5b506101e26106e5565b6040518082815260200191505060405180910390f35b34801561020457600080fd5b506102716004803603606081101561021b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106ef565b604051808215151515815260200191505060405180910390f35b34801561029757600080fd5b506102a061080c565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102c857600080fd5b50610315600480360360408110156102df57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610823565b604051808215151515815260200191505060405180910390f35b34801561033b57600080fd5b506103686004803603602081101561035257600080fd5b81019080803590602001909291905050506108d6565b005b34801561037657600080fd5b506103b96004803603602081101561038d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108ea565b6040518082815260200191505060405180910390f35b3480156103db57600080fd5b50610428600480360360408110156103f257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610932565b005b34801561043657600080fd5b5061043f610940565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561047f578082015181840152602081019050610464565b50505050905090810190601f1680156104ac5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104c657600080fd5b50610513600480360360408110156104dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109e2565b604051808215151515815260200191505060405180910390f35b34801561053957600080fd5b506105866004803603604081101561055057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610af3565b604051808215151515815260200191505060405180910390f35b3480156105ac57600080fd5b5061060f600480360360408110156105c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b11565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106bd5780601f10610692576101008083540402835291602001916106bd565b820191906000526020600020905b8154815290600101906020018083116106a057829003601f168201915b5050505050905090565b60006106db6106d4610b98565b8484610ba0565b6001905092915050565b6000600254905090565b60006106fc848484610e21565b61080184610708610b98565b6107fc85606060405190810160405280602881526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206181526020017f6c6c6f77616e6365000000000000000000000000000000000000000000000000815250600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006107b2610b98565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a59092919063ffffffff16565b610ba0565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006108cc610830610b98565b846108c78560016000610841610b98565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461126790919063ffffffff16565b610ba0565b6001905092915050565b6108e76108e1610b98565b826112f1565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61093c8282611532565b5050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109d85780601f106109ad576101008083540402835291602001916109d8565b820191906000526020600020905b8154815290600101906020018083116109bb57829003601f168201915b5050505050905090565b6000610ae96109ef610b98565b84610ae485606060405190810160405280602581526020017f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7781526020017f207a65726f00000000000000000000000000000000000000000000000000000081525060016000610a5d610b98565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a59092919063ffffffff16565b610ba0565b6001905092915050565b6000610b07610b00610b98565b8484610e21565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610c6b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001807f45524332303a20617070726f76652066726f6d20746865207a65726f2061646481526020017f726573730000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610d36576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001807f45524332303a20617070726f766520746f20746865207a65726f20616464726581526020017f737300000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610eec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001807f45524332303a207472616e736665722066726f6d20746865207a65726f20616481526020017f647265737300000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610fb7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f45524332303a207472616e7366657220746f20746865207a65726f206164647281526020017f657373000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b61106681606060405190810160405280602681526020017f45524332303a207472616e7366657220616d6f756e742065786365656473206281526020017f616c616e636500000000000000000000000000000000000000000000000000008152506000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a59092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110f9816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461126790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008383111582901515611254576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156112195780820151818401526020810190506111fe565b50505050905090810190601f1680156112465780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101515156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156113bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001807f45524332303a206275726e2066726f6d20746865207a65726f2061646472657381526020017f730000000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b61146b81606060405190810160405280602281526020017f45524332303a206275726e20616d6f756e7420657863656564732062616c616e81526020017f63650000000000000000000000000000000000000000000000000000000000008152506000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a59092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114c28160025461164590919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b61153c82826112f1565b61164182611548610b98565b61163c84606060405190810160405280602481526020017f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7781526020017f616e636500000000000000000000000000000000000000000000000000000000815250600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006115f2610b98565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111a59092919063ffffffff16565b610ba0565b5050565b600061168783836040805190810160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111a5565b90509291505056fea165627a7a7230582009f759c4ac14d10497d1cf0ca132cf7ec494cb4701557a87ff3813b4b594bf3a0029
[ 38 ]
0xf1de9f3570383846f63fb397eff5c1f20bf1e35b
/** @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:::@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@:::::-@@@@@@::::::@@:::::::::::::::::::::::::@::=-:@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@:***+:@@@@@@::**-+@@:*********+:************-=:**-:@@-::::@@@@@@@@@@@@@@@@@@ @@@@@:****-:@@@@@::**-*@@:***+++++++:+***********-=-**-=@@-:**-*@@@@@@@@@@@@@@@@@ @@@@@:*****::@@@@::**-*@@:**-------:::----**------*:--=*@@-:**-*@@@@@@@@@@@@@@@@@ @@@@@:**+**+-@@@@::**-*@@:**-+**********+-**-******@=+*@@@-:**-*@@@@@@@@@@@@@@@@@ @@@@@:**--**-:@@@::**-*@@:**-+@@@@@@@@@@-:**-*@@@@@::::@::::**--::@@@:::::@@@@@@@ @@@@@:**--***=:@@::**-*@@:**-=::::::@@@@-:**-*@@@@@:-=-*:-==**+=--@:::=+==-::@@@@ @@@@@:**--:**+:@@::**-*@@:**-:::::::@@@@-:**-*@@@@@:**-*:-******-=:: ******:-@@@@ @@@@@:**--:=**+::::**-*@@:********-:#@@@-:**-*@@@@@:**-*:-=+**+=-=:**+==-=-+*@@@@ @@@@@:**--@:+**=:::**-*@@:********-:%@@@-:**-*@@@@@:**-*@**-**-***:**+:--:+*@@@@@ @@@@@:**--@::***-::**-*@@:**-:::::::%@@@-:**-*@@@@@:**-*@@-:**-*@@:=**+=::+@@@@@@ @@@@@:**--@@:-***::**-*@@:**-+@@@@@@@@@@-:**-*@@@@@:**-*@@-:**-*@@--*****+::@@@@@ @@@@@:**--@@@:=**=:**-*@@:**-+@@@@@@@@@@-:**-*@@@@@:**-*@@-:**-*@@@::==***+::@@@@ @@@@@:**--@@@@:******-*@@:**-+@@@@@@@@@@-:**-*@@@@@:**-*@@-:**-*@@@::+-:+**-:@@@@ @@@@@:**--@@@@:-*****-*@@:**-+@@@@@@@@@@-:**-*@@@@@:**-*@@-:**-*@@::::::=**-=@@@@ @@@@@:**--@@@@@:=****-*@@:**-+@@@@@@@@@@-:**-*@@@@@:**-*@@-:**-*@::-*+--+**-+@@@@ @@@@@:**--@@@@@-:=***-*@@:**-+@@@@@@@@@@-:**-*@@@@@:**-*@@-:**-*@::=******=+*@@@@ @@@@@::::-@@@@@@@::::-*@@::::+@@@@@@@@@@-::::*@@@@@::::*@@-::::*@@@:--++--+*@@@@@ @@@@@::::=@@@@@@@::::-*@@::::+@@@@@@@@@@:::::*@@@@@::::*@@-::::*@@@@+:=++**@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ The NFTits Club | Official Contract | Gals Of The Galaxy */ // SPDX-License-Identifier: MIT // 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/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/cryptography/ECDSA.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol) 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 = 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)); } } // File: @openzeppelin/contracts/utils/Context.sol // 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; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (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() { _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); } } // File: @openzeppelin/contracts/utils/Address.sol // 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); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (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 // OpenZeppelin Contracts v4.4.1 (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/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (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); /** * @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/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (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: contracts/ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 private currentIndex = 0; uint256 internal immutable maxBatchSize; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) private _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // 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 * `maxBatchSize` refers to how much a minter can mint at a time. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), "ERC721A: global index out of bounds"); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), "ERC721A: owner index out of bounds"); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx = 0; address currOwnershipAddr = address(0); for (uint256 i = 0; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } revert("ERC721A: unable to get token of owner by index"); } /** * @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 || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721A: balance query for the zero address"); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), "ERC721A: number minted query for the zero address"); return uint256(_addressData[owner].numberMinted); } function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), "ERC721A: owner query for nonexistent token"); uint256 lowestTokenToCheck; if (tokenId >= maxBatchSize) { lowestTokenToCheck = tokenId - maxBatchSize + 1; } for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } revert("ERC721A: unable to determine the owner of token"); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @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 override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, "ERC721A: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721A: approve caller is not owner nor approved for all" ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721A: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), "ERC721A: 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 override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), "ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` cannot be larger than the max batch size. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = currentIndex; require(to != address(0), "ERC721A: mint to the zero address"); // We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering. require(!_exists(startTokenId), "ERC721A: token already minted"); require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high"); _beforeTokenTransfers(address(0), to, startTokenId, quantity); AddressData memory addressData = _addressData[to]; _addressData[to] = AddressData( addressData.balance + uint128(quantity), addressData.numberMinted + uint128(quantity) ); _ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp)); uint256 updatedIndex = startTokenId; for (uint256 i = 0; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); require( _checkOnERC721Received(address(0), to, updatedIndex, _data), "ERC721A: transfer to non ERC721Receiver implementer" ); updatedIndex++; } currentIndex = updatedIndex; _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, "ERC721A: transfer caller is not owner nor approved"); require(prevOwnership.addr == from, "ERC721A: transfer from incorrect owner"); require(to != address(0), "ERC721A: transfer to the zero address"); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId] = TokenOwnership(to, uint64(block.timestamp)); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId] = TokenOwnership(prevOwnership.addr, prevOwnership.startTimestamp); } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } uint256 public nextOwnerToExplicitlySet = 0; /** * @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf(). */ function _setOwnersExplicit(uint256 quantity) internal { uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet; require(quantity > 0, "quantity must be nonzero"); uint256 endIndex = oldNextOwnerToSet + quantity - 1; if (endIndex > currentIndex - 1) { endIndex = currentIndex - 1; } // We know if the last one in the group exists, all in the group exist, due to serial ordering. require(_exists(endIndex), "not enough minted yet for this cleanup"); for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) { if (_ownerships[i].addr == address(0)) { TokenOwnership memory ownership = ownershipOf(i); _ownerships[i] = TokenOwnership(ownership.addr, ownership.startTimestamp); } } nextOwnerToExplicitlySet = endIndex + 1; } /** * @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("ERC721A: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * 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`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: contracts/con2.sol pragma solidity ^0.8.4; contract NFTits is ERC721A, Ownable, ReentrancyGuard { using ECDSA for bytes32; string baseURI = "ipfs://QmZbvgq4RHxLYTsNDB37s7jp1hNdx6jqxPU3q657H27MAs/"; string baseExtension = ".json"; uint256 public salePrice = 0.1 ether; uint256 public presalePrice = 0.07 ether; uint256 maxSupply = 7777; bool public paused = true; bool public presalePaused = true; mapping (address => uint256) public whitelistMintedAmount; uint256 public presaleMaxMint = 10; uint256 public saleMintAmount = 50; address public signerAddress = 0xBA3Daf4d95A0B5A31eD0278CfeceDCe54EB23C16; constructor() ERC721A( "The NFTits Club", "TIT", saleMintAmount){ } function matchAddressSigner(address account, bytes calldata signature) internal view returns (bool){ return ECDSA.recover(keccak256(abi.encodePacked(account)).toEthSignedMessageHash(), signature) == signerAddress; } function presaleMint(uint256 quantity, bytes calldata signature) external payable nonReentrant{ require(matchAddressSigner(msg.sender, signature), "not on whitelist"); require(whitelistMintedAmount[msg.sender] + quantity <= presaleMaxMint); require(msg.value >= quantity * presalePrice); require(!presalePaused); whitelistMintedAmount[msg.sender] += quantity; _safeMint(msg.sender, quantity); } function mint(address _to, uint quantity) external payable { uint256 supply = totalSupply(); require (quantity <= saleMintAmount); require(supply + quantity <= maxSupply); if (msg.sender != owner()){ require (!paused); require(msg.value >= quantity * salePrice); } _safeMint(_to, quantity); } function _baseURI() internal view override returns (string memory){ return baseURI; } function changeWhitelistAddress(address _newWhitelistSigner)public onlyOwner{ signerAddress = _newWhitelistSigner; } // only owner function togglePaused() public onlyOwner{ paused = !paused; } function togglePresalePaused() public onlyOwner{ presalePaused = !presalePaused; } function setPrice(uint256 _newPrice) public onlyOwner(){ salePrice = _newPrice; } function setPresalePrice(uint256 _newPrice) public onlyOwner(){ presalePrice = _newPrice; } function setMaxMintAmount(uint256 _newMaxMintAmount) public onlyOwner(){ saleMintAmount = _newMaxMintAmount; } function setMaxPresaleMint(uint256 _newMaxMintAmount) public onlyOwner(){ presaleMaxMint = _newMaxMintAmount; } function updateMaxSupply (uint256 _newMax) public onlyOwner(){ maxSupply = _newMax; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
0x73f1de9f3570383846f63fb397eff5c1f20bf1e35b30146080604052600080fdfea264697066735822122094ad91fcc70c9fd147364e9e07bb4fa522e72f9bb4431251e34f1d501e3c526c64736f6c63430008070033
[ 5, 9, 12 ]
0xf1ded284e891943b3e9c657d7fc376b86164ffc2
/** *Submitted for verification at Etherscan.io on 2020-10-09 */ // 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) { // 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; } } /** * @title Proxy * @dev Implements delegation of calls to other contracts, with proper * forwarding of return values and bubbling of failures. * It defines a fallback function that delegates all calls to the address * returned by the abstract _implementation() internal function. */ abstract contract Proxy { /** * @dev Fallback function. * Implemented entirely in `_fallback`. */ fallback () payable external { _fallback(); } /** * @dev Receive function. * Implemented entirely in `_fallback`. */ receive () payable external { _fallback(); } /** * @return The Address of the implementation. */ function _implementation() internal virtual view returns (address); /** * @dev Delegates execution to an implementation contract. * This is a low level function that doesn't return to its internal call site. * It will return to the external caller whatever the implementation returns. * @param implementation Address to delegate. */ function _delegate(address implementation) internal { 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 Function that is run as the first thing in the fallback function. * Can be redefined in derived contracts to add functionality. * Redefinitions must call super._willFallback(). */ function _willFallback() internal virtual { } /** * @dev fallback implementation. * Extracted to enable manual triggering. */ function _fallback() internal { _willFallback(); _delegate(_implementation()); } } /** * @title UpgradeabilityProxy * @dev This contract implements a proxy that allows to change the * implementation address to which it will delegate. * Such a change is called an implementation upgrade. */ contract UpgradeabilityProxy is Proxy { /** * @dev Contract constructor. * @param _logic Address of the initial implementation. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, bytes memory _data) public payable { assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)); _setImplementation(_logic); if(_data.length > 0) { (bool success,) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. * @param implementation Address of the new implementation. */ event Upgraded(address indexed implementation); /** * @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. * @return impl Address of the current implementation */ function _implementation() internal override view returns (address impl) { bytes32 slot = IMPLEMENTATION_SLOT; assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * @param newImplementation Address of the new implementation. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Sets the implementation address of the proxy. * @param newImplementation Address of the new implementation. */ function _setImplementation(address newImplementation) internal { require(Address.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address"); bytes32 slot = IMPLEMENTATION_SLOT; assembly { sstore(slot, newImplementation) } } } /** * @title AdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _admin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, address _admin, bytes memory _data) UpgradeabilityProxy(_logic, _data) public payable { assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_admin); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin { _upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal override virtual { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101185780638f28397014610149578063f851a4401461017c5761005d565b3661005d5761005b610191565b005b61005b610191565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101ab565b61005b600480360360408110156100ae57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100d957600080fd5b8201836020820111156100eb57600080fd5b8035906020019184600183028401116401000000008311171561010d57600080fd5b5090925090506101e5565b34801561012457600080fd5b5061012d610292565b604080516001600160a01b039092168252519081900360200190f35b34801561015557600080fd5b5061005b6004803603602081101561016c57600080fd5b50356001600160a01b03166102cf565b34801561018857600080fd5b5061012d610389565b6101996103ba565b6101a96101a461041a565b61043f565b565b6101b3610463565b6001600160a01b0316336001600160a01b031614156101da576101d581610488565b6101e2565b6101e2610191565b50565b6101ed610463565b6001600160a01b0316336001600160a01b031614156102855761020f83610488565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d806000811461026c576040519150601f19603f3d011682016040523d82523d6000602084013e610271565b606091505b505090508061027f57600080fd5b5061028d565b61028d610191565b505050565b600061029c610463565b6001600160a01b0316336001600160a01b031614156102c4576102bd61041a565b90506102cc565b6102cc610191565b90565b6102d7610463565b6001600160a01b0316336001600160a01b031614156101da576001600160a01b0381166103355760405162461bcd60e51b81526004018080602001828103825260368152602001806105876036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61035e610463565b604080516001600160a01b03928316815291841660208301528051918290030190a16101d5816104c8565b6000610393610463565b6001600160a01b0316336001600160a01b031614156102c4576102bd610463565b3b151590565b6103c2610463565b6001600160a01b0316336001600160a01b031614156104125760405162461bcd60e51b81526004018080602001828103825260328152602001806105556032913960400191505060405180910390fd5b6101a96101a9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b610491816104ec565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6104f5816103b4565b6105305760405162461bcd60e51b815260040180806020018281038252603b8152602001806105bd603b913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f206164647265737343616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a264697066735822122073c4c21e5c673ed7cd3c216206991b426c7391cadd714e9a2c3f3ee94217be2b64736f6c634300060c0033
[ 38 ]
0xf1def7f0e620f39531eb352fe13da6825218e7df
pragma solidity ^0.4.22; 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) { 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 ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } 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); } 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); } interface Token { function distr(address _to, uint256 _value) external returns (bool); function totalSupply() constant external returns (uint256 supply); function balanceOf(address _owner) constant external returns (uint256 balance); } contract BITDINERO is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public blacklist; string public constant name = "Bit Dinero"; string public constant symbol = "XBD"; uint public constant decimals = 18; uint256 public totalSupply = 30000000000e18; uint256 public totalDistributed = 15000000000e18; uint256 public totalRemaining = totalSupply.sub(totalDistributed); uint256 public value = 150000e18; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyWhitelist() { require(blacklist[msg.sender] == false); _; } function BITDINERO() public { owner = msg.sender; balances[owner] = totalDistributed; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); totalRemaining = totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; if (totalDistributed >= totalSupply) { distributionFinished = true; } } function () external payable { getTokens(); } function getTokens() payable canDistr onlyWhitelist public { if (value > totalRemaining) { value = totalRemaining; } require(value <= totalRemaining); address investor = msg.sender; uint256 toGive = value; distr(investor, toGive); if (toGive > 0) { blacklist[investor] = true; } if (totalDistributed >= totalSupply) { distributionFinished = true; } value = value.div(100000).mul(99999); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { uint256 etherBalance = address(this).balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x60806040526004361061011d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610127578063095ea7b3146101b757806318160ddd1461021c57806323b872dd14610247578063313ce567146102cc5780633ccfd60b146102f75780633fa4f2451461030e57806342966c681461033957806370a082311461036657806395d89b41146103bd5780639b1cbccc1461044d578063a9059cbb1461047c578063aa6ca808146104e1578063c108d542146104eb578063c489744b1461051a578063d8a5436014610591578063dd62ed3e146105bc578063e58fc54c14610633578063efca2eed1461068e578063f2fde38b146106b9578063f9f92be4146106fc575b610125610757565b005b34801561013357600080fd5b5061013c6108d3565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561017c578082015181840152602081019050610161565b50505050905090810190601f1680156101a95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c357600080fd5b50610202600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061090c565b604051808215151515815260200191505060405180910390f35b34801561022857600080fd5b50610231610a9a565b6040518082815260200191505060405180910390f35b34801561025357600080fd5b506102b2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aa0565b604051808215151515815260200191505060405180910390f35b3480156102d857600080fd5b506102e1610e76565b6040518082815260200191505060405180910390f35b34801561030357600080fd5b5061030c610e7b565b005b34801561031a57600080fd5b50610323610f5f565b6040518082815260200191505060405180910390f35b34801561034557600080fd5b5061036460048036038101908080359060200190929190505050610f65565b005b34801561037257600080fd5b506103a7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611131565b6040518082815260200191505060405180910390f35b3480156103c957600080fd5b506103d261117a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104125780820151818401526020810190506103f7565b50505050905090810190601f16801561043f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561045957600080fd5b506104626111b3565b604051808215151515815260200191505060405180910390f35b34801561048857600080fd5b506104c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061127b565b604051808215151515815260200191505060405180910390f35b6104e9610757565b005b3480156104f757600080fd5b506105006114b6565b604051808215151515815260200191505060405180910390f35b34801561052657600080fd5b5061057b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114c9565b6040518082815260200191505060405180910390f35b34801561059d57600080fd5b506105a66115b4565b6040518082815260200191505060405180910390f35b3480156105c857600080fd5b5061061d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115ba565b6040518082815260200191505060405180910390f35b34801561063f57600080fd5b50610674600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611641565b604051808215151515815260200191505060405180910390f35b34801561069a57600080fd5b506106a3611886565b6040518082815260200191505060405180910390f35b3480156106c557600080fd5b506106fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061188c565b005b34801561070857600080fd5b5061073d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611963565b604051808215151515815260200191505060405180910390f35b600080600960009054906101000a900460ff1615151561077657600080fd5b60001515600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415156107d557600080fd5b60075460085411156107eb576007546008819055505b600754600854111515156107fe57600080fd5b33915060085490506108108282611983565b506000811115610873576001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b60055460065410151561089c576001600960006101000a81548160ff0219169083151502179055505b6108c96201869f6108bb620186a0600854611b2a90919063ffffffff16565b611b4590919063ffffffff16565b6008819055505050565b6040805190810160405280600a81526020017f4269742044696e65726f0000000000000000000000000000000000000000000081525081565b600080821415801561099b57506000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b156109a95760009050610a94565b81600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60055481565b6000606060048101600036905010151515610ab757fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515610af357600080fd5b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610b4157600080fd5b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548311151515610bcc57600080fd5b610c1e83600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b7890919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cf083600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b7890919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dc283600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b9190919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b601281565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ed957600080fd5b3073ffffffffffffffffffffffffffffffffffffffff16319050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610f5b573d6000803e3d6000fd5b5050565b60085481565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fc357600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561101157600080fd5b33905061106682600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b7890919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110be82600554611b7890919063ffffffff16565b6005819055506110d982600654611b7890919063ffffffff16565b6006819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a25050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6040805190810160405280600381526020017f584244000000000000000000000000000000000000000000000000000000000081525081565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561121157600080fd5b600960009054906101000a900460ff1615151561122d57600080fd5b6001600960006101000a81548160ff0219169083151502179055507f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc60405160405180910390a16001905090565b600060406004810160003690501015151561129257fe5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141515156112ce57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054831115151561131c57600080fd5b61136e83600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b7890919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061140383600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b9190919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3600191505092915050565b600960009054906101000a900460ff1681565b60008060008491508173ffffffffffffffffffffffffffffffffffffffff166370a08231856040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561156c57600080fd5b505af1158015611580573d6000803e3d6000fd5b505050506040513d602081101561159657600080fd5b81019080805190602001909291905050509050809250505092915050565b60075481565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116a257600080fd5b8391508173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561174057600080fd5b505af1158015611754573d6000803e3d6000fd5b505050506040513d602081101561176a57600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561184257600080fd5b505af1158015611856573d6000803e3d6000fd5b505050506040513d602081101561186c57600080fd5b810190808051906020019092919050505092505050919050565b60065481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118e857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156119605780600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60046020528060005260406000206000915054906101000a900460ff1681565b6000600960009054906101000a900460ff161515156119a157600080fd5b6119b682600654611b9190919063ffffffff16565b6006819055506119d182600754611b7890919063ffffffff16565b600781905550611a2982600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b9190919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff167f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a77836040518082815260200191505060405180910390a28273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808284811515611b3857fe5b0490508091505092915050565b60008082840290506000841480611b665750828482811515611b6357fe5b04145b1515611b6e57fe5b8091505092915050565b6000828211151515611b8657fe5b818303905092915050565b6000808284019050838110151515611ba557fe5b80915050929150505600a165627a7a72305820700e27c9ae1fc953e6093fe0d8414483eeb4dba99a0404ee7ea508778f84742f0029
[ 14, 4 ]
0xf1df089f731b12f246bdaa372d8781ff4fffecae
// SPDX-License-Identifier: Unlicense pragma solidity ^0.8.9; import '../../interfaces/IHardwareSVGs.sol'; import '../../interfaces/ICategories.sol'; /// @dev Experimenting with a contract that holds huuuge svg strings contract HardwareSVGs19 is IHardwareSVGs, ICategories { function hardware_73() public pure returns (HardwareData memory) { return HardwareData( 'Four Wheels', HardwareCategories.STANDARD, string( abi.encodePacked( '<defs><linearGradient gradientTransform="translate(18.63 -18.63)" gradientUnits="userSpaceOnUse" id="h73-a" x1="-2.62" x2="3.33" y1="40.6" y2="34.65"><stop offset="0" stop-color="gray"/><stop offset="1" stop-color="#fff"/></linearGradient><linearGradient id="h73-b" x1="-12.9" x2="13.66" xlink:href="#h73-a" y1="50.88" y2="24.32"/><linearGradient gradientTransform="translate(18.63 -18.63)" gradientUnits="userSpaceOnUse" id="h73-c" x1="0.36" x2="0.36" y1="33.37" y2="41.87"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="gray"/></linearGradient><linearGradient id="h73-d" x1="0.36" x2="0.36" xlink:href="#h73-c" y1="18.63" y2="56.61"/><linearGradient id="h73-e" x1="0.36" x2="0.36" xlink:href="#h73-a" y1="35.12" y2="40.13"/><linearGradient id="h73-f" x1="0.36" x2="0.36" xlink:href="#h73-a" y1="35.13" y2="40.12"/><linearGradient id="h73-g" x1="0.36" x2="0.36" xlink:href="#h73-a" y1="21.92" y2="53.32"/><linearGradient gradientUnits="userSpaceOnUse" id="h73-h" x1="-0.16" x2="4.29" y1="6.05" y2="6.05"><stop offset="0" stop-color="gray"/><stop offset="0.24" stop-color="#4b4b4b"/><stop offset="0.68" stop-color="#fff"/><stop offset="1" stop-color="gray"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="h73-i" x2="4.35" y1="10.9" y2="10.9"><stop offset="0" stop-color="gray"/><stop offset="0.5" stop-color="#fff"/><stop offset="1" stop-color="gray"/></linearGradient><filter id="h73-j" name="shadow"><feDropShadow dx="0" dy="2" stdDeviation="0"/></filter><symbol id="h73-m" viewBox="0 0 4.35 12.1"><path d="M4.348,12.1H0v-.8l2.1-.235,2.244.235ZM4.009,0,3.4,10.707H.951L.337,0Z" fill="url(#h73-h)"/><path d="M4.348,11.3,3.4,10.5H.951L0,11.3v0Z" fill="url(#h73-i)"/></symbol><symbol id="h73-l" viewBox="0 0 4.35 28.93"><use height="12.1" transform="translate(0 16.83)" width="4.35" xlink:href="#h73-m"/><use height="12.1" transform="matrix(1, 0, 0, -1, 0, 12.1)" width="4.35" xlink:href="#h73-m"/></symbol><symbol id="h73-k" viewBox="0 0 37.98 37.98"><use height="28.93" transform="translate(16.77 3.54) scale(1.02 1.07)" width="4.35" xlink:href="#h73-l"/><use height="28.93" transform="translate(6.5 9.63) rotate(-45) scale(1.02 1.07)" width="4.35" xlink:href="#h73-l"/><use height="28.93" transform="matrix(0, -1.02, 1.07, 0, 3.54, 21.2)" width="4.35" xlink:href="#h73-l"/><use height="28.93" transform="matrix(-0.72, -0.72, 0.76, -0.76, 9.63, 31.48)" width="4.35" xlink:href="#h73-l"/><path d="M19,22.2A3.21,3.21,0,1,1,22.2,19,3.21,3.21,0,0,1,19,22.2Z" fill="none" stroke="url(#h73-a)" stroke-width="2"/><path d="M19,36A17,17,0,1,1,36,19,17,17,0,0,1,19,36Z" fill="none" stroke="url(#h73-b)" stroke-width="3.57"/><path d="M19,23a4,4,0,1,1,4-4A4,4,0,0,1,19,23Z" fill="none" stroke="url(#h73-c)" stroke-width="0.5"/><path d="M19,37.72A18.74,18.74,0,1,1,37.72,19,18.76,18.76,0,0,1,19,37.72Z" fill="none" stroke="url(#h73-d)" stroke-width="0.5"/><circle cx="18.99" cy="18.99" fill="none" r="2.25" stroke="url(#h73-e)" stroke-width="0.5"/><circle cx="18.99" cy="18.99" fill="none" r="2.25" stroke="url(#h73-f)" stroke-width="0.5"/><circle cx="18.99" cy="18.99" fill="none" r="15.45" stroke="url(#h73-g)" stroke-width="0.5"/><path d="M18.19,2a.73.73,0,1,1,.73.73A.73.73,0,0,1,18.19,2Zm.87,34.8a.72.72,0,0,0,.72-.72.73.73,0,0,0-.72-.73.73.73,0,0,0-.73.73A.73.73,0,0,0,19.06,36.75ZM6.89,7.72a.73.73,0,1,0,0-1.46.73.73,0,0,0,0,1.46ZM2,19.78a.73.73,0,0,0,.73-.72.73.73,0,0,0-1.46,0A.73.73,0,0,0,2,19.78Zm5,12a.73.73,0,0,0,.73-.72.73.73,0,1,0-1.46,0A.73.73,0,0,0,7,31.81ZM31.81,7a.73.73,0,0,0-.72-.73.73.73,0,0,0,0,1.46A.73.73,0,0,0,31.81,7Zm4.94,12.07a.73.73,0,0,0-.72-.73.73.73,0,0,0-.73.73.73.73,0,0,0,.73.72A.72.72,0,0,0,36.75,19.06Zm-5,12a.73.73,0,0,0-.72-.73.73.73,0,0,0-.73.73.73.73,0,0,0,.73.72A.72.72,0,0,0,31.71,31.09Z"/></symbol></defs><g filter="url(#h73-j)"><use height="37.98" transform="translate(91.01 83.01)" width="37.98" xlink:href="#h73-k"/><use height="37.98" transform="translate(91.01 143.01)" width="37.98" xlink:href="#h73-k"/><use height="37.98" transform="translate(116.01 113.01)" width="37.98" xlink:href="#h73-k"/><use height="37.98" transform="translate(66.01 113.01)" width="37.98" xlink:href="#h73-k"/></g>' ) ) ); } function hardware_74() public pure returns (HardwareData memory) { return HardwareData( 'Pear Diamond', HardwareCategories.STANDARD, string( abi.encodePacked( '<defs><linearGradient gradientUnits="userSpaceOnUse" id="h74-a" x1="13.03" x2="26.03" y1="57.83" y2="77.44"><stop offset="0" stop-color="#4b4b4b"/><stop offset="0.85" stop-color="#fff"/></linearGradient><linearGradient id="h74-b" x1="7.56" x2="7.56" xlink:href="#h74-a" y1="16.09" y2="31.8"/><linearGradient id="h74-c" x1="15.94" x2="15.94" xlink:href="#h74-a" y1="6.89" y2="19.53"/><linearGradient id="h74-d" x1="8.02" x2="8.02" xlink:href="#h74-a" y1="31.74" y2="51.84"/><linearGradient gradientTransform="translate(16534.01 16496.31) rotate(180)" id="h74-e" x1="16528.6" x2="16528.6" xlink:href="#h74-a" y1="16476.78" y2="16454.51"/><linearGradient gradientTransform="translate(16534.01 16496.31) rotate(180)" id="h74-f" x1="16519.5" x2="16519.5" xlink:href="#h74-a" y1="16454.51" y2="16421.7"/><linearGradient id="h74-g" x1="18.73" x2="26.02" xlink:href="#h74-a" y1="74.06" y2="88.86"/><linearGradient gradientTransform="translate(16534.01 16496.31) rotate(180)" id="h74-h" x1="16528.91" x2="16528.91" xlink:href="#h74-a" y1="16454.51" y2="16431.68"/><linearGradient gradientTransform="translate(16534.01 16496.31) rotate(180)" id="h74-i" x1="16526" x2="16526" xlink:href="#h74-a" y1="16454.51" y2="16454.51"/><linearGradient gradientTransform="translate(16534.01 16496.31) rotate(180)" id="h74-j" x1="16520.38" x2="16520.38" xlink:href="#h74-a" y1="16493.76" y2="16487.72"/><linearGradient gradientTransform="translate(16534.01 16496.31) rotate(180)" id="h74-k" x1="16510.95" x2="16510.95" xlink:href="#h74-a" y1="16496.31" y2="16489.42"/><linearGradient id="h74-l" x1="6.71" x2="19.51" xlink:href="#h74-a" y1="6.16" y2="19.57"/><filter id="h74-m" name="shadow"><feDropShadow dx="0" dy="2" stdDeviation="0"/></filter><linearGradient id="h74-n" x1="110" x2="110" xlink:href="#h74-a" y1="94.31" y2="148.8"/><linearGradient gradientTransform="translate(340.88 286.88) rotate(180)" id="h74-o" x1="230.88" x2="230.88" xlink:href="#h74-a" y1="128.49" y2="107.25"/><linearGradient gradientTransform="translate(340.88 286.88) rotate(180)" id="h74-p" x1="230.88" x2="230.88" xlink:href="#h74-a" y1="196.68" y2="186.37"/><linearGradient id="h74-q" x1="110.95" x2="109.79" xlink:href="#h74-a" y1="179.82" y2="161.55"/><linearGradient gradientTransform="matrix(1, 0, 0, -1, -120.88, 286.88)" id="h74-r" x1="230.88" x2="230.88" xlink:href="#h74-a" y1="196.68" y2="186.37"/><symbol id="h74-s" viewBox="0 0 29.13 89.43"><polygon fill="url(#h74-a)" points="16.04 51.84 8.3 64.62 19.1 80.84 29.13 68.19 16.04 51.84"/><polygon fill="url(#h74-b)" points="2.75 16.09 0 31.8 10.81 31.74 15.12 16.32 2.75 16.09"/><path d="M8,8.59l-5.26,7.5,4.88,3.44,7.49-3.21,14-6L19.25,6.89Z" fill="url(#h74-c)"/><polygon fill="url(#h74-d)" points="10.81 31.74 0 31.8 1.91 45.8 16.04 51.84 10.81 31.74"/><polygon fill="url(#h74-e)" points="8.01 41.8 10.81 31.74 7.63 19.53 0 31.8 8.01 41.8 8.01 41.8"/><polygon fill="url(#h74-f)" points="16.04 51.84 8.01 41.8 7.05 51.84 8.3 64.62 21.97 74.61 16.04 51.84"/><polygon fill="url(#h74-g)" points="19.1 80.84 29.13 89.43 21.97 74.61 19.1 80.84"/><polygon fill="url(#h74-h)" points="8.01 41.8 1.91 45.8 8.3 64.62 8.01 41.8 8.01 41.8"/><path d="M8,41.8Z" fill="url(#h74-i)"/><polygon fill="url(#h74-j)" points="16.98 2.54 8.01 8.59 19.25 6.89 16.98 2.54"/><polygon fill="url(#h74-k)" points="29.13 0 16.98 2.54 19.25 6.89 29.13 0"/><polygon fill="url(#h74-l)" points="15.12 16.32 15.12 16.32 19.25 6.89 8.01 8.59 7.63 19.53 15.12 16.32"/></symbol></defs><g filter="url(#h74-m)"><polygon fill="url(#h74-n)" points="110 179.63 80.87 121.94 110 90.2 139.13 121.94 110 179.63"/><polygon fill="url(#h74-o)" points="110 158.39 102.84 164.81 110 179.63 117.16 164.81 110 158.39"/><polygon fill="url(#h74-p)" points="110 100.5 119.89 97.09 110 90.2 100.11 97.09 110 100.5"/><use height="89.43" transform="translate(80.87 90.2)" width="29.13" xlink:href="#h74-s"/><use height="89.43" transform="matrix(-1, 0, 0, 1, 139.13, 90.2)" width="29.13" xlink:href="#h74-s"/><polygon fill="url(#h74-q)" points="110 158.39 117.16 164.81 110 179.63 102.84 164.81 110 158.39"/><polygon fill="url(#h74-r)" points="110 100.5 100.11 97.09 110 90.2 119.89 97.09 110 100.5"/></g>' ) ) ); } function hardware_75() public pure returns (HardwareData memory) { return HardwareData( 'Maple Leaf', HardwareCategories.STANDARD, string( abi.encodePacked( '<defs><linearGradient gradientUnits="userSpaceOnUse" id="h75-a" x1="26.36" x2="30.62" y1="44.28" y2="70.19"><stop offset="0" stop-color="#4b4b4b"/><stop offset="1" stop-color="#fff"/></linearGradient><linearGradient id="h75-b" x1="17" x2="18.27" xlink:href="#h75-a" y1="21.01" y2="57.05"/><linearGradient id="h75-c" x1="18.87" x2="21.63" xlink:href="#h75-a" y1="40.7" y2="65.11"/><linearGradient gradientUnits="userSpaceOnUse" id="h75-d" x1="48.21" x2="14.41" y1="12.9" y2="35.84"><stop offset="0" stop-color="gray"/><stop offset="1" stop-color="#fff"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="h75-e" x1="15.53" x2="15.53" y1="12.36" y2="47.7"><stop offset="0" stop-color="gray"/><stop offset="0.5" stop-color="#fff"/><stop offset="1" stop-color="gray"/></linearGradient><radialGradient cx="38.69" cy="5.78" gradientUnits="userSpaceOnUse" id="h75-f" r="58.63"><stop offset="0" stop-color="#fff"/><stop offset="0.32" stop-color="gray"/><stop offset="1" stop-color="#fff"/></radialGradient><linearGradient gradientUnits="userSpaceOnUse" id="h75-g" x1="29.66" x2="29.66" y1="5.52" y2="68.83"><stop offset="0" stop-color="#fff"/><stop offset="1" stop-color="#4b4b4b"/></linearGradient><radialGradient cx="17.86" cy="22.14" gradientUnits="userSpaceOnUse" id="h75-h" r="15.95"><stop offset="0" stop-color="gray"/><stop offset="0.5" stop-color="#fff"/><stop offset="0.6" stop-color="#4b4b4b"/><stop offset="1" stop-color="#fff"/></radialGradient><filter id="h75-i" name="shadow"><feDropShadow dx="0" dy="2" stdDeviation="0"/></filter><clipPath id="h75-j"><path d="M122,127.87s20-4.27,21.92-3.85c0,0-8.92-3.25-9.28-5.37s6.72-8.14,8.69-9.23c0,0-13,1.94-13.62,1s.78-7.76.94-8c0,0-17,20.15-15.25,14.94l11-27.84s-5.61,4.95-7.94,4S110,80.25,110,80.24s-6.15,12.36-8.47,13.29-7.94-4-7.94-4l11,27.84c1.73,5.21-15.25-14.94-15.25-14.94.16.29,1.54,7.16.94,8s-13.62-1-13.62-1c2,1.09,9,7.11,8.69,9.23S76.08,124,76.08,124C78,123.6,98,127.87,98,127.87c5,2.23-17.06,4.13-17.06,4.13,2.69.68,5.32.77,5.87,2s-7.27,8.15-7.27,8.15c6.15-2.12,7.76-2.16,8.83-1.28s-2.26,6.23-2.26,6.23c6-7.4,9.11-7.88,10.63-6.67,2.12,1.7-.95,8.62-.95,8.62h0c7.22-8.67,11.29-9.28,12.57-7.65s-1.31,16.2-1.31,16.2L110,171l3-13.29s-2.64-14.67-1.36-16.29,5.35-1,12.57,7.65h0s-3.07-6.92-.95-8.62c1.52-1.21,4.59-.73,10.63,6.67,0,0-3.32-5.36-2.26-6.23s2.68-.84,8.83,1.28c0,0-7.82-6.91-7.27-8.15s3.18-1.32,5.87-2C139.06,132,117,130.1,122,127.87Z" fill="none"/></clipPath><radialGradient cx="110" cy="114.81" id="h75-k" r="34.06" xlink:href="#h75-e"/><symbol id="h75-l" viewBox="0 0 35.92 82.61"><path d="M21.71,68.81s.52,13.8,14.21,13.8V49.26Z" fill="url(#h75-a)"/><path d="M2.59,29.18S-4.84,48.85,5.46,61.9c12.35,2.25,30.46-10.14,30.46-10.14C32.19,32.33,2.59,29.18,2.59,29.18Z" fill="url(#h75-b)"/><path d="M5.46,61.9S19,53,35.92,51.76L21.71,68.81h0C6.86,71.43,5.46,61.9,5.46,61.9Z" fill="url(#h75-c)"/><path d="M35.92,0V51.76C26.28,40.18,2.59,29.18,2.59,29.18-1.67.77,35.92,0,35.92,0Z" fill="url(#h75-d)"/></symbol><symbol id="h75-n" viewBox="0 0 40.51 56.26"><path d="M27.85,39.74c3.28,4.25,4.22,9.18-.8,6.87-2.22-1-4.86-2.87-6.6-8.3A17.77,17.77,0,0,0,11,27.6c-7.3-3.28-8.41-3.85-9.52-6.28C0,18.09.34,12.86,1.83,12.86" fill="none" stroke="url(#h75-e)" stroke-miterlimit="10"/><path d="M39.51,34.88V56.26l-4.66-4.77A23.93,23.93,0,0,0,37,41.65c-.5-10.73-2.21-15-6.86-16.88-5.43-2.25-10.57,1.71-6.55,5C26.27,32.45,25,35,28.4,39.39s3.82,9.15-1.19,6.84c-2.22-1-4.38-2.22-6.13-7.65a19.39,19.39,0,0,0-9.83-11.29C4,24,2.9,23.59,1.79,21.16c-1.47-3.23-1.49-8.82,0-8.82.65,0,3,2.11,4.13,3.17a51.46,51.46,0,0,0,8,5.67c5.14,2.89,6.3,3.68,7.93,2.91,4.39-2.08,6.57-2.34,10.79-.47C38.82,26.74,39.51,34.88,39.51,34.88Z" fill="url(#h75-f)"/><path d="M40.51,32.55c0-16.32-1-32.55-1-32.55L39,.62s-.06,8.1-.06,11.72-.79,15.3-.79,15.3-3.66-5.28-10.27-5.28c-3.55,0-6.25,2.51-9.07,2.3,0,1.44.86,2.19,2.33,2.5-.93-2.25,5.68-5.13,9.61-3.5,4.65,1.88,7.56,5.26,7.22,17.92,0,2.79-.59,6.36-.21,9.33a16.31,16.31,0,0,0,1.75,5.35S40.51,48.87,40.51,32.55Z" fill="url(#h75-g)"/><path d="M23.54,31.93c0,2.28-3.51,4.06-4.46,2.53-1.58-2.56-5.1-5.43-7-6.75s.4-4.9,2.33-4.9C19.59,22.81,23.54,30.59,23.54,31.93Z" fill="url(#h75-h)"/></symbol></defs><g filter="url(#h75-i)"><g clip-path="url(#h75-j)"><use height="82.61" transform="translate(74.08 80.24)" width="35.92" xlink:href="#h75-l"/><use height="82.61" transform="matrix(-1, 0, 0, 1, 145.92, 80.24)" width="35.92" xlink:href="#h75-l"/><path d="M110,132,95.79,149.05M110,132c-17,1.23-30.46,10.15-30.46,10.15m-2.87-32.73s23.68,11,33.33,22.58V80.24m14.21,68.81L110,132m30.46,10.15S127,133.23,110,132m0-51.76V132c9.65-11.58,33.33-22.58,33.33-22.58" fill="none" stroke="url(#h75-k)" stroke-miterlimit="10"/></g><use height="56.26" transform="translate(70.49 132.67)" width="40.51" xlink:href="#h75-n"/><use height="56.26" transform="matrix(-1, 0, 0, 1, 149.51, 132.67)" width="40.51" xlink:href="#h75-n"/></g>' ) ) ); } } // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.9; import './ICategories.sol'; interface IHardwareSVGs { struct HardwareData { string title; ICategories.HardwareCategories hardwareType; string svgString; } } // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.9; interface ICategories { enum FieldCategories { MYTHIC, HERALDIC } enum HardwareCategories { STANDARD, SPECIAL } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80635da06e4c14610046578063907769d914610064578063f0e551bc14610082575b600080fd5b61004e6100a0565b60405161005b91906103e1565b60405180910390f35b61006c61012d565b60405161007991906103e1565b60405180910390f35b61008a6101ba565b60405161009791906103e1565b60405180910390f35b6100a8610247565b60405180606001604052806040518060400160405280600c81526020017f50656172204469616d6f6e64000000000000000000000000000000000000000081525081526020016000600181111561010257610101610313565b5b815260200160405160200161011690611823565b604051602081830303815290604052815250905090565b610135610247565b60405180606001604052806040518060400160405280600b81526020017f466f757220576865656c7300000000000000000000000000000000000000000081525081526020016000600181111561018f5761018e610313565b5b81526020016040516020016101a390612c4d565b604051602081830303815290604052815250905090565b6101c2610247565b60405180606001604052806040518060400160405280600a81526020017f4d61706c65204c6561660000000000000000000000000000000000000000000081525081526020016000600181111561021c5761021b610313565b5b8152602001604051602001610230906143d1565b604051602081830303815290604052815250905090565b6040518060600160405280606081526020016000600181111561026d5761026c610313565b5b8152602001606081525090565b600081519050919050565b600082825260208201905092915050565b60005b838110156102b4578082015181840152602081019050610299565b838111156102c3576000848401525b50505050565b6000601f19601f8301169050919050565b60006102e58261027a565b6102ef8185610285565b93506102ff818560208601610296565b610308816102c9565b840191505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6002811061035357610352610313565b5b50565b600081905061036482610342565b919050565b600061037482610356565b9050919050565b61038481610369565b82525050565b600060608301600083015184820360008601526103a782826102da565b91505060208301516103bc602086018261037b565b50604083015184820360408601526103d482826102da565b9150508091505092915050565b600060208201905081810360008301526103fb818461038a565b905092915050565b600081905092915050565b7f3c646566733e3c6c696e6561724772616469656e74206772616469656e74556e60008201527f6974733d227573657253706163654f6e557365222069643d226837342d61222060208201527f78313d2231332e3033222078323d2232362e3033222079313d2235372e38332260408201527f2079323d2237372e3434223e3c73746f70206f66667365743d2230222073746f60608201527f702d636f6c6f723d2223346234623462222f3e3c73746f70206f66667365743d60808201527f22302e3835222073746f702d636f6c6f723d2223666666222f3e3c2f6c696e6560a08201527f61724772616469656e743e3c6c696e6561724772616469656e742069643d226860c08201527f37342d62222078313d22372e3536222078323d22372e35362220786c696e6b3a60e08201527f687265663d22236837342d61222079313d2231362e3039222079323d2233312e6101008201527f38222f3e3c6c696e6561724772616469656e742069643d226837342d632220786101208201527f313d2231352e3934222078323d2231352e39342220786c696e6b3a687265663d6101408201527f22236837342d61222079313d22362e3839222079323d2231392e3533222f3e3c6101608201527f6c696e6561724772616469656e742069643d226837342d64222078313d22382e6101808201527f3032222078323d22382e30322220786c696e6b3a687265663d22236837342d616101a08201527f222079313d2233312e3734222079323d2235312e3834222f3e3c6c696e6561726101c08201527f4772616469656e74206772616469656e745472616e73666f726d3d227472616e6101e08201527f736c6174652831363533342e30312031363439362e33312920726f74617465286102008201527f31383029222069643d226837342d65222078313d2231363532382e36222078326102208201527f3d2231363532382e362220786c696e6b3a687265663d22236837342d612220796102408201527f313d2231363437362e3738222079323d2231363435342e3531222f3e3c6c696e6102608201527f6561724772616469656e74206772616469656e745472616e73666f726d3d22746102808201527f72616e736c6174652831363533342e30312031363439362e33312920726f74616102a08201527f74652831383029222069643d226837342d66222078313d2231363531392e35226102c08201527f2078323d2231363531392e352220786c696e6b3a687265663d22236837342d616102e08201527f222079313d2231363435342e3531222079323d2231363432312e37222f3e3c6c6103008201527f696e6561724772616469656e742069643d226837342d67222078313d2231382e6103208201527f3733222078323d2232362e30322220786c696e6b3a687265663d22236837342d6103408201527f61222079313d2237342e3036222079323d2238382e3836222f3e3c6c696e65616103608201527f724772616469656e74206772616469656e745472616e73666f726d3d227472616103808201527f6e736c6174652831363533342e30312031363439362e33312920726f746174656103a08201527f2831383029222069643d226837342d68222078313d2231363532382e393122206103c08201527f78323d2231363532382e39312220786c696e6b3a687265663d22236837342d616103e08201527f222079313d2231363435342e3531222079323d2231363433312e3638222f3e3c6104008201527f6c696e6561724772616469656e74206772616469656e745472616e73666f726d6104208201527f3d227472616e736c6174652831363533342e30312031363439362e33312920726104408201527f6f746174652831383029222069643d226837342d69222078313d2231363532366104608201527f222078323d2231363532362220786c696e6b3a687265663d22236837342d61226104808201527f2079313d2231363435342e3531222079323d2231363435342e3531222f3e3c6c6104a08201527f696e6561724772616469656e74206772616469656e745472616e73666f726d3d6104c08201527f227472616e736c6174652831363533342e30312031363439362e33312920726f6104e08201527f746174652831383029222069643d226837342d6a222078313d2231363532302e6105008201527f3338222078323d2231363532302e33382220786c696e6b3a687265663d2223686105208201527f37342d61222079313d2231363439332e3736222079323d2231363438372e37326105408201527f222f3e3c6c696e6561724772616469656e74206772616469656e745472616e736105608201527f666f726d3d227472616e736c6174652831363533342e30312031363439362e336105808201527f312920726f746174652831383029222069643d226837342d6b222078313d22316105a08201527f363531302e3935222078323d2231363531302e39352220786c696e6b3a6872656105c08201527f663d22236837342d61222079313d2231363439362e3331222079323d223136346105e08201527f38392e3432222f3e3c6c696e6561724772616469656e742069643d226837342d6106008201527f6c222078313d22362e3731222078323d2231392e35312220786c696e6b3a68726106208201527f65663d22236837342d61222079313d22362e3136222079323d2231392e3537226106408201527f2f3e3c66696c7465722069643d226837342d6d22206e616d653d22736861646f6106608201527f77223e3c666544726f70536861646f772064783d2230222064793d22322220736106808201527f7464446576696174696f6e3d2230222f3e3c2f66696c7465723e3c6c696e65616106a08201527f724772616469656e742069643d226837342d6e222078313d22313130222078326106c08201527f3d223131302220786c696e6b3a687265663d22236837342d61222079313d22396106e08201527f342e3331222079323d223134382e38222f3e3c6c696e6561724772616469656e6107008201527f74206772616469656e745472616e73666f726d3d227472616e736c61746528336107208201527f34302e3838203238362e38382920726f746174652831383029222069643d22686107408201527f37342d6f222078313d223233302e3838222078323d223233302e38382220786c6107608201527f696e6b3a687265663d22236837342d61222079313d223132382e3439222079326107808201527f3d223130372e3235222f3e3c6c696e6561724772616469656e742067726164696107a08201527f656e745472616e73666f726d3d227472616e736c617465283334302e383820326107c08201527f38362e38382920726f746174652831383029222069643d226837342d702220786107e08201527f313d223233302e3838222078323d223233302e38382220786c696e6b3a6872656108008201527f663d22236837342d61222079313d223139362e3638222079323d223138362e336108208201527f37222f3e3c6c696e6561724772616469656e742069643d226837342d712220786108408201527f313d223131302e3935222078323d223130392e37392220786c696e6b3a6872656108608201527f663d22236837342d61222079313d223137392e3832222079323d223136312e356108808201527f35222f3e3c6c696e6561724772616469656e74206772616469656e745472616e6108a08201527f73666f726d3d226d617472697828312c20302c20302c202d312c202d3132302e6108c08201527f38382c203238362e383829222069643d226837342d72222078313d223233302e6108e08201527f3838222078323d223233302e38382220786c696e6b3a687265663d22236837346109008201527f2d61222079313d223139362e3638222079323d223138362e3337222f3e3c73796109208201527f6d626f6c2069643d226837342d73222076696577426f783d223020302032392e6109408201527f31332038392e3433223e3c706f6c79676f6e2066696c6c3d2275726c282368376109608201527f342d61292220706f696e74733d2231362e30342035312e383420382e332036346109808201527f2e36322031392e312038302e38342032392e31332036382e31392031362e30346109a08201527f2035312e3834222f3e3c706f6c79676f6e2066696c6c3d2275726c28236837346109c08201527f2d62292220706f696e74733d22322e37352031362e303920302033312e3820316109e08201527f302e38312033312e37342031352e31322031362e333220322e37352031362e30610a008201527f39222f3e3c7061746820643d224d382c382e35396c2d352e32362c372e352c34610a208201527f2e38382c332e34342c372e34392d332e32312c31342d364c31392e32352c362e610a408201527f38395a222066696c6c3d2275726c28236837342d6329222f3e3c706f6c79676f610a608201527f6e2066696c6c3d2275726c28236837342d64292220706f696e74733d2231302e610a808201527f38312033312e373420302033312e3820312e39312034352e382031362e303420610aa08201527f35312e38342031302e38312033312e3734222f3e3c706f6c79676f6e2066696c610ac08201527f6c3d2275726c28236837342d65292220706f696e74733d22382e30312034312e610ae08201527f382031302e38312033312e373420372e36332031392e353320302033312e3820610b008201527f382e30312034312e3820382e30312034312e38222f3e3c706f6c79676f6e2066610b208201527f696c6c3d2275726c28236837342d66292220706f696e74733d2231362e303420610b408201527f35312e383420382e30312034312e3820372e30352035312e383420382e332036610b608201527f342e36322032312e39372037342e36312031362e30342035312e3834222f3e3c610b808201527f706f6c79676f6e2066696c6c3d2275726c28236837342d67292220706f696e74610ba08201527f733d2231392e312038302e38342032392e31332038392e34332032312e393720610bc08201527f37342e36312031392e312038302e3834222f3e3c706f6c79676f6e2066696c6c610be08201527f3d2275726c28236837342d68292220706f696e74733d22382e30312034312e38610c008201527f20312e39312034352e3820382e332036342e363220382e30312034312e382038610c208201527f2e30312034312e38222f3e3c7061746820643d224d382c34312e385a22206669610c408201527f6c6c3d2275726c28236837342d6929222f3e3c706f6c79676f6e2066696c6c3d610c608201527f2275726c28236837342d6a292220706f696e74733d2231362e393820322e3534610c808201527f20382e303120382e35392031392e323520362e38392031362e393820322e3534610ca08201527f222f3e3c706f6c79676f6e2066696c6c3d2275726c28236837342d6b29222070610cc08201527f6f696e74733d2232392e313320302031362e393820322e35342031392e323520610ce08201527f362e38392032392e31332030222f3e3c706f6c79676f6e2066696c6c3d227572610d008201527f6c28236837342d6c292220706f696e74733d2231352e31322031362e33322031610d208201527f352e31322031362e33322031392e323520362e383920382e303120382e353920610d408201527f372e36332031392e35332031352e31322031362e3332222f3e3c2f73796d626f610d608201527f6c3e3c2f646566733e3c672066696c7465723d2275726c28236837342d6d2922610d808201527f3e3c706f6c79676f6e2066696c6c3d2275726c28236837342d6e292220706f69610da08201527f6e74733d22313130203137392e36332038302e3837203132312e393420313130610dc08201527f2039302e32203133392e3133203132312e393420313130203137392e3633222f610de08201527f3e3c706f6c79676f6e2066696c6c3d2275726c28236837342d6f292220706f69610e008201527f6e74733d22313130203135382e3339203130322e3834203136342e3831203131610e208201527f30203137392e3633203131372e3136203136342e383120313130203135382e33610e408201527f39222f3e3c706f6c79676f6e2066696c6c3d2275726c28236837342d70292220610e608201527f706f696e74733d22313130203130302e35203131392e38392039372e30392031610e808201527f31302039302e32203130302e31312039372e303920313130203130302e35222f610ea08201527f3e3c757365206865696768743d2238392e343322207472616e73666f726d3d22610ec08201527f7472616e736c6174652838302e38372039302e3229222077696474683d223239610ee08201527f2e31332220786c696e6b3a687265663d22236837342d73222f3e3c7573652068610f008201527f65696768743d2238392e343322207472616e73666f726d3d226d617472697828610f208201527f2d312c20302c20302c20312c203133392e31332c2039302e3229222077696474610f408201527f683d2232392e31332220786c696e6b3a687265663d22236837342d73222f3e3c610f608201527f706f6c79676f6e2066696c6c3d2275726c28236837342d71292220706f696e74610f808201527f733d22313130203135382e3339203131372e3136203136342e38312031313020610fa08201527f3137392e3633203130322e3834203136342e383120313130203135382e333922610fc08201527f2f3e3c706f6c79676f6e2066696c6c3d2275726c28236837342d72292220706f610fe08201527f696e74733d22313130203130302e35203130302e31312039372e3039203131306110008201527f2039302e32203131392e38392039372e303920313130203130302e35222f3e3c6110208201527f2f673e000000000000000000000000000000000000000000000000000000000061104082015250565b600061180c61104383610403565b91506118178261040e565b61104382019050919050565b600061182e826117fe565b9150819050919050565b7f3c646566733e3c6c696e6561724772616469656e74206772616469656e74547260008201527f616e73666f726d3d227472616e736c6174652831382e3633202d31382e36332960208201527f22206772616469656e74556e6974733d227573657253706163654f6e5573652260408201527f2069643d226837332d61222078313d222d322e3632222078323d22332e33332260608201527f2079313d2234302e36222079323d2233342e3635223e3c73746f70206f66667360808201527f65743d2230222073746f702d636f6c6f723d2267726179222f3e3c73746f702060a08201527f6f66667365743d2231222073746f702d636f6c6f723d2223666666222f3e3c2f60c08201527f6c696e6561724772616469656e743e3c6c696e6561724772616469656e74206960e08201527f643d226837332d62222078313d222d31322e39222078323d2231332e363622206101008201527f786c696e6b3a687265663d22236837332d61222079313d2235302e38382220796101208201527f323d2232342e3332222f3e3c6c696e6561724772616469656e742067726164696101408201527f656e745472616e73666f726d3d227472616e736c6174652831382e3633202d316101608201527f382e36332922206772616469656e74556e6974733d227573657253706163654f6101808201527f6e557365222069643d226837332d63222078313d22302e3336222078323d22306101a08201527f2e3336222079313d2233332e3337222079323d2234312e3837223e3c73746f706101c08201527f206f66667365743d2230222073746f702d636f6c6f723d2223666666222f3e3c6101e08201527f73746f70206f66667365743d2231222073746f702d636f6c6f723d22677261796102008201527f222f3e3c2f6c696e6561724772616469656e743e3c6c696e65617247726164696102208201527f656e742069643d226837332d64222078313d22302e3336222078323d22302e336102408201527f362220786c696e6b3a687265663d22236837332d63222079313d2231382e36336102608201527f222079323d2235362e3631222f3e3c6c696e6561724772616469656e742069646102808201527f3d226837332d65222078313d22302e3336222078323d22302e33362220786c696102a08201527f6e6b3a687265663d22236837332d61222079313d2233352e3132222079323d226102c08201527f34302e3133222f3e3c6c696e6561724772616469656e742069643d226837332d6102e08201527f66222078313d22302e3336222078323d22302e33362220786c696e6b3a6872656103008201527f663d22236837332d61222079313d2233352e3133222079323d2234302e3132226103208201527f2f3e3c6c696e6561724772616469656e742069643d226837332d67222078313d6103408201527f22302e3336222078323d22302e33362220786c696e6b3a687265663d222368376103608201527f332d61222079313d2232312e3932222079323d2235332e3332222f3e3c6c696e6103808201527f6561724772616469656e74206772616469656e74556e6974733d2275736572536103a08201527f706163654f6e557365222069643d226837332d68222078313d222d302e3136226103c08201527f2078323d22342e3239222079313d22362e3035222079323d22362e3035223e3c6103e08201527f73746f70206f66667365743d2230222073746f702d636f6c6f723d22677261796104008201527f222f3e3c73746f70206f66667365743d22302e3234222073746f702d636f6c6f6104208201527f723d2223346234623462222f3e3c73746f70206f66667365743d22302e3638226104408201527f2073746f702d636f6c6f723d2223666666222f3e3c73746f70206f66667365746104608201527f3d2231222073746f702d636f6c6f723d2267726179222f3e3c2f6c696e6561726104808201527f4772616469656e743e3c6c696e6561724772616469656e74206772616469656e6104a08201527f74556e6974733d227573657253706163654f6e557365222069643d226837332d6104c08201527f69222078323d22342e3335222079313d2231302e39222079323d2231302e39226104e08201527f3e3c73746f70206f66667365743d2230222073746f702d636f6c6f723d2267726105008201527f6179222f3e3c73746f70206f66667365743d22302e35222073746f702d636f6c6105208201527f6f723d2223666666222f3e3c73746f70206f66667365743d2231222073746f706105408201527f2d636f6c6f723d2267726179222f3e3c2f6c696e6561724772616469656e743e6105608201527f3c66696c7465722069643d226837332d6a22206e616d653d22736861646f77226105808201527f3e3c666544726f70536861646f772064783d2230222064793d223222207374646105a08201527f446576696174696f6e3d2230222f3e3c2f66696c7465723e3c73796d626f6c206105c08201527f69643d226837332d6d222076696577426f783d2230203020342e33352031322e6105e08201527f31223e3c7061746820643d224d342e3334382c31322e314830762d2e386c322e6106008201527f312d2e3233352c322e3234342e3233355a4d342e3030392c302c332e342c31306106208201527f2e373037482e3935314c2e3333372c305a222066696c6c3d2275726c282368376106408201527f332d6829222f3e3c7061746820643d224d342e3334382c31312e332c332e342c6106608201527f31302e35482e3935314c302c31312e3376305a222066696c6c3d2275726c28236106808201527f6837332d6929222f3e3c2f73796d626f6c3e3c73796d626f6c2069643d2268376106a08201527f332d6c222076696577426f783d2230203020342e33352032382e3933223e3c756106c08201527f7365206865696768743d2231322e3122207472616e73666f726d3d227472616e6106e08201527f736c61746528302031362e383329222077696474683d22342e33352220786c696107008201527f6e6b3a687265663d22236837332d6d222f3e3c757365206865696768743d22316107208201527f322e3122207472616e73666f726d3d226d617472697828312c20302c20302c206107408201527f2d312c20302c2031322e3129222077696474683d22342e33352220786c696e6b6107608201527f3a687265663d22236837332d6d222f3e3c2f73796d626f6c3e3c73796d626f6c6107808201527f2069643d226837332d6b222076696577426f783d223020302033372e393820336107a08201527f372e3938223e3c757365206865696768743d2232382e393322207472616e73666107c08201527f6f726d3d227472616e736c6174652831362e373720332e353429207363616c656107e08201527f28312e303220312e303729222077696474683d22342e33352220786c696e6b3a6108008201527f687265663d22236837332d6c222f3e3c757365206865696768743d2232382e396108208201527f3322207472616e73666f726d3d227472616e736c61746528362e3520392e36336108408201527f2920726f74617465282d343529207363616c6528312e303220312e30372922206108608201527f77696474683d22342e33352220786c696e6b3a687265663d22236837332d6c226108808201527f2f3e3c757365206865696768743d2232382e393322207472616e73666f726d3d6108a08201527f226d617472697828302c202d312e30322c20312e30372c20302c20332e35342c6108c08201527f2032312e3229222077696474683d22342e33352220786c696e6b3a687265663d6108e08201527f22236837332d6c222f3e3c757365206865696768743d2232382e3933222074726109008201527f616e73666f726d3d226d6174726978282d302e37322c202d302e37322c20302e6109208201527f37362c202d302e37362c20392e36332c2033312e343829222077696474683d226109408201527f342e33352220786c696e6b3a687265663d22236837332d6c222f3e3c706174686109608201527f20643d224d31392c32322e3241332e32312c332e32312c302c312c312c32322e6109808201527f322c31392c332e32312c332e32312c302c302c312c31392c32322e325a2220666109a08201527f696c6c3d226e6f6e6522207374726f6b653d2275726c28236837332d612922206109c08201527f7374726f6b652d77696474683d2232222f3e3c7061746820643d224d31392c336109e08201527f364131372c31372c302c312c312c33362c31392c31372c31372c302c302c312c610a008201527f31392c33365a222066696c6c3d226e6f6e6522207374726f6b653d2275726c28610a208201527f236837332d622922207374726f6b652d77696474683d22332e3537222f3e3c70610a408201527f61746820643d224d31392c323361342c342c302c312c312c342d3441342c342c610a608201527f302c302c312c31392c32335a222066696c6c3d226e6f6e6522207374726f6b65610a808201527f3d2275726c28236837332d632922207374726f6b652d77696474683d22302e35610aa08201527f222f3e3c7061746820643d224d31392c33372e37324131382e37342c31382e37610ac08201527f342c302c312c312c33372e37322c31392c31382e37362c31382e37362c302c30610ae08201527f2c312c31392c33372e37325a222066696c6c3d226e6f6e6522207374726f6b65610b008201527f3d2275726c28236837332d642922207374726f6b652d77696474683d22302e35610b208201527f222f3e3c636972636c652063783d2231382e3939222063793d2231382e393922610b408201527f2066696c6c3d226e6f6e652220723d22322e323522207374726f6b653d227572610b608201527f6c28236837332d652922207374726f6b652d77696474683d22302e35222f3e3c610b808201527f636972636c652063783d2231382e3939222063793d2231382e3939222066696c610ba08201527f6c3d226e6f6e652220723d22322e323522207374726f6b653d2275726c282368610bc08201527f37332d662922207374726f6b652d77696474683d22302e35222f3e3c63697263610be08201527f6c652063783d2231382e3939222063793d2231382e3939222066696c6c3d226e610c008201527f6f6e652220723d2231352e343522207374726f6b653d2275726c28236837332d610c208201527f672922207374726f6b652d77696474683d22302e35222f3e3c7061746820643d610c408201527f224d31382e31392c32612e37332e37332c302c312c312c2e37332e3733412e37610c608201527f332e37332c302c302c312c31382e31392c325a6d2e38372c33342e38612e3732610c808201527f2e37322c302c302c302c2e37322d2e37322e37332e37332c302c302c302d2e37610ca08201527f322d2e37332e37332e37332c302c302c302d2e37332e3733412e37332e37332c610cc08201527f302c302c302c31392e30362c33362e37355a4d362e38392c372e3732612e3733610ce08201527f2e37332c302c312c302c302d312e34362e37332e37332c302c302c302c302c31610d008201527f2e34365a4d322c31392e3738612e37332e37332c302c302c302c2e37332d2e37610d208201527f322e37332e37332c302c302c302d312e34362c30412e37332e37332c302c302c610d408201527f302c322c31392e37385a6d352c3132612e37332e37332c302c302c302c2e3733610d608201527f2d2e37322e37332e37332c302c312c302d312e34362c30412e37332e37332c30610d808201527f2c302c302c372c33312e38315a4d33312e38312c37612e37332e37332c302c30610da08201527f2c302d2e37322d2e37332e37332e37332c302c302c302c302c312e3436412e37610dc08201527f332e37332c302c302c302c33312e38312c375a6d342e39342c31322e3037612e610de08201527f37332e37332c302c302c302d2e37322d2e37332e37332e37332c302c302c302d610e008201527f2e37332e37332e37332e37332c302c302c302c2e37332e3732412e37322e3732610e208201527f2c302c302c302c33362e37352c31392e30365a6d2d352c3132612e37332e3733610e408201527f2c302c302c302d2e37322d2e37332e37332e37332c302c302c302d2e37332e37610e608201527f332e37332e37332c302c302c302c2e37332e3732412e37322e37322c302c302c610e808201527f302c33312e37312c33312e30395a222f3e3c2f73796d626f6c3e3c2f64656673610ea08201527f3e3c672066696c7465723d2275726c28236837332d6a29223e3c757365206865610ec08201527f696768743d2233372e393822207472616e73666f726d3d227472616e736c6174610ee08201527f652839312e30312038332e303129222077696474683d2233372e39382220786c610f008201527f696e6b3a687265663d22236837332d6b222f3e3c757365206865696768743d22610f208201527f33372e393822207472616e73666f726d3d227472616e736c6174652839312e30610f408201527f31203134332e303129222077696474683d2233372e39382220786c696e6b3a68610f608201527f7265663d22236837332d6b222f3e3c757365206865696768743d2233372e3938610f808201527f22207472616e73666f726d3d227472616e736c617465283131362e3031203131610fa08201527f332e303129222077696474683d2233372e39382220786c696e6b3a687265663d610fc08201527f22236837332d6b222f3e3c757365206865696768743d2233372e393822207472610fe08201527f616e73666f726d3d227472616e736c6174652836362e3031203131332e3031296110008201527f222077696474683d2233372e39382220786c696e6b3a687265663d22236837336110208201527f2d6b222f3e3c2f673e000000000000000000000000000000000000000000000061104082015250565b6000612c3661104983610403565b9150612c4182611838565b61104982019050919050565b6000612c5882612c28565b9150819050919050565b7f3c646566733e3c6c696e6561724772616469656e74206772616469656e74556e60008201527f6974733d227573657253706163654f6e557365222069643d226837352d61222060208201527f78313d2232362e3336222078323d2233302e3632222079313d2234342e32382260408201527f2079323d2237302e3139223e3c73746f70206f66667365743d2230222073746f60608201527f702d636f6c6f723d2223346234623462222f3e3c73746f70206f66667365743d60808201527f2231222073746f702d636f6c6f723d2223666666222f3e3c2f6c696e6561724760a08201527f72616469656e743e3c6c696e6561724772616469656e742069643d226837352d60c08201527f62222078313d223137222078323d2231382e32372220786c696e6b3a6872656660e08201527f3d22236837352d61222079313d2232312e3031222079323d2235372e3035222f6101008201527f3e3c6c696e6561724772616469656e742069643d226837352d63222078313d226101208201527f31382e3837222078323d2232312e36332220786c696e6b3a687265663d2223686101408201527f37352d61222079313d2234302e37222079323d2236352e3131222f3e3c6c696e6101608201527f6561724772616469656e74206772616469656e74556e6974733d2275736572536101808201527f706163654f6e557365222069643d226837352d64222078313d2234382e3231226101a08201527f2078323d2231342e3431222079313d2231322e39222079323d2233352e3834226101c08201527f3e3c73746f70206f66667365743d2230222073746f702d636f6c6f723d2267726101e08201527f6179222f3e3c73746f70206f66667365743d2231222073746f702d636f6c6f726102008201527f3d2223666666222f3e3c2f6c696e6561724772616469656e743e3c6c696e65616102208201527f724772616469656e74206772616469656e74556e6974733d22757365725370616102408201527f63654f6e557365222069643d226837352d65222078313d2231352e35332220786102608201527f323d2231352e3533222079313d2231322e3336222079323d2234372e37223e3c6102808201527f73746f70206f66667365743d2230222073746f702d636f6c6f723d22677261796102a08201527f222f3e3c73746f70206f66667365743d22302e35222073746f702d636f6c6f726102c08201527f3d2223666666222f3e3c73746f70206f66667365743d2231222073746f702d636102e08201527f6f6c6f723d2267726179222f3e3c2f6c696e6561724772616469656e743e3c726103008201527f616469616c4772616469656e742063783d2233382e3639222063793d22352e376103208201527f3822206772616469656e74556e6974733d227573657253706163654f6e5573656103408201527f222069643d226837352d662220723d2235382e3633223e3c73746f70206f66666103608201527f7365743d2230222073746f702d636f6c6f723d2223666666222f3e3c73746f706103808201527f206f66667365743d22302e3332222073746f702d636f6c6f723d2267726179226103a08201527f2f3e3c73746f70206f66667365743d2231222073746f702d636f6c6f723d22236103c08201527f666666222f3e3c2f72616469616c4772616469656e743e3c6c696e65617247726103e08201527f616469656e74206772616469656e74556e6974733d227573657253706163654f6104008201527f6e557365222069643d226837352d67222078313d2232392e3636222078323d226104208201527f32392e3636222079313d22352e3532222079323d2236382e3833223e3c73746f6104408201527f70206f66667365743d2230222073746f702d636f6c6f723d2223666666222f3e6104608201527f3c73746f70206f66667365743d2231222073746f702d636f6c6f723d222334626104808201527f34623462222f3e3c2f6c696e6561724772616469656e743e3c72616469616c476104a08201527f72616469656e742063783d2231372e3836222063793d2232322e3134222067726104c08201527f616469656e74556e6974733d227573657253706163654f6e557365222069643d6104e08201527f226837352d682220723d2231352e3935223e3c73746f70206f66667365743d226105008201527f30222073746f702d636f6c6f723d2267726179222f3e3c73746f70206f6666736105208201527f65743d22302e35222073746f702d636f6c6f723d2223666666222f3e3c73746f6105408201527f70206f66667365743d22302e36222073746f702d636f6c6f723d2223346234626105608201527f3462222f3e3c73746f70206f66667365743d2231222073746f702d636f6c6f726105808201527f3d2223666666222f3e3c2f72616469616c4772616469656e743e3c66696c74656105a08201527f722069643d226837352d6922206e616d653d22736861646f77223e3c666544726105c08201527f6f70536861646f772064783d2230222064793d223222207374644465766961746105e08201527f696f6e3d2230222f3e3c2f66696c7465723e3c636c6970506174682069643d226106008201527f6837352d6a223e3c7061746820643d224d3132322c3132372e38377332302d346106208201527f2e32372c32312e39322d332e383563302c302d382e39322d332e32352d392e326106408201527f382d352e333773362e37322d382e31342c382e36392d392e323363302c302d316106608201527f332c312e39342d31332e36322c31732e37382d372e37362e39342d3863302c306106808201527f2d31372c32302e31352d31352e32352c31342e39346c31312d32372e3834732d6106a08201527f352e36312c342e39352d372e39342c34533131302c38302e32352c3131302c386106c08201527f302e3234732d362e31352c31322e33362d382e34372c31332e32392d372e39346106e08201527f2d342d372e39342d346c31312c32372e383463312e37332c352e32312d31352e6107008201527f32352d31342e39342d31352e32352d31342e39342e31362e32392c312e35342c6107208201527f372e31362e39342c38732d31332e36322d312d31332e36322d3163322c312e306107408201527f392c392c372e31312c382e36392c392e32335337362e30382c3132342c37362e6107608201527f30382c3132344337382c3132332e362c39382c3132372e38372c39382c3132376107808201527f2e383763352c322e32332d31372e30362c342e31332d31372e30362c342e31336107a08201527f2c322e36392e36382c352e33322e37372c352e38372c32732d372e32372c382e6107c08201527f31352d372e32372c382e313563362e31352d322e31322c372e37362d322e31366107e08201527f2c382e38332d312e3238732d322e32362c362e32332d322e32362c362e3233636108008201527f362d372e342c392e31312d372e38382c31302e36332d362e36372c322e31322c6108208201527f312e372d2e39352c382e36322d2e39352c382e3632683063372e32322d382e366108408201527f372c31312e32392d392e32382c31322e35372d372e3635732d312e33312c31366108608201527f2e322d312e33312c31362e324c3131302c3137316c332d31332e3239732d322e6108808201527f36342d31342e36372d312e33362d31362e32392c352e33352d312c31322e35376108a08201527f2c372e36356830732d332e30372d362e39322d2e39352d382e363263312e35326108c08201527f2d312e32312c342e35392d2e37332c31302e36332c362e36372c302c302d332e6108e08201527f33322d352e33362d322e32362d362e323373322e36382d2e38342c382e38332c6109008201527f312e323863302c302d372e38322d362e39312d372e32372d382e313573332e316109208201527f382d312e33322c352e38372d32433133392e30362c3133322c3131372c3133306109408201527f2e312c3132322c3132372e38375a222066696c6c3d226e6f6e65222f3e3c2f636109608201527f6c6970506174683e3c72616469616c4772616469656e742063783d22313130226109808201527f2063793d223131342e3831222069643d226837352d6b2220723d2233342e30366109a08201527f2220786c696e6b3a687265663d22236837352d65222f3e3c73796d626f6c20696109c08201527f643d226837352d6c222076696577426f783d223020302033352e39322038322e6109e08201527f3631223e3c7061746820643d224d32312e37312c36382e3831732e35322c3133610a008201527f2e382c31342e32312c31332e385634392e32365a222066696c6c3d2275726c28610a208201527f236837352d6129222f3e3c7061746820643d224d322e35392c32392e3138532d610a408201527f342e38342c34382e38352c352e34362c36312e396331322e33352c322e32352c610a608201527f33302e34362d31302e31342c33302e34362d31302e31344333322e31392c3332610a808201527f2e33332c322e35392c32392e31382c322e35392c32392e31385a222066696c6c610aa08201527f3d2275726c28236837352d6229222f3e3c7061746820643d224d352e34362c36610ac08201527f312e395331392c35332c33352e39322c35312e37364c32312e37312c36382e38610ae08201527f31683043362e38362c37312e34332c352e34362c36312e392c352e34362c3631610b008201527f2e395a222066696c6c3d2275726c28236837352d6329222f3e3c706174682064610b208201527f3d224d33352e39322c305635312e37364332362e32382c34302e31382c322e35610b408201527f392c32392e31382c322e35392c32392e31382d312e36372e37372c33352e3932610b608201527f2c302c33352e39322c305a222066696c6c3d2275726c28236837352d6429222f610b808201527f3e3c2f73796d626f6c3e3c73796d626f6c2069643d226837352d6e2220766965610ba08201527f77426f783d223020302034302e35312035362e3236223e3c7061746820643d22610bc08201527f4d32372e38352c33392e373463332e32382c342e32352c342e32322c392e3138610be08201527f2d2e382c362e38372d322e32322d312d342e38362d322e38372d362e362d382e610c008201527f334131372e37372c31372e37372c302c302c302c31312c32372e36632d372e33610c208201527f2d332e32382d382e34312d332e38352d392e35322d362e323843302c31382e30610c408201527f392e33342c31322e38362c312e38332c31322e3836222066696c6c3d226e6f6e610c608201527f6522207374726f6b653d2275726c28236837352d652922207374726f6b652d6d610c808201527f697465726c696d69743d223130222f3e3c7061746820643d224d33392e35312c610ca08201527f33342e38385635362e32366c2d342e36362d342e37374132332e39332c32332e610cc08201527f39332c302c302c302c33372c34312e3635632d2e352d31302e37332d322e3231610ce08201527f2d31352d362e38362d31362e38382d352e34332d322e32352d31302e35372c31610d008201527f2e37312d362e35352c354332362e32372c33322e34352c32352c33352c32382e610d208201527f342c33392e333973332e38322c392e31352d312e31392c362e3834632d322e32610d408201527f322d312d342e33382d322e32322d362e31332d372e36356131392e33392c3139610d608201527f2e33392c302c302c302d392e38332d31312e323943342c32342c322e392c3233610d808201527f2e35392c312e37392c32312e3136632d312e34372d332e32332d312e34392d38610da08201527f2e38322c302d382e38322e36352c302c332c322e31312c342e31332c332e3137610dc08201527f6135312e34362c35312e34362c302c302c302c382c352e363763352e31342c32610de08201527f2e38392c362e332c332e36382c372e39332c322e39312c342e33392d322e3038610e008201527f2c362e35372d322e33342c31302e37392d2e34374333382e38322c32362e3734610e208201527f2c33392e35312c33342e38382c33392e35312c33342e38385a222066696c6c3d610e408201527f2275726c28236837352d6629222f3e3c7061746820643d224d34302e35312c33610e608201527f322e353563302d31362e33322d312d33322e35352d312d33322e35354c33392c610e808201527f2e3632732d2e30362c382e312d2e30362c31312e37322d2e37392c31352e332d610ea08201527f2e37392c31352e332d332e36362d352e32382d31302e32372d352e3238632d33610ec08201527f2e35352c302d362e32352c322e35312d392e30372c322e332c302c312e34342e610ee08201527f38362c322e31392c322e33332c322e352d2e39332d322e32352c352e36382d35610f008201527f2e31332c392e36312d332e352c342e36352c312e38382c372e35362c352e3236610f208201527f2c372e32322c31372e39322c302c322e37392d2e35392c362e33362d2e32312c610f408201527f392e33336131362e33312c31362e33312c302c302c302c312e37352c352e3335610f608201527f5334302e35312c34382e38372c34302e35312c33322e35355a222066696c6c3d610f808201527f2275726c28236837352d6729222f3e3c7061746820643d224d32332e35342c33610fa08201527f312e393363302c322e32382d332e35312c342e30362d342e34362c322e35332d610fc08201527f312e35382d322e35362d352e312d352e34332d372d362e3735732e342d342e39610fe08201527f2c322e33332d342e394331392e35392c32322e38312c32332e35342c33302e356110008201527f392c32332e35342c33312e39335a222066696c6c3d2275726c28236837352d686110208201527f29222f3e3c2f73796d626f6c3e3c2f646566733e3c672066696c7465723d22756110408201527f726c28236837352d6929223e3c6720636c69702d706174683d2275726c2823686110608201527f37352d6a29223e3c757365206865696768743d2238322e363122207472616e736110808201527f666f726d3d227472616e736c6174652837342e30382038302e323429222077696110a08201527f6474683d2233352e39322220786c696e6b3a687265663d22236837352d6c222f6110c08201527f3e3c757365206865696768743d2238322e363122207472616e73666f726d3d226110e08201527f6d6174726978282d312c20302c20302c20312c203134352e39322c2038302e326111008201527f3429222077696474683d2233352e39322220786c696e6b3a687265663d2223686111208201527f37352d6c222f3e3c7061746820643d224d3131302c3133322c39352e37392c316111408201527f34392e30354d3131302c313332632d31372c312e32332d33302e34362c31302e6111608201527f31352d33302e34362c31302e31356d2d322e38372d33322e37337332332e36386111808201527f2c31312c33332e33332c32322e35385638302e32346d31342e32312c36382e386111a08201527f314c3131302c3133326d33302e34362c31302e3135533132372c3133332e32336111c08201527f2c3131302c3133326d302d35312e37365631333263392e36352d31312e35382c6111e08201527f33332e33332d32322e35382c33332e33332d32322e3538222066696c6c3d226e6112008201527f6f6e6522207374726f6b653d2275726c28236837352d6b2922207374726f6b656112208201527f2d6d697465726c696d69743d223130222f3e3c2f673e3c7573652068656967686112408201527f743d2235362e323622207472616e73666f726d3d227472616e736c61746528376112608201527f302e3439203133322e363729222077696474683d2234302e35312220786c696e6112808201527f6b3a687265663d22236837352d6e222f3e3c757365206865696768743d2235366112a08201527f2e323622207472616e73666f726d3d226d6174726978282d312c20302c20302c6112c08201527f20312c203134392e35312c203133322e363729222077696474683d2234302e356112e08201527f312220786c696e6b3a687265663d22236837352d6e222f3e3c2f673e0000000061130082015250565b60006143ba61131c83610403565b91506143c582612c62565b61131c82019050919050565b60006143dc826143ac565b915081905091905056fea164736f6c6343000809000a
[ 38 ]
0xf1df21D46921Ca23906c2689b9DA25e63e686934
// SPDX-License-Identifier: MIT pragma solidity ^0.8.3; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./interfaces/IUbiquityAlgorithmicDollar.sol"; import "./interfaces/ICurveFactory.sol"; import "./interfaces/IMetaPool.sol"; import "./TWAPOracle.sol"; import "hardhat/console.sol"; /// @title A central config for the uAD system. Also acts as a central /// access control manager. /// @notice For storing constants. For storing variables and allowing them to /// be changed by the admin (governance) /// @dev This should be used as a central access control manager which other /// contracts use to check permissions contract UbiquityAlgorithmicDollarManager is AccessControl { using SafeERC20 for IERC20; bytes32 public constant UBQ_MINTER_ROLE = keccak256("UBQ_MINTER_ROLE"); bytes32 public constant UBQ_BURNER_ROLE = keccak256("UBQ_BURNER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant COUPON_MANAGER_ROLE = keccak256("COUPON_MANAGER"); bytes32 public constant BONDING_MANAGER_ROLE = keccak256("BONDING_MANAGER"); bytes32 public constant INCENTIVE_MANAGER_ROLE = keccak256("INCENTIVE_MANAGER"); bytes32 public constant UBQ_TOKEN_MANAGER_ROLE = keccak256("UBQ_TOKEN_MANAGER_ROLE"); address public twapOracleAddress; address public debtCouponAddress; address public uADTokenAddress; address public couponCalculatorAddress; address public dollarMintingCalculatorAddress; address public bondingShareAddress; address public bondingContractAddress; address public stableSwapMetaPoolAddress; address public curve3PoolTokenAddress; // 3CRV address public treasuryAddress; address public uGOVTokenAddress; address public sushiSwapPoolAddress; // sushi pool uAD-uGOV address public masterChefAddress; address public formulasAddress; address public autoRedeemTokenAddress; // uAR address public uarCalculatorAddress; // uAR calculator //key = address of couponmanager, value = excessdollardistributor mapping(address => address) private _excessDollarDistributors; modifier onlyAdmin() { require( hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "uADMGR: Caller is not admin" ); _; } constructor(address _admin) { _setupRole(DEFAULT_ADMIN_ROLE, _admin); _setupRole(UBQ_MINTER_ROLE, _admin); _setupRole(PAUSER_ROLE, _admin); _setupRole(COUPON_MANAGER_ROLE, _admin); _setupRole(BONDING_MANAGER_ROLE, _admin); _setupRole(INCENTIVE_MANAGER_ROLE, _admin); _setupRole(UBQ_TOKEN_MANAGER_ROLE, address(this)); } // TODO Add a generic setter for extra addresses that needs to be linked function setTwapOracleAddress(address _twapOracleAddress) external onlyAdmin { twapOracleAddress = _twapOracleAddress; // to be removed TWAPOracle oracle = TWAPOracle(twapOracleAddress); oracle.update(); } function setuARTokenAddress(address _uarTokenAddress) external onlyAdmin { autoRedeemTokenAddress = _uarTokenAddress; } function setDebtCouponAddress(address _debtCouponAddress) external onlyAdmin { debtCouponAddress = _debtCouponAddress; } function setIncentiveToUAD(address _account, address _incentiveAddress) external onlyAdmin { IUbiquityAlgorithmicDollar(uADTokenAddress).setIncentiveContract( _account, _incentiveAddress ); } function setuADTokenAddress(address _uADTokenAddress) external onlyAdmin { uADTokenAddress = _uADTokenAddress; } function setuGOVTokenAddress(address _uGOVTokenAddress) external onlyAdmin { uGOVTokenAddress = _uGOVTokenAddress; } function setSushiSwapPoolAddress(address _sushiSwapPoolAddress) external onlyAdmin { sushiSwapPoolAddress = _sushiSwapPoolAddress; } function setUARCalculatorAddress(address _uarCalculatorAddress) external onlyAdmin { uarCalculatorAddress = _uarCalculatorAddress; } function setCouponCalculatorAddress(address _couponCalculatorAddress) external onlyAdmin { couponCalculatorAddress = _couponCalculatorAddress; } function setDollarMintingCalculatorAddress( address _dollarMintingCalculatorAddress ) external onlyAdmin { dollarMintingCalculatorAddress = _dollarMintingCalculatorAddress; } function setExcessDollarsDistributor( address debtCouponManagerAddress, address excessCouponDistributor ) external onlyAdmin { _excessDollarDistributors[ debtCouponManagerAddress ] = excessCouponDistributor; } function setMasterChefAddress(address _masterChefAddress) external onlyAdmin { masterChefAddress = _masterChefAddress; } function setFormulasAddress(address _formulasAddress) external onlyAdmin { formulasAddress = _formulasAddress; } function setBondingShareAddress(address _bondingShareAddress) external onlyAdmin { bondingShareAddress = _bondingShareAddress; } function setStableSwapMetaPoolAddress(address _stableSwapMetaPoolAddress) external onlyAdmin { stableSwapMetaPoolAddress = _stableSwapMetaPoolAddress; } /** @notice set the bonding bontract smart contract address @dev bonding contract participants deposit curve LP token for a certain duration to earn uGOV and more curve LP token @param _bondingContractAddress bonding contract address */ function setBondingContractAddress(address _bondingContractAddress) external onlyAdmin { bondingContractAddress = _bondingContractAddress; } /** @notice set the treasury address @dev the treasury fund is used to maintain the protocol @param _treasuryAddress treasury fund address */ function setTreasuryAddress(address _treasuryAddress) external onlyAdmin { treasuryAddress = _treasuryAddress; } /** @notice deploy a new Curve metapools for uAD Token uAD/3Pool @dev From the curve documentation for uncollateralized algorithmic stablecoins amplification should be 5-10 @param _curveFactory MetaPool factory address @param _crvBasePool Address of the base pool to use within the new metapool. @param _crv3PoolTokenAddress curve 3Pool token Address @param _amplificationCoefficient amplification coefficient. The smaller it is the closer to a constant product we are. @param _fee Trade fee, given as an integer with 1e10 precision. */ function deployStableSwapPool( address _curveFactory, address _crvBasePool, address _crv3PoolTokenAddress, uint256 _amplificationCoefficient, uint256 _fee ) external onlyAdmin { // Create new StableSwap meta pool (uAD <-> 3Crv) address metaPool = ICurveFactory(_curveFactory).deploy_metapool( _crvBasePool, ERC20(uADTokenAddress).name(), ERC20(uADTokenAddress).symbol(), uADTokenAddress, _amplificationCoefficient, _fee ); stableSwapMetaPoolAddress = metaPool; // Approve the newly-deployed meta pool to transfer this contract's funds uint256 crv3PoolTokenAmount = IERC20(_crv3PoolTokenAddress).balanceOf(address(this)); uint256 uADTokenAmount = IERC20(uADTokenAddress).balanceOf(address(this)); // safe approve revert if approve from non-zero to non-zero allowance IERC20(_crv3PoolTokenAddress).safeApprove(metaPool, 0); IERC20(_crv3PoolTokenAddress).safeApprove( metaPool, crv3PoolTokenAmount ); IERC20(uADTokenAddress).safeApprove(metaPool, 0); IERC20(uADTokenAddress).safeApprove(metaPool, uADTokenAmount); // coin at index 0 is uAD and index 1 is 3CRV require( IMetaPool(metaPool).coins(0) == uADTokenAddress && IMetaPool(metaPool).coins(1) == _crv3PoolTokenAddress, "uADMGR: COIN_ORDER_MISMATCH" ); // Add the initial liquidity to the StableSwap meta pool uint256[2] memory amounts = [ IERC20(uADTokenAddress).balanceOf(address(this)), IERC20(_crv3PoolTokenAddress).balanceOf(address(this)) ]; // set curve 3Pool address curve3PoolTokenAddress = _crv3PoolTokenAddress; IMetaPool(metaPool).add_liquidity(amounts, 0, msg.sender); } function getExcessDollarsDistributor(address _debtCouponManagerAddress) external view returns (address) { return _excessDollarDistributors[_debtCouponManagerAddress]; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; import "../utils/Strings.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 Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @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 Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if(!hasRole(role, account)) { revert(string(abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ))); } } /** * @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 onlyRole(getRoleAdmin(role)) { _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 onlyRole(getRoleAdmin(role)) { _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()); } } } // SPDX-License-Identifier: MIT 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 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 { } } // 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: Apache-2.0 pragma solidity ^0.8.3; import "./IERC20Ubiquity.sol"; /// @title UAD stablecoin interface /// @author Ubiquity Algorithmic Dollar interface IUbiquityAlgorithmicDollar is IERC20Ubiquity { event IncentiveContractUpdate( address indexed _incentivized, address indexed _incentiveContract ); function setIncentiveContract(address account, address incentive) external; function incentiveContract(address account) external view returns (address); } // SPDX-License-Identifier: MIT // !! THIS FILE WAS AUTOGENERATED BY abi-to-sol. SEE BELOW FOR SOURCE. !! pragma solidity ^0.8.3; interface ICurveFactory { event BasePoolAdded(address base_pool, address implementat); event MetaPoolDeployed( address coin, address base_pool, uint256 A, uint256 fee, address deployer ); function find_pool_for_coins(address _from, address _to) external view returns (address); function find_pool_for_coins( address _from, address _to, uint256 i ) external view returns (address); function get_n_coins(address _pool) external view returns (uint256, uint256); function get_coins(address _pool) external view returns (address[2] memory); function get_underlying_coins(address _pool) external view returns (address[8] memory); function get_decimals(address _pool) external view returns (uint256[2] memory); function get_underlying_decimals(address _pool) external view returns (uint256[8] memory); function get_rates(address _pool) external view returns (uint256[2] memory); function get_balances(address _pool) external view returns (uint256[2] memory); function get_underlying_balances(address _pool) external view returns (uint256[8] memory); function get_A(address _pool) external view returns (uint256); function get_fees(address _pool) external view returns (uint256, uint256); function get_admin_balances(address _pool) external view returns (uint256[2] memory); function get_coin_indices( address _pool, address _from, address _to ) external view returns ( int128, int128, bool ); function add_base_pool( address _base_pool, address _metapool_implementation, address _fee_receiver ) external; function deploy_metapool( address _base_pool, string memory _name, string memory _symbol, address _coin, uint256 _A, uint256 _fee ) external returns (address); function commit_transfer_ownership(address addr) external; function accept_transfer_ownership() external; function set_fee_receiver(address _base_pool, address _fee_receiver) external; function convert_fees() external returns (bool); function admin() external view returns (address); function future_admin() external view returns (address); function pool_list(uint256 arg0) external view returns (address); function pool_count() external view returns (uint256); function base_pool_list(uint256 arg0) external view returns (address); function base_pool_count() external view returns (uint256); function fee_receiver(address arg0) external view returns (address); } // SPDX-License-Identifier: UNLICENSED // !! THIS FILE WAS AUTOGENERATED BY abi-to-sol. SEE BELOW FOR SOURCE. !! pragma solidity ^0.8.3; interface IMetaPool { event Transfer( address indexed sender, address indexed receiver, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value ); event TokenExchange( address indexed buyer, int128 sold_id, uint256 tokens_sold, int128 bought_id, uint256 tokens_bought ); event TokenExchangeUnderlying( address indexed buyer, int128 sold_id, uint256 tokens_sold, int128 bought_id, uint256 tokens_bought ); event AddLiquidity( address indexed provider, uint256[2] token_amounts, uint256[2] fees, uint256 invariant, uint256 token_supply ); event RemoveLiquidity( address indexed provider, uint256[2] token_amounts, uint256[2] fees, uint256 token_supply ); event RemoveLiquidityOne( address indexed provider, uint256 token_amount, uint256 coin_amount, uint256 token_supply ); event RemoveLiquidityImbalance( address indexed provider, uint256[2] token_amounts, uint256[2] fees, uint256 invariant, uint256 token_supply ); event CommitNewAdmin(uint256 indexed deadline, address indexed admin); event NewAdmin(address indexed admin); event CommitNewFee( uint256 indexed deadline, uint256 fee, uint256 admin_fee ); event NewFee(uint256 fee, uint256 admin_fee); event RampA( uint256 old_A, uint256 new_A, uint256 initial_time, uint256 future_time ); event StopRampA(uint256 A, uint256 t); function initialize( string memory _name, string memory _symbol, address _coin, uint256 _decimals, uint256 _A, uint256 _fee, address _admin ) external; function decimals() 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); function get_previous_balances() external view returns (uint256[2] memory); function get_balances() external view returns (uint256[2] memory); function get_twap_balances( uint256[2] memory _first_balances, uint256[2] memory _last_balances, uint256 _time_elapsed ) external view returns (uint256[2] memory); function get_price_cumulative_last() external view returns (uint256[2] memory); function admin_fee() external view returns (uint256); function A() external view returns (uint256); function A_precise() external view returns (uint256); function get_virtual_price() external view returns (uint256); function calc_token_amount(uint256[2] memory _amounts, bool _is_deposit) external view returns (uint256); function calc_token_amount( uint256[2] memory _amounts, bool _is_deposit, bool _previous ) external view returns (uint256); function add_liquidity(uint256[2] memory _amounts, uint256 _min_mint_amount) external returns (uint256); function add_liquidity( uint256[2] memory _amounts, uint256 _min_mint_amount, address _receiver ) external returns (uint256); function get_dy( int128 i, int128 j, uint256 dx ) external view returns (uint256); function get_dy( int128 i, int128 j, uint256 dx, uint256[2] memory _balances ) external view returns (uint256); function get_dy_underlying( int128 i, int128 j, uint256 dx ) external view returns (uint256); function get_dy_underlying( int128 i, int128 j, uint256 dx, uint256[2] memory _balances ) external view returns (uint256); function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy ) external returns (uint256); function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy, address _receiver ) external returns (uint256); function exchange_underlying( int128 i, int128 j, uint256 dx, uint256 min_dy ) external returns (uint256); function exchange_underlying( int128 i, int128 j, uint256 dx, uint256 min_dy, address _receiver ) external returns (uint256); function remove_liquidity( uint256 _burn_amount, uint256[2] memory _min_amounts ) external returns (uint256[2] memory); function remove_liquidity( uint256 _burn_amount, uint256[2] memory _min_amounts, address _receiver ) external returns (uint256[2] memory); function remove_liquidity_imbalance( uint256[2] memory _amounts, uint256 _max_burn_amount ) external returns (uint256); function remove_liquidity_imbalance( uint256[2] memory _amounts, uint256 _max_burn_amount, address _receiver ) external returns (uint256); function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256); function calc_withdraw_one_coin( uint256 _burn_amount, int128 i, bool _previous ) external view returns (uint256); function remove_liquidity_one_coin( uint256 _burn_amount, int128 i, uint256 _min_received ) external returns (uint256); function remove_liquidity_one_coin( uint256 _burn_amount, int128 i, uint256 _min_received, address _receiver ) external returns (uint256); function ramp_A(uint256 _future_A, uint256 _future_time) external; function stop_ramp_A() external; function admin_balances(uint256 i) external view returns (uint256); function withdraw_admin_fees() external; function admin() external view returns (address); function coins(uint256 arg0) external view returns (address); function balances(uint256 arg0) external view returns (uint256); function fee() external view returns (uint256); function block_timestamp_last() external view returns (uint256); function initial_A() external view returns (uint256); function future_A() external view returns (uint256); function initial_A_time() external view returns (uint256); function future_A_time() external view returns (uint256); function name() external view returns (string memory); function symbol() external view returns (string memory); function balanceOf(address arg0) external view returns (uint256); function allowance(address arg0, address arg1) external view returns (uint256); function totalSupply() external view returns (uint256); } // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.3; import "./interfaces/IMetaPool.sol"; import "hardhat/console.sol"; contract TWAPOracle { address public immutable pool; address public immutable token0; address public immutable token1; uint256 public price0Average; uint256 public price1Average; uint256 public pricesBlockTimestampLast; uint256[2] public priceCumulativeLast; constructor( address _pool, address _uADtoken0, address _curve3CRVtoken1 ) { pool = _pool; // coin at index 0 is uAD and index 1 is 3CRV require( IMetaPool(_pool).coins(0) == _uADtoken0 && IMetaPool(_pool).coins(1) == _curve3CRVtoken1, "TWAPOracle: COIN_ORDER_MISMATCH" ); token0 = _uADtoken0; token1 = _curve3CRVtoken1; uint256 _reserve0 = uint112(IMetaPool(_pool).balances(0)); uint256 _reserve1 = uint112(IMetaPool(_pool).balances(1)); // ensure that there's liquidity in the pair require(_reserve0 != 0 && _reserve1 != 0, "TWAPOracle: NO_RESERVES"); // ensure that pair balance is perfect require(_reserve0 == _reserve1, "TWAPOracle: PAIR_UNBALANCED"); priceCumulativeLast = IMetaPool(_pool).get_price_cumulative_last(); pricesBlockTimestampLast = IMetaPool(_pool).block_timestamp_last(); price0Average = 1 ether; price1Average = 1 ether; } // calculate average price function update() external { (uint256[2] memory priceCumulative, uint256 blockTimestamp) = _currentCumulativePrices(); if (blockTimestamp - pricesBlockTimestampLast > 0) { // get the balances between now and the last price cumulative snapshot uint256[2] memory twapBalances = IMetaPool(pool).get_twap_balances( priceCumulativeLast, priceCumulative, blockTimestamp - pricesBlockTimestampLast ); // price to exchange amounIn uAD to 3CRV based on TWAP price0Average = IMetaPool(pool).get_dy(0, 1, 1 ether, twapBalances); // price to exchange amounIn 3CRV to uAD based on TWAP price1Average = IMetaPool(pool).get_dy(1, 0, 1 ether, twapBalances); // we update the priceCumulative priceCumulativeLast = priceCumulative; pricesBlockTimestampLast = blockTimestamp; } } // note this will always return 0 before update has been called successfully // for the first time. function consult(address token) external view returns (uint256 amountOut) { if (token == token0) { // price to exchange 1 uAD to 3CRV based on TWAP amountOut = price0Average; } else { require(token == token1, "TWAPOracle: INVALID_TOKEN"); // price to exchange 1 3CRV to uAD based on TWAP amountOut = price1Average; } } function _currentCumulativePrices() internal view returns (uint256[2] memory priceCumulative, uint256 blockTimestamp) { priceCumulative = IMetaPool(pool).get_price_cumulative_last(); blockTimestamp = IMetaPool(pool).block_timestamp_last(); } } // SPDX-License-Identifier: MIT pragma solidity >= 0.4.22 <0.9.0; library console { address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); function _sendLogPayload(bytes memory payload) private view { uint256 payloadLength = payload.length; address consoleAddress = CONSOLE_ADDRESS; assembly { let payloadStart := add(payload, 32) let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0) } } function log() internal view { _sendLogPayload(abi.encodeWithSignature("log()")); } function logInt(int p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(int)", p0)); } function logUint(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function logString(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function logBool(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function logAddress(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function logBytes(bytes memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes)", p0)); } function logBytes1(bytes1 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0)); } function logBytes2(bytes2 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0)); } function logBytes3(bytes3 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0)); } function logBytes4(bytes4 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0)); } function logBytes5(bytes5 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0)); } function logBytes6(bytes6 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0)); } function logBytes7(bytes7 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0)); } function logBytes8(bytes8 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0)); } function logBytes9(bytes9 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0)); } function logBytes10(bytes10 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0)); } function logBytes11(bytes11 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0)); } function logBytes12(bytes12 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0)); } function logBytes13(bytes13 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0)); } function logBytes14(bytes14 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0)); } function logBytes15(bytes15 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0)); } function logBytes16(bytes16 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0)); } function logBytes17(bytes17 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0)); } function logBytes18(bytes18 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0)); } function logBytes19(bytes19 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0)); } function logBytes20(bytes20 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0)); } function logBytes21(bytes21 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0)); } function logBytes22(bytes22 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0)); } function logBytes23(bytes23 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0)); } function logBytes24(bytes24 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0)); } function logBytes25(bytes25 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0)); } function logBytes26(bytes26 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0)); } function logBytes27(bytes27 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0)); } function logBytes28(bytes28 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0)); } function logBytes29(bytes29 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0)); } function logBytes30(bytes30 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0)); } function logBytes31(bytes31 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0)); } function logBytes32(bytes32 p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0)); } function log(uint p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint)", p0)); } function log(string memory p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(string)", p0)); } function log(bool p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool)", p0)); } function log(address p0) internal view { _sendLogPayload(abi.encodeWithSignature("log(address)", p0)); } function log(uint p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1)); } function log(uint p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1)); } function log(uint p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1)); } function log(uint p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1)); } function log(string memory p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1)); } function log(string memory p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1)); } function log(string memory p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); } function log(string memory p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); } function log(bool p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1)); } function log(bool p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1)); } function log(bool p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1)); } function log(bool p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1)); } function log(address p0, uint p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1)); } function log(address p0, string memory p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1)); } function log(address p0, bool p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1)); } function log(address p0, address p1) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1)); } function log(uint p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2)); } function log(uint p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2)); } function log(uint p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2)); } function log(uint p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2)); } function log(uint p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2)); } function log(uint p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2)); } function log(uint p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2)); } function log(uint p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2)); } function log(uint p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2)); } function log(uint p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2)); } function log(uint p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2)); } function log(uint p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2)); } function log(uint p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2)); } function log(uint p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2)); } function log(uint p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2)); } function log(uint p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2)); } function log(string memory p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2)); } function log(string memory p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2)); } function log(string memory p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2)); } function log(string memory p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2)); } function log(string memory p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2)); } function log(string memory p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); } function log(string memory p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2)); } function log(string memory p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2)); } function log(string memory p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2)); } function log(string memory p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2)); } function log(string memory p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2)); } function log(string memory p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2)); } function log(string memory p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2)); } function log(string memory p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2)); } function log(string memory p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2)); } function log(string memory p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2)); } function log(bool p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2)); } function log(bool p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2)); } function log(bool p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2)); } function log(bool p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2)); } function log(bool p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2)); } function log(bool p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2)); } function log(bool p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2)); } function log(bool p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2)); } function log(bool p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2)); } function log(bool p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2)); } function log(bool p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2)); } function log(bool p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2)); } function log(bool p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2)); } function log(bool p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2)); } function log(bool p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2)); } function log(bool p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2)); } function log(address p0, uint p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2)); } function log(address p0, uint p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2)); } function log(address p0, uint p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2)); } function log(address p0, uint p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2)); } function log(address p0, string memory p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2)); } function log(address p0, string memory p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2)); } function log(address p0, string memory p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2)); } function log(address p0, string memory p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2)); } function log(address p0, bool p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2)); } function log(address p0, bool p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2)); } function log(address p0, bool p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2)); } function log(address p0, bool p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2)); } function log(address p0, address p1, uint p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2)); } function log(address p0, address p1, string memory p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2)); } function log(address p0, address p1, bool p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2)); } function log(address p0, address p1, address p2) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2)); } function log(uint p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3)); } function log(uint p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3)); } function log(uint p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3)); } function log(uint p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3)); } function log(uint p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3)); } function log(string memory p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3)); } function log(bool p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3)); } function log(bool p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3)); } function log(bool p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3)); } function log(bool p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3)); } function log(address p0, uint p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3)); } function log(address p0, string memory p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3)); } function log(address p0, bool p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, uint p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, string memory p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, bool p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, uint p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, string memory p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, bool p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3)); } function log(address p0, address p1, address p2, address p3) internal view { _sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3)); } } // 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; /** * @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); } } // 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 "../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); } // 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: Apache-2.0 pragma solidity ^0.8.3; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /// @title ERC20 Ubiquiti preset interface /// @author Ubiquity Algorithmic Dollar interface IERC20Ubiquity is IERC20 { // ----------- Events ----------- event Minting( address indexed _to, address indexed _minter, uint256 _amount ); event Burning(address indexed _burned, uint256 _amount); // ----------- State changing api ----------- function burn(uint256 amount) external; function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; // ----------- Burner only state changing api ----------- function burnFrom(address account, uint256 amount) external; // ----------- Minter only state changing api ----------- function mint(address account, uint256 amount) external; }
0x608060405234801561001057600080fd5b506004361061032b5760003560e01c80635b1fd415116101b2578063bc2ec02f116100f9578063d547741f116100a2578063e6c735401161007c578063e6c735401461076a578063f39e5a4714610791578063f6f172cb146107b8578063fbff3a41146107cb5761032b565b8063d547741f1461071d578063de71c1db14610730578063e63ab1e9146107435761032b565b8063c5ba7598116100d3578063c5ba7598146106e4578063c5f956af146106f7578063d3815fb91461070a5761032b565b8063bc2ec02f146106ab578063be1d86e1146106be578063c431e83c146106d15761032b565b8063923246111161015b578063aef6be3c11610135578063aef6be3c14610659578063b3094fd614610685578063b90bbaff146106985761032b565b80639232461114610617578063a217fddf1461062a578063a41dd6e6146106325761032b565b8063749cface1161018c578063749cface146105ba5780638fe63683146105cd57806391d14854146105e05761032b565b80635b1fd415146105815780636605bfda146105945780636c6ae480146105a75761032b565b806338174654116102765780634ac116081161021f57806356593ea3116101f957806356593ea31461053457806357f6a22a1461054757806359f6deac1461056e5761032b565b80634ac11608146104fb5780634c9f5d861461050e57806353b07507146105215761032b565b80633b4d9773116102505780633b4d9773146104ae5780633e916ced146104d557806347091398146104e85761032b565b806338174654146104755780633ae3d9a4146104885780633b194dcc1461049b5761032b565b8063221e2e60116102d85780632f533cb7116102b25780632f533cb71461042857806336568abe1461044f57806336c3df24146104625761032b565b8063221e2e60146103d1578063248a9ca3146103e45780632f2ff15d146104155761032b565b8063147f1b9611610309578063147f1b961461039857806315f97398146103ab578063214f7882146103be5761032b565b8063017df3271461033057806301ffc9a7146103605780630bcf9ca314610383575b600080fd5b600954610343906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b61037361036e3660046120d6565b6107de565b6040519015158152602001610357565b610396610391366004611fb0565b610815565b005b6103966103a6366004611fb0565b610896565b6103966103b9366004611fb0565b610912565b600e54610343906001600160a01b031681565b600d54610343906001600160a01b031681565b6104076103f236600461209a565b60009081526020819052604090206001015490565b604051908152602001610357565b6103966104233660046120b2565b61098e565b6104077f3a2e010201653e4743db35ee85e81b63eb19cf8948f24794ef2b4dba5ecf49c981565b61039661045d3660046120b2565b6109ba565b600c54610343906001600160a01b031681565b610396610483366004611fb0565b610a46565b600f54610343906001600160a01b031681565b6103966104a9366004611fb0565b610ac2565b6104077f9a46abf6358a50f8b5f443e7d26ec0762bffead3f6c78af4ff80f12ba16bb56881565b600454610343906001600160a01b031681565b6103966104f6366004611fb0565b610b8e565b610396610509366004611fb0565b610c0a565b61039661051c366004611fb0565b610c86565b61039661052f366004611fe8565b610d02565b600254610343906001600160a01b031681565b6104077faf1a415cb2281de448f1771a3c8144f554e6e38bb3bc1acc8218c01a5d75721d81565b600554610343906001600160a01b031681565b61039661058f366004611fb0565b610dab565b6103966105a2366004611fb0565b610e27565b600b54610343906001600160a01b031681565b601054610343906001600160a01b031681565b600154610343906001600160a01b031681565b6103736105ee3660046120b2565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610396610625366004611fb0565b610ea3565b610407600081565b6104077feaff283aa1cb5c8448e8e6df1f1d9256a0b9e1d4a11bca9e915ecfb8d881be7e81565b610343610667366004611fb0565b6001600160a01b039081166000908152601160205260409020541690565b610396610693366004611fb0565b610f1f565b6103966106a6366004611fb0565b610f9b565b600354610343906001600160a01b031681565b6103966106cc366004611fb0565b611017565b600654610343906001600160a01b031681565b6103966106f2366004611fb0565b611093565b600a54610343906001600160a01b031681565b600854610343906001600160a01b031681565b61039661072b3660046120b2565b61110f565b600754610343906001600160a01b031681565b6104077f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6104077fb59de930ba65d9ac0d4dbd09127a305101a071683af551ffece1d125909542d881565b6104077fa3405bb4244d0786f3e4178acef3953ebb3f56c1e97e9530871f50739923c1cf81565b6103966107c6366004611fe8565b611135565b6103966107d9366004612020565b6111bd565b60006001600160e01b03198216637965db0b60e01b148061080f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b33600090815260008051602061240e833981519152602052604090205460ff166108745760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee83398151915260448201526064015b60405180910390fd5b600680546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff166108f05760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff1661096c5760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6000828152602081905260409020600101546109ab81335b611849565b6109b583836118c7565b505050565b6001600160a01b0381163314610a385760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c660000000000000000000000000000000000606482015260840161086b565b610a428282611965565b5050565b33600090815260008051602061240e833981519152602052604090205460ff16610aa05760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610b1c5760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600180546001600160a01b0319166001600160a01b0383169081179091556040805163a2e6204560e01b81529051829163a2e6204591600480830192600092919082900301818387803b158015610b7257600080fd5b505af1158015610b86573d6000803e3d6000fd5b505050505050565b33600090815260008051602061240e833981519152602052604090205460ff16610be85760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610c645760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b601080546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610ce05760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610d5c5760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b60035460405163b6232c9960e01b81526001600160a01b03848116600483015283811660248301529091169063b6232c9990604401600060405180830381600087803b158015610b7257600080fd5b33600090815260008051602061240e833981519152602052604090205460ff16610e055760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610e815760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610efd5760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610f795760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff16610ff55760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff166110715760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b33600090815260008051602061240e833981519152602052604090205460ff166110ed5760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60008281526020819052604090206001015461112b81336109a6565b6109b58383611965565b33600090815260008051602061240e833981519152602052604090205460ff1661118f5760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b6001600160a01b03918216600090815260116020526040902080546001600160a01b03191691909216179055565b33600090815260008051602061240e833981519152602052604090205460ff166112175760405162461bcd60e51b815260206004820152601b60248201526000805160206123ee833981519152604482015260640161086b565b6000856001600160a01b031663e339eb4f86600360009054906101000a90046001600160a01b03166001600160a01b03166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b15801561127757600080fd5b505afa15801561128b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112b391908101906120fe565b600360009054906101000a90046001600160a01b03166001600160a01b03166395d89b416040518163ffffffff1660e01b815260040160006040518083038186803b15801561130157600080fd5b505afa158015611315573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261133d91908101906120fe565b6003546040516001600160e01b031960e087901b168152611371949392916001600160a01b0316908a908a9060040161227d565b602060405180830381600087803b15801561138b57600080fd5b505af115801561139f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113c39190611fcc565b600880546001600160a01b0319166001600160a01b03838116919091179091556040516370a0823160e01b8152306004820152919250600091908616906370a082319060240160206040518083038186803b15801561142157600080fd5b505afa158015611435573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611459919061219c565b6003546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b1580156114a257600080fd5b505afa1580156114b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114da919061219c565b90506114f16001600160a01b0387168460006119e4565b6115056001600160a01b03871684846119e4565b60035461151d906001600160a01b03168460006119e4565b600354611534906001600160a01b031684836119e4565b60035460405163c661065760e01b8152600060048201526001600160a01b039182169185169063c66106579060240160206040518083038186803b15801561157b57600080fd5b505afa15801561158f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b39190611fcc565b6001600160a01b031614801561164c575060405163c661065760e01b8152600160048201526001600160a01b03808816919085169063c66106579060240160206040518083038186803b15801561160957600080fd5b505afa15801561161d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116419190611fcc565b6001600160a01b0316145b6116985760405162461bcd60e51b815260206004820152601b60248201527f7541444d47523a20434f494e5f4f524445525f4d49534d415443480000000000604482015260640161086b565b60408051808201918290526003546370a0823160e01b90925230604482015260009181906001600160a01b03166370a082316064830160206040518083038186803b1580156116e657600080fd5b505afa1580156116fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171e919061219c565b81526040516370a0823160e01b81523060048201526020909101906001600160a01b038a16906370a082319060240160206040518083038186803b15801561176557600080fd5b505afa158015611779573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179d919061219c565b9052600980546001600160a01b0319166001600160a01b038a81169190911790915560405163030f92d560e21b8152919250851690630c3e4b54906117eb90849060009033906004016122d0565b602060405180830381600087803b15801561180557600080fd5b505af1158015611819573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183d919061219c565b50505050505050505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610a4257611885816001600160a01b03166014611b46565b611890836020611b46565b6040516020016118a19291906121fc565b60408051601f198184030181529082905262461bcd60e51b825261086b91600401612318565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610a42576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556119213390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610a42576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b801580611a6d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015611a3357600080fd5b505afa158015611a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6b919061219c565b155b611adf5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606482015260840161086b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663095ea7b360e01b1790526109b5908490611d3c565b60606000611b55836002612343565b611b6090600261232b565b67ffffffffffffffff811115611b8657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611bb0576020820181803683370190505b509050600360fc1b81600081518110611bd957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611c1657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000611c3a846002612343565b611c4590600161232b565b90505b6001811115611ce6577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611c9457634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110611cb857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93611cdf81612392565b9050611c48565b508315611d355760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161086b565b9392505050565b6000611d91826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611e219092919063ffffffff16565b8051909150156109b55780806020019051810190611daf919061207a565b6109b55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161086b565b6060611e308484600085611e38565b949350505050565b606082471015611eb05760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161086b565b843b611efe5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161086b565b600080866001600160a01b03168587604051611f1a91906121e0565b60006040518083038185875af1925050503d8060008114611f57576040519150601f19603f3d011682016040523d82523d6000602084013e611f5c565b606091505b5091509150611f6c828286611f77565b979650505050505050565b60608315611f86575081611d35565b825115611f965782518084602001fd5b8160405162461bcd60e51b815260040161086b9190612318565b600060208284031215611fc1578081fd5b8135611d35816123d5565b600060208284031215611fdd578081fd5b8151611d35816123d5565b60008060408385031215611ffa578081fd5b8235612005816123d5565b91506020830135612015816123d5565b809150509250929050565b600080600080600060a08688031215612037578081fd5b8535612042816123d5565b94506020860135612052816123d5565b93506040860135612062816123d5565b94979396509394606081013594506080013592915050565b60006020828403121561208b578081fd5b81518015158114611d35578182fd5b6000602082840312156120ab578081fd5b5035919050565b600080604083850312156120c4578182fd5b823591506020830135612015816123d5565b6000602082840312156120e7578081fd5b81356001600160e01b031981168114611d35578182fd5b60006020828403121561210f578081fd5b815167ffffffffffffffff80821115612126578283fd5b818401915084601f830112612139578283fd5b81518181111561214b5761214b6123bf565b604051601f8201601f19908116603f01168101908382118183101715612173576121736123bf565b8160405282815287602084870101111561218b578586fd5b611f6c836020830160208801612362565b6000602082840312156121ad578081fd5b5051919050565b600081518084526121cc816020860160208601612362565b601f01601f19169290920160200192915050565b600082516121f2818460208701612362565b9190910192915050565b60007f416363657373436f6e74726f6c3a206163636f756e742000000000000000000082528351612234816017850160208801612362565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351612271816028840160208801612362565b01602801949350505050565b60006001600160a01b03808916835260c060208401526122a060c08401896121b4565b83810360408501526122b281896121b4565b91909616606084015260808301949094525060a00152949350505050565b60808101818560005b60028110156122f85781518352602092830192909101906001016122d9565b5050508360408301526001600160a01b0383166060830152949350505050565b600060208252611d3560208301846121b4565b6000821982111561233e5761233e6123a9565b500190565b600081600019048311821515161561235d5761235d6123a9565b500290565b60005b8381101561237d578181015183820152602001612365565b8381111561238c576000848401525b50505050565b6000816123a1576123a16123a9565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146123ea57600080fd5b5056fe7541444d47523a2043616c6c6572206973206e6f742061646d696e0000000000ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5a164736f6c6343000803000a
[ 5 ]
0xf1df5b9797f5b8d367c0f95f2a5f15483ae6719b
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 = 28425600; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x849013e4383e0B358ade2082f6eF93e8f3b8b255; } 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; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a723058203623ec99ca8b4da0f11c6bb4483b147f4b3ca47be0217ffda28de48d8b830e880029
[ 16, 7 ]
0xF1e0304FDc9428d02D404fDC471d8399753108B4
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/utils/Context.sol // 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; } } // File: @openzeppelin/contracts/access/Ownable.sol // OpenZeppelin Contracts v4.4.1 (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() { _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); } } // File: @openzeppelin/contracts/security/Pausable.sol // OpenZeppelin Contracts v4.4.1 (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/token/ERC20/IERC20.sol // OpenZeppelin Contracts (last updated v4.5.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 `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, 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 `from` to `to` 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 from, address to, 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.1 (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/token/ERC20/ERC20.sol // OpenZeppelin Contracts (last updated v4.5.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: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, 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}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, 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}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, 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) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][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) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, 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: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, 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 Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - 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: @openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol) pragma solidity ^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: @openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^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 { /** * @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 { _spendAllowance(account, _msgSender(), amount); _burn(account, amount); } } // File: contracts/GJS.sol pragma solidity ^0.8.0; contract GJS is ERC20, ERC20Burnable, ERC20Pausable, Ownable{ mapping (address => bool) public frozenAccount; event Freeze(address indexed holder); event Unfreeze(address indexed holder); modifier notFrozen(address _holder) { require(!frozenAccount[_holder]); _; } constructor(uint256 initialSupply) ERC20("GJS Protocol", "GJS") { _mint(msg.sender, initialSupply); } function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } function transfer(address to, uint256 value) public notFrozen(msg.sender) override returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public notFrozen(from) override returns (bool) { return super.transferFrom(from, to, value); } function freezeAccount(address holder) public onlyOwner returns (bool) { require(!frozenAccount[holder]); frozenAccount[holder] = true; emit Freeze(holder); return true; } function unfreezeAccount(address holder) public onlyOwner returns (bool) { require(frozenAccount[holder]); frozenAccount[holder] = false; emit Unfreeze(holder); return true; } function puase() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063715018a6116100b8578063a457c2d71161007c578063a457c2d714610341578063a9059cbb14610371578063b414d4b6146103a1578063dd62ed3e146103d1578063f26c159f14610401578063f2fde38b1461043157610142565b8063715018a6146102af578063788649ea146102b957806379cc6790146102e95780638da5cb5b1461030557806395d89b411461032357610142565b8063395093511161010a57806339509351146102015780633f4ba83a1461023157806342966c681461023b5780635c975abb146102575780635d5eaa4f1461027557806370a082311461027f57610142565b806306fdde0314610147578063095ea7b31461016557806318160ddd1461019557806323b872dd146101b3578063313ce567146101e3575b600080fd5b61014f61044d565b60405161015c9190611911565b60405180910390f35b61017f600480360381019061017a91906119cc565b6104df565b60405161018c9190611a27565b60405180910390f35b61019d610502565b6040516101aa9190611a51565b60405180910390f35b6101cd60048036038101906101c89190611a6c565b61050c565b6040516101da9190611a27565b60405180910390f35b6101eb61057b565b6040516101f89190611adb565b60405180910390f35b61021b600480360381019061021691906119cc565b610584565b6040516102289190611a27565b60405180910390f35b61023961062e565b005b61025560048036038101906102509190611af6565b6106b4565b005b61025f6106c8565b60405161026c9190611a27565b60405180910390f35b61027d6106df565b005b61029960048036038101906102949190611b23565b610765565b6040516102a69190611a51565b60405180910390f35b6102b76107ad565b005b6102d360048036038101906102ce9190611b23565b610835565b6040516102e09190611a27565b60405180910390f35b61030360048036038101906102fe91906119cc565b6109ad565b005b61030d6109cd565b60405161031a9190611b5f565b60405180910390f35b61032b6109f7565b6040516103389190611911565b60405180910390f35b61035b600480360381019061035691906119cc565b610a89565b6040516103689190611a27565b60405180910390f35b61038b600480360381019061038691906119cc565b610b73565b6040516103989190611a27565b60405180910390f35b6103bb60048036038101906103b69190611b23565b610be0565b6040516103c89190611a27565b60405180910390f35b6103eb60048036038101906103e69190611b7a565b610c00565b6040516103f89190611a51565b60405180910390f35b61041b60048036038101906104169190611b23565b610c87565b6040516104289190611a27565b60405180910390f35b61044b60048036038101906104469190611b23565b610e00565b005b60606003805461045c90611be9565b80601f016020809104026020016040519081016040528092919081815260200182805461048890611be9565b80156104d55780601f106104aa576101008083540402835291602001916104d5565b820191906000526020600020905b8154815290600101906020018083116104b857829003601f168201915b5050505050905090565b6000806104ea610f54565b90506104f7818585610f5c565b600191505092915050565b6000600254905090565b600083600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561056657600080fd5b610571858585611125565b9150509392505050565b60006012905090565b60008061058f610f54565b9050610623818585600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461061e9190611c49565b610f5c565b600191505092915050565b610636610f54565b73ffffffffffffffffffffffffffffffffffffffff166106546109cd565b73ffffffffffffffffffffffffffffffffffffffff16146106aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a190611ceb565b60405180910390fd5b6106b2611154565b565b6106c56106bf610f54565b826111f6565b50565b6000600560009054906101000a900460ff16905090565b6106e7610f54565b73ffffffffffffffffffffffffffffffffffffffff166107056109cd565b73ffffffffffffffffffffffffffffffffffffffff161461075b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075290611ceb565b60405180910390fd5b6107636113cc565b565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6107b5610f54565b73ffffffffffffffffffffffffffffffffffffffff166107d36109cd565b73ffffffffffffffffffffffffffffffffffffffff1614610829576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082090611ceb565b60405180910390fd5b610833600061146f565b565b600061083f610f54565b73ffffffffffffffffffffffffffffffffffffffff1661085d6109cd565b73ffffffffffffffffffffffffffffffffffffffff16146108b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108aa90611ceb565b60405180910390fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661090957600080fd5b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167fca5069937e68fd197927055037f59d7c90bf75ac104e6e375539ef480c3ad6ee60405160405180910390a260019050919050565b6109bf826109b9610f54565b83611535565b6109c982826111f6565b5050565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054610a0690611be9565b80601f0160208091040260200160405190810160405280929190818152602001828054610a3290611be9565b8015610a7f5780601f10610a5457610100808354040283529160200191610a7f565b820191906000526020600020905b815481529060010190602001808311610a6257829003601f168201915b5050505050905090565b600080610a94610f54565b90506000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905083811015610b5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b5190611d7d565b60405180910390fd5b610b678286868403610f5c565b60019250505092915050565b600033600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610bcd57600080fd5b610bd784846115c1565b91505092915050565b60066020528060005260406000206000915054906101000a900460ff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000610c91610f54565b73ffffffffffffffffffffffffffffffffffffffff16610caf6109cd565b73ffffffffffffffffffffffffffffffffffffffff1614610d05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfc90611ceb565b60405180910390fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610d5c57600080fd5b6001600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167faf85b60d26151edd11443b704d424da6c43d0468f2235ebae3d1904dbc32304960405160405180910390a260019050919050565b610e08610f54565b73ffffffffffffffffffffffffffffffffffffffff16610e266109cd565b73ffffffffffffffffffffffffffffffffffffffff1614610e7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7390611ceb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610eeb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ee290611e0f565b60405180910390fd5b610ef48161146f565b50565b610f02838383610f4f565b610f0a6106c8565b15610f4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4190611ea1565b60405180910390fd5b505050565b505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610fcb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc290611f33565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361103a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103190611fc5565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111189190611a51565b60405180910390a3505050565b600080611130610f54565b905061113d858285611535565b6111488585856115e4565b60019150509392505050565b61115c6106c8565b61119b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119290612031565b60405180910390fd5b6000600560006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6111df610f54565b6040516111ec9190611b5f565b60405180910390a1565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611265576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125c906120c3565b60405180910390fd5b61127182600083611863565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156112f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112ee90612155565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816002600082825461134e9190612175565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113b39190611a51565b60405180910390a36113c783600084611873565b505050565b6113d46106c8565b15611414576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140b906121f5565b60405180910390fd5b6001600560006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611458610f54565b6040516114659190611b5f565b60405180910390a1565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60006115418484610c00565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146115bb57818110156115ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a490612261565b60405180910390fd5b6115ba8484848403610f5c565b5b50505050565b6000806115cc610f54565b90506115d98185856115e4565b600191505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611653576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164a906122f3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036116c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b990612385565b60405180910390fd5b6116cd838383611863565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611753576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174a90612417565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546117e69190611c49565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161184a9190611a51565b60405180910390a361185d848484611873565b50505050565b61186e838383610ef7565b505050565b505050565b600081519050919050565b600082825260208201905092915050565b60005b838110156118b2578082015181840152602081019050611897565b838111156118c1576000848401525b50505050565b6000601f19601f8301169050919050565b60006118e382611878565b6118ed8185611883565b93506118fd818560208601611894565b611906816118c7565b840191505092915050565b6000602082019050818103600083015261192b81846118d8565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061196382611938565b9050919050565b61197381611958565b811461197e57600080fd5b50565b6000813590506119908161196a565b92915050565b6000819050919050565b6119a981611996565b81146119b457600080fd5b50565b6000813590506119c6816119a0565b92915050565b600080604083850312156119e3576119e2611933565b5b60006119f185828601611981565b9250506020611a02858286016119b7565b9150509250929050565b60008115159050919050565b611a2181611a0c565b82525050565b6000602082019050611a3c6000830184611a18565b92915050565b611a4b81611996565b82525050565b6000602082019050611a666000830184611a42565b92915050565b600080600060608486031215611a8557611a84611933565b5b6000611a9386828701611981565b9350506020611aa486828701611981565b9250506040611ab5868287016119b7565b9150509250925092565b600060ff82169050919050565b611ad581611abf565b82525050565b6000602082019050611af06000830184611acc565b92915050565b600060208284031215611b0c57611b0b611933565b5b6000611b1a848285016119b7565b91505092915050565b600060208284031215611b3957611b38611933565b5b6000611b4784828501611981565b91505092915050565b611b5981611958565b82525050565b6000602082019050611b746000830184611b50565b92915050565b60008060408385031215611b9157611b90611933565b5b6000611b9f85828601611981565b9250506020611bb085828601611981565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680611c0157607f821691505b602082108103611c1457611c13611bba565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611c5482611996565b9150611c5f83611996565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611c9457611c93611c1a565b5b828201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000611cd5602083611883565b9150611ce082611c9f565b602082019050919050565b60006020820190508181036000830152611d0481611cc8565b9050919050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000611d67602583611883565b9150611d7282611d0b565b604082019050919050565b60006020820190508181036000830152611d9681611d5a565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000611df9602683611883565b9150611e0482611d9d565b604082019050919050565b60006020820190508181036000830152611e2881611dec565b9050919050565b7f45524332305061757361626c653a20746f6b656e207472616e7366657220776860008201527f696c652070617573656400000000000000000000000000000000000000000000602082015250565b6000611e8b602a83611883565b9150611e9682611e2f565b604082019050919050565b60006020820190508181036000830152611eba81611e7e565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000611f1d602483611883565b9150611f2882611ec1565b604082019050919050565b60006020820190508181036000830152611f4c81611f10565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000611faf602283611883565b9150611fba82611f53565b604082019050919050565b60006020820190508181036000830152611fde81611fa2565b9050919050565b7f5061757361626c653a206e6f7420706175736564000000000000000000000000600082015250565b600061201b601483611883565b915061202682611fe5565b602082019050919050565b6000602082019050818103600083015261204a8161200e565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b60006120ad602183611883565b91506120b882612051565b604082019050919050565b600060208201905081810360008301526120dc816120a0565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b600061213f602283611883565b915061214a826120e3565b604082019050919050565b6000602082019050818103600083015261216e81612132565b9050919050565b600061218082611996565b915061218b83611996565b92508282101561219e5761219d611c1a565b5b828203905092915050565b7f5061757361626c653a2070617573656400000000000000000000000000000000600082015250565b60006121df601083611883565b91506121ea826121a9565b602082019050919050565b6000602082019050818103600083015261220e816121d2565b9050919050565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b600061224b601d83611883565b915061225682612215565b602082019050919050565b6000602082019050818103600083015261227a8161223e565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b60006122dd602583611883565b91506122e882612281565b604082019050919050565b6000602082019050818103600083015261230c816122d0565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b600061236f602383611883565b915061237a82612313565b604082019050919050565b6000602082019050818103600083015261239e81612362565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000612401602683611883565b915061240c826123a5565b604082019050919050565b60006020820190508181036000830152612430816123f4565b905091905056fea2646970667358221220feb9665d74e624fd3085c124089e4b21ce15c7abfef8f82a46484f1736a1dde764736f6c634300080d0033
[ 38 ]
0xf1e064f1e24c1dc18f1f0759cceff68d7f48ee6c
pragma solidity ^0.6.12; // SPDX-License-Identifier: Unlicensed interface IERC20 { 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 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; } } 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; } } /** * @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); } } } } /** * @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; 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; } } // pragma solidity >=0.5.0; 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; } // pragma solidity >=0.5.0; 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; } // pragma solidity >=0.6.2; 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); } // pragma solidity >=0.6.2; 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 Onizuka 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 _tTotal = 1000000000 * 10**6 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "Onizuka Inu"; string private _symbol = "Onizuka"; uint8 private _decimals = 9; uint256 public _taxFee = 1; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 40; uint256 private _previousLiquidityFee = _liquidityFee; address payable public _devWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9; uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor (address payable devWalletAddress) public { _devWalletAddress = devWalletAddress; _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function setDevFeeDisabled(bool _devFeeEnabled ) public returns (bool){ require(msg.sender == _devWalletAddress, "Only Dev Address can disable dev fee"); swapAndLiquifyEnabled = _devFeeEnabled; return(swapAndLiquifyEnabled); } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner() { _liquidityFee = liquidityFee; } function _setdevWallet(address payable devWalletAddress) external onlyOwner() { _devWalletAddress = devWalletAddress; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function addBotToBlackList(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not 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 removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlackListedBot[to], "You have no power here!"); require(!_isBlackListedBot[msg.sender], "You have no power here!"); require(!_isBlackListedBot[from], "You have no power here!"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves uint256 tokenBalance = contractTokenBalance; // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(tokenBalance); // <- breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); sendETHTodev(newBalance); // add liquidity to uniswap emit SwapAndLiquify(tokenBalance, newBalance); } function sendETHTodev(uint256 amount) private { _devWalletAddress.transfer(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 owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102345760003560e01c80635342acb41161012e578063a0c072d4116100ab578063c49b9a801161006f578063c49b9a801461082d578063d543dbeb14610859578063dd62ed3e14610883578063ea2f0b37146108be578063f2fde38b146108f15761023b565b8063a0c072d414610747578063a457c2d71461077a578063a9059cbb146107b3578063aae11571146107ec578063b425bac3146108185761023b565b80637ded4d6a116100f25780637ded4d6a1461068d57806388f82020146106c05780638da5cb5b146106f35780638ee88c531461070857806395d89b41146107325761023b565b80635342acb4146105e85780636bc87c3a1461061b57806370a0823114610630578063715018a6146106635780637d1db4a5146106785761023b565b80633685d419116101bc578063437823ec11610180578063437823ec146105265780634549b0391461055957806349bd5a5e1461058b5780634a74bb02146105a057806352390c02146105b55761023b565b80633685d41914610448578063395093511461047b5780633b124fe7146104b45780633bd5d173146104c95780634303443d146104f35761023b565b80631694505e116102035780631694505e1461036a57806318160ddd1461039b57806323b872dd146103b05780632d838119146103f3578063313ce5671461041d5761023b565b8063061c82d01461024057806306fdde031461026c578063095ea7b3146102f657806313114a9d146103435761023b565b3661023b57005b600080fd5b34801561024c57600080fd5b5061026a6004803603602081101561026357600080fd5b5035610924565b005b34801561027857600080fd5b50610281610981565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102bb5781810151838201526020016102a3565b50505050905090810190601f1680156102e85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561030257600080fd5b5061032f6004803603604081101561031957600080fd5b506001600160a01b038135169060200135610a17565b604080519115158252519081900360200190f35b34801561034f57600080fd5b50610358610a35565b60408051918252519081900360200190f35b34801561037657600080fd5b5061037f610a3b565b604080516001600160a01b039092168252519081900360200190f35b3480156103a757600080fd5b50610358610a5f565b3480156103bc57600080fd5b5061032f600480360360608110156103d357600080fd5b506001600160a01b03813581169160208101359091169060400135610a65565b3480156103ff57600080fd5b506103586004803603602081101561041657600080fd5b5035610aec565b34801561042957600080fd5b50610432610b4e565b6040805160ff9092168252519081900360200190f35b34801561045457600080fd5b5061026a6004803603602081101561046b57600080fd5b50356001600160a01b0316610b57565b34801561048757600080fd5b5061032f6004803603604081101561049e57600080fd5b506001600160a01b038135169060200135610d18565b3480156104c057600080fd5b50610358610d66565b3480156104d557600080fd5b5061026a600480360360208110156104ec57600080fd5b5035610d6c565b3480156104ff57600080fd5b5061026a6004803603602081101561051657600080fd5b50356001600160a01b0316610e46565b34801561053257600080fd5b5061026a6004803603602081101561054957600080fd5b50356001600160a01b0316610fce565b34801561056557600080fd5b506103586004803603604081101561057c57600080fd5b5080359060200135151561104a565b34801561059757600080fd5b5061037f6110dc565b3480156105ac57600080fd5b5061032f611100565b3480156105c157600080fd5b5061026a600480360360208110156105d857600080fd5b50356001600160a01b0316611110565b3480156105f457600080fd5b5061032f6004803603602081101561060b57600080fd5b50356001600160a01b0316611296565b34801561062757600080fd5b506103586112b4565b34801561063c57600080fd5b506103586004803603602081101561065357600080fd5b50356001600160a01b03166112ba565b34801561066f57600080fd5b5061026a61131c565b34801561068457600080fd5b506103586113be565b34801561069957600080fd5b5061026a600480360360208110156106b057600080fd5b50356001600160a01b03166113c4565b3480156106cc57600080fd5b5061032f600480360360208110156106e357600080fd5b50356001600160a01b0316611551565b3480156106ff57600080fd5b5061037f61156f565b34801561071457600080fd5b5061026a6004803603602081101561072b57600080fd5b503561157e565b34801561073e57600080fd5b506102816115db565b34801561075357600080fd5b5061026a6004803603602081101561076a57600080fd5b50356001600160a01b031661163c565b34801561078657600080fd5b5061032f6004803603604081101561079d57600080fd5b506001600160a01b0381351690602001356116b6565b3480156107bf57600080fd5b5061032f600480360360408110156107d657600080fd5b506001600160a01b03813516906020013561171e565b3480156107f857600080fd5b5061032f6004803603602081101561080f57600080fd5b50351515611732565b34801561082457600080fd5b5061037f6117a2565b34801561083957600080fd5b5061026a6004803603602081101561085057600080fd5b503515156117b1565b34801561086557600080fd5b5061026a6004803603602081101561087c57600080fd5b503561185c565b34801561088f57600080fd5b50610358600480360360408110156108a657600080fd5b506001600160a01b03813581169160200135166118da565b3480156108ca57600080fd5b5061026a600480360360208110156108e157600080fd5b50356001600160a01b0316611905565b3480156108fd57600080fd5b5061026a6004803603602081101561091457600080fd5b50356001600160a01b031661197e565b61092c611a76565b6000546001600160a01b0390811691161461097c576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b601155565b600e8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a0d5780601f106109e257610100808354040283529160200191610a0d565b820191906000526020600020905b8154815290600101906020018083116109f057829003601f168201915b5050505050905090565b6000610a2b610a24611a76565b8484611a7a565b5060015b92915050565b600d5490565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b600b5490565b6000610a72848484611b66565b610ae284610a7e611a76565b610add85604051806060016040528060288152602001612c6c602891396001600160a01b038a16600090815260056020526040812090610abc611a76565b6001600160a01b031681526020810191909152604001600020549190611edf565b611a7a565b5060019392505050565b6000600c54821115610b2f5760405162461bcd60e51b815260040180806020018281038252602a815260200180612bb1602a913960400191505060405180910390fd5b6000610b39611f76565b9050610b458382611f99565b9150505b919050565b60105460ff1690565b610b5f611a76565b6000546001600160a01b03908116911614610baf576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16610c1c576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600854811015610d1457816001600160a01b031660088281548110610c4057fe5b6000918252602090912001546001600160a01b03161415610d0c57600880546000198101908110610c6d57fe5b600091825260209091200154600880546001600160a01b039092169183908110610c9357fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610ce557fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610d14565b600101610c1f565b5050565b6000610a2b610d25611a76565b84610add8560056000610d36611a76565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611fe2565b60115481565b6000610d76611a76565b6001600160a01b03811660009081526007602052604090205490915060ff1615610dd15760405162461bcd60e51b815260040180806020018281038252602c815260200180612d4a602c913960400191505060405180910390fd5b6000610ddc8361203c565b505050506001600160a01b038416600090815260036020526040902054919250610e089190508261208b565b6001600160a01b038316600090815260036020526040902055600c54610e2e908261208b565b600c55600d54610e3e9084611fe2565b600d55505050565b610e4e611a76565b6000546001600160a01b03908116911614610e9e576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0382161415610efa5760405162461bcd60e51b8152600401808060200182810382526024815260200180612cdd6024913960400191505060405180910390fd5b6001600160a01b03811660009081526009602052604090205460ff1615610f68576040805162461bcd60e51b815260206004820152601e60248201527f4163636f756e7420697320616c726561647920626c61636b6c69737465640000604482015290519081900360640190fd5b6001600160a01b03166000818152600960205260408120805460ff19166001908117909155600a805491820181559091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b0319169091179055565b610fd6611a76565b6000546001600160a01b03908116911614611026576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156110a3576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b816110c25760006110b38461203c565b50939550610a2f945050505050565b60006110cd8461203c565b50929550610a2f945050505050565b7f000000000000000000000000c16db39dcd58a4af4cb1a2eeec41b43aee2fe31b81565b601554600160a81b900460ff1681565b611118611a76565b6000546001600160a01b03908116911614611168576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16156111d6576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526003602052604090205415611230576001600160a01b03811660009081526003602052604090205461121690610aec565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6001600160a01b031660009081526006602052604090205460ff1690565b60135481565b6001600160a01b03811660009081526007602052604081205460ff16156112fa57506001600160a01b038116600090815260046020526040902054610b49565b6001600160a01b038216600090815260036020526040902054610a2f90610aec565b611324611a76565b6000546001600160a01b03908116911614611374576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60165481565b6113cc611a76565b6000546001600160a01b0390811691161461141c576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526009602052604090205460ff16611489576040805162461bcd60e51b815260206004820152601a60248201527f4163636f756e74206973206e6f7420626c61636b6c6973746564000000000000604482015290519081900360640190fd5b60005b600a54811015610d1457816001600160a01b0316600a82815481106114ad57fe5b6000918252602090912001546001600160a01b0316141561154957600a805460001981019081106114da57fe5b600091825260209091200154600a80546001600160a01b03909216918390811061150057fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600990915260409020805460ff19169055600a805480610ce557fe5b60010161148c565b6001600160a01b031660009081526007602052604090205460ff1690565b6000546001600160a01b031690565b611586611a76565b6000546001600160a01b039081169116146115d6576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b601355565b600f8054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a0d5780601f106109e257610100808354040283529160200191610a0d565b611644611a76565b6000546001600160a01b03908116911614611694576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b601580546001600160a01b0319166001600160a01b0392909216919091179055565b6000610a2b6116c3611a76565b84610add85604051806060016040528060258152602001612d7660259139600560006116ed611a76565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190611edf565b6000610a2b61172b611a76565b8484611b66565b6015546000906001600160a01b0316331461177e5760405162461bcd60e51b8152600401808060200182810382526024815260200180612b6a6024913960400191505060405180910390fd5b506015805460ff60a81b1916600160a81b9215158302179081905560ff9190041690565b6015546001600160a01b031681565b6117b9611a76565b6000546001600160a01b03908116911614611809576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b60158054821515600160a81b810260ff60a81b199092169190911790915560408051918252517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599181900360200190a150565b611864611a76565b6000546001600160a01b039081169116146118b4576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6118d460646118ce83600b546120cd90919063ffffffff16565b90611f99565b60165550565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b61190d611a76565b6000546001600160a01b0390811691161461195d576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b611986611a76565b6000546001600160a01b039081169116146119d6576040805162461bcd60e51b81526020600482018190526024820152600080516020612c94833981519152604482015290519081900360640190fd5b6001600160a01b038116611a1b5760405162461bcd60e51b8152600401808060200182810382526026815260200180612bdb6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b038316611abf5760405162461bcd60e51b8152600401808060200182810382526024815260200180612d266024913960400191505060405180910390fd5b6001600160a01b038216611b045760405162461bcd60e51b8152600401808060200182810382526022815260200180612c016022913960400191505060405180910390fd5b6001600160a01b03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611bab5760405162461bcd60e51b8152600401808060200182810382526025815260200180612d016025913960400191505060405180910390fd5b6001600160a01b038216611bf05760405162461bcd60e51b8152600401808060200182810382526023815260200180612b8e6023913960400191505060405180910390fd5b60008111611c2f5760405162461bcd60e51b8152600401808060200182810382526029815260200180612cb46029913960400191505060405180910390fd5b6001600160a01b03821660009081526009602052604090205460ff1615611c97576040805162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b604482015290519081900360640190fd5b3360009081526009602052604090205460ff1615611cf6576040805162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b604482015290519081900360640190fd5b6001600160a01b03831660009081526009602052604090205460ff1615611d5e576040805162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b604482015290519081900360640190fd5b611d6661156f565b6001600160a01b0316836001600160a01b031614158015611da05750611d8a61156f565b6001600160a01b0316826001600160a01b031614155b15611de657601654811115611de65760405162461bcd60e51b8152600401808060200182810382526028815260200180612c236028913960400191505060405180910390fd5b6000611df1306112ba565b90506016548110611e0157506016545b60175481108015908190611e1f5750601554600160a01b900460ff16155b8015611e5d57507f000000000000000000000000c16db39dcd58a4af4cb1a2eeec41b43aee2fe31b6001600160a01b0316856001600160a01b031614155b8015611e725750601554600160a81b900460ff165b15611e8057611e8082612126565b6001600160a01b03851660009081526006602052604090205460019060ff1680611ec257506001600160a01b03851660009081526006602052604090205460ff165b15611ecb575060005b611ed7868686846121a9565b505050505050565b60008184841115611f6e5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611f33578181015183820152602001611f1b565b50505050905090810190601f168015611f605780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000806000611f8361231d565b9092509050611f928282611f99565b9250505090565b6000611fdb83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612480565b9392505050565b600082820183811015611fdb576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008060008060008060008060006120538a6124e5565b92509250925060008060006120718d868661206c611f76565b612527565b919f909e50909c50959a5093985091965092945050505050565b6000611fdb83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611edf565b6000826120dc57506000610a2f565b828202828482816120e957fe5b0414611fdb5760405162461bcd60e51b8152600401808060200182810382526021815260200180612c4b6021913960400191505060405180910390fd5b6015805460ff60a01b1916600160a01b179055804761214482612577565b6000612150478361208b565b905061215b81612786565b604080518481526020810183905281517f28fc98272ce761178794ad6768050fea1648e07f1e2ffe15afd3a290f8381486929181900390910190a150506015805460ff60a01b191690555050565b806121b6576121b66127c0565b6001600160a01b03841660009081526007602052604090205460ff1680156121f757506001600160a01b03831660009081526007602052604090205460ff16155b1561220c576122078484846127f2565b61230a565b6001600160a01b03841660009081526007602052604090205460ff1615801561224d57506001600160a01b03831660009081526007602052604090205460ff165b1561225d57612207848484612916565b6001600160a01b03841660009081526007602052604090205460ff1615801561229f57506001600160a01b03831660009081526007602052604090205460ff16155b156122af576122078484846129bf565b6001600160a01b03841660009081526007602052604090205460ff1680156122ef57506001600160a01b03831660009081526007602052604090205460ff165b156122ff57612207848484612a03565b61230a8484846129bf565b8061231757612317612a76565b50505050565b600c54600b546000918291825b60085481101561244e5782600360006008848154811061234657fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806123ab575081600460006008848154811061238457fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156123c257600c54600b549450945050505061247c565b61240260036000600884815481106123d657fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054849061208b565b9250612444600460006008848154811061241857fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054839061208b565b915060010161232a565b50600b54600c5461245e91611f99565b82101561247657600c54600b5493509350505061247c565b90925090505b9091565b600081836124cf5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611f33578181015183820152602001611f1b565b5060008385816124db57fe5b0495945050505050565b6000806000806124f485612a84565b9050600061250186612aa0565b9050600061251982612513898661208b565b9061208b565b979296509094509092505050565b600080808061253688866120cd565b9050600061254488876120cd565b9050600061255288886120cd565b9050600061256482612513868661208b565b939b939a50919850919650505050505050565b604080516002808252606080830184529260208301908036833701905050905030816000815181106125a557fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561261e57600080fd5b505afa158015612632573d6000803e3d6000fd5b505050506040513d602081101561264857600080fd5b505181518290600190811061265957fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506126a4307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a7a565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015612749578181015183820152602001612731565b505050509050019650505050505050600060405180830381600087803b15801561277257600080fd5b505af1158015611ed7573d6000803e3d6000fd5b6015546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610d14573d6000803e3d6000fd5b6011541580156127d05750601354155b156127da576127f0565b6011805460125560138054601455600091829055555b565b6000806000806000806128048761203c565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612836908861208b565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612865908761208b565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546128949086611fe2565b6001600160a01b0389166000908152600360205260409020556128b681612abc565b6128c08483612b45565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806129288761203c565b6001600160a01b038f16600090815260036020526040902054959b5093995091975095509350915061295a908761208b565b6001600160a01b03808b16600090815260036020908152604080832094909455918b168152600490915220546129909084611fe2565b6001600160a01b0389166000908152600460209081526040808320939093556003905220546128949086611fe2565b6000806000806000806129d18761203c565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612865908761208b565b600080600080600080612a158761203c565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612a47908861208b565b6001600160a01b038a1660009081526004602090815260408083209390935560039052205461295a908761208b565b601254601155601454601355565b6000610a2f60646118ce601154856120cd90919063ffffffff16565b6000610a2f60646118ce601354856120cd90919063ffffffff16565b6000612ac6611f76565b90506000612ad483836120cd565b30600090815260036020526040902054909150612af19082611fe2565b3060009081526003602090815260408083209390935560079052205460ff1615612b405730600090815260046020526040902054612b2f9084611fe2565b306000908152600460205260409020555b505050565b600c54612b52908361208b565b600c55600d54612b629082611fe2565b600d55505056fe4f6e6c792044657620416464726573732063616e2064697361626c65206465762066656545524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f57652063616e206e6f7420626c61636b6c69737420556e697377617020726f757465722e45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220588df820addcd7a156ffc08c7a50300ae1e0f40e6749796ddf37468e6ace902764736f6c634300060c0033
[ 13, 5, 11 ]
0xf1e09536a44caf421b7e885e4da036397dc276ef
// Partial License: 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; } } // Partial License: 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; } } // Partial License: MIT pragma solidity ^0.6.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); } // Partial License: 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; } } // Partial License: 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); } } } } // Partial License: 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"); // 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((amount == 0) || (_allowances[msg.sender][spender] == 0)); _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.0; contract SYSXToken is ERC20 { constructor(uint256 _initialSupply) ERC20("SYSX Token", "SYSX") public payable { _setupDecimals(18); _mint(msg.sender, _initialSupply); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025f57806370a08231146102c557806395d89b411461031d578063a457c2d7146103a0578063a9059cbb14610406578063dd62ed3e1461046c576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019757806323b872dd146101b5578063313ce5671461023b575b600080fd5b6100b66104e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610586565b604051808215151515815260200191505060405180910390f35b61019f6105a4565b6040518082815260200191505060405180910390f35b610221600480360360608110156101cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ae565b604051808215151515815260200191505060405180910390f35b610243610687565b604051808260ff1660ff16815260200191505060405180910390f35b6102ab6004803603604081101561027557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069e565b604051808215151515815260200191505060405180910390f35b610307600480360360208110156102db57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610751565b6040518082815260200191505060405180910390f35b610325610799565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561036557808201518184015260208101905061034a565b50505050905090810190601f1680156103925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103ec600480360360408110156103b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061083b565b604051808215151515815260200191505060405180910390f35b6104526004803603604081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610908565b604051808215151515815260200191505060405180910390f35b6104ce6004803603604081101561048257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610926565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b600061059a6105936109ad565b84846109b5565b6001905092915050565b6000600254905090565b60006105bb848484610c40565b61067c846105c76109ad565b610677856040518060600160405280602881526020016110ba60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061062d6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f019092919063ffffffff16565b6109b5565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107476106ab6109ad565b8461074285600160006106bc6109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fc190919063ffffffff16565b6109b5565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108315780601f1061080657610100808354040283529160200191610831565b820191906000526020600020905b81548152906001019060200180831161081457829003601f168201915b5050505050905090565b60006108fe6108486109ad565b846108f98560405180606001604052806025815260200161112b60259139600160006108726109ad565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f019092919063ffffffff16565b6109b5565b6001905092915050565b600061091c6109156109ad565b8484610c40565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806111076024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ac1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110726022913960400191505060405180910390fd5b6000811480610b4c57506000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b610b5557600080fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cc6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110e26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061104f6023913960400191505060405180910390fd5b610d57838383611049565b610dc281604051806060016040528060268152602001611094602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f019092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e55816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fc190919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f73578082015181840152602081019050610f58565b50505050905090810190601f168015610fa05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561103f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220aedf8b7b77ff7a37cfd7f7d829222e4f86668044dc8b5375922f4150eef6e2f964736f6c63430006060033
[ 2 ]
0xf1e0beca4eac65f902466881cdfdd0099d91e47b
// File: 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/interfaces/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: contracts/interfaces/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: contracts/interfaces/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: contracts/interfaces/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: contracts/interfaces/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: 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: 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: contracts/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. */ /** * @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 () { // 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) external override view 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 { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // File: contracts/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. */ /* * 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 * * => 0x06fdde03 ^ 0x95d89b41 == 0x93254542 */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x93254542; /* * 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; constructor (string memory name_, string memory symbol_) { _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 _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 "https://ipfs.apeonly.com/apes/"; } /** * @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 _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 || ERC721.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: contracts/ApeOnly.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. * * 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 () { 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; } } contract ApeOnly is Ownable, ERC721 { address payable public apesWallet; uint256 public apesLength; uint256 public constant MAX_APES = 999; uint256 public constant SALE_DAYS = 14 days; uint256 public immutable SALE_END_DAY ; uint256 _ethAmount = 0.3 ether; constructor(address _apesWallet) ERC721("ApeOnly","APES") { apesWallet = payable(_apesWallet); SALE_END_DAY = block.timestamp+SALE_DAYS; } function changeApesWallet(address payable wallet) external onlyOwner() returns(bool){ apesWallet = wallet; return true; } function setEthAmount(uint256 amount) external onlyOwner() returns(bool){ _ethAmount = amount; return true; } function _getCurrentEthAmount() internal view returns(uint256 ethAmount){ return _ethAmount; } function getCurrentEthAmount() external view returns(uint256){ return _getCurrentEthAmount(); } function _genrateApesToken() internal returns(bool){ apesLength+=1; require(MAX_APES >= apesLength,"max limit reach"); if(block.timestamp < SALE_END_DAY){ require(msg.value >= _getCurrentEthAmount(),"eth amount error"); apesWallet.transfer(msg.value); } _mint(msg.sender,apesLength); return true; } function genrateApesTokenToOwner(uint256 _numberOfApes) external onlyOwner returns(bool){ require(block.timestamp > SALE_END_DAY,"sale not ended"); for(uint i=0;i < _numberOfApes;i++){ _genrateApesToken(); } return true; } function genrateApesToken() external payable returns(bool){ require(block.timestamp < SALE_END_DAY,"sale ended"); return _genrateApesToken(); } fallback() external payable{ require(block.timestamp < SALE_END_DAY,"sale ended"); _genrateApesToken(); } receive() external payable{ require(block.timestamp < SALE_END_DAY,"sale ended"); _genrateApesToken(); } function burnApes(uint256 tokenId) external returns(bool){ require(ERC721.ownerOf(tokenId) == msg.sender, "ERC721: transfer of token that is not own"); _burn(tokenId); return true; } }
0x6080604052600436106101bb5760003560e01c8063715018a6116100ec578063b88d4fde1161008a578063bb8a16bd11610064578063bb8a16bd1461050b578063c87b56dd14610520578063e985e9c514610540578063f2fde38b1461056057610213565b8063b88d4fde146104b6578063b8d69d56146104d6578063b9ceedb9146104f657610213565b806390612b30116100c657806390612b301461044157806395d89b4114610461578063a22cb46514610476578063b87c7d431461049657610213565b8063715018a6146104025780638da5cb5b146104175780638f32d59b1461042c57610213565b806342842e0e11610159578063624936c711610133578063624936c7146103985780636352211e146103ad5780636a07786d146103cd57806370a08231146103e257610213565b806342842e0e1461035b5780634744a2551461037b5780635b55374f1461038357610213565b8063095ea7b311610195578063095ea7b3146102d75780630a7834fc146102f957806310307abe1461031957806323b872dd1461033b57610213565b806301ffc9a71461025257806306fdde0314610288578063081812fc146102aa57610213565b36610213577f0000000000000000000000000000000000000000000000000000000060816e5542106102085760405162461bcd60e51b81526004016101ff906117e6565b60405180910390fd5b610210610580565b50005b7f0000000000000000000000000000000000000000000000000000000060816e5542106102085760405162461bcd60e51b81526004016101ff906117e6565b34801561025e57600080fd5b5061027261026d3660046115fd565b61065a565b60405161027f91906116f9565b60405180910390f35b34801561029457600080fd5b5061029d61067d565b60405161027f9190611704565b3480156102b657600080fd5b506102ca6102c5366004611635565b61070f565b60405161027f91906116a8565b3480156102e357600080fd5b506102f76102f23660046115d2565b610752565b005b34801561030557600080fd5b50610272610314366004611635565b6107ea565b34801561032557600080fd5b5061032e61082d565b60405161027f9190611c1c565b34801561034757600080fd5b506102f7610356366004611491565b610834565b34801561036757600080fd5b506102f7610376366004611491565b61086c565b610272610887565b34801561038f57600080fd5b5061032e6108d5565b3480156103a457600080fd5b5061032e6108f9565b3480156103b957600080fd5b506102ca6103c8366004611635565b6108ff565b3480156103d957600080fd5b5061032e61093a565b3480156103ee57600080fd5b5061032e6103fd36600461143d565b610944565b34801561040e57600080fd5b506102f7610988565b34801561042357600080fd5b506102ca6109f6565b34801561043857600080fd5b50610272610a05565b34801561044d57600080fd5b5061027261045c36600461143d565b610a29565b34801561046d57600080fd5b5061029d610a74565b34801561048257600080fd5b506102f76104913660046115a1565b610a83565b3480156104a257600080fd5b506102726104b1366004611635565b610b51565b3480156104c257600080fd5b506102f76104d13660046114d1565b610b80565b3480156104e257600080fd5b506102726104f1366004611635565b610bbf565b34801561050257600080fd5b506102ca610c53565b34801561051757600080fd5b5061032e610c62565b34801561052c57600080fd5b5061029d61053b366004611635565b610c68565b34801561054c57600080fd5b5061027261055b366004611459565b610ceb565b34801561056c57600080fd5b506102f761057b36600461143d565b610d19565b60006001600960008282546105959190611c25565b90915550506009546103e710156105be5760405162461bcd60e51b81526004016101ff90611ba2565b7f0000000000000000000000000000000000000000000000000000000060816e55421015610648576105ee610d49565b34101561060d5760405162461bcd60e51b81526004016101ff90611a77565b6008546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015610646573d6000803e3d6000fd5b505b61065433600954610d4f565b50600190565b6001600160e01b0319811660009081526001602052604090205460ff165b919050565b60606002805461068c90611c94565b80601f01602080910402602001604051908101604052809291908181526020018280546106b890611c94565b80156107055780601f106106da57610100808354040283529160200191610705565b820191906000526020600020905b8154815290600101906020018083116106e857829003601f168201915b5050505050905090565b600061071a82610e2e565b6107365760405162461bcd60e51b81526004016101ff906119f6565b506000908152600660205260409020546001600160a01b031690565b600061075d826108ff565b9050806001600160a01b0316836001600160a01b031614156107915760405162461bcd60e51b81526004016101ff90611b61565b806001600160a01b03166107a3610e4b565b6001600160a01b031614806107bf57506107bf8161055b610e4b565b6107db5760405162461bcd60e51b81526004016101ff906118d1565b6107e58383610e4f565b505050565b6000336107f6836108ff565b6001600160a01b03161461081c5760405162461bcd60e51b81526004016101ff90611aa1565b61082582610ebd565b506001919050565b6212750081565b61084561083f610e4b565b82610f64565b6108615760405162461bcd60e51b81526004016101ff90611bcb565b6107e5838383610fe9565b6107e583838360405180602001604052806000815250610b80565b60007f0000000000000000000000000000000000000000000000000000000060816e5542106108c85760405162461bcd60e51b81526004016101ff906117e6565b6108d0610580565b905090565b7f0000000000000000000000000000000000000000000000000000000060816e5581565b60095481565b6000818152600460205260408120546001600160a01b0316806109345760405162461bcd60e51b81526004016101ff90611978565b92915050565b60006108d0610d49565b60006001600160a01b03821661096c5760405162461bcd60e51b81526004016101ff9061192e565b506001600160a01b031660009081526005602052604090205490565b610990610a05565b6109ac5760405162461bcd60e51b81526004016101ff90611a42565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b600080546001600160a01b0316610a1a610e4b565b6001600160a01b031614905090565b6000610a33610a05565b610a4f5760405162461bcd60e51b81526004016101ff90611a42565b50600880546001600160a01b0383166001600160a01b03199091161790556001919050565b60606003805461068c90611c94565b610a8b610e4b565b6001600160a01b0316826001600160a01b03161415610abc5760405162461bcd60e51b81526004016101ff9061184e565b8060076000610ac9610e4b565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610b0d610e4b565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610b4591906116f9565b60405180910390a35050565b6000610b5b610a05565b610b775760405162461bcd60e51b81526004016101ff90611a42565b50600a55600190565b610b91610b8b610e4b565b83610f64565b610bad5760405162461bcd60e51b81526004016101ff90611bcb565b610bb984848484611116565b50505050565b6000610bc9610a05565b610be55760405162461bcd60e51b81526004016101ff90611a42565b7f0000000000000000000000000000000000000000000000000000000060816e554211610c245760405162461bcd60e51b81526004016101ff90611b39565b60005b82811015610c4a57610c37610580565b5080610c4281611ccf565b915050610c27565b50600192915050565b6008546001600160a01b031681565b6103e781565b6060610c7382610e2e565b610c8f5760405162461bcd60e51b81526004016101ff90611aea565b6000610c99611149565b90506000815111610cb95760405180602001604052806000815250610ce4565b80610cc384611180565b604051602001610cd4929190611679565b6040516020818303038152906040525b9392505050565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b610d21610a05565b610d3d5760405162461bcd60e51b81526004016101ff90611a42565b610d468161129b565b50565b600a5490565b6001600160a01b038216610d755760405162461bcd60e51b81526004016101ff906119c1565b610d7e81610e2e565b15610d9b5760405162461bcd60e51b81526004016101ff906117af565b610da7600083836107e5565b6001600160a01b0382166000908152600560205260408120805460019290610dd0908490611c25565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000908152600460205260409020546001600160a01b0316151590565b3390565b600081815260066020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610e84826108ff565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610ec8826108ff565b9050610ed6816000846107e5565b610ee1600083610e4f565b6001600160a01b0381166000908152600560205260408120805460019290610f0a908490611c51565b909155505060008281526004602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000610f6f82610e2e565b610f8b5760405162461bcd60e51b81526004016101ff90611885565b6000610f96836108ff565b9050806001600160a01b0316846001600160a01b03161480610fd15750836001600160a01b0316610fc68461070f565b6001600160a01b0316145b80610fe15750610fe18185610ceb565b949350505050565b826001600160a01b0316610ffc826108ff565b6001600160a01b0316146110225760405162461bcd60e51b81526004016101ff90611aa1565b6001600160a01b0382166110485760405162461bcd60e51b81526004016101ff9061180a565b6110538383836107e5565b61105e600082610e4f565b6001600160a01b0383166000908152600560205260408120805460019290611087908490611c51565b90915550506001600160a01b03821660009081526005602052604081208054600192906110b5908490611c25565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b611121848484610fe9565b61112d8484848461131c565b610bb95760405162461bcd60e51b81526004016101ff90611717565b60408051808201909152601e81527f68747470733a2f2f697066732e6170656f6e6c792e636f6d2f617065732f0000602082015290565b6060816111a557506040805180820190915260018152600360fc1b6020820152610678565b8160005b81156111cf57806111b981611ccf565b91506111c89050600a83611c3d565b91506111a9565b60008167ffffffffffffffff8111156111f857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611222576020820181803683370190505b5090505b8415610fe157611237600183611c51565b9150611244600a86611cea565b61124f906030611c25565b60f81b81838151811061127257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611294600a86611c3d565b9450611226565b6001600160a01b0381166112c15760405162461bcd60e51b81526004016101ff90611769565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000611330846001600160a01b0316611437565b1561142c57836001600160a01b031663150b7a0261134c610e4b565b8786866040518563ffffffff1660e01b815260040161136e94939291906116bc565b602060405180830381600087803b15801561138857600080fd5b505af19250505080156113b8575060408051601f3d908101601f191682019092526113b591810190611619565b60015b611412573d8080156113e6576040519150601f19603f3d011682016040523d82523d6000602084013e6113eb565b606091505b50805161140a5760405162461bcd60e51b81526004016101ff90611717565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610fe1565b506001949350505050565b3b151590565b60006020828403121561144e578081fd5b8135610ce481611d40565b6000806040838503121561146b578081fd5b823561147681611d40565b9150602083013561148681611d40565b809150509250929050565b6000806000606084860312156114a5578081fd5b83356114b081611d40565b925060208401356114c081611d40565b929592945050506040919091013590565b600080600080608085870312156114e6578081fd5b84356114f181611d40565b935060208581013561150281611d40565b935060408601359250606086013567ffffffffffffffff80821115611525578384fd5b818801915088601f830112611538578384fd5b81358181111561154a5761154a611d2a565b604051601f8201601f191681018501838111828210171561156d5761156d611d2a565b60405281815283820185018b1015611583578586fd5b81858501868301379081019093019390935250939692955090935050565b600080604083850312156115b3578182fd5b82356115be81611d40565b915060208301358015158114611486578182fd5b600080604083850312156115e4578182fd5b82356115ef81611d40565b946020939093013593505050565b60006020828403121561160e578081fd5b8135610ce481611d55565b60006020828403121561162a578081fd5b8151610ce481611d55565b600060208284031215611646578081fd5b5035919050565b60008151808452611665816020860160208601611c68565b601f01601f19169290920160200192915050565b6000835161168b818460208801611c68565b83519083019061169f818360208801611c68565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906116ef9083018461164d565b9695505050505050565b901515815260200190565b600060208252610ce4602083018461164d565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252600a90820152691cd85b1948195b99195960b21b604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526010908201526f32ba341030b6b7bab73a1032b93937b960811b604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b6020808252600e908201526d1cd85b19481b9bdd08195b99195960921b604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252600f908201526e0dac2f040d8d2dad2e840e4cac2c6d608b1b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b90815260200190565b60008219821115611c3857611c38611cfe565b500190565b600082611c4c57611c4c611d14565b500490565b600082821015611c6357611c63611cfe565b500390565b60005b83811015611c83578181015183820152602001611c6b565b83811115610bb95750506000910152565b600281046001821680611ca857607f821691505b60208210811415611cc957634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611ce357611ce3611cfe565b5060010190565b600082611cf957611cf9611d14565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610d4657600080fd5b6001600160e01b031981168114610d4657600080fdfea2646970667358221220c67cf1c83c52b571ac342fc35f984ada4a3aaf58dbf7ce9858d978dac2791fee64736f6c63430008000033
[ 5 ]
0xF1E0EFf3DFddA747058f082123473d9b03aab42C
// SPDX-License-Identifier: MIT pragma solidity ^0.5.0; contract CompoundLogger { event Repay( address indexed owner, uint256 collateralAmount, uint256 borrowAmount, address collAddr, address borrowAddr ); event Boost( address indexed owner, uint256 borrowAmount, uint256 collateralAmount, address collAddr, address borrowAddr ); // solhint-disable-next-line func-name-mixedcase function LogRepay(address _owner, uint256 _collateralAmount, uint256 _borrowAmount, address _collAddr, address _borrowAddr) public { emit Repay(_owner, _collateralAmount, _borrowAmount, _collAddr, _borrowAddr); } // solhint-disable-next-line func-name-mixedcase function LogBoost(address _owner, uint256 _borrowAmount, uint256 _collateralAmount, address _collAddr, address _borrowAddr) public { emit Boost(_owner, _borrowAmount, _collateralAmount, _collAddr, _borrowAddr); } }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c80630b0975d61461003b5780637fbce5c814610081575b600080fd5b61007f600480360360a081101561005157600080fd5b506001600160a01b0381358116916020810135916040820135916060810135821691608090910135166100c5565b005b61007f600480360360a081101561009757600080fd5b506001600160a01b038135811691602081013591604082013591606081013582169160809091013516610121565b60408051858152602081018590526001600160a01b038481168284015283811660608301529151918716917f9f214cf571e9fe7a02539f0d043f5eafa722bbd1dfbae316407b4adb81bc3beb9181900360800190a25050505050565b60408051858152602081018590526001600160a01b038481168284015283811660608301529151918716917f26dc52b5c4d19b7ffb0231ad147b9cda6e6deb994e17c5ce48711384fce2d52e9181900360800190a2505050505056fea265627a7a7231582051faab12a4b974104687eaa949cb18c4547efb45afabd12d3040ade5493ca1f064736f6c63430005110032
[ 38 ]
0xf1e2db30b1b1f8647225cbc93648076ad58faa9f
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'ACT814134' token contract // // Deployed to : 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187 // Symbol : ACT814134 // Name : ADZbuzz Fluentin3months.com Community Token // Total supply: 2000000 // Decimals : 8 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // (c) by Darwin Jayme with ADZbuzz Ltd. UK (adzbuzz.com) 2018. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- 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); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ADZbuzzCommunityToken() public { symbol = "ACT814134"; name = "ADZbuzz Fluentin3months.com Community Token"; decimals = 8; _totalSupply = 200000000000000; balances[0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187] = _totalSupply; emit Transfer(address(0), 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112c7565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112f8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061131e565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061145d565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114e4565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611500565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114e4565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b5af115156112b957600080fd5b505050600190509392505050565b6000818302905060008314806112e757508183828115156112e457fe5b04145b15156112f257600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137b57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561143e57600080fd5b5af1151561144b57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156114fa57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561155b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058209949394b6ed0a0fed43c949fa8d36e0543ec8c32c18b374ae8adcbef130354420029
[ 2 ]
0xf1e345ea7c33fd6c05f5512a780eb5839ee31674
// SPDX-License-Identifier: MIT pragma solidity 0.8.12; // ---------------------------------------------------------------------------- // 'TELE' token governance smart contract // // Symbol : TELE // Name : Telefy // Max Total Circulating supply: 1000000000 // Decimals : 18 // // // // (c) by Telefy Technologies Private Limited. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- /** * @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. */ contract SafeMath { function safeAdd(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath: addition overflow"); } function safeSub(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b <= a, "SafeMath: subtraction overflow"); c = a - b; } function safeMul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { c = 0; } else { c = a * b; } require((a == 0 || c / a == b), "SafeMath: multiplication overflow"); } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b > 0, "SafeMath: division by zero"); c = a / b; } function safeMod(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b != 0, "SafeMath: modulo by zero"); c = a % b; } } // ---------------------------------------------------------------------------- // Information of context: Sender and Data // ---------------------------------------------------------------------------- abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // Warning: silence state mutability without generating bytecode return msg.data; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- abstract contract ERC20Interface { function totalSupply() public view virtual returns (uint256); function balanceOf(address tokenOwner) public view virtual returns (uint256 balance); function allowance(address tokenOwner, address spender) public view virtual returns (uint256 remaining); function transfer(address to, uint256 tokens) external virtual returns (bool success); function approve(address spender, uint256 tokens) public virtual returns (bool success); function transferFrom( address from, address to, uint256 tokens ) external virtual returns (bool success); event Transfer(address indexed from, address indexed to, uint256 tokens); event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- abstract contract ApproveAndCallFallBack { function receiveApproval( address from, uint256 tokens, address token, bytes memory data ) public virtual; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() { owner = msg.sender; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) external onlyOwner { newOwner = _newOwner; } function acceptOwnership() external { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // @dev Collection of functions related to the address type // @openzeppelin/contracts/utils/Address.sol // ---------------------------------------------------------------------------- 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`, TELEe 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`]. // _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`. // _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); } } } } // ---------------------------------------------------------------------------- // TELE Token, with the addition of symbol, name and decimals and assisted // token transfers // TELE is Governance token for TELEFY // ---------------------------------------------------------------------------- contract TELEToken is ERC20Interface, Owned, SafeMath, Context { using Address for address; string public symbol; string public name; uint8 public decimals; uint256 private _totalSupply; address private _minter; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; /// @notice The timestamp after which minting may occur uint256 public mintingAllowedAfter; /// @notice Minimum time between mints uint32 public constant minimumTimeBetweenMints = 1 days * 7; /// @notice Cap on the percentage of totalSupply that can be minted at each mint /// We are going to divide this by 1000. so below is 0.2 percent of totalSupply uint8 public constant mintCap = 2; /// @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 The EIP-712 typehash for the permit struct used by the contract bytes32 public constant PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; // @notice An event thats emitted when multiple transactions made event TransferMultiple(address indexed from, address[] indexed to, uint256[] tokens); /// @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, uint256 previousBalance, uint256 newBalance ); // @notice An event thats emitted when the minter address is changed event MinterChanged(address minter, address newMinter); // ------------------------------------------------------------------------ // Constructor ///** //* @notice Construct a new TELE token //* @param account The initial account to grant all the tokens //* @param minter_ The account with minting ability //* @param mintingAllowedAfter_ The timestamp after which minting may occur //* // ------------------------------------------------------------------------ constructor() { symbol = "TELE"; name = "Telefy"; decimals = 18; _totalSupply = 600_000_000e18; balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); _minter = 0xa270dA3c3175ED9992c9Ad3B6Bb679Bf81c35BA8; mintingAllowedAfter = safeAdd(block.timestamp, minimumTimeBetweenMints); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view override returns (uint256) { return safeSub(_totalSupply, balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view override returns (uint256 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, uint256 tokens) external override returns (bool success) { require(to != address(0), "TELE: transfer to the zero address"); _transferTokens(to, tokens); emit Transfer(_msgSender(), to, tokens); return true; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to multiple accounts // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferMultiple(address[] memory to, uint256[] memory tokens) external returns (bool success) { require( to.length == tokens.length, "TELE: number of receiver addresses and number of amounts should be equal" ); for (uint256 i = 0; i < to.length; i++) { if (to[i] != address(0)) { _transferTokens(to[i], tokens[i]); } } emit TransferMultiple(_msgSender(), to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint256 tokens) public override returns (bool success) { require(spender != address(0), "TELE: transfer to the zero address"); allowed[_msgSender()][spender] = tokens; emit Approval(_msgSender(), spender, tokens); return true; } // ------------------------------------------------------------------------ // @notice Triggers an approval from owner to spends // @param owner The address to approve from // @param spender The address to be approved // @param rawAmount The number of tokens that are approved (2^256-1 means infinite) // @param deadline 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 permit( address owner, address spender, uint256 rawAmount, uint256 deadline, 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(PERMIT_TYPEHASH, owner, spender, rawAmount, nonces[owner]++, deadline) ); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "TELE::permit: invalid signature"); require(signatory == owner, "TELE::permit: unauthorized"); require(block.timestamp <= deadline, "TELE::permit: signature expired"); allowed[owner][spender] = rawAmount; emit Approval(owner, spender, rawAmount); } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom( address from, address to, uint256 tokens ) external override returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][_msgSender()] = safeSub(allowed[from][_msgSender()], tokens); emit Approval(from, to, tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); _moveDelegates(_delegates[from], _delegates[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 override returns (uint256 remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // @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. // ------------------------------------------------------------------------ function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool) { approve(spender, safeAdd(allowed[_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. // ------------------------------------------------------------------------ function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { approve(spender, safeSub(allowed[_msgSender()][spender], subtractedValue)); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall( address spender, uint256 tokens, bytes memory data ) external returns (bool success) { allowed[_msgSender()][spender] = tokens; emit Approval(_msgSender(), spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(_msgSender(), tokens, address(this), data); return true; } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint256 tokens) external onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } // ------------------------------------------------------------------------ // @dev Destroys `amount` tokens from `account`'s allowance, reducing the // total supply which requires approval from user before this action can be performed. // Emits a {Transfer} event with `to` set to the zero address. // ------------------------------------------------------------------------ function burn(address account, uint256 amount) external { require(_msgSender() == _minter, "TELE::burn: only the minter can mint"); require(account != address(0), "TELE: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); balances[account] = safeSub(balances[account], amount); // Sets `amount` as the allowance of `spender` allowed[account][_msgSender()] = safeSub(allowed[account][_msgSender()], amount); emit Approval(account, _msgSender(), amount); _totalSupply = safeSub(_totalSupply, amount); emit Transfer(account, address(0), amount); _moveDelegates(address(0), _delegates[account], 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. // ------------------------------------------------------------------------ function mint(address account, uint256 amount) external { require(_msgSender() == _minter, "TELE::mint: only the minter can mint"); require(block.timestamp >= mintingAllowedAfter, "TELE::mint: minting not allowed yet"); require(account != address(0), "TELE: mint to the zero address"); // record the mint mintingAllowedAfter = safeAdd(block.timestamp, minimumTimeBetweenMints); _beforeTokenTransfer(address(0), account, amount); // mint amount should not exceed mint cap require(amount <= safeDiv(safeMul(_totalSupply, mintCap), 1000)); _totalSupply = safeAdd(_totalSupply, amount); balances[account] = safeAdd(balances[account], amount); emit Transfer(address(0), account, amount); _moveDelegates(address(0), _delegates[account], amount); } // ------------------------------------------------------------------------ // @notice Change the minter address // @param minter_ The address of the new minter // ------------------------------------------------------------------------ function setMinter(address minter_) external { require( _msgSender() == _minter, "TELE::setMinter: only the minter can change the minter address" ); emit MinterChanged(_minter, minter_); _minter = minter_; } // ------------------------------------------------------------------------ // @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(_msgSender(), 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, uint256 nonce, uint256 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), "TELE::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "TELE::delegateBySig: invalid nonce"); require(block.timestamp <= expiry, "TELE::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, uint256 blockNumber) external view returns (uint256) { require(blockNumber < block.number, "TELE::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 _transferTokens(address to, uint256 tokens) internal { balances[_msgSender()] = safeSub(balances[_msgSender()], tokens); balances[to] = safeAdd(balances[to], tokens); _moveDelegates(_delegates[_msgSender()], _delegates[to], tokens); } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying TELEs (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 = safeSub(srcRepOld, 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 = safeAdd(dstRepOld, amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32( block.number, "TELE::_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(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
0x608060405234801561001057600080fd5b506004361061021c5760003560e01c80637ecebe0011610125578063cae9ca51116100ad578063dd62ed3e1161007c578063dd62ed3e1461050a578063e7a324dc14610543578063f1127ed81461056a578063f2fde38b146105c1578063fca3b5aa146105d457600080fd5b8063cae9ca51146104be578063d4ee1d90146104d1578063d505accf146104e4578063dc39d06d146104f757600080fd5b8063a05fccef116100f4578063a05fccef1461045f578063a457c2d714610472578063a9059cbb14610485578063b4b5ea5714610498578063c3cda520146104ab57600080fd5b80637ecebe00146104115780638da5cb5b1461043157806395d89b41146104445780639dc29fac1461044c57600080fd5b806340c10f19116101a85780636fcfff45116101775780636fcfff451461039f57806370a08231146103c557806376c71ca1146103ee578063782d6fe1146103f657806379ba50971461040957600080fd5b806340c10f1914610314578063587cde1e146103295780635c11d62f1461036d5780635c19a95c1461038c57600080fd5b806323b872dd116101ef57806323b872dd1461029f57806330adf81f146102b257806330b36cef146102d9578063313ce567146102e2578063395093511461030157600080fd5b806306fdde0314610221578063095ea7b31461023f57806318160ddd1461026257806320606b7014610278575b600080fd5b6102296105e7565b6040516102369190612064565b60405180910390f35b61025261024d366004612093565b610675565b6040519015158152602001610236565b61026a6106fa565b604051908152602001610236565b61026a7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6102526102ad3660046120bd565b610739565b61026a7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61026a60095481565b6004546102ef9060ff1681565b60405160ff9091168152602001610236565b61025261030f366004612093565b610888565b610327610322366004612093565b6108bc565b005b6103556103373660046120f9565b6001600160a01b039081166000908152600a60205260409020541690565b6040516001600160a01b039091168152602001610236565b61037762093a8081565b60405163ffffffff9091168152602001610236565b61032761039a3660046120f9565b610ab8565b6103776103ad3660046120f9565b600c6020526000908152604090205463ffffffff1681565b61026a6103d33660046120f9565b6001600160a01b031660009081526007602052604090205490565b6102ef600281565b61026a610404366004612093565b610ac5565b610327610d2a565b61026a61041f3660046120f9565b600d6020526000908152604090205481565b600054610355906001600160a01b031681565b610229610da5565b61032761045a366004612093565b610db2565b61025261046d3660046121ea565b610f72565b610252610480366004612093565b6110df565b610252610493366004612093565b611113565b61026a6104a63660046120f9565b611170565b6103276104b93660046122bb565b6111e5565b6102526104cc366004612313565b6114bb565b600154610355906001600160a01b031681565b6103276104f23660046123c2565b611575565b610252610505366004612093565b611891565b61026a61051836600461242c565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b61026a7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6105a561057836600461245f565b600b6020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b6040805163ffffffff9093168352602083019190915201610236565b6103276105cf3660046120f9565b611920565b6103276105e23660046120f9565b611959565b600380546105f49061249f565b80601f01602080910402602001604051908101604052809291908181526020018280546106209061249f565b801561066d5780601f106106425761010080835404028352916020019161066d565b820191906000526020600020905b81548152906001019060200180831161065057829003601f168201915b505050505081565b60006001600160a01b0383166106a65760405162461bcd60e51b815260040161069d906124da565b60405180910390fd5b3360008181526008602090815260408083206001600160a01b03881680855290835292819020869055518581529192916000805160206127ea83398151915291015b60405180910390a35060015b92915050565b600554600080805260076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df54909161073491611a4b565b905090565b6001600160a01b03831660009081526007602052604081205461075c9083611a4b565b6001600160a01b03851660009081526007602090815260408083209390935560088152828220338352905220546107939083611a4b565b6001600160a01b03858116600081815260086020908152604080832033845282529182902094909455518581529186169290916000805160206127ea833981519152910160405180910390a36001600160a01b0383166000908152600760205260409020546108029083611aa7565b6001600160a01b0380851660008181526007602052604090819020939093559151908616906000805160206127ca833981519152906108449086815260200190565b60405180910390a36001600160a01b038085166000908152600a602052604080822054868416835291205461087e92918216911684611b05565b5060019392505050565b3360009081526008602090815260408083206001600160a01b038616845290915281205461087e90849061024d9085611aa7565b6006546001600160a01b0316336001600160a01b03161461092b5760405162461bcd60e51b8152602060048201526024808201527f54454c453a3a6d696e743a206f6e6c7920746865206d696e7465722063616e206044820152631b5a5b9d60e21b606482015260840161069d565b6009544210156109895760405162461bcd60e51b815260206004820152602360248201527f54454c453a3a6d696e743a206d696e74696e67206e6f7420616c6c6f776564206044820152621e595d60ea1b606482015260840161069d565b6001600160a01b0382166109df5760405162461bcd60e51b815260206004820152601e60248201527f54454c453a206d696e7420746f20746865207a65726f20616464726573730000604482015260640161069d565b6109ec4262093a80611aa7565b600955610a0a610a02600554600260ff16611c69565b6103e8611cf0565b811115610a1657600080fd5b610a2260055482611aa7565b6005556001600160a01b038216600090815260076020526040902054610a489082611aa7565b6001600160a01b0383166000818152600760205260408082209390935591519091906000805160206127ca83398151915290610a879085815260200190565b60405180910390a36001600160a01b038083166000908152600a6020526040812054610ab4921683611b05565b5050565b610ac23382611d4b565b50565b6000438210610b265760405162461bcd60e51b815260206004820152602760248201527f54454c453a3a6765745072696f72566f7465733a206e6f742079657420646574604482015266195c9b5a5b995960ca1b606482015260840161069d565b6001600160a01b0383166000908152600c602052604090205463ffffffff1680610b545760009150506106f4565b6001600160a01b0384166000908152600b602052604081208491610b79600185612532565b63ffffffff90811682526020820192909252604001600020541611610be2576001600160a01b0384166000908152600b6020526040812090610bbc600184612532565b63ffffffff1663ffffffff168152602001908152602001600020600101549150506106f4565b6001600160a01b0384166000908152600b6020908152604080832083805290915290205463ffffffff16831015610c1d5760009150506106f4565b600080610c2b600184612532565b90505b8163ffffffff168163ffffffff161115610cf35760006002610c508484612532565b610c5a919061256d565b610c649083612532565b6001600160a01b0388166000908152600b6020908152604080832063ffffffff8086168552908352928190208151808301909252805490931680825260019093015491810191909152919250871415610cc7576020015194506106f49350505050565b805163ffffffff16871115610cde57819350610cec565b610ce9600183612532565b92505b5050610c2e565b506001600160a01b0385166000908152600b6020908152604080832063ffffffff9094168352929052206001015491505092915050565b6001546001600160a01b03163314610d4157600080fd5b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b600280546105f49061249f565b6006546001600160a01b0316336001600160a01b031614610e215760405162461bcd60e51b8152602060048201526024808201527f54454c453a3a6275726e3a206f6e6c7920746865206d696e7465722063616e206044820152631b5a5b9d60e21b606482015260840161069d565b6001600160a01b038216610e775760405162461bcd60e51b815260206004820181905260248201527f54454c453a206275726e2066726f6d20746865207a65726f2061646472657373604482015260640161069d565b6001600160a01b038216600090815260076020526040902054610e9a9082611a4b565b6001600160a01b03831660009081526007602090815260408083209390935560089052908120610eed91335b6001600160a01b03166001600160a01b031681526020019081526020016000205482611a4b565b6001600160a01b0383166000818152600860209081526040808320338085529083529281902094909455925184815290926000805160206127ea833981519152910160405180910390a3610f4360055482611a4b565b6005556040518181526000906001600160a01b038416906000805160206127ca83398151915290602001610a87565b60008151835114610ffc5760405162461bcd60e51b815260206004820152604860248201527f54454c453a206e756d626572206f66207265636569766572206164647265737360448201527f657320616e64206e756d626572206f6620616d6f756e74732073686f756c6420606482015267189948195c5d585b60c21b608482015260a40161069d565b60005b83518110156110895760006001600160a01b031684828151811061102557611025612590565b60200260200101516001600160a01b0316146110775761107784828151811061105057611050612590565b602002602001015184838151811061106a5761106a612590565b6020026020010151611dcb565b80611081816125a6565b915050610fff565b508260405161109891906125c1565b60405180910390206110a73390565b6001600160a01b03167f5547f7300f7510fad9df5d36f90cbd1099aebd10d4dd65d3fa3ac7af89db29e9846040516106e89190612600565b3360009081526008602090815260408083206001600160a01b038616845290915281205461087e90849061024d9085611a4b565b60006001600160a01b03831661113b5760405162461bcd60e51b815260040161069d906124da565b6111458383611dcb565b6040518281526001600160a01b0384169033906000805160206127ca833981519152906020016106e8565b6001600160a01b0381166000908152600c602052604081205463ffffffff168061119b5760006111de565b6001600160a01b0383166000908152600b60205260408120906111bf600184612532565b63ffffffff1663ffffffff168152602001908152602001600020600101545b9392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86660036040516112179190612644565b60405180910390206112264690565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a90528251808503909101815261014084019092528151919093012061190160f01b610160830152610162820183905261018282018190529192506000906101a20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015611352573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166113c45760405162461bcd60e51b815260206004820152602660248201527f54454c453a3a64656c656761746542795369673a20696e76616c6964207369676044820152656e617475726560d01b606482015260840161069d565b6001600160a01b0381166000908152600d602052604081208054916113e8836125a6565b9190505589146114455760405162461bcd60e51b815260206004820152602260248201527f54454c453a3a64656c656761746542795369673a20696e76616c6964206e6f6e604482015261636560f01b606482015260840161069d565b874211156114a45760405162461bcd60e51b815260206004820152602660248201527f54454c453a3a64656c656761746542795369673a207369676e617475726520656044820152651e1c1a5c995960d21b606482015260840161069d565b6114ae818b611d4b565b505050505b505050505050565b3360008181526008602090815260408083206001600160a01b03881680855290835281842087905590518681529293909290916000805160206127ea833981519152910160405180910390a3604051638f4ffcb160e01b81526001600160a01b03851690638f4ffcb1906115399033908790309088906004016126e0565b600060405180830381600087803b15801561155357600080fd5b505af1158015611567573d6000803e3d6000fd5b506001979650505050505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86660036040516115a79190612644565b60405180910390206115b64690565b604080516020810194909452830191909152606082015230608082015260a00160408051601f1981840301815291815281516020928301206001600160a01b038b166000908152600d90935290822080549193507f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b918661163c836125a6565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e001604051602081830303815290604052805190602001209050600082826040516020016116bb92919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015611726573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166117895760405162461bcd60e51b815260206004820152601f60248201527f54454c453a3a7065726d69743a20696e76616c6964207369676e617475726500604482015260640161069d565b8a6001600160a01b0316816001600160a01b0316146117ea5760405162461bcd60e51b815260206004820152601a60248201527f54454c453a3a7065726d69743a20756e617574686f72697a6564000000000000604482015260640161069d565b8742111561183a5760405162461bcd60e51b815260206004820152601f60248201527f54454c453a3a7065726d69743a207369676e6174757265206578706972656400604482015260640161069d565b6001600160a01b038b81166000818152600860209081526040808320948f16808452948252918290208d905590518c81526000805160206127ea833981519152910160405180910390a35050505050505050505050565b600080546001600160a01b031633146118a957600080fd5b60005460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018490529084169063a9059cbb906044016020604051808303816000875af11580156118fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111de919061271d565b6000546001600160a01b0316331461193757600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b0316336001600160a01b0316146119e25760405162461bcd60e51b815260206004820152603e60248201527f54454c453a3a7365744d696e7465723a206f6e6c7920746865206d696e74657260448201527f2063616e206368616e676520746865206d696e74657220616464726573730000606482015260840161069d565b600654604080516001600160a01b03928316815291831660208301527f3b0007eb941cf645526cbb3a4fdaecda9d28ce4843167d9263b536a1f1edc0f6910160405180910390a1600680546001600160a01b0319166001600160a01b0392909216919091179055565b600082821115611a9d5760405162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015260640161069d565b6111de828461273f565b6000611ab38284612756565b9050828110156106f45760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161069d565b816001600160a01b0316836001600160a01b031614158015611b275750600081115b15611c64576001600160a01b03831615611bca576001600160a01b0383166000908152600c602052604081205463ffffffff169081611b67576000611baa565b6001600160a01b0385166000908152600b6020526040812090611b8b600185612532565b63ffffffff1663ffffffff168152602001908152602001600020600101545b90506000611bb88285611a4b565b9050611bc686848484611e45565b5050505b6001600160a01b03821615611c64576001600160a01b0382166000908152600c602052604081205463ffffffff169081611c05576000611c48565b6001600160a01b0384166000908152600b6020526040812090611c29600185612532565b63ffffffff1663ffffffff168152602001908152602001600020600101545b90506000611c568285611aa7565b90506114b385848484611e45565b505050565b600082611c7857506000611c85565b611c82828461276e565b90505b821580611c9a575081611c98848361278d565b145b6106f45760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161069d565b6000808211611d415760405162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015260640161069d565b6111de828461278d565b6001600160a01b038281166000818152600a6020818152604080842080546007845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a4611dc5828483611b05565b50505050565b611dd86007600033610ec6565b33600090815260076020526040808220929092556001600160a01b03841681522054611e049082611aa7565b6001600160a01b03838116600081815260076020908152604080832095909555338252600a9052838120549181529290922054610ab4928216911683611b05565b6000611e694360405180606001604052806034815260200161280a60349139611fe7565b905060008463ffffffff16118015611ec357506001600160a01b0385166000908152600b6020526040812063ffffffff831691611ea7600188612532565b63ffffffff908116825260208201929092526040016000205416145b15611f0c576001600160a01b0385166000908152600b602052604081208391611eed600188612532565b63ffffffff168152602081019190915260400160002060010155611f9c565b60408051808201825263ffffffff838116825260208083018681526001600160a01b038a166000908152600b83528581208a851682529092529390209151825463ffffffff191691161781559051600191820155611f6b9085906127a1565b6001600160a01b0386166000908152600c60205260409020805463ffffffff191663ffffffff929092169190911790555b60408051848152602081018490526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b600081640100000000841061200f5760405162461bcd60e51b815260040161069d9190612064565b509192915050565b6000815180845260005b8181101561203d57602081850181015186830182015201612021565b8181111561204f576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006111de6020830184612017565b80356001600160a01b038116811461208e57600080fd5b919050565b600080604083850312156120a657600080fd5b6120af83612077565b946020939093013593505050565b6000806000606084860312156120d257600080fd5b6120db84612077565b92506120e960208501612077565b9150604084013590509250925092565b60006020828403121561210b57600080fd5b6111de82612077565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561215357612153612114565b604052919050565b600067ffffffffffffffff82111561217557612175612114565b5060051b60200190565b600082601f83011261219057600080fd5b813560206121a56121a08361215b565b61212a565b82815260059290921b840181019181810190868411156121c457600080fd5b8286015b848110156121df57803583529183019183016121c8565b509695505050505050565b600080604083850312156121fd57600080fd5b823567ffffffffffffffff8082111561221557600080fd5b818501915085601f83011261222957600080fd5b813560206122396121a08361215b565b82815260059290921b8401810191818101908984111561225857600080fd5b948201945b8386101561227d5761226e86612077565b8252948201949082019061225d565b9650508601359250508082111561229357600080fd5b506122a08582860161217f565b9150509250929050565b803560ff8116811461208e57600080fd5b60008060008060008060c087890312156122d457600080fd5b6122dd87612077565b955060208701359450604087013593506122f9606088016122aa565b92506080870135915060a087013590509295509295509295565b60008060006060848603121561232857600080fd5b61233184612077565b92506020808501359250604085013567ffffffffffffffff8082111561235657600080fd5b818701915087601f83011261236a57600080fd5b81358181111561237c5761237c612114565b61238e601f8201601f1916850161212a565b915080825288848285010111156123a457600080fd5b80848401858401376000848284010152508093505050509250925092565b600080600080600080600060e0888a0312156123dd57600080fd5b6123e688612077565b96506123f460208901612077565b95506040880135945060608801359350612410608089016122aa565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561243f57600080fd5b61244883612077565b915061245660208401612077565b90509250929050565b6000806040838503121561247257600080fd5b61247b83612077565b9150602083013563ffffffff8116811461249457600080fd5b809150509250929050565b600181811c908216806124b357607f821691505b602082108114156124d457634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526022908201527f54454c453a207472616e7366657220746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff8381169083168181101561254f5761254f61251c565b039392505050565b634e487b7160e01b600052601260045260246000fd5b600063ffffffff8084168061258457612584612557565b92169190910492915050565b634e487b7160e01b600052603260045260246000fd5b60006000198214156125ba576125ba61251c565b5060010190565b815160009082906020808601845b838110156125f45781516001600160a01b0316855293820193908201906001016125cf565b50929695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156126385783518352928401929184019160010161261c565b50909695505050505050565b600080835481600182811c91508083168061266057607f831692505b602080841082141561268057634e487b7160e01b86526022600452602486fd5b81801561269457600181146126a5576126d2565b60ff198616895284890196506126d2565b60008a81526020902060005b868110156126ca5781548b8201529085019083016126b1565b505084890196505b509498975050505050505050565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061271390830184612017565b9695505050505050565b60006020828403121561272f57600080fd5b815180151581146111de57600080fd5b6000828210156127515761275161251c565b500390565b600082198211156127695761276961251c565b500190565b60008160001904831182151516156127885761278861251c565b500290565b60008261279c5761279c612557565b500490565b600063ffffffff8083168185168083038211156127c0576127c061251c565b0194935050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92554454c453a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473a2646970667358221220d0e5c1c4f29130c4545892d49f0999fd6c7d78abdfd0da46f7e1dd0b952f2e8264736f6c634300080c0033
[ 9 ]
0xf1e39e619dd4e88c1f0dd641a694cc612218c573
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// ////////MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM//////// ////////MMMMMMMMMMMMMMMN0xl;'. .';cd0NMMMMMMMMMMMMMMM//////// ////////MMMMMMMMMMMMNOl,. .,lONMMMMMMMMMMMM//////// ////////MMMMMMMMMMXx;. .,xXMMMMMMMMMM//////// ////////MMMMMMMMWO; ;OWMMMMMMMM//////// ////////MMMMMMMNd. .dNMMMMMMM//////// ////////MMMMMMNo. .',,. .oNMMMMMM//////// ////////MMMMMMx. .,xxlokl. .xMMMMMM//////// ////////MMMMMM, ':cc;. ,dko. :O: ,MMMMMM//////// ////////MMMMMM. ,kl,;ldokXx. :k; .MMMMMM//////// ////////MMMMMM 'xl .:xOc ,xl. MMMMMM//////// ////////MMMMMM ,dl. . ;xl. MMMMMM//////// ////////MMMMMM. .ld;. .lx: .MMMMMM//////// ////////MMMMMMl ,oo;'.;xo. cMMMMMM//////// ////////MMMMMMK; 'cool, ,KMMMMMM//////// ////////MMMMMMM0; ,0MMMMMMM//////// ////////MMMMMMMMKc. .cKMMMMMMMM//////// ////////MMMMMMMMMNk;. ,kNMMMMMMMMM//////// ////////MMMMMMMMMMWNk:. .:kNWMMMMMMMMMM//////// ////////MMMMMMMMMMMMMWKxc,. .,cxKWMMMMMMMMMMMMM//////// ////////MMMMMMMMMMMMWMMMMNOo:'.. ..':oONMMMMMMMMMMMMMMMMM//////// ////////MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM//////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// contract PakCommunityLove is ERC721URIStorage { using Counters for Counters.Counter; Counters.Counter private _tokenIds; constructor(string memory _tokenURI) ERC721("PakCommunityLove", "PCL") { mint(_tokenURI); } function mint(string memory tokenURI) private { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _mint(msg.sender, newItemId); _setTokenURI(newItemId, tokenURI); } } // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol) 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 // 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 (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 (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); }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80636352211e1161008c578063a22cb46511610066578063a22cb46514610224578063b88d4fde14610240578063c87b56dd1461025c578063e985e9c51461028c576100cf565b80636352211e146101a657806370a08231146101d657806395d89b4114610206576100cf565b806301ffc9a7146100d457806306fdde0314610104578063081812fc14610122578063095ea7b31461015257806323b872dd1461016e57806342842e0e1461018a575b600080fd5b6100ee60048036038101906100e991906117f7565b6102bc565b6040516100fb9190611b94565b60405180910390f35b61010c61039e565b6040516101199190611baf565b60405180910390f35b61013c60048036038101906101379190611849565b610430565b6040516101499190611b2d565b60405180910390f35b61016c600480360381019061016791906117bb565b6104b5565b005b610188600480360381019061018391906116b5565b6105cd565b005b6101a4600480360381019061019f91906116b5565b61062d565b005b6101c060048036038101906101bb9190611849565b61064d565b6040516101cd9190611b2d565b60405180910390f35b6101f060048036038101906101eb9190611650565b6106ff565b6040516101fd9190611d71565b60405180910390f35b61020e6107b7565b60405161021b9190611baf565b60405180910390f35b61023e6004803603810190610239919061177f565b610849565b005b61025a60048036038101906102559190611704565b61085f565b005b61027660048036038101906102719190611849565b6108c1565b6040516102839190611baf565b60405180910390f35b6102a660048036038101906102a19190611679565b610a13565b6040516102b39190611b94565b60405180910390f35b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061038757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610397575061039682610acb565b5b9050919050565b6060600080546103ad90611f96565b80601f01602080910402602001604051908101604052809291908181526020018280546103d990611f96565b80156104265780601f106103fb57610100808354040283529160200191610426565b820191906000526020600020905b81548152906001019060200180831161040957829003601f168201915b5050505050905090565b600061043b82610b35565b61047a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047190611cd1565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006104c08261064d565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610531576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052890611d31565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610550610ba1565b73ffffffffffffffffffffffffffffffffffffffff16148061057f575061057e81610579610ba1565b610a13565b5b6105be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105b590611c51565b60405180910390fd5b6105c88383610ba9565b505050565b6105de6105d8610ba1565b82610c62565b61061d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061490611d51565b60405180910390fd5b610628838383610d40565b505050565b6106488383836040518060200160405280600081525061085f565b505050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156106f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ed90611c91565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610770576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076790611c71565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600180546107c690611f96565b80601f01602080910402602001604051908101604052809291908181526020018280546107f290611f96565b801561083f5780601f106108145761010080835404028352916020019161083f565b820191906000526020600020905b81548152906001019060200180831161082257829003601f168201915b5050505050905090565b61085b610854610ba1565b8383610f9c565b5050565b61087061086a610ba1565b83610c62565b6108af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a690611d51565b60405180910390fd5b6108bb84848484611109565b50505050565b60606108cc82610b35565b61090b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090290611cb1565b60405180910390fd5b600060066000848152602001908152602001600020805461092b90611f96565b80601f016020809104026020016040519081016040528092919081815260200182805461095790611f96565b80156109a45780601f10610979576101008083540402835291602001916109a4565b820191906000526020600020905b81548152906001019060200180831161098757829003601f168201915b5050505050905060006109b5611165565b90506000815114156109cb578192505050610a0e565b600082511115610a005780826040516020016109e8929190611b09565b60405160208183030381529060405292505050610a0e565b610a098461117c565b925050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6001816000016000828254019250508190555050565b600081600001549050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16610c1c8361064d565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610c6d82610b35565b610cac576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca390611c31565b60405180910390fd5b6000610cb78361064d565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480610d2657508373ffffffffffffffffffffffffffffffffffffffff16610d0e84610430565b73ffffffffffffffffffffffffffffffffffffffff16145b80610d375750610d368185610a13565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16610d608261064d565b73ffffffffffffffffffffffffffffffffffffffff1614610db6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dad90611cf1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e1d90611bf1565b60405180910390fd5b610e31838383611223565b610e3c600082610ba9565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610e8c9190611eac565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ee39190611e25565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561100b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100290611c11565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516110fc9190611b94565b60405180910390a3505050565b611114848484610d40565b61112084848484611228565b61115f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115690611bd1565b60405180910390fd5b50505050565b606060405180602001604052806000815250905090565b606061118782610b35565b6111c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111bd90611d11565b60405180910390fd5b60006111d0611165565b905060008151116111f0576040518060200160405280600081525061121b565b806111fa846113bf565b60405160200161120b929190611b09565b6040516020818303038152906040525b915050919050565b505050565b60006112498473ffffffffffffffffffffffffffffffffffffffff1661156c565b156113b2578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611272610ba1565b8786866040518563ffffffff1660e01b81526004016112949493929190611b48565b602060405180830381600087803b1580156112ae57600080fd5b505af19250505080156112df57506040513d601f19601f820116820180604052508101906112dc9190611820565b60015b611362573d806000811461130f576040519150601f19603f3d011682016040523d82523d6000602084013e611314565b606091505b5060008151141561135a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161135190611bd1565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506113b7565b600190505b949350505050565b60606000821415611407576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611567565b600082905060005b6000821461143957808061142290611ff9565b915050600a826114329190611e7b565b915061140f565b60008167ffffffffffffffff81111561147b577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156114ad5781602001600182028036833780820191505090505b5090505b60008514611560576001826114c69190611eac565b9150600a856114d59190612042565b60306114e19190611e25565b60f81b81838151811061151d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856115599190611e7b565b94506114b1565b8093505050505b919050565b600080823b905060008111915050919050565b600061159261158d84611db1565b611d8c565b9050828152602081018484840111156115aa57600080fd5b6115b5848285611f54565b509392505050565b6000813590506115cc8161251d565b92915050565b6000813590506115e181612534565b92915050565b6000813590506115f68161254b565b92915050565b60008151905061160b8161254b565b92915050565b600082601f83011261162257600080fd5b813561163284826020860161157f565b91505092915050565b60008135905061164a81612562565b92915050565b60006020828403121561166257600080fd5b6000611670848285016115bd565b91505092915050565b6000806040838503121561168c57600080fd5b600061169a858286016115bd565b92505060206116ab858286016115bd565b9150509250929050565b6000806000606084860312156116ca57600080fd5b60006116d8868287016115bd565b93505060206116e9868287016115bd565b92505060406116fa8682870161163b565b9150509250925092565b6000806000806080858703121561171a57600080fd5b6000611728878288016115bd565b9450506020611739878288016115bd565b935050604061174a8782880161163b565b925050606085013567ffffffffffffffff81111561176757600080fd5b61177387828801611611565b91505092959194509250565b6000806040838503121561179257600080fd5b60006117a0858286016115bd565b92505060206117b1858286016115d2565b9150509250929050565b600080604083850312156117ce57600080fd5b60006117dc858286016115bd565b92505060206117ed8582860161163b565b9150509250929050565b60006020828403121561180957600080fd5b6000611817848285016115e7565b91505092915050565b60006020828403121561183257600080fd5b6000611840848285016115fc565b91505092915050565b60006020828403121561185b57600080fd5b60006118698482850161163b565b91505092915050565b61187b81611ee0565b82525050565b61188a81611ef2565b82525050565b600061189b82611de2565b6118a58185611df8565b93506118b5818560208601611f63565b6118be8161212f565b840191505092915050565b60006118d482611ded565b6118de8185611e09565b93506118ee818560208601611f63565b6118f78161212f565b840191505092915050565b600061190d82611ded565b6119178185611e1a565b9350611927818560208601611f63565b80840191505092915050565b6000611940603283611e09565b915061194b82612140565b604082019050919050565b6000611963602483611e09565b915061196e8261218f565b604082019050919050565b6000611986601983611e09565b9150611991826121de565b602082019050919050565b60006119a9602c83611e09565b91506119b482612207565b604082019050919050565b60006119cc603883611e09565b91506119d782612256565b604082019050919050565b60006119ef602a83611e09565b91506119fa826122a5565b604082019050919050565b6000611a12602983611e09565b9150611a1d826122f4565b604082019050919050565b6000611a35603183611e09565b9150611a4082612343565b604082019050919050565b6000611a58602c83611e09565b9150611a6382612392565b604082019050919050565b6000611a7b602983611e09565b9150611a86826123e1565b604082019050919050565b6000611a9e602f83611e09565b9150611aa982612430565b604082019050919050565b6000611ac1602183611e09565b9150611acc8261247f565b604082019050919050565b6000611ae4603183611e09565b9150611aef826124ce565b604082019050919050565b611b0381611f4a565b82525050565b6000611b158285611902565b9150611b218284611902565b91508190509392505050565b6000602082019050611b426000830184611872565b92915050565b6000608082019050611b5d6000830187611872565b611b6a6020830186611872565b611b776040830185611afa565b8181036060830152611b898184611890565b905095945050505050565b6000602082019050611ba96000830184611881565b92915050565b60006020820190508181036000830152611bc981846118c9565b905092915050565b60006020820190508181036000830152611bea81611933565b9050919050565b60006020820190508181036000830152611c0a81611956565b9050919050565b60006020820190508181036000830152611c2a81611979565b9050919050565b60006020820190508181036000830152611c4a8161199c565b9050919050565b60006020820190508181036000830152611c6a816119bf565b9050919050565b60006020820190508181036000830152611c8a816119e2565b9050919050565b60006020820190508181036000830152611caa81611a05565b9050919050565b60006020820190508181036000830152611cca81611a28565b9050919050565b60006020820190508181036000830152611cea81611a4b565b9050919050565b60006020820190508181036000830152611d0a81611a6e565b9050919050565b60006020820190508181036000830152611d2a81611a91565b9050919050565b60006020820190508181036000830152611d4a81611ab4565b9050919050565b60006020820190508181036000830152611d6a81611ad7565b9050919050565b6000602082019050611d866000830184611afa565b92915050565b6000611d96611da7565b9050611da28282611fc8565b919050565b6000604051905090565b600067ffffffffffffffff821115611dcc57611dcb612100565b5b611dd58261212f565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000611e3082611f4a565b9150611e3b83611f4a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611e7057611e6f612073565b5b828201905092915050565b6000611e8682611f4a565b9150611e9183611f4a565b925082611ea157611ea06120a2565b5b828204905092915050565b6000611eb782611f4a565b9150611ec283611f4a565b925082821015611ed557611ed4612073565b5b828203905092915050565b6000611eeb82611f2a565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015611f81578082015181840152602081019050611f66565b83811115611f90576000848401525b50505050565b60006002820490506001821680611fae57607f821691505b60208210811415611fc257611fc16120d1565b5b50919050565b611fd18261212f565b810181811067ffffffffffffffff82111715611ff057611fef612100565b5b80604052505050565b600061200482611f4a565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561203757612036612073565b5b600182019050919050565b600061204d82611f4a565b915061205883611f4a565b925082612068576120676120a2565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f45524337323155524953746f726167653a2055524920717565727920666f722060008201527f6e6f6e6578697374656e7420746f6b656e000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b61252681611ee0565b811461253157600080fd5b50565b61253d81611ef2565b811461254857600080fd5b50565b61255481611efe565b811461255f57600080fd5b50565b61256b81611f4a565b811461257657600080fd5b5056fea2646970667358221220e2c910f6f28112995d542cababd9c67884c2a1e97f27545713c694365a44a78364736f6c63430008020033
[ 5 ]
0xF1E3AF9152Ad1f93bE2Ab2F8766D41744fAD823a
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; 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; } } 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() internal { 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; } } 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; } } library Counters { using SafeMath for uint256; 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 { // 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); } } 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); } 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); } 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); } 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); } 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; } } 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); } } } } 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)); } } 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))) ); } } 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); } } 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 {} } 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() internal { _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()); } } abstract contract ERC721Pausable is ERC721, Pausable { /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); require(!paused(), "ERC721Pausable: token transfer while paused"); } } abstract contract ERC721Burnable is Context, ERC721 { /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved" ); _burn(tokenId); } } contract CryptoGogos is ERC721Burnable, ERC721Pausable, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; //Counter is a struct in the Counters library using SafeMath for uint256; uint256 private maxSupply = 7777; uint256 private maxSalePrice = 1 ether; event MAX_SUPPLY_UPDATED(uint256 maxSupply); event MAX_PRICE_UPDATED(uint256 maxPrice); constructor(string memory _baseURI) public ERC721("GOGOS", "GOG") { _setBaseURI(_baseURI); } /** * @dev Gets current gogo Pack Price */ function getNFTPackPrice() public view returns (uint256) { uint256 currentSupply = totalSupply(); if (currentSupply >= 7150) { return maxSalePrice.mul(3 * 83333333).div(100000000); } else if (currentSupply >= 3150) { return 0.55 ether; } else if (currentSupply >= 850) { return 0.4 ether; } else { return 0; } } /** * @dev Gets current gogo Price */ function getNFTPrice() public view returns (uint256) { uint256 currentSupply = totalSupply(); if (currentSupply >= 7150) { return maxSalePrice; } else if (currentSupply >= 3150) { return 0.2 ether; } else if (currentSupply >= 1150) { return 0.15 ether; } else if (currentSupply >= 300) { return 0.1 ether; } else if (currentSupply >= 150) { return 0.07 ether; } else { return 0.05 ether; } } /** * @dev Gets current gogo Price */ function cantMint() public view returns (bool) { uint256 currentSupply = totalSupply(); if (currentSupply <= 150 && balanceOf(msg.sender) >= 2) return false; if (currentSupply <= 300 && balanceOf(msg.sender) >= 4) return false; return true; } /** * @dev Gets current gogo Price */ function updateMaxPrice(uint256 _price) public onlyOwner { maxSalePrice = _price; emit MAX_PRICE_UPDATED(_price); } /** * @dev Creates a new token for `to`. Its token ID will be automatically * assigned (and available on the emitted {IERC721-Transfer} event), and the token * URI autogenerated based on the base URI passed at construction. * * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mintByAdmin(address to) public onlyOwner { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); require(newItemId <= maxSupply); _mint(to, newItemId); } /* * _tokenURI is link to json */ function mint() public payable returns (uint256) { require(getNFTPrice() == msg.value, "Ether value sent is not correct"); require(!paused(), "ERC721Pausable: token mint while paused"); uint256 currentSupply = totalSupply(); if (!cantMint()) revert(); _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); require(newItemId <= maxSupply); _mint(msg.sender, newItemId); return newItemId; } /* * _tokenURIs is a array of links to json */ function mintPack() public payable returns (uint256) { require(totalSupply() >= 850, "Pack is not available now"); require( getNFTPackPrice() == msg.value, "Ether value sent is not correct" ); require(!paused(), "ERC721Pausable: token mint while paused"); uint256 newItemId; for (uint256 i = 0; i < 3; i++) { _tokenIds.increment(); newItemId = _tokenIds.current(); require(newItemId <= maxSupply); _mint(msg.sender, newItemId); } return newItemId; } function updateBaseURI(string memory _baseURI) public onlyOwner { _setBaseURI(_baseURI); } /** * @dev Withdraw ether from this contract (Callable by owner) */ function withdraw() external onlyOwner { uint256 balance = address(this).balance; msg.sender.transfer(balance); } /** * @dev See {ERC721-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721Pausable, ERC721) { super._beforeTokenTransfer(from, to, tokenId); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function unpause() public onlyOwner whenPaused { _unpause(); } function updateMaxSupply(uint256 _maxSupply) public onlyOwner { maxSupply = _maxSupply; emit MAX_SUPPLY_UPDATED(_maxSupply); } }
0x6080604052600436106101f95760003560e01c80636352211e1161010d578063931688cb116100a0578063c87b56dd1161006f578063c87b56dd146106cd578063e985e9c51461070a578063f103b43314610747578063f2fde38b14610770578063fb107a4f14610799576101f9565b8063931688cb1461062757806395d89b4114610650578063a22cb4651461067b578063b88d4fde146106a4576101f9565b8063722676e2116100dc578063722676e21461059e5780638456cb59146105bc5780638da5cb5b146105d35780638ea0507b146105fe576101f9565b80636352211e146104e25780636c0360eb1461051f57806370a082311461054a578063715018a614610587576101f9565b80632f745c591161019057806342966c681161015f57806342966c68146103fd578063469619f2146104265780634f6ccce71461044f5780635ac117251461048c5780635c975abb146104b7576101f9565b80632f745c59146103695780633ccfd60b146103a65780633f4ba83a146103bd57806342842e0e146103d4576101f9565b80631249c58b116101cc5780631249c58b146102cc57806318160ddd146102ea57806319e325151461031557806323b872dd14610340576101f9565b806301ffc9a7146101fe57806306fdde031461023b578063081812fc14610266578063095ea7b3146102a3575b600080fd5b34801561020a57600080fd5b50610225600480360381019061022091906135f0565b6107c4565b6040516102329190614234565b60405180910390f35b34801561024757600080fd5b5061025061082b565b60405161025d919061424f565b60405180910390f35b34801561027257600080fd5b5061028d60048036038101906102889190613683565b6108cd565b60405161029a91906141b2565b60405180910390f35b3480156102af57600080fd5b506102ca60048036038101906102c591906135b4565b610952565b005b6102d4610a6a565b6040516102e191906145f1565b60405180910390f35b3480156102f657600080fd5b506102ff610b53565b60405161030c91906145f1565b60405180910390f35b34801561032157600080fd5b5061032a610b64565b6040516103379190614234565b60405180910390f35b34801561034c57600080fd5b50610367600480360381019061036291906134ae565b610bcd565b005b34801561037557600080fd5b50610390600480360381019061038b91906135b4565b610c2d565b60405161039d91906145f1565b60405180910390f35b3480156103b257600080fd5b506103bb610c88565b005b3480156103c957600080fd5b506103d2610d53565b005b3480156103e057600080fd5b506103fb60048036038101906103f691906134ae565b610e20565b005b34801561040957600080fd5b50610424600480360381019061041f9190613683565b610e40565b005b34801561043257600080fd5b5061044d60048036038101906104489190613683565b610e9c565b005b34801561045b57600080fd5b5061047660048036038101906104719190613683565b610f59565b60405161048391906145f1565b60405180910390f35b34801561049857600080fd5b506104a1610f7c565b6040516104ae91906145f1565b60405180910390f35b3480156104c357600080fd5b506104cc611006565b6040516104d99190614234565b60405180910390f35b3480156104ee57600080fd5b5061050960048036038101906105049190613683565b61101d565b60405161051691906141b2565b60405180910390f35b34801561052b57600080fd5b50610534611054565b604051610541919061424f565b60405180910390f35b34801561055657600080fd5b50610571600480360381019061056c9190613449565b6110f6565b60405161057e91906145f1565b60405180910390f35b34801561059357600080fd5b5061059c6111b5565b005b6105a66112f2565b6040516105b391906145f1565b60405180910390f35b3480156105c857600080fd5b506105d1611426565b005b3480156105df57600080fd5b506105e86114f4565b6040516105f591906141b2565b60405180910390f35b34801561060a57600080fd5b5061062560048036038101906106209190613449565b61151e565b005b34801561063357600080fd5b5061064e60048036038101906106499190613642565b6115cf565b005b34801561065c57600080fd5b50610665611657565b604051610672919061424f565b60405180910390f35b34801561068757600080fd5b506106a2600480360381019061069d9190613578565b6116f9565b005b3480156106b057600080fd5b506106cb60048036038101906106c691906134fd565b61187a565b005b3480156106d957600080fd5b506106f460048036038101906106ef9190613683565b6118dc565b604051610701919061424f565b60405180910390f35b34801561071657600080fd5b50610731600480360381019061072c9190613472565b611a5f565b60405161073e9190614234565b60405180910390f35b34801561075357600080fd5b5061076e60048036038101906107699190613683565b611af3565b005b34801561077c57600080fd5b5061079760048036038101906107929190613449565b611bb0565b005b3480156107a557600080fd5b506107ae611d5c565b6040516107bb91906145f1565b60405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108c35780601f10610898576101008083540402835291602001916108c3565b820191906000526020600020905b8154815290600101906020018083116108a657829003601f168201915b5050505050905090565b60006108d882611df2565b610917576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090e906144f1565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061095d8261101d565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c590614571565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166109ed611e0f565b73ffffffffffffffffffffffffffffffffffffffff161480610a1c5750610a1b81610a16611e0f565b611a5f565b5b610a5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5290614431565b60405180910390fd5b610a658383611e17565b505050565b600034610a75611d5c565b14610ab5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aac90614371565b60405180910390fd5b610abd611006565b15610afd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af4906144b1565b60405180910390fd5b6000610b07610b53565b9050610b11610b64565b610b1a57600080fd5b610b24600b611ed0565b6000610b30600b611ee6565b9050600c54811115610b4157600080fd5b610b4b3382611ef4565b809250505090565b6000610b5f6002612082565b905090565b600080610b6f610b53565b905060968111158015610b8b57506002610b88336110f6565b10155b15610b9a576000915050610bca565b61012c8111158015610bb557506004610bb2336110f6565b10155b15610bc4576000915050610bca565b60019150505b90565b610bde610bd8611e0f565b82612097565b610c1d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1490614591565b60405180910390fd5b610c28838383612175565b505050565b6000610c8082600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061238c90919063ffffffff16565b905092915050565b610c90611e0f565b73ffffffffffffffffffffffffffffffffffffffff16610cae6114f4565b73ffffffffffffffffffffffffffffffffffffffff1614610d04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfb90614511565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610d4f573d6000803e3d6000fd5b5050565b610d5b611e0f565b73ffffffffffffffffffffffffffffffffffffffff16610d796114f4565b73ffffffffffffffffffffffffffffffffffffffff1614610dcf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc690614511565b60405180910390fd5b610dd7611006565b610e16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e0d906142b1565b60405180910390fd5b610e1e6123a6565b565b610e3b8383836040518060200160405280600081525061187a565b505050565b610e51610e4b611e0f565b82612097565b610e90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e87906145d1565b60405180910390fd5b610e9981612448565b50565b610ea4611e0f565b73ffffffffffffffffffffffffffffffffffffffff16610ec26114f4565b73ffffffffffffffffffffffffffffffffffffffff1614610f18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f0f90614511565b60405180910390fd5b80600d819055507f4b9d786179e2599e65d6eb10cdb73af77287bb79b562194500404a8612be165781604051610f4e91906145f1565b60405180910390a150565b600080610f7083600261258290919063ffffffff16565b50905080915050919050565b600080610f87610b53565b9050611bee8110610fc957610fc16305f5e100610fb3630ee6b27f600d546125ae90919063ffffffff16565b61261e90919063ffffffff16565b915050611003565b610c4e8110610fe3576707a1fe1602770000915050611003565b6103528110610ffd5767058d15e176280000915050611003565b60009150505b90565b6000600a60009054906101000a900460ff16905090565b600061104d8260405180606001604052806029815260200161487d6029913960026126749092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110ec5780601f106110c1576101008083540402835291602001916110ec565b820191906000526020600020905b8154815290600101906020018083116110cf57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115e90614451565b60405180910390fd5b6111ae600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612693565b9050919050565b6111bd611e0f565b73ffffffffffffffffffffffffffffffffffffffff166111db6114f4565b73ffffffffffffffffffffffffffffffffffffffff1614611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890614511565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60006103526112ff610b53565b1015611340576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133790614391565b60405180910390fd5b34611349610f7c565b14611389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138090614371565b60405180910390fd5b611391611006565b156113d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c8906144b1565b60405180910390fd5b600080600090505b600381101561141e576113ec600b611ed0565b6113f6600b611ee6565b9150600c5482111561140757600080fd5b6114113383611ef4565b80806001019150506113d9565b508091505090565b61142e611e0f565b73ffffffffffffffffffffffffffffffffffffffff1661144c6114f4565b73ffffffffffffffffffffffffffffffffffffffff16146114a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149990614511565b60405180910390fd5b6114aa611006565b156114ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e190614411565b60405180910390fd5b6114f26126a8565b565b6000600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611526611e0f565b73ffffffffffffffffffffffffffffffffffffffff166115446114f4565b73ffffffffffffffffffffffffffffffffffffffff161461159a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159190614511565b60405180910390fd5b6115a4600b611ed0565b60006115b0600b611ee6565b9050600c548111156115c157600080fd5b6115cb8282611ef4565b5050565b6115d7611e0f565b73ffffffffffffffffffffffffffffffffffffffff166115f56114f4565b73ffffffffffffffffffffffffffffffffffffffff161461164b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164290614511565b60405180910390fd5b6116548161274b565b50565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156116ef5780601f106116c4576101008083540402835291602001916116ef565b820191906000526020600020905b8154815290600101906020018083116116d257829003601f168201915b5050505050905090565b611701611e0f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561176f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176690614351565b60405180910390fd5b806005600061177c611e0f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611829611e0f565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161186e9190614234565b60405180910390a35050565b61188b611885611e0f565b83612097565b6118ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c190614591565b60405180910390fd5b6118d684848484612765565b50505050565b60606118e782611df2565b611926576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191d90614551565b60405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156119cf5780601f106119a4576101008083540402835291602001916119cf565b820191906000526020600020905b8154815290600101906020018083116119b257829003601f168201915b5050505050905060606119e0611054565b90506000815114156119f6578192505050611a5a565b600082511115611a2b578082604051602001611a1392919061418e565b60405160208183030381529060405292505050611a5a565b80611a35856127c1565b604051602001611a4692919061418e565b604051602081830303815290604052925050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611afb611e0f565b73ffffffffffffffffffffffffffffffffffffffff16611b196114f4565b73ffffffffffffffffffffffffffffffffffffffff1614611b6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6690614511565b60405180910390fd5b80600c819055507fd8419718ffd2a34111add9f7b4dca791378fc702c0803a6c6b12bf0b1896278d81604051611ba591906145f1565b60405180910390a150565b611bb8611e0f565b73ffffffffffffffffffffffffffffffffffffffff16611bd66114f4565b73ffffffffffffffffffffffffffffffffffffffff1614611c2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c2390614511565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c93906142f1565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080611d67610b53565b9050611bee8110611d7d57600d54915050611def565b610c4e8110611d97576702c68af0bb140000915050611def565b61047e8110611db157670214e8348c4f0000915050611def565b61012c8110611dcb5767016345785d8a0000915050611def565b60968110611de35766f8b0a10e470000915050611def565b66b1a2bc2ec500009150505b90565b6000611e0882600261290890919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611e8a8361101d565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6001816000016000828254019250508190555050565b600081600001549050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5b90614491565b60405180910390fd5b611f6d81611df2565b15611fad576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fa490614311565b60405180910390fd5b611fb960008383612922565b61200a81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061293290919063ffffffff16565b506120218183600261294c9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600061209082600001612981565b9050919050565b60006120a282611df2565b6120e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120d8906143d1565b60405180910390fd5b60006120ec8361101d565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061215b57508373ffffffffffffffffffffffffffffffffffffffff16612143846108cd565b73ffffffffffffffffffffffffffffffffffffffff16145b8061216c575061216b8185611a5f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166121958261101d565b73ffffffffffffffffffffffffffffffffffffffff16146121eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121e290614531565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561225b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225290614331565b60405180910390fd5b612266838383612922565b612271600082611e17565b6122c281600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061299290919063ffffffff16565b5061231481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061293290919063ffffffff16565b5061232b8183600261294c9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061239b83600001836129ac565b60001c905092915050565b6123ae611006565b6123ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123e4906142b1565b60405180910390fd5b6000600a60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612431611e0f565b60405161243e91906141cd565b60405180910390a1565b60006124538261101d565b905061246181600084612922565b61246c600083611e17565b600060086000848152602001908152602001600020805460018160011615610100020316600290049050146124bb576008600083815260200190815260200160002060006124ba9190613253565b5b61250c82600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061299290919063ffffffff16565b50612521826002612a1990919063ffffffff16565b5081600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6000806000806125958660000186612a33565b915091508160001c8160001c9350935050509250929050565b6000808314156125c15760009050612618565b60008284029050828482816125d257fe5b0414612613576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161260a906144d1565b60405180910390fd5b809150505b92915050565b6000808211612662576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612659906143f1565b60405180910390fd5b81838161266b57fe5b04905092915050565b6000612687846000018460001b84612ab6565b60001c90509392505050565b60006126a182600001612b47565b9050919050565b6126b0611006565b156126f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126e790614411565b60405180910390fd5b6001600a60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612734611e0f565b60405161274191906141cd565b60405180910390a1565b806009908051906020019061276192919061329b565b5050565b612770848484612175565b61277c84848484612b58565b6127bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127b2906142d1565b60405180910390fd5b50505050565b60606000821415612809576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612903565b600082905060005b60008214612833578080600101915050600a828161282b57fe5b049150612811565b60608167ffffffffffffffff8111801561284c57600080fd5b506040519080825280601f01601f19166020018201604052801561287f5781602001600182028036833780820191505090505b50905060006001830390508593505b600084146128fb57600a84816128a057fe5b0660300160f81b828280600190039350815181106128ba57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84816128f357fe5b04935061288e565b819450505050505b919050565b600061291a836000018360001b612cbc565b905092915050565b61292d838383612cdf565b505050565b6000612944836000018360001b612d37565b905092915050565b6000612978846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b612da7565b90509392505050565b600081600001805490509050919050565b60006129a4836000018360001b612e83565b905092915050565b6000818360000180549050116129f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129ee90614271565b60405180910390fd5b826000018281548110612a0657fe5b9060005260206000200154905092915050565b6000612a2b836000018360001b612f6b565b905092915050565b60008082846000018054905011612a7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a7690614471565b60405180910390fd5b6000846000018481548110612a9057fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390612b18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b0f919061424f565b60405180910390fd5b50846000016001820381548110612b2b57fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b6000612b798473ffffffffffffffffffffffffffffffffffffffff16613084565b612b865760019050612cb4565b6060612c4d63150b7a0260e01b612b9b611e0f565b888787604051602401612bb194939291906141e8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405180606001604052806032815260200161484b603291398773ffffffffffffffffffffffffffffffffffffffff166130979092919063ffffffff16565b9050600081806020019051810190612c659190613619565b905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b612cea8383836130af565b612cf2611006565b15612d32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d2990614291565b60405180910390fd5b505050565b6000612d4383836130b4565b612d9c578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612da1565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415612e4e57846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050612e7c565b82856000016001830381548110612e6157fe5b90600052602060002090600202016001018190555060009150505b9392505050565b60008083600101600084815260200190815260200160002054905060008114612f5f5760006001820390506000600186600001805490500390506000866000018281548110612ece57fe5b9060005260206000200154905080876000018481548110612eeb57fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612f2357fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612f65565b60009150505b92915050565b600080836001016000848152602001908152602001600020549050600081146130785760006001820390506000600186600001805490500390506000866000018281548110612fb657fe5b9060005260206000209060020201905080876000018481548110612fd657fe5b906000526020600020906002020160008201548160000155600182015481600101559050506001830187600101600083600001548152602001908152602001600020819055508660000180548061302957fe5b600190038181906000526020600020906002020160008082016000905560018201600090555050905586600101600087815260200190815260200160002060009055600194505050505061307e565b60009150505b92915050565b600080823b905060008111915050919050565b60606130a684846000856130d7565b90509392505050565b505050565b600080836001016000848152602001908152602001600020541415905092915050565b60608247101561311c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613113906143b1565b60405180910390fd5b61312585613084565b613164576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161315b906145b1565b60405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff16858760405161318e9190614177565b60006040518083038185875af1925050503d80600081146131cb576040519150601f19603f3d011682016040523d82523d6000602084013e6131d0565b606091505b50915091506131e08282866131ec565b92505050949350505050565b606083156131fc5782905061324c565b60008351111561320f5782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613243919061424f565b60405180910390fd5b9392505050565b50805460018160011615610100020316600290046000825580601f106132795750613298565b601f016020900490600052602060002090810190613297919061331b565b5b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106132dc57805160ff191683800117855561330a565b8280016001018555821561330a579182015b828111156133095782518255916020019190600101906132ee565b5b509050613317919061331b565b5090565b5b8082111561333457600081600090555060010161331c565b5090565b600081359050613347816147ee565b92915050565b60008135905061335c81614805565b92915050565b6000813590506133718161481c565b92915050565b6000815190506133868161481c565b92915050565b600082601f83011261339d57600080fd5b81356133b06133ab82614639565b61460c565b915080825260208301602083018583830111156133cc57600080fd5b6133d783828461479b565b50505092915050565b600082601f8301126133f157600080fd5b81356134046133ff82614665565b61460c565b9150808252602083016020830185838301111561342057600080fd5b61342b83828461479b565b50505092915050565b60008135905061344381614833565b92915050565b60006020828403121561345b57600080fd5b600061346984828501613338565b91505092915050565b6000806040838503121561348557600080fd5b600061349385828601613338565b92505060206134a485828601613338565b9150509250929050565b6000806000606084860312156134c357600080fd5b60006134d186828701613338565b93505060206134e286828701613338565b92505060406134f386828701613434565b9150509250925092565b6000806000806080858703121561351357600080fd5b600061352187828801613338565b945050602061353287828801613338565b935050604061354387828801613434565b925050606085013567ffffffffffffffff81111561356057600080fd5b61356c8782880161338c565b91505092959194509250565b6000806040838503121561358b57600080fd5b600061359985828601613338565b92505060206135aa8582860161334d565b9150509250929050565b600080604083850312156135c757600080fd5b60006135d585828601613338565b92505060206135e685828601613434565b9150509250929050565b60006020828403121561360257600080fd5b600061361084828501613362565b91505092915050565b60006020828403121561362b57600080fd5b600061363984828501613377565b91505092915050565b60006020828403121561365457600080fd5b600082013567ffffffffffffffff81111561366e57600080fd5b61367a848285016133e0565b91505092915050565b60006020828403121561369557600080fd5b60006136a384828501613434565b91505092915050565b6136b581614765565b82525050565b6136c4816146f1565b82525050565b6136d3816146df565b82525050565b6136e281614703565b82525050565b60006136f382614691565b6136fd81856146a7565b935061370d8185602086016147aa565b613716816147dd565b840191505092915050565b600061372c82614691565b61373681856146b8565b93506137468185602086016147aa565b80840191505092915050565b600061375d8261469c565b61376781856146c3565b93506137778185602086016147aa565b613780816147dd565b840191505092915050565b60006137968261469c565b6137a081856146d4565b93506137b08185602086016147aa565b80840191505092915050565b60006137c96022836146c3565b91507f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061382f602b836146c3565b91507f4552433732315061757361626c653a20746f6b656e207472616e73666572207760008301527f68696c65207061757365640000000000000000000000000000000000000000006020830152604082019050919050565b60006138956014836146c3565b91507f5061757361626c653a206e6f74207061757365640000000000000000000000006000830152602082019050919050565b60006138d56032836146c3565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b600061393b6026836146c3565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006139a1601c836146c3565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b60006139e16024836146c3565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613a476019836146c3565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000613a87601f836146c3565b91507f45746865722076616c75652073656e74206973206e6f7420636f7272656374006000830152602082019050919050565b6000613ac76019836146c3565b91507f5061636b206973206e6f7420617661696c61626c65206e6f77000000000000006000830152602082019050919050565b6000613b076026836146c3565b91507f416464726573733a20696e73756666696369656e742062616c616e636520666f60008301527f722063616c6c00000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613b6d602c836146c3565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613bd3601a836146c3565b91507f536166654d6174683a206469766973696f6e206279207a65726f0000000000006000830152602082019050919050565b6000613c136010836146c3565b91507f5061757361626c653a20706175736564000000000000000000000000000000006000830152602082019050919050565b6000613c536038836146c3565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000613cb9602a836146c3565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000613d1f6022836146c3565b91507f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613d856020836146c3565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000613dc56027836146c3565b91507f4552433732315061757361626c653a20746f6b656e206d696e74207768696c6560008301527f20706175736564000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613e2b6021836146c3565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613e91602c836146c3565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613ef76020836146c3565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613f376029836146c3565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000613f9d602f836146c3565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b60006140036021836146c3565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006140696031836146c3565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b60006140cf601d836146c3565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b600061410f6030836146c3565b91507f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f766564000000000000000000000000000000006020830152604082019050919050565b6141718161475b565b82525050565b60006141838284613721565b915081905092915050565b600061419a828561378b565b91506141a6828461378b565b91508190509392505050565b60006020820190506141c760008301846136ca565b92915050565b60006020820190506141e260008301846136ac565b92915050565b60006080820190506141fd60008301876136bb565b61420a60208301866136ca565b6142176040830185614168565b818103606083015261422981846136e8565b905095945050505050565b600060208201905061424960008301846136d9565b92915050565b600060208201905081810360008301526142698184613752565b905092915050565b6000602082019050818103600083015261428a816137bc565b9050919050565b600060208201905081810360008301526142aa81613822565b9050919050565b600060208201905081810360008301526142ca81613888565b9050919050565b600060208201905081810360008301526142ea816138c8565b9050919050565b6000602082019050818103600083015261430a8161392e565b9050919050565b6000602082019050818103600083015261432a81613994565b9050919050565b6000602082019050818103600083015261434a816139d4565b9050919050565b6000602082019050818103600083015261436a81613a3a565b9050919050565b6000602082019050818103600083015261438a81613a7a565b9050919050565b600060208201905081810360008301526143aa81613aba565b9050919050565b600060208201905081810360008301526143ca81613afa565b9050919050565b600060208201905081810360008301526143ea81613b60565b9050919050565b6000602082019050818103600083015261440a81613bc6565b9050919050565b6000602082019050818103600083015261442a81613c06565b9050919050565b6000602082019050818103600083015261444a81613c46565b9050919050565b6000602082019050818103600083015261446a81613cac565b9050919050565b6000602082019050818103600083015261448a81613d12565b9050919050565b600060208201905081810360008301526144aa81613d78565b9050919050565b600060208201905081810360008301526144ca81613db8565b9050919050565b600060208201905081810360008301526144ea81613e1e565b9050919050565b6000602082019050818103600083015261450a81613e84565b9050919050565b6000602082019050818103600083015261452a81613eea565b9050919050565b6000602082019050818103600083015261454a81613f2a565b9050919050565b6000602082019050818103600083015261456a81613f90565b9050919050565b6000602082019050818103600083015261458a81613ff6565b9050919050565b600060208201905081810360008301526145aa8161405c565b9050919050565b600060208201905081810360008301526145ca816140c2565b9050919050565b600060208201905081810360008301526145ea81614102565b9050919050565b60006020820190506146066000830184614168565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561462f57600080fd5b8060405250919050565b600067ffffffffffffffff82111561465057600080fd5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff82111561467c57600080fd5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006146ea8261473b565b9050919050565b60006146fc8261473b565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061477082614777565b9050919050565b600061478282614789565b9050919050565b60006147948261473b565b9050919050565b82818337600083830152505050565b60005b838110156147c85780820151818401526020810190506147ad565b838111156147d7576000848401525b50505050565b6000601f19601f8301169050919050565b6147f7816146df565b811461480257600080fd5b50565b61480e81614703565b811461481957600080fd5b50565b6148258161470f565b811461483057600080fd5b50565b61483c8161475b565b811461484757600080fd5b5056fe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea2646970667358221220e5012c02ec2c17618d7710a25f17f0c0f410a6118d027bdba0f534cda8829ebe64736f6c63430007000033
[ 5, 12 ]
0xf1e3f9b0db05ab76489948972d0dd8297adbb959
pragma solidity ^0.4.20; /** * @title SafeMath */ library SafeMath { /** * Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * 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; } /** * 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; } /** * 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; } } contract Thetoken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } 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); } 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); } contract RealivePlatformTokens is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; string public constant name = "Realive platform"; // Token Names string public constant symbol = "RLIVE"; // Ticker or Symbol uint public constant decimals = 18; // Decimals Points uint256 public totalSupply = 500000000000000000000000000; // Based with WEI uint256 public totalDistributed = 0; uint256 public tokensPerEth = 220000000000000000000000; uint256 public constant minContribution = 1 ether / 100; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function doAirdrop(address _participant, uint _amount) internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function adminClaimAirdrop(address _participant, uint _amount) public onlyOwner { doAirdrop(_participant, _amount); } function adminClaimAirdropMultiple(address[] _addresses, uint _amount) public onlyOwner { for (uint i = 0; i < _addresses.length; i++) doAirdrop(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; require( msg.value >= minContribution ); require( msg.value > 0 ); tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (tokens > 0) { distr(investor, tokens); } if (totalDistributed >= totalSupply) { distributionFinished = true; } } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } // mitigates the ERC20 short address attack modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { // mitigates the ERC20 spend/approval race condition if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ Thetoken t = Thetoken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawThetokens(address _tokenContract) onlyOwner public returns (bool) { Thetoken token = Thetoken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x6080604052600436106101325763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461013c578063095ea7b3146101c657806318160ddd146101fe57806323b872dd14610225578063313ce5671461024f5780633ccfd60b1461026457806342966c681461027957806343aefca0146102915780634a63464d146102b257806367220fd7146102d657806370a082311461032d57806395d89b411461034e5780639b1cbccc146103635780639ea407be14610378578063a9059cbb14610390578063aa6ca80814610132578063aaffadf3146103b4578063c108d542146103c9578063c489744b146103de578063cbdd69b514610405578063dd62ed3e1461041a578063efca2eed14610441578063f2fde38b14610456575b61013a610477565b005b34801561014857600080fd5b5061015161050f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561018b578181015183820152602001610173565b50505050905090810190601f1680156101b85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101d257600080fd5b506101ea600160a060020a0360043516602435610546565b604080519115158252519081900360200190f35b34801561020a57600080fd5b506102136105ee565b60408051918252519081900360200190f35b34801561023157600080fd5b506101ea600160a060020a03600435811690602435166044356105f4565b34801561025b57600080fd5b50610213610767565b34801561027057600080fd5b5061013a61076c565b34801561028557600080fd5b5061013a6004356107ce565b34801561029d57600080fd5b506101ea600160a060020a03600435166108ad565b3480156102be57600080fd5b5061013a600160a060020a0360043516602435610a01565b3480156102e257600080fd5b506040805160206004803580820135838102808601850190965280855261013a953695939460249493850192918291850190849080828437509497505093359450610a229350505050565b34801561033957600080fd5b50610213600160a060020a0360043516610a72565b34801561035a57600080fd5b50610151610a8d565b34801561036f57600080fd5b506101ea610ac4565b34801561038457600080fd5b5061013a600435610b2a565b34801561039c57600080fd5b506101ea600160a060020a0360043516602435610b7c565b3480156103c057600080fd5b50610213610c5b565b3480156103d557600080fd5b506101ea610c66565b3480156103ea57600080fd5b50610213600160a060020a0360043581169060243516610c6f565b34801561041157600080fd5b50610213610d20565b34801561042657600080fd5b50610213600160a060020a0360043581169060243516610d26565b34801561044d57600080fd5b50610213610d51565b34801561046257600080fd5b5061013a600160a060020a0360043516610d57565b600754600090819060ff161561048c57600080fd5b60009150662386f26fc100003410156104a457600080fd5b600034116104b157600080fd5b600654670de0b6b3a7640000906104ce903463ffffffff610da916565b8115156104d757fe5b04915033905060008211156104f2576104f08183610dd2565b505b6004546005541061050b576007805460ff191660011790555b5050565b60408051808201909152601081527f5265616c69766520706c6174666f726d00000000000000000000000000000000602082015281565b600081158015906105795750336000908152600360209081526040808320600160a060020a038716845290915290205415155b15610586575060006105e8565b336000818152600360209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60045481565b60006060606436101561060357fe5b600160a060020a038416151561061857600080fd5b600160a060020a03851660009081526002602052604090205483111561063d57600080fd5b600160a060020a038516600090815260036020908152604080832033845290915290205483111561066d57600080fd5b600160a060020a038516600090815260026020526040902054610696908463ffffffff610eae16565b600160a060020a03861660009081526002602090815260408083209390935560038152828220338352905220546106d3908463ffffffff610eae16565b600160a060020a038087166000908152600360209081526040808320338452825280832094909455918716815260029091522054610717908463ffffffff610ec016565b600160a060020a038086166000818152600260209081526040918290209490945580518781529051919392891692600080516020610fe183398151915292918290030190a3506001949350505050565b601281565b6001546000908190600160a060020a0316331461078857600080fd5b50506001546040513091823191600160a060020a03909116906108fc8315029083906000818181858888f193505050501580156107c9573d6000803e3d6000fd5b505050565b600154600090600160a060020a031633146107e857600080fd5b3360009081526002602052604090205482111561080457600080fd5b5033600081815260026020526040902054610825908363ffffffff610eae16565b600160a060020a038216600090815260026020526040902055600454610851908363ffffffff610eae16565b600455600554610867908363ffffffff610eae16565b600555604080518381529051600160a060020a038316917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a25050565b60015460009081908190600160a060020a031633146108cb57600080fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051859350600160a060020a038416916370a082319160248083019260209291908290030181600087803b15801561092f57600080fd5b505af1158015610943573d6000803e3d6000fd5b505050506040513d602081101561095957600080fd5b5051600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810184905290519293509084169163a9059cbb916044808201926020929091908290030181600087803b1580156109cd57600080fd5b505af11580156109e1573d6000803e3d6000fd5b505050506040513d60208110156109f757600080fd5b5051949350505050565b600154600160a060020a03163314610a1857600080fd5b61050b8282610ecd565b600154600090600160a060020a03163314610a3c57600080fd5b5060005b82518110156107c957610a6a8382815181101515610a5a57fe5b9060200190602002015183610ecd565b600101610a40565b600160a060020a031660009081526002602052604090205490565b60408051808201909152600581527f524c495645000000000000000000000000000000000000000000000000000000602082015281565b600154600090600160a060020a03163314610ade57600080fd5b60075460ff1615610aee57600080fd5b6007805460ff191660011790556040517f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc90600090a150600190565b600154600160a060020a03163314610b4157600080fd5b60068190556040805182815290517ff7729fa834bbef70b6d3257c2317a562aa88b56c81b544814f93dc5963a2c0039181900360200190a150565b600060406044361015610b8b57fe5b600160a060020a0384161515610ba057600080fd5b33600090815260026020526040902054831115610bbc57600080fd5b33600090815260026020526040902054610bdc908463ffffffff610eae16565b3360009081526002602052604080822092909255600160a060020a03861681522054610c0e908463ffffffff610ec016565b600160a060020a038516600081815260026020908152604091829020939093558051868152905191923392600080516020610fe18339815191529281900390910190a35060019392505050565b662386f26fc1000081565b60075460ff1681565b600080600084915081600160a060020a03166370a08231856040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b158015610ceb57600080fd5b505af1158015610cff573d6000803e3d6000fd5b505050506040513d6020811015610d1557600080fd5b505195945050505050565b60065481565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b60055481565b600154600160a060020a03163314610d6e57600080fd5b600160a060020a03811615610da6576001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b6000821515610dba575060006105e8565b50818102818382811515610dca57fe5b04146105e857fe5b60075460009060ff1615610de557600080fd5b600554610df8908363ffffffff610ec016565b600555600160a060020a038316600090815260026020526040902054610e24908363ffffffff610ec016565b600160a060020a038416600081815260026020908152604091829020939093558051858152905191927f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a7792918290030190a2604080518381529051600160a060020a03851691600091600080516020610fe18339815191529181900360200190a350600192915050565b600082821115610eba57fe5b50900390565b818101828110156105e857fe5b60008111610eda57600080fd5b60045460055410610eea57600080fd5b600160a060020a038216600090815260026020526040902054610f13908263ffffffff610ec016565b600160a060020a038316600090815260026020526040902055600554610f3f908263ffffffff610ec016565b600581905560045411610f5a576007805460ff191660011790555b600160a060020a0382166000818152600260209081526040918290205482518581529182015281517fada993ad066837289fe186cd37227aa338d27519a8a1547472ecb9831486d272929181900390910190a2604080518281529051600160a060020a03841691600091600080516020610fe18339815191529181900360200190a350505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a72305820cf1990571ec7dab91592f14365197228c719c7890ca2c995a41895c0836f2d9a0029
[ 14 ]
0xf1e42cde4008c9660087c020c0d267f16d2a0bb8
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; } } /** * @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); } 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 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 _supply(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: supply 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 * supplying 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 supplyed 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 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; } } contract REVGOLD is ERC20("Revolution Gold", "RVG"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function supply(address _to, uint256 _amount) public onlyOwner { _supply(_to, _amount); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb14610485578063dd62ed3e146104e9578063f2b9fdb814610561578063f2fde38b146105af576100f5565b8063715018a6146103605780638da5cb5b1461036a57806395d89b411461039e578063a457c2d714610421576100f5565b806323b872dd116100d357806323b872dd146101ff578063313ce5671461028357806339509351146102a457806370a0823114610308576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e1575b600080fd5b6101026105f3565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610695565b60405180821515815260200191505060405180910390f35b6101e96106b3565b6040518082815260200191505060405180910390f35b61026b6004803603606081101561021557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106bd565b60405180821515815260200191505060405180910390f35b61028b610796565b604051808260ff16815260200191505060405180910390f35b6102f0600480360360408110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107ad565b60405180821515815260200191505060405180910390f35b61034a6004803603602081101561031e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610860565b6040518082815260200191505060405180910390f35b6103686108a8565b005b610372610a33565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103a6610a5d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103e65780820151818401526020810190506103cb565b50505050905090810190601f1680156104135780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61046d6004803603604081101561043757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aff565b60405180821515815260200191505060405180910390f35b6104d16004803603604081101561049b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bcc565b60405180821515815260200191505060405180910390f35b61054b600480360360408110156104ff57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bea565b6040518082815260200191505060405180910390f35b6105ad6004803603604081101561057757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c71565b005b6105f1600480360360208110156105c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d49565b005b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561068b5780601f106106605761010080835404028352916020019161068b565b820191906000526020600020905b81548152906001019060200180831161066e57829003601f168201915b5050505050905090565b60006106a96106a2610f59565b8484610f61565b6001905092915050565b6000600254905090565b60006106ca848484611158565b61078b846106d6610f59565b610786856040518060600160405280602881526020016117c360289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061073c610f59565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114199092919063ffffffff16565b610f61565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006108566107ba610f59565b8461085185600160006107cb610f59565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114d990919063ffffffff16565b610f61565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108b0610f59565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610972576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610af55780601f10610aca57610100808354040283529160200191610af5565b820191906000526020600020905b815481529060010190602001808311610ad857829003601f168201915b5050505050905090565b6000610bc2610b0c610f59565b84610bbd856040518060600160405280602581526020016118346025913960016000610b36610f59565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114199092919063ffffffff16565b610f61565b6001905092915050565b6000610be0610bd9610f59565b8484611158565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610c79610f59565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610d458282611561565b5050565b610d51610f59565b73ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e13576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e99576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806117346026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fe7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806118106024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561106d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061175a6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156111de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117eb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611264576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806117116023913960400191505060405180910390fd5b61126f83838361170b565b6112da8160405180606001604052806026815260200161177c602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114199092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061136d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114d990919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008383111582906114c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561148b578082015181840152602081019050611470565b50505050905090810190601f1680156114b85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611557576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117a26021913960400191505060405180910390fd5b6115f36000838361170b565b611608816002546114d990919063ffffffff16565b60028190555061165f816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114d990919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a20737570706c7920746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b77371eece579aa2ee7d1b4db90bf0050770acd3fdeef3223df18906807c758464736f6c634300060c0033
[ 38 ]
0xf1e4712c44b24d5633972a6b0edca99b967d989e
pragma solidity 0.7.6; // SPDX-License-Identifier: UNLICENSED 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; } } contract FSilver { function getColor() external pure returns (bytes32) { return bytes32("BRONZE"); } } contract FConst is FSilver, ReentrancyGuard { uint public constant BASE = 10**18; uint public constant MIN_BOUND_TOKENS = 2; uint public constant MAX_BOUND_TOKENS = 2; uint public constant MIN_FEE = 2000000000000000; uint public constant MAX_FEE = 2000000000000000; // FREE BUYS and sells pay 0.2% to liquidity providers uint public constant EXIT_FEE = BASE / 100; uint public constant DEFAULT_RESERVES_RATIO = 0; uint public constant MIN_WEIGHT = BASE; uint public constant MAX_WEIGHT = BASE * 50; uint public constant MAX_TOTAL_WEIGHT = BASE * 50; uint public constant MIN_BALANCE = BASE / 10**12; uint public constant INIT_POOL_SUPPLY = BASE * 100; uint public SM = 10; address public FEGstake = 0x04788562Ab11eA3a5201d579e2b3Ee7A3F74F1fA; uint public constant MIN_BPOW_BASE = 1 wei; uint public constant MAX_BPOW_BASE = (2 * BASE) - 1 wei; uint public constant BPOW_PRECISION = BASE / 10**10; uint public constant MAX_IN_RATIO = BASE / 2; uint public constant MAX_OUT_RATIO = (BASE / 3) + 1 wei; uint public MAX_SELL_RATIO = BASE / SM; } contract FNum is ReentrancyGuard, FConst { function btoi(uint a) internal pure returns (uint) { return a / BASE; } function bfloor(uint a) internal pure returns (uint) { return btoi(a) * BASE; } function badd(uint a, uint b) internal pure returns (uint) { uint c = a + b; require(c >= a, "ERR_ADD_OVERFLOW"); return c; } function bsub(uint a, uint b) internal pure returns (uint) { (uint c, bool flag) = bsubSign(a, b); require(!flag, "ERR_SUB_UNDERFLOW"); return c; } function bsubSign(uint a, uint b) internal pure returns (uint, bool) { if (a >= b) { return (a - b, false); } else { return (b - a, true); } } function bmul(uint a, uint b) internal pure returns (uint) { uint c0 = a * b; require(a == 0 || c0 / a == b, "ERR_MUL_OVERFLOW"); uint c1 = c0 + (BASE / 2); require(c1 >= c0, "ERR_MUL_OVERFLOW"); uint c2 = c1 / BASE; return c2; } function bdiv(uint a, uint b) internal pure returns (uint) { require(b != 0, "ERR_DIV_ZERO"); uint c0 = a * BASE; require(a == 0 || c0 / a == BASE, "ERR_DIV_INTERNAL"); // bmul overflow uint c1 = c0 + (b / 2); require(c1 >= c0, "ERR_DIV_INTERNAL"); // badd require uint c2 = c1 / b; return c2; } function bpowi(uint a, uint n) internal pure returns (uint) { uint z = n % 2 != 0 ? a : BASE; for (n /= 2; n != 0; n /= 2) { a = bmul(a, a); if (n % 2 != 0) { z = bmul(z, a); } } return z; } function bpow(uint base, uint exp) internal pure returns (uint) { require(base >= MIN_BPOW_BASE, "ERR_BPOW_BASE_TOO_LOW"); require(base <= MAX_BPOW_BASE, "ERR_BPOW_BASE_TOO_HIGH"); uint whole = bfloor(exp); uint remain = bsub(exp, whole); uint wholePow = bpowi(base, btoi(whole)); if (remain == 0) { return wholePow; } uint partialResult = bpowApprox(base, remain, BPOW_PRECISION); return bmul(wholePow, partialResult); } function bpowApprox(uint base, uint exp, uint precision) internal pure returns (uint) { uint a = exp; (uint x, bool xneg) = bsubSign(base, BASE); uint term = BASE; uint sum = term; bool negative = false; for (uint i = 1; term >= precision; i++) { uint bigK = i * BASE; (uint c, bool cneg) = bsubSign(a, bsub(bigK, BASE)); term = bmul(term, bmul(c, x)); term = bdiv(term, bigK); if (term == 0) break; if (xneg) negative = !negative; if (cneg) negative = !negative; if (negative) { sum = bsub(sum, term); } else { sum = badd(sum, term); } } return sum; } } contract FMath is FSilver, FConst, FNum { function calcSpotPrice( uint tokenBalanceIn, uint tokenWeightIn, uint tokenBalanceOut, uint tokenWeightOut, uint swapFee ) public pure returns (uint spotPrice) { uint numer = bdiv(tokenBalanceIn, tokenWeightIn); uint denom = bdiv(tokenBalanceOut, tokenWeightOut); uint ratio = bdiv(numer, denom); uint scale = bdiv(BASE, bsub(BASE, swapFee)); return (spotPrice = bmul(ratio, scale)); } function calcOutGivenIn( uint tokenBalanceIn, uint tokenWeightIn, uint tokenBalanceOut, uint tokenWeightOut, uint tokenAmountIn, uint swapFee ) public pure returns (uint tokenAmountOut, uint tokenInFee) { uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut); uint adjustedIn = bsub(BASE, swapFee); adjustedIn = bmul(tokenAmountIn, adjustedIn); uint y = bdiv(tokenBalanceIn, badd(tokenBalanceIn, adjustedIn)); uint foo = bpow(y, weightRatio); uint bar = bsub(BASE, foo); tokenAmountOut = bmul(tokenBalanceOut, bar); tokenInFee = bsub(tokenAmountIn, adjustedIn); return (tokenAmountOut, tokenInFee); } function calcInGivenOut( uint tokenBalanceIn, uint tokenWeightIn, uint tokenBalanceOut, uint tokenWeightOut, uint tokenAmountOut, uint swapFee ) public pure returns (uint tokenAmountIn, uint tokenInFee) { uint weightRatio = bdiv(tokenWeightOut, tokenWeightIn); uint diff = bsub(tokenBalanceOut, tokenAmountOut); uint y = bdiv(tokenBalanceOut, diff); uint foo = bpow(y, weightRatio); foo = bsub(foo, BASE); foo = bmul(tokenBalanceIn, foo); tokenAmountIn = bsub(BASE, swapFee); tokenAmountIn = bdiv(foo, tokenAmountIn); tokenInFee = bdiv(foo, BASE); tokenInFee = bsub(tokenAmountIn, tokenInFee); return (tokenAmountIn, tokenInFee); } function calcPoolOutGivenSingleIn( uint tokenBalanceIn, uint tokenWeightIn, uint poolSupply, uint totalWeight, uint tokenAmountIn, uint swapFee, uint reservesRatio ) public pure returns (uint poolAmountOut, uint reserves) { uint normalizedWeight = bdiv(tokenWeightIn, totalWeight); uint zaz = bmul(bsub(BASE, normalizedWeight), swapFee); uint tokenAmountInAfterFee = bmul(tokenAmountIn, bsub(BASE, zaz)); reserves = calcReserves(tokenAmountIn, tokenAmountInAfterFee, reservesRatio); uint newTokenBalanceIn = badd(tokenBalanceIn, tokenAmountInAfterFee); uint tokenInRatio = bdiv(newTokenBalanceIn, tokenBalanceIn); uint poolRatio = bpow(tokenInRatio, normalizedWeight); uint newPoolSupply = bmul(poolRatio, poolSupply); poolAmountOut = bsub(newPoolSupply, poolSupply); return (poolAmountOut, reserves); } function calcSingleOutGivenPoolIn( uint tokenBalanceOut, uint tokenWeightOut, uint poolSupply, uint totalWeight, uint poolAmountIn, uint swapFee ) public pure returns (uint tokenAmountOut) { uint normalizedWeight = bdiv(tokenWeightOut, totalWeight); uint poolAmountInAfterExitFee = bmul(poolAmountIn, bsub(BASE, EXIT_FEE)); uint newPoolSupply = bsub(poolSupply, poolAmountInAfterExitFee); uint poolRatio = bdiv(newPoolSupply, poolSupply); uint tokenOutRatio = bpow(poolRatio, bdiv(BASE, normalizedWeight)); uint newTokenBalanceOut = bmul(tokenOutRatio, tokenBalanceOut); uint tokenAmountOutBeforeSwapFee = bsub(tokenBalanceOut, newTokenBalanceOut); uint zaz = bmul(bsub(BASE, normalizedWeight), swapFee); tokenAmountOut = bmul(tokenAmountOutBeforeSwapFee, bsub(BASE, zaz)); return tokenAmountOut; } function calcPoolInGivenSingleOut( uint tokenBalanceOut, uint tokenWeightOut, uint poolSupply, uint totalWeight, uint tokenAmountOut, uint swapFee, uint reservesRatio ) public pure returns (uint poolAmountIn, uint reserves) { uint normalizedWeight = bdiv(tokenWeightOut, totalWeight); uint zar = bmul(bsub(BASE, normalizedWeight), swapFee); uint tokenAmountOutBeforeSwapFee = bdiv(tokenAmountOut, bsub(BASE, zar)); reserves = calcReserves(tokenAmountOutBeforeSwapFee, tokenAmountOut, reservesRatio); uint newTokenBalanceOut = bsub(tokenBalanceOut, tokenAmountOutBeforeSwapFee); uint tokenOutRatio = bdiv(newTokenBalanceOut, tokenBalanceOut); uint poolRatio = bpow(tokenOutRatio, normalizedWeight); uint newPoolSupply = bmul(poolRatio, poolSupply); uint poolAmountInAfterExitFee = bsub(poolSupply, newPoolSupply); poolAmountIn = bdiv(poolAmountInAfterExitFee, bsub(BASE, EXIT_FEE)); return (poolAmountIn, reserves); } function calcReserves(uint amountWithFee, uint amountWithoutFee, uint reservesRatio) internal pure returns (uint reserves) { require(amountWithFee >= amountWithoutFee, "ERR_MATH_APPROX"); require(reservesRatio <= BASE, "ERR_INVALID_RESERVE"); uint swapFeeAndReserves = bsub(amountWithFee, amountWithoutFee); reserves = bmul(swapFeeAndReserves, reservesRatio); require(swapFeeAndReserves >= reserves, "ERR_MATH_APPROX"); } function calcReservesFromFee(uint fee, uint reservesRatio) internal pure returns (uint reserves) { require(reservesRatio <= BASE, "ERR_INVALID_RESERVE"); reserves = bmul(fee, reservesRatio); } } interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address whom) external view returns (uint); function allowance(address src, address dst) external view returns (uint); function approve(address dst, uint amt) external returns (bool); function transfer(address dst, uint amt) external returns (bool); function transferFrom( address src, address dst, uint amt ) external returns (bool); } interface wrap { function deposit() external payable; function withdraw(uint amt) external; function transfer(address recipient, uint256 amount) external returns (bool); } library TransferHelper { function safeApprove(address token, address to, uint value) internal { (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 { (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 { (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 FTokenBase is ReentrancyGuard, FNum { mapping(address => uint) internal _balance; mapping(address => mapping(address=>uint)) internal _allowance; uint internal _totalSupply; event Approval(address indexed src, address indexed dst, uint amt); event Transfer(address indexed src, address indexed dst, uint amt); function _mint(uint amt) internal { _balance[address(this)] = badd(_balance[address(this)], amt); _totalSupply = badd(_totalSupply, amt); emit Transfer(address(0), address(this), amt); } function _burn(uint amt) internal { require(_balance[address(this)] >= amt); _balance[address(this)] = bsub(_balance[address(this)], amt); _totalSupply = bsub(_totalSupply, amt); emit Transfer(address(this), address(0), amt); } function _move(address src, address dst, uint amt) internal { require(_balance[src] >= amt); _balance[src] = bsub(_balance[src], amt); _balance[dst] = badd(_balance[dst], amt); emit Transfer(src, dst, amt); } function _push(address to, uint amt) internal { _move(address(this), to, amt); } function _pull(address from, uint amt) internal { _move(from, address(this), amt); } } contract FToken is ReentrancyGuard, FTokenBase { string private _name = "FEGexV2"; string private _symbol = "FEGfETH"; uint8 private _decimals = 18; function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns(uint8) { return _decimals; } function allowance(address src, address dst) external view returns (uint) { return _allowance[src][dst]; } function balanceOf(address whom) external view returns (uint) { return _balance[whom]; } function totalSupply() public view returns (uint) { return _totalSupply; } function approve(address dst, uint amt) external returns (bool) { _allowance[msg.sender][dst] = amt; emit Approval(msg.sender, dst, amt); return true; } function increaseApproval(address dst, uint amt) external returns (bool) { _allowance[msg.sender][dst] = badd(_allowance[msg.sender][dst], amt); emit Approval(msg.sender, dst, _allowance[msg.sender][dst]); return true; } function decreaseApproval(address dst, uint amt) external returns (bool) { uint oldValue = _allowance[msg.sender][dst]; if (amt > oldValue) { _allowance[msg.sender][dst] = 0; } else { _allowance[msg.sender][dst] = bsub(oldValue, amt); } emit Approval(msg.sender, dst, _allowance[msg.sender][dst]); return true; } function transfer(address dst, uint amt) external returns (bool) { FEGexV2 ulock; bool getlock = ulock.getUserLock(msg.sender); require(getlock == true, 'Liquidity is locked, you cannot remove liquidity until after lock time.'); _move(msg.sender, dst, amt); return true; } function transferFrom(address src, address dst, uint amt) external returns (bool) { require(msg.sender == src || amt <= _allowance[src][msg.sender]); FEGexV2 ulock; bool getlock = ulock.getUserLock(msg.sender); require(getlock == true, 'Transfer is Locked '); _move(src, dst, amt); if (msg.sender != src && _allowance[src][msg.sender] != uint256(-1)) { _allowance[src][msg.sender] = bsub(_allowance[src][msg.sender], amt); emit Approval(msg.sender, dst, _allowance[src][msg.sender]); } return true; } } contract FEGexV2 is FSilver, ReentrancyGuard, FToken, FMath { struct Record { bool bound; // is token bound to pool uint denorm; // denormalized weight will always be even uint index; uint balance; } struct userLock { bool setLock; // true = locked, false = unlocked uint unlockTime; } function getUserLock(address usr) public view returns(bool lock){ return _userlock[usr].setLock; } event LOG_SWAP( address indexed caller, address indexed tokenIn, address indexed tokenOut, uint256 tokenAmountIn, uint256 tokenAmountOut ); event LOG_JOIN( address indexed caller, address indexed tokenIn, uint256 tokenAmountIn, uint256 reservesAmount ); event LOG_EXIT( address indexed caller, address indexed tokenOut, uint256 tokenAmountOut, uint256 reservesAmount ); event LOG_CLAIM_RESERVES( address indexed caller, address indexed tokenOut, uint256 tokenAmountOut ); event LOG_ADD_RESERVES( address indexed token, uint256 reservesAmount ); event LOG_CALL( bytes4 indexed sig, address indexed caller, bytes data ) anonymous; modifier _logs_() { emit LOG_CALL(msg.sig, msg.sender, msg.data); _; } modifier _lock_() { require(!_mutex); _mutex = true; _; _mutex = false; } modifier _viewlock_() { require(!_mutex); _; } bool private _mutex; wrap wrapp; address private _factory = 0x1Eb421973d639C3422904c65Cccc2972b37a17e8; address private _controller = 0x4c9BC793716e8dC05d1F48D8cA8f84318Ec3043C; address private _poolOwner; address public Wrap = 0xf786c34106762Ab4Eeb45a51B42a62470E9D5332; address public Token = 0x389999216860AB8E0175387A0c90E5c52522C945; address public pairRewardPool = 0x94D4Ac11689C6EbbA91cDC1430fc7dfa9a858753; address public burn = 0x000000000000000000000000000000000000dEaD; uint public FSS = 25; // FEGstake Share uint public PSS = 20; // pairRewardPool Share uint public RPF = 1000; //Smart Rising Price Floor Setting uint public SHR = 995; //p2p fee Token uint public SHR1 = 997; //p2p fee Wrap uint private _swapFee; address[] private _tokens; uint256 public _totalSupply1; uint256 public _totalSupply2; bool public live = false; mapping(address=>Record) private _records; mapping(address=>userLock) public _userlock; mapping(address=>userLock) public _unlockTime; mapping(address=>bool) public whiteListContract; mapping(address => uint256) private _balances1; mapping(address => uint256) private _balances2; uint private _totalWeight; constructor() { wrapp = wrap(Wrap); _poolOwner = msg.sender; //pairRewardPool = msg.sender; _swapFee = MIN_FEE; } receive() external payable { } function userBalanceInternal(address _addr) public view returns (uint256 token, uint256 fwrap) { return (_balances1[_addr], _balances2[_addr]); } function isContract(address account) internal view returns (bool) { if(IsWhiteListContract(account)) { return false; } bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } function addWhiteListContract(address _addy, bool boolean) public { require(msg.sender == _controller); require(_addy != address(0), "setting 0 address;;"); whiteListContract[_addy] = boolean; } function IsWhiteListContract(address _addy) public view returns(bool){ require(_addy != address(0), "setting 0 address;;"); return whiteListContract[_addy]; } modifier noContract() { require(isContract(msg.sender) == false, 'Unapproved contracts are not allowed to interact with the swap'); _; } function setMaxSellRatio(uint256 _amount) public { require(msg.sender == _poolOwner, "You do not have permission"); require (_amount > 0, "cannot turn off"); require (_amount <= 100, "cannot set under 1%"); SM = _amount; } function setStakePool(address _addy) public { require(msg.sender == _controller); FEGstake = _addy; } function setPairRewardPool(address _addy) public { require(msg.sender == _controller); pairRewardPool = _addy; } function setupWrap() public { IERC20(address(this)).approve(address(Wrap), 100000000000000000e18); } function isBound(address t) external view returns (bool) { return _records[t].bound; } function getFinalTokens() external view _viewlock_ returns (address[] memory tokens) { return _tokens; } function getDenormalizedWeight(address token) external view _viewlock_ { require(_records[token].bound); } function getTotalDenormalizedWeight() external view _viewlock_ returns (uint) { return _totalWeight; } function getNormalizedWeight(address token) external view _viewlock_ returns (uint) { require(_records[token].bound); return _totalWeight; } function getBalance(address token) external view _viewlock_ returns (uint) { require(_records[token].bound); return _records[token].balance; } function getSwapFee() external view _viewlock_ returns (uint) { return _swapFee; } function getController() external view _viewlock_ returns (address) { return _controller; } function setController(address manager) external _logs_ _lock_ { require(msg.sender == _controller); _controller = manager; } function deploySwap (uint256 amtoftoken, uint256 amtofwrap) external { require(msg.sender == _poolOwner); require(live == false); address tokenIn = Token; address tokenIn1 = Wrap; _records[Token] = Record({ bound: true, denorm: BASE * 25, index: _tokens.length, balance: (amtoftoken * 98/100) }); _records[Wrap] = Record({ bound: true, denorm: BASE * 25, index: _tokens.length, balance: (amtofwrap * 99/100) }); live = true; _tokens.push(Token); _tokens.push(Wrap); _pullUnderlying(tokenIn, msg.sender, amtoftoken); _pullUnderlying(tokenIn1, msg.sender, amtofwrap); _mint(INIT_POOL_SUPPLY); _pushPoolShare(msg.sender, INIT_POOL_SUPPLY); address user = msg.sender; userLock storage ulock = _userlock[user]; userLock storage time = _unlockTime[user]; ulock.setLock = true; time.unlockTime = block.timestamp + 365 days ; } function saveLostTokens(address token, uint amount) external _logs_ _lock_ { require(msg.sender == _controller); require(!_records[token].bound); uint bal = IERC20(token).balanceOf(address(this)); require(amount <= bal); _pushUnderlying(token, msg.sender, amount); } function getSpotPrice(address tokenIn, address tokenOut) external view _viewlock_ returns (uint spotPrice) { require(_records[tokenIn].bound, "ERR_NOT_BOUND"); require(_records[tokenOut].bound, "ERR_NOT_BOUND"); Record storage inRecord = _records[address(tokenIn)]; Record storage outRecord = _records[address(tokenOut)]; return calcSpotPrice(inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee);} function depositToken(uint256 amt) external noContract nonReentrant { address tokenIn = Token; _pullUnderlying(tokenIn, msg.sender, amt); uint256 finalAmount = amt * 98/100; _totalSupply1 = _totalSupply1 + finalAmount; _balances1[msg.sender] = _balances1[msg.sender] + finalAmount; } function depositWrap(uint256 amt) external noContract nonReentrant { address tokenIn = Wrap; _pullUnderlying(tokenIn, msg.sender, amt); uint256 finalAmount = amt * 99/100; _totalSupply2 = _totalSupply2 + finalAmount; _balances2[msg.sender] = _balances2[msg.sender] + finalAmount; } function withdrawToken(uint256 amt) external noContract nonReentrant { address tokenIn = Token; require(_balances1[msg.sender] >= amt, "Not enough token"); _totalSupply1 = _totalSupply1 - amt; _balances1[msg.sender] = _balances1[msg.sender] - amt; _pushUnderlying(tokenIn, msg.sender, amt); } function withdrawWrap(uint256 amt) external noContract nonReentrant{ address tokenIn = Wrap; require(_balances2[msg.sender] >= amt, "Not enough Wrap"); _totalSupply2 = _totalSupply2 - amt; _balances2[msg.sender] = _balances2[msg.sender] - amt; _pushUnderlying(tokenIn, msg.sender, amt); } function addBothLiquidity(uint poolAmountOut, uint[] calldata maxAmountsIn) noContract nonReentrant external _logs_ _lock_ { uint poolTotal = totalSupply(); uint ratio = bdiv(poolAmountOut, poolTotal); require(ratio != 0, "ERR_MATH_APPROX"); for (uint i = 0; i < _tokens.length; i++) { address t = _tokens[i]; uint bal = _records[t].balance; uint tokenAmountIn = bmul(ratio, bal); require(tokenAmountIn != 0, "ERR_MATH_APPROX"); require(tokenAmountIn <= maxAmountsIn[i], "ERR_LIMIT_IN"); emit LOG_JOIN(msg.sender, t, tokenAmountIn * 98/100, 0); _pullUnderlying(t, msg.sender, tokenAmountIn); _records[Token].balance = IERC20(Token).balanceOf(address(this)) - _totalSupply1; _records[Wrap].balance = IERC20(Wrap).balanceOf(address(this)) - _totalSupply2; } _mintPoolShare(poolAmountOut); _pushPoolShare(msg.sender, poolAmountOut); } function removeBothLiquidity(uint poolAmountIn, uint[] calldata minAmountsOut) noContract nonReentrant external _logs_ _lock_ { userLock storage ulock = _userlock[msg.sender]; if(ulock.setLock == true) { require(ulock.unlockTime <= block.timestamp, "Liquidity is locked, you cannot remove liquidity until after lock time."); } uint poolTotal = totalSupply(); uint exitFee = bmul(poolAmountIn, EXIT_FEE); uint pAiAfterExitFee = bsub(poolAmountIn, exitFee); uint ratio = bdiv(pAiAfterExitFee, poolTotal); require(ratio != 0, "ERR_MATH_APPROX"); _pullPoolShare(msg.sender, poolAmountIn); _pushPoolShare(_factory, exitFee); _burnPoolShare(pAiAfterExitFee); for (uint i = 0; i < _tokens.length; i++) { address t = _tokens[i]; uint bal = _records[t].balance; uint tokenAmountOut = bmul(ratio, bal); require(tokenAmountOut != 0, "ERR_MATH_APPROX"); require(tokenAmountOut >= minAmountsOut[i], "ERR_LIMIT_OUT"); emit LOG_EXIT(msg.sender, t, tokenAmountOut, 0); _pushUnderlying(t, msg.sender, tokenAmountOut); _records[Token].balance = IERC20(Token).balanceOf(address(this)) - _totalSupply1; _records[Wrap].balance = IERC20(Wrap).balanceOf(address(this)) - _totalSupply2; } } function BUYSmart( uint tokenAmountIn, uint minAmountOut ) noContract nonReentrant external _logs_ _lock_ returns (uint tokenAmountOut, uint spotPriceAfter) { address tokenIn = Wrap; address tokenOut = Token; require(_balances2[msg.sender] >= tokenAmountIn, "Not enough Wrap, deposit more"); Record storage inRecord = _records[address(tokenIn)]; Record storage outRecord = _records[address(tokenOut)]; require(tokenAmountIn <= bmul(inRecord.balance, MAX_IN_RATIO), "ERR_MAX_IN_RATIO"); uint spotPriceBefore = calcSpotPrice( inRecord.balance , BASE * 25, outRecord.balance, BASE * 25, _swapFee * 0 ); uint tokenInFee; (tokenAmountOut, tokenInFee) = calcOutGivenIn( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, tokenAmountIn * 99/100, _swapFee * 0 ); require(tokenAmountOut >= minAmountOut, "ERR_LIMIT_OUT"); require(spotPriceBefore <= bdiv(tokenAmountIn, tokenAmountOut), "ERR_MATH_APPROX"); _balances2[msg.sender] = _balances2[msg.sender] - tokenAmountIn; _balances1[msg.sender] = _balances1[msg.sender] + tokenAmountOut; _totalSupply2 = _totalSupply2 - tokenAmountIn; _totalSupply1 = _totalSupply1 + tokenAmountOut; _records[Token].balance = IERC20(Token).balanceOf(address(this)) - _totalSupply1; _records[Wrap].balance = IERC20(Wrap).balanceOf(address(this)) - _totalSupply2; spotPriceAfter = calcSpotPrice( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee * 0 ); require(spotPriceAfter >= spotPriceBefore, "ERR_MATH_APPROX"); emit LOG_SWAP(msg.sender, tokenIn, tokenOut, tokenAmountIn, tokenAmountOut); return (tokenAmountOut, spotPriceAfter); } function BUY( address to, uint minAmountOut ) noContract nonReentrant external payable _logs_ _lock_ returns (uint tokenAmountOut, uint spotPriceAfter) { address tokenIn = Wrap; address tokenOut = Token; Record storage inRecord = _records[address(tokenIn)]; Record storage outRecord = _records[address(tokenOut)]; require(msg.value <= bmul(inRecord.balance, MAX_IN_RATIO), "ERR_MAX_IN_RATIO"); uint spotPriceBefore = calcSpotPrice( inRecord.balance , BASE * 25, outRecord.balance, BASE * 25, _swapFee * 0 ); uint tokenInFee; (tokenAmountOut, tokenInFee) = calcOutGivenIn( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, msg.value * 99/100, _swapFee * 0 ); require(tokenAmountOut >= minAmountOut, "ERR_LIMIT_OUT"); require(spotPriceBefore <= bdiv(msg.value * 99/100, tokenAmountOut), "ERR_MATH_APPROX"); wrap(Wrap).deposit{value: msg.value}(); _pushUnderlying(tokenOut, to, tokenAmountOut); _records[Token].balance = IERC20(Token).balanceOf(address(this)) - _totalSupply1; _records[Wrap].balance = IERC20(Wrap).balanceOf(address(this)) - _totalSupply2; spotPriceAfter = calcSpotPrice( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee * 0 ); require(spotPriceAfter >= spotPriceBefore, "ERR_MATH_APPROX"); emit LOG_SWAP(msg.sender, tokenIn, tokenOut, msg.value * 99/100, tokenAmountOut * 98/100); return (tokenAmountOut, spotPriceAfter); } function SELL( address to, uint tokenAmountIn, uint minAmountOut ) noContract nonReentrant external _logs_ _lock_ returns (uint tokenAmountOut, uint spotPriceAfter) { address tokenIn = Token; address tokenOut = Wrap; Record storage inRecord = _records[address(tokenIn)]; Record storage outRecord = _records[address(tokenOut)]; require(tokenAmountIn <= bmul(inRecord.balance, MAX_SELL_RATIO), "ERR_SELL_RATIO"); uint tokenInFee; (tokenAmountOut, tokenInFee) = calcOutGivenIn( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, tokenAmountIn * 98/100, _swapFee ); require(tokenAmountOut >= minAmountOut, "ERR_LIMIT_OUT"); emit LOG_SWAP(msg.sender, tokenIn, tokenOut, tokenAmountIn * 98/100, tokenAmountOut * 99/100); _pullUnderlying(tokenIn, msg.sender, tokenAmountIn); uint256 toka = bmul(tokenAmountOut, bdiv(RPF, 1000)); uint256 tokAmountI = bmul(tokenAmountOut, bdiv(FSS, 10000)); uint256 tokAmountI2 = bmul(tokenAmountOut, bdiv(PSS, 10000)); uint256 tokAmountI1 = bsub(toka, badd(tokAmountI, tokAmountI2)); uint256 out1 = tokAmountI1; wrap(Wrap).withdraw(out1); TransferHelper.safeTransferETH(to, (out1 * 99/100)); _pushUnderlying1(tokenOut, tokAmountI); _balances2[pairRewardPool] = _balances2[pairRewardPool] + tokAmountI2; _totalSupply2 = _totalSupply2 + tokAmountI2; uint spotPriceBefore = calcSpotPrice( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee ); require(spotPriceBefore <= bdiv(tokenAmountIn, tokenAmountOut), "ERR_MATH_APPROX"); _records[Token].balance = IERC20(Token).balanceOf(address(this)) - _totalSupply1; _records[Wrap].balance = IERC20(Wrap).balanceOf(address(this)) - _totalSupply2; spotPriceAfter = calcSpotPrice( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee ); require(spotPriceAfter >= spotPriceBefore, "ERR_MATH_APPROX"); return (tokenAmountOut, spotPriceAfter); } function SELLSmart( uint tokenAmountIn, uint minAmountOut ) noContract nonReentrant external _logs_ _lock_ returns (uint tokenAmountOut, uint spotPriceAfter) { address tokenIn = Token; address tokenOut = Wrap; require(_balances1[msg.sender] >= tokenAmountIn, "Not enough Token"); Record storage inRecord = _records[address(tokenIn)]; Record storage outRecord = _records[address(tokenOut)]; require(tokenAmountIn <= bmul(inRecord.balance, MAX_SELL_RATIO), "ERR_SELL_RATIO"); uint spotPriceBefore = calcSpotPrice( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee ); uint tokenInFee; (tokenAmountOut, tokenInFee) = calcOutGivenIn( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, tokenAmountIn * 98/100, _swapFee ); require(tokenAmountOut >= minAmountOut, "ERR_LIMIT_OUT"); require(spotPriceBefore <= bdiv(tokenAmountIn, tokenAmountOut), "ERR_MATH_APPROX"); emit LOG_SWAP(msg.sender, tokenIn, tokenOut, tokenAmountIn, tokenAmountOut); uint256 toka = bmul(tokenAmountOut, bdiv(RPF, 1000)); uint256 tokAmountI = bmul(tokenAmountOut, bdiv(FSS, 10000)); uint256 tokAmountI2 = bmul(tokenAmountOut, bdiv(PSS, 10000)); uint256 tokAmountI1 = bsub(toka, badd(tokAmountI, tokAmountI2)); uint256 tok2 = badd(tokAmountI1, tokAmountI2); _balances1[msg.sender] = _balances1[msg.sender] - tokenAmountIn; _balances2[msg.sender] = _balances2[msg.sender] + tokAmountI1; _totalSupply2 = _totalSupply2 + tok2; _totalSupply1 = _totalSupply1 - tokenAmountIn; _pushUnderlying1(tokenOut, tokAmountI); _balances2[pairRewardPool] = _balances2[pairRewardPool] + tokAmountI2; _records[Token].balance = IERC20(Token).balanceOf(address(this)) - _totalSupply1; _records[Wrap].balance = IERC20(Wrap).balanceOf(address(this)) - _totalSupply2; spotPriceAfter = calcSpotPrice( inRecord.balance, BASE * 25, outRecord.balance, BASE * 25, _swapFee ); require(spotPriceAfter >= spotPriceBefore, "ERR_MATH_APPROX"); return (tokenAmountOut, spotPriceAfter); } function setFSS(uint _FSS ) external { require(msg.sender == _controller); require(_FSS <= 100, " Cannot set over 1%"); require(_FSS > 0, " Cannot set to 0"); FSS = _FSS; } function setPSS(uint _PSS ) external { require(msg.sender == _poolOwner); require(_PSS <= 100, " Cannot set over 1%"); require(_PSS > 0, " Cannot set to 0"); PSS = _PSS; } function setRPF(uint _RPF ) external { require(msg.sender == _poolOwner); require(_RPF <= 200, " Cannot set over 20%"); require(_RPF > 0, " Cannot set to 0"); RPF = _RPF; } function setSHR(uint _SHR, uint _SHR1 ) external { require(msg.sender == _controller); require(_SHR <= 100 && _SHR1 <=100, " Cannot set over 10%"); require(_SHR > 0 && _SHR1 > 0, " Cannot set to 0"); SHR = _SHR; SHR1 = _SHR1; } function setLockLiquidity() external { // address user = msg.sender; userLock storage ulock = _userlock[user]; userLock storage time = _unlockTime[user]; ulock.setLock = true; time.unlockTime = block.timestamp + 365 days ; } function releaseLiquidity() external { // Allows removal of liquidity after the lock period is over address user = msg.sender; userLock storage ulock = _userlock[user]; userLock storage time = _unlockTime[user]; require (block.timestamp >= time.unlockTime, "Liquidity is locked, you cannot remove liquidity until after lock time."); ulock.setLock = false; } function emergencyLockOverride(address user, bool _bool, uint _time) external { require(msg.sender == _controller); userLock storage ulock = _userlock[user]; userLock storage time = _unlockTime[user]; ulock.setLock = _bool; time.unlockTime = _time; } function _pullUnderlying(address erc20, address from, uint amount) internal { //require(amount > 0, "Cannot deposit nothing"); bool xfer = IERC20(erc20).transferFrom(from, address(this), amount); require(xfer, "ERR_ERC20_FALSE"); } function _pushUnderlying(address erc20, address to, uint amount) internal { //require(amount > 0, "Cannot withdraw nothing"); bool xfer = IERC20(erc20).transfer(to, amount); require(xfer, "ERR_ERC20_FALSE"); } function _pushUnderlying1(address erc20, uint amount) internal { bool xfer = IERC20(erc20).transfer(FEGstake, amount); require(xfer, "ERR_ERC20_FALSE"); } function _pullPoolShare(address from, uint amount) internal { _pull(from, amount); } function _pushPoolShare(address to, uint amount) internal { _push(to, amount); } function _mintPoolShare(uint amount) internal { _mint(amount); } function _burnPoolShare(uint amount) internal { _burn(amount); } function PayWrap(address payee, uint amount) external noContract nonReentrant { require(_balances2[msg.sender] >= amount, "Not enough token"); uint256 amt = amount * SHR1/1000; uint256 amt1 = amount - amt; _balances2[msg.sender] = _balances2[msg.sender] - amount; _balances2[payee] = _balances2[payee] + amt; _balances2[_factory] = _balances2[_factory] + amt1; } function PayToken(address payee, uint amount) external noContract nonReentrant { require(_balances1[msg.sender] >= amount, "Not enough token"); uint256 amt = amount * SHR/1000; uint256 amt1 = amount - amt; _balances1[msg.sender] = _balances1[msg.sender] - amount; _balances1[payee] = _balances1[payee] + amt; _pushUnderlying(Token, burn, amt1); _totalSupply1 = _totalSupply1 - amt1; } }
0x6080604052600436106104fa5760003560e01c806392eefe9b1161028c578063ba019dab1161015a578063d4cadf68116100cc578063f1091b6e11610085578063f1091b6e14611345578063f1b8a9b71461135a578063f319dba81461138d578063f8b2cb4f146113bd578063f8d6aed4146113f0578063fea4393a1461143857610501565b8063d4cadf68146112a7578063d73dd623146112bc578063dd62ed3e146112f5578063e4a28a5214610701578063ec09302114611330578063ec342ad0146108cf57610501565b8063c24126761161011e578063c2412676146111ca578063c627fbfa146111df578063c6580d1214611212578063c879a14b14611227578063cbee44ba14611251578063cdfec52d1461129257610501565b8063ba019dab146110f3578063ba9530a614611108578063bc063e1a14610d5a578063bc694ea214611150578063be3bbd2e1461116557610501565b80639f074aad116101fe578063a5a54ea5116101b7578063a5a54ea51461102d578063a9059cbb14611042578063ae1931be1461107b578063b0e0d136146110ab578063b44ec921146110c0578063b7b800a4146110ab57610501565b80639f074aad14610f585780639f6d847414610f6d578063a16faa1814610f97578063a221ee4914610fac578063a2e70a2e14610fee578063a2e73cb61461100357610501565b8063957aa58c11610250578063957aa58c14610ec557806395d89b4114610eda578063992e2a9214610eef5780639a78458a14610f045780639a86139b14610f195780639ae7707314610f2e57610501565b806392eefe9b14610e20578063936c347714610e535780639381cd2b14610e6857806393c88d1414610e7d578063948d8ce614610e9257610501565b80632f37b624116103c95780635f45e8d51161033b57806372015efc116102f457806372015efc14610d4557806376c7a3c714610d5a578063867378c514610d6f5780638929801214610d845780638d811d1f14610dcc578063909f319014610df657610501565b80635f45e8d514610bdd5780636215be7714610bf25780636618846314610c1c5780636c24846914610c5557806370a0823114610c8e57806371a1e6dd14610cc157610501565b8063390221d61161038d578063390221d614610aed5780633a0e928814610b2657806344df8e7014610b595780634cc0fa7e14610b6e57806350baa62214610b9e5780635c7b55bd14610bc857610501565b80632f37b62414610a2c5780633018205f14610a5f5780633109db0314610a74578063313ce56714610aad5780633170570514610ad857610501565b80631489cc2c1161046d5780632140fb40116104265780632140fb401461089c578063218b5382146108cf57806321abba01146108e457806323b872dd1461093257806329dfe3b2146109755780632b9abe1a146109f957610501565b80631489cc2c146107b257806315e84af9146107c757806316f76357146108025780631764d5951461083357806318160ddd14610872578063189d00ca1461088757610501565b806307d729c4116104bf57806307d729c41461067a578063095ea7b3146106c857806309a3bbe414610701578063103ff68d1461071657806311c42a991461075357806312b69b5d1461077f57610501565b80627b44a7146105065780630149e5c71461052d578063024eb2e314610574578063036fe1bb146105db57806306fdde03146105f057610501565b3661050157005b600080fd5b34801561051257600080fd5b5061051b611468565b60408051918252519081900360200190f35b34801561053957600080fd5b506105606004803603602081101561055057600080fd5b50356001600160a01b031661146e565b604080519115158252519081900360200190f35b34801561058057600080fd5b506105c2600480360360e081101561059757600080fd5b5080359060208101359060408101359060608101359060808101359060a08101359060c001356114e4565b6040805192835260208301919091528051918290030190f35b3480156105e757600080fd5b5061051b6115b6565b3480156105fc57600080fd5b506106056115bc565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561063f578181015183820152602001610627565b50505050905090810190601f16801561066c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561068657600080fd5b506106ad6004803603602081101561069d57600080fd5b50356001600160a01b0316611652565b60408051921515835260208301919091528051918290030190f35b3480156106d457600080fd5b50610560600480360360408110156106eb57600080fd5b506001600160a01b038135169060200135611671565b34801561070d57600080fd5b5061051b6116c6565b34801561072257600080fd5b506107516004803603604081101561073957600080fd5b506001600160a01b03813516906020013515156116d3565b005b6105c26004803603604081101561076957600080fd5b506001600160a01b038135169060200135611766565b34801561078b57600080fd5b506106ad600480360360208110156107a257600080fd5b50356001600160a01b0316611c73565b3480156107be57600080fd5b5061051b611c92565b3480156107d357600080fd5b5061051b600480360360408110156107ea57600080fd5b506001600160a01b0381358116916020013516611c98565b34801561080e57600080fd5b50610817611db8565b604080516001600160a01b039092168252519081900360200190f35b34801561083f57600080fd5b506105c26004803603606081101561085657600080fd5b506001600160a01b038135169060208101359060400135611dc7565b34801561087e57600080fd5b5061051b612361565b34801561089357600080fd5b5061051b612367565b3480156108a857600080fd5b50610560600480360360208110156108bf57600080fd5b50356001600160a01b031661237b565b3480156108db57600080fd5b5061051b612399565b3480156108f057600080fd5b506105c2600480360360e081101561090757600080fd5b5080359060208101359060408101359060608101359060808101359060a08101359060c001356123a5565b34801561093e57600080fd5b506105606004803603606081101561095557600080fd5b506001600160a01b0381358116916020810135909116906040013561244d565b34801561098157600080fd5b506107516004803603604081101561099857600080fd5b813591908101906040810160208201356401000000008111156109ba57600080fd5b8201836020820111156109cc57600080fd5b803590602001918460208302840111640100000000831117156109ee57600080fd5b509092509050612625565b348015610a0557600080fd5b506105c260048036036020811015610a1c57600080fd5b50356001600160a01b0316612ad3565b348015610a3857600080fd5b5061056060048036036020811015610a4f57600080fd5b50356001600160a01b0316612af9565b348015610a6b57600080fd5b50610817612b17565b348015610a8057600080fd5b5061075160048036036040811015610a9757600080fd5b506001600160a01b038135169060200135612b3f565b348015610ab957600080fd5b50610ac2612c98565b6040805160ff9092168252519081900360200190f35b348015610ae457600080fd5b50610817612ca1565b348015610af957600080fd5b5061075160048036036040811015610b1057600080fd5b506001600160a01b038135169060200135612cb0565b348015610b3257600080fd5b5061075160048036036020811015610b4957600080fd5b50356001600160a01b0316612e19565b348015610b6557600080fd5b50610817612e52565b348015610b7a57600080fd5b5061075160048036036040811015610b9157600080fd5b5080359060200135612e61565b348015610baa57600080fd5b5061075160048036036020811015610bc157600080fd5b5035613089565b348015610bd457600080fd5b5061051b6131b3565b348015610be957600080fd5b5061051b6131b9565b348015610bfe57600080fd5b5061075160048036036020811015610c1557600080fd5b50356131bf565b348015610c2857600080fd5b5061056060048036036040811015610c3f57600080fd5b506001600160a01b038135169060200135613299565b348015610c6157600080fd5b5061075160048036036040811015610c7857600080fd5b506001600160a01b038135169060200135613371565b348015610c9a57600080fd5b5061051b60048036036020811015610cb157600080fd5b50356001600160a01b03166134b4565b348015610ccd57600080fd5b5061075160048036036040811015610ce457600080fd5b81359190810190604081016020820135640100000000811115610d0657600080fd5b820183602082011115610d1857600080fd5b80359060200191846020830284011164010000000083111715610d3a57600080fd5b5090925090506134cf565b348015610d5157600080fd5b506107516138e0565b348015610d6657600080fd5b5061051b613949565b348015610d7b57600080fd5b5061051b613954565b348015610d9057600080fd5b5061051b600480360360c0811015610da757600080fd5b5080359060208101359060408101359060608101359060808101359060a00135613968565b348015610dd857600080fd5b5061075160048036036020811015610def57600080fd5b5035613a32565b348015610e0257600080fd5b5061075160048036036020811015610e1957600080fd5b5035613b29565b348015610e2c57600080fd5b5061075160048036036020811015610e4357600080fd5b50356001600160a01b0316613bda565b348015610e5f57600080fd5b5061051b613ca5565b348015610e7457600080fd5b5061051b613cc4565b348015610e8957600080fd5b5061051b613cd1565b348015610e9e57600080fd5b5061075160048036036020811015610eb557600080fd5b50356001600160a01b0316613cd6565b348015610ed157600080fd5b50610560613d13565b348015610ee657600080fd5b50610605613d1c565b348015610efb57600080fd5b5061051b613d7d565b348015610f1057600080fd5b50610817613d89565b348015610f2557600080fd5b5061051b613d98565b348015610f3a57600080fd5b5061075160048036036020811015610f5157600080fd5b5035613da5565b348015610f6457600080fd5b50610751613ec3565b348015610f7957600080fd5b5061075160048036036020811015610f9057600080fd5b5035613f51565b348015610fa357600080fd5b50610751614001565b348015610fb857600080fd5b5061051b600480360360a0811015610fcf57600080fd5b5080359060208101359060408101359060608101359060800135614035565b348015610ffa57600080fd5b5061051b61409a565b34801561100f57600080fd5b506107516004803603602081101561102657600080fd5b50356140a0565b34801561103957600080fd5b5061051b614150565b34801561104e57600080fd5b506105606004803603604081101561106557600080fd5b506001600160a01b038135169060200135614156565b34801561108757600080fd5b506105c26004803603604081101561109e57600080fd5b508035906020013561422d565b3480156110b757600080fd5b5061051b614862565b3480156110cc57600080fd5b50610560600480360360208110156110e357600080fd5b50356001600160a01b0316614867565b3480156110ff57600080fd5b5061051b61487c565b34801561111457600080fd5b506105c2600480360360c081101561112b57600080fd5b5080359060208101359060408101359060608101359060808101359060a00135614881565b34801561115c57600080fd5b5061051b614912565b34801561117157600080fd5b5061117a61491e565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156111b657818101518382015260200161119e565b505050509050019250505060405180910390f35b3480156111d657600080fd5b50610817614995565b3480156111eb57600080fd5b506107516004803603602081101561120257600080fd5b50356001600160a01b03166149a4565b34801561121e57600080fd5b5061051b6149dd565b34801561123357600080fd5b506107516004803603602081101561124a57600080fd5b50356149ed565b34801561125d57600080fd5b506107516004803603606081101561127457600080fd5b506001600160a01b0381351690602081013515159060400135614ac6565b34801561129e57600080fd5b5061051b614b17565b3480156112b357600080fd5b5061051b614b1d565b3480156112c857600080fd5b50610560600480360360408110156112df57600080fd5b506001600160a01b038135169060200135614b3c565b34801561130157600080fd5b5061051b6004803603604081101561131857600080fd5b506001600160a01b0381358116916020013516614bbd565b34801561133c57600080fd5b5061051b614be8565b34801561135157600080fd5b5061051b614bf8565b34801561136657600080fd5b5061051b6004803603602081101561137d57600080fd5b50356001600160a01b0316614bfe565b34801561139957600080fd5b50610751600480360360408110156113b057600080fd5b5080359060200135614c43565b3480156113c957600080fd5b5061051b600480360360208110156113e057600080fd5b50356001600160a01b0316614d13565b3480156113fc57600080fd5b506105c2600480360360c081101561141357600080fd5b5080359060208101359060408101359060608101359060808101359060a00135614d6f565b34801561144457600080fd5b506105c26004803603604081101561145b57600080fd5b5080359060200135614e19565b60135481565b60006001600160a01b0382166114c1576040805162461bcd60e51b815260206004820152601360248201527273657474696e67203020616464726573733b3b60681b604482015290519081900360640190fd5b506001600160a01b0381166000908152601e602052604090205460ff165b919050565b60008060006114f38988615346565b9050600061151261150c670de0b6b3a764000084615459565b876154bb565b905060006115318861152c670de0b6b3a764000085615459565b615346565b905061153e81898861557d565b9350600061154c8d83615459565b9050600061155a828f615346565b90506000611568828761567a565b90506000611576828f6154bb565b905060006115848f83615459565b90506115a08161152c670de0b6b3a76400006064815b04615459565b9950505050505050505097509795505050505050565b60195481565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156116485780601f1061161d57610100808354040283529160200191611648565b820191906000526020600020905b81548152906001019060200180831161162b57829003601f168201915b5050505050905090565b601d602052600090815260409020805460019091015460ff9091169082565b3360008181526005602090815260408083206001600160a01b03871680855290835281842086905581518681529151939490939092600080516020615f76833981519152928290030190a35060015b92915050565b6802b5e3af16b188000081565b600b546001600160a01b031633146116ea57600080fd5b6001600160a01b03821661173b576040805162461bcd60e51b815260206004820152601360248201527273657474696e67203020616464726573733b3b60681b604482015290519081900360640190fd5b6001600160a01b03919091166000908152601e60205260409020805460ff1916911515919091179055565b60008061177233615788565b156117ae5760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b600260005414156117f4576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b600260009081556040805160208082523690820181905233936001600160e01b03198135169390929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff161561185d57600080fd5b6009805461ff001916610100179055600d54600e546001600160a01b039182166000818152601b6020526040808220939094168082529390206003830154919392916118b5906002670de0b6b3a76400005b046154bb565b3411156118fc576040805162461bcd60e51b815260206004820152601060248201526f4552525f4d41585f494e5f524154494f60801b604482015290519081900360640190fd5b6003808301549082015460009161191f9168015af1d78b58c40000908185614035565b9050600061195d8460030154670de0b6b3a76400006019028560030154670de0b6b3a76400006019026064346063028161195557fe5b046000614881565b9098509050888810156119a7576040805162461bcd60e51b815260206004820152600d60248201526c11549497d31253525517d3d555609a1b604482015290519081900360640190fd5b6119b76064606334020489615346565b8211156119fd576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b600d60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611a4d57600080fd5b505af1158015611a61573d6000803e3d6000fd5b5050505050611a71858b8a6157da565b601854600e54604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015611abf57600080fd5b505afa158015611ad3573d6000803e3d6000fd5b505050506040513d6020811015611ae957600080fd5b5051600e546001600160a01b039081166000908152601b602090815260409182902094909303600390940193909355601954600d5484516370a0823160e01b8152306004820152945191949216926370a082319260248082019391829003018186803b158015611b5857600080fd5b505afa158015611b6c573d6000803e3d6000fd5b505050506040513d6020811015611b8257600080fd5b5051600d546001600160a01b03166000908152601b60205260408120929091036003928301558582015491850154611bc8929168015af1d78b58c4000091908290614035565b965081871015611c11576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b6001600160a01b0380861690871633600080516020615ed183398151915260646063340204606460628e026040805193845291900460208301528051918290030190a45050505050506009805461ff0019169055600160005590939092509050565b601c602052600090815260409020805460019091015460ff9091169082565b60155481565b600954600090610100900460ff1615611cb057600080fd5b6001600160a01b0383166000908152601b602052604090205460ff16611d0d576040805162461bcd60e51b815260206004820152600d60248201526c11549497d393d517d093d55391609a1b604482015290519081900360640190fd5b6001600160a01b0382166000908152601b602052604090205460ff16611d6a576040805162461bcd60e51b815260206004820152600d60248201526c11549497d393d517d093d55391609a1b604482015290519081900360640190fd5b6001600160a01b038084166000908152601b60205260408082209285168252902060038083015490820154601654611daf929168015af1d78b58c40000918290614035565b95945050505050565b600d546001600160a01b031681565b600080611dd333615788565b15611e0f5760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b60026000541415611e55576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b600260009081556040805160208082523690820181905233936001600160e01b03198135169390929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff1615611ebe57600080fd5b6009805461ff001916610100179055600e54600d546001600160a01b039182166000818152601b602052604080822093909416808252939020600380840154905492949392611f0d91906154bb565b881115611f52576040805162461bcd60e51b815260206004820152600e60248201526d4552525f53454c4c5f524154494f60901b604482015290519081900360640190fd5b60038083015490820154600091611f7f9168015af1d78b58c400009081606460628f025b04601654614881565b909750905087871015611fc9576040805162461bcd60e51b815260206004820152600d60248201526c11549497d31253525517d3d555609a1b604482015290519081900360640190fd5b6001600160a01b0380851690861633600080516020615ed1833981519152606460628e0204606460638d026040805193845291900460208301528051918290030190a461201785338b6158ab565b60006120308861202b6013546103e8615346565b6154bb565b905060006120468961202b601154612710615346565b9050600061205c8a61202b601254612710615346565b905060006120738461206e8585615904565b615459565b600d5460408051632e1a7d4d60e01b815260048101849052905192935083926001600160a01b0390921691632e1a7d4d9160248082019260009290919082900301818387803b1580156120c557600080fd5b505af11580156120d9573d6000803e3d6000fd5b505050506120f48f606483606302816120ee57fe5b04615958565b6120fe8985615a50565b600f546001600160a01b03166000908152602080526040812080548501905560198054850190556003808a015490890154601654612149929168015af1d78b58c40000918290614035565b90506121558f8e615346565b81111561219b576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b601854600e54604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156121e957600080fd5b505afa1580156121fd573d6000803e3d6000fd5b505050506040513d602081101561221357600080fd5b5051600e546001600160a01b039081166000908152601b602090815260409182902094909303600390940193909355601954600d5484516370a0823160e01b8152306004820152945191949216926370a082319260248082019391829003018186803b15801561228257600080fd5b505afa158015612296573d6000803e3d6000fd5b505050506040513d60208110156122ac57600080fd5b5051600d546001600160a01b03166000908152601b6020526040902091900360039182015589810154908901546016546122f3929168015af1d78b58c40000918290614035565b9b50808c101561233c576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b50505050505050505050506009805461ff001916905560016000559094909350915050565b60065490565b6402540be400670de0b6b3a76400005b0481565b6001600160a01b03166000908152601c602052604090205460ff1690565b670de0b6b3a764000081565b60008060006123b48988615346565b905060006123cd61150c670de0b6b3a764000084615459565b905060006123e78861202b670de0b6b3a764000085615459565b90506123f488828861557d565b935060006124028d83615904565b90506000612410828f615346565b9050600061241e828761567a565b9050600061242c828f6154bb565b9050612438818f615459565b98505050505050505097509795505050505050565b6000336001600160a01b038516148061248957506001600160a01b03841660009081526005602090815260408083203384529091529020548211155b61249257600080fd5b60408051628503ed60e61b8152336004820152905160009182918291632140fb40916024808301926020929190829003018186803b1580156124d357600080fd5b505afa1580156124e7573d6000803e3d6000fd5b505050506040513d60208110156124fd57600080fd5b5051905060018115151461254e576040805162461bcd60e51b815260206004820152601360248201527202a3930b739b332b91034b9902637b1b5b2b21606d1b604482015290519081900360640190fd5b612559868686615b18565b336001600160a01b0387161480159061259757506001600160a01b038616600090815260056020908152604080832033845290915290205460001914155b15612619576001600160a01b03861660009081526005602090815260408083203384529091529020546125ca9085615459565b6001600160a01b0387811660009081526005602090815260408083203380855290835292819020859055805194855251928916939192600080516020615f768339815191529281900390910190a35b50600195945050505050565b61262e33615788565b1561266a5760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b600260005414156126b0576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b600260009081556040805160208082523690820181905233936001600160e01b03198135169390929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff161561271957600080fd5b6009805461ff001916610100179055336000908152601c60205260409020805460ff161515600114156127895742816001015411156127895760405162461bcd60e51b8152600401808060200182810382526047815260200180615ef16047913960600191505060405180910390fd5b6000612793612361565b905060006127ab866064670de0b6b3a76400006118af565b905060006127b98783615459565b905060006127c78285615346565b90508061280d576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b6128173389615beb565b600a5461282d906001600160a01b031684615bf5565b61283682615bff565b60005b601754811015612ab85760006017828154811061285257fe5b60009182526020808320909101546001600160a01b0316808352601b90915260408220600301549092509061288785836154bb565b9050806128cd576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b8a8a858181106128d957fe5b90506020020135811015612924576040805162461bcd60e51b815260206004820152600d60248201526c11549497d31253525517d3d555609a1b604482015290519081900360640190fd5b604080518281526000602082015281516001600160a01b0386169233927f9d9058fd2f25ccc389fec7720abef0ca83472f5abfafd5f10d37f51e6a0493f3929081900390910190a36129778333836157da565b601854600e54604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156129c557600080fd5b505afa1580156129d9573d6000803e3d6000fd5b505050506040513d60208110156129ef57600080fd5b5051600e546001600160a01b039081166000908152601b602090815260409182902094909303600390940193909355601954600d5484516370a0823160e01b8152306004820152945191949216926370a082319260248082019391829003018186803b158015612a5e57600080fd5b505afa158015612a72573d6000803e3d6000fd5b505050506040513d6020811015612a8857600080fd5b5051600d546001600160a01b03166000908152601b60205260409020919003600390910155505050600101612839565b50506009805461ff0019169055505060016000555050505050565b6001600160a01b03166000908152601f6020908152604080832054918052909120549091565b6001600160a01b03166000908152601b602052604090205460ff1690565b600954600090610100900460ff1615612b2f57600080fd5b50600b546001600160a01b031690565b612b4833615788565b15612b845760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b60026000541415612bca576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b60026000908155338152601f6020526040902054811115612c25576040805162461bcd60e51b815260206004820152601060248201526f2737ba1032b737bab3b4103a37b5b2b760811b604482015290519081900360640190fd5b60006103e8601454830281612c3657fe5b336000908152601f6020526040808220805487900390556001600160a01b0387811683529120805493909204928301909155600e5460105492935083850392612c84929182169116836157da565b601880549190910390555050600160005550565b60095460ff1690565b600f546001600160a01b031681565b336001600160a01b03166000356001600160e01b0319166001600160e01b03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff1615612d2657600080fd5b6009805461ff001916610100179055600b54336001600160a01b0390911614612d4e57600080fd5b6001600160a01b0382166000908152601b602052604090205460ff1615612d7457600080fd5b6000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612dc357600080fd5b505afa158015612dd7573d6000803e3d6000fd5b505050506040513d6020811015612ded57600080fd5b5051905080821115612dfe57600080fd5b612e098333846157da565b50506009805461ff001916905550565b600b546001600160a01b03163314612e3057600080fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6010546001600160a01b031681565b600c546001600160a01b03163314612e7857600080fd5b601a5460ff1615612e8857600080fd5b600e54600d54604080516080810182526001815268015af1d78b58c400006020820152601754918101919091526001600160a01b03928316929091169060608101606460628702049052600e546001600160a01b03166000908152601b60209081526040918290208351815460ff191690151517815583820151600180830191909155848401516002830155606094850151600390920191909155825160808101845290815268015af1d78b58c400009181019190915260175491810191909152908101606460638602049052600d80546001600160a01b039081166000908152601b602090815260408083208651815490151560ff1991821617825592870151600182810191909155918701516002820155606090960151600390960195909555601a805490911685179055600e54601780548087018255928190527fc624b66cc0138b8fabc209247f72d758e1cf3343756d543badbf24212bed8c1592830180546001600160a01b0319908116938616939093179055935484549586019094559301805490931691161790556130218233866158ab565b61302c8133856158ab565b61303e68056bc75e2d63100000615c08565b6130513368056bc75e2d63100000615bf5565b5050336000908152601c60209081526040808320601d909252909120815460ff191660019081179092556301e1338042019101555050565b61309233615788565b156130ce5760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b60026000541415613114576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b60026000908155600e54338252601f6020526040909120546001600160a01b039091169082111561317f576040805162461bcd60e51b815260206004820152601060248201526f2737ba1032b737bab3b4103a37b5b2b760811b604482015290519081900360640190fd5b601880548390039055336000818152601f60205260409020805484900390556131aa908290846157da565b50506001600055565b60115481565b60145481565b6131c833615788565b156132045760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b6002600054141561324a576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b6002600055600e546001600160a01b03166132668133846158ab565b50601880546064606293909302929092049182019055336000908152601f60205260408120805490920190915560019055565b3360009081526005602090815260408083206001600160a01b0386168452909152812054808311156132ee573360009081526005602090815260408083206001600160a01b038816845290915281205561331d565b6132f88184615459565b3360009081526005602090815260408083206001600160a01b03891684529091529020555b3360008181526005602090815260408083206001600160a01b038916808552908352928190205481519081529051929392600080516020615f76833981519152929181900390910190a35060019392505050565b61337a33615788565b156133b65760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b600260005414156133fc576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b60026000908155338152602080526040902054811115613456576040805162461bcd60e51b815260206004820152601060248201526f2737ba1032b737bab3b4103a37b5b2b760811b604482015290519081900360640190fd5b60006103e860155483028161346757fe5b336000908152602080526040808220805487900390556001600160a01b039687168252808220805494909304938401909255600a5490951685528420805491909303019091555060019055565b6001600160a01b031660009081526004602052604090205490565b6134d833615788565b156135145760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b6002600054141561355a576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b600260009081556040805160208082523690820181905233936001600160e01b03198135169390929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff16156135c357600080fd5b6009805461ff00191661010017905560006135dc612361565b905060006135ea8583615346565b905080613630576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b60005b6017548110156138b55760006017828154811061364c57fe5b60009182526020808320909101546001600160a01b0316808352601b90915260408220600301549092509061368185836154bb565b9050806136c7576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b8787858181106136d357fe5b9050602002013581111561371d576040805162461bcd60e51b815260206004820152600c60248201526b22a9292fa624a6a4aa2fa4a760a11b604482015290519081900360640190fd5b6001600160a01b038316337f15a8ca63e37b2cff1677df2b6b82d36fcf8a524228bd7a4b4d02d107c28c1e8a60646062850260408051929091048252600060208301528051918290030190a36137748333836158ab565b601854600e54604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156137c257600080fd5b505afa1580156137d6573d6000803e3d6000fd5b505050506040513d60208110156137ec57600080fd5b5051600e546001600160a01b039081166000908152601b602090815260409182902094909303600390940193909355601954600d5484516370a0823160e01b8152306004820152945191949216926370a082319260248082019391829003018186803b15801561385b57600080fd5b505afa15801561386f573d6000803e3d6000fd5b505050506040513d602081101561388557600080fd5b5051600d546001600160a01b03166000908152601b60205260409020919003600390910155505050600101613633565b506138bf85615c7d565b6138c93386615bf5565b50506009805461ff00191690555050600160005550565b336000818152601c60209081526040808320601d909252909120600181015442101561393d5760405162461bcd60e51b8152600401808060200182810382526047815260200180615ef16047913960600191505060405180910390fd5b50805460ff1916905550565b66071afd498d000081565b64e8d4a51000670de0b6b3a7640000612377565b6000806139758786615346565b905060006139918561202b670de0b6b3a764000060648161159a565b9050600061399f8883615459565b905060006139ad828a615346565b905060006139cc826139c7670de0b6b3a764000088615346565b61567a565b905060006139da828e6154bb565b905060006139e88e83615459565b90506000613a07613a01670de0b6b3a76400008a615459565b8b6154bb565b9050613a1f8261202b670de0b6b3a764000084615459565b9f9e505050505050505050505050505050565b600c546001600160a01b03163314613a91576040805162461bcd60e51b815260206004820152601a60248201527f596f7520646f206e6f742068617665207065726d697373696f6e000000000000604482015290519081900360640190fd5b60008111613ad8576040805162461bcd60e51b815260206004820152600f60248201526e31b0b73737ba103a3ab9371037b33360891b604482015290519081900360640190fd5b6064811115613b24576040805162461bcd60e51b815260206004820152601360248201527263616e6e6f742073657420756e64657220312560681b604482015290519081900360640190fd5b600155565b600c546001600160a01b03163314613b4057600080fd5b60c8811115613b8d576040805162461bcd60e51b81526020600482015260146024820152732043616e6e6f7420736574206f7665722032302560601b604482015290519081900360640190fd5b60008111613bd5576040805162461bcd60e51b815260206004820152601060248201526f02043616e6e6f742073657420746f20360841b604482015290519081900360640190fd5b601355565b336001600160a01b03166000356001600160e01b0319166001600160e01b03191660003660405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff1615613c5057600080fd5b6009805461ff001916610100179055600b54336001600160a01b0390911614613c7857600080fd5b600b80546001600160a01b0319166001600160a01b03929092169190911790556009805461ff0019169055565b600954600090610100900460ff1615613cbd57600080fd5b5060215490565b68056bc75e2d6310000081565b600081565b600954610100900460ff1615613ceb57600080fd5b6001600160a01b0381166000908152601b602052604090205460ff16613d1057600080fd5b50565b601a5460ff1681565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156116485780601f1061161d57610100808354040283529160200191611648565b6704a03ce68d21555681565b6002546001600160a01b031681565b6542524f4e5a4560d01b90565b613dae33615788565b15613dea5760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b60026000541415613e30576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b60026000908155600d54338252602080526040909120546001600160a01b0390911690821115613e99576040805162461bcd60e51b815260206004820152600f60248201526e04e6f7420656e6f756768205772617608c1b604482015290519081900360640190fd5b6019805483900390553360008181526020805260409020805484900390556131aa908290846157da565b600d546040805163095ea7b360e01b81526001600160a01b0390921660048301526e13426172c74d822b878fe800000000602483015251309163095ea7b39160448083019260209291908290030181600087803b158015613f2357600080fd5b505af1158015613f37573d6000803e3d6000fd5b505050506040513d6020811015613f4d57600080fd5b5050565b600b546001600160a01b03163314613f6857600080fd5b6064811115613fb4576040805162461bcd60e51b81526020600482015260136024820152722043616e6e6f7420736574206f76657220312560681b604482015290519081900360640190fd5b60008111613ffc576040805162461bcd60e51b815260206004820152601060248201526f02043616e6e6f742073657420746f20360841b604482015290519081900360640190fd5b601155565b336000908152601c60209081526040808320601d909252909120815460ff191660019081179092556301e133804201910155565b6000806140428787615346565b905060006140508686615346565b9050600061405e8383615346565b90506000614080670de0b6b3a764000061152c670de0b6b3a764000089615459565b905061408c82826154bb565b9a9950505050505050505050565b60185481565b600c546001600160a01b031633146140b757600080fd5b6064811115614103576040805162461bcd60e51b81526020600482015260136024820152722043616e6e6f7420736574206f76657220312560681b604482015290519081900360640190fd5b6000811161414b576040805162461bcd60e51b815260206004820152601060248201526f02043616e6e6f742073657420746f20360841b604482015290519081900360640190fd5b601255565b60015481565b6000806000816001600160a01b0316632140fb40336040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156141a857600080fd5b505afa1580156141bc573d6000803e3d6000fd5b505050506040513d60208110156141d257600080fd5b505190506001811515146142175760405162461bcd60e51b8152600401808060200182810382526047815260200180615ef16047913960600191505060405180910390fd5b614222338686615b18565b506001949350505050565b60008061423933615788565b156142755760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b600260005414156142bb576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b600260009081556040805160208082523690820181905233936001600160e01b03198135169390929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff161561432457600080fd5b6009805461ff001916610100179055600e54600d54336000908152601f60205260409020546001600160a01b039283169291909116908611156143a1576040805162461bcd60e51b815260206004820152601060248201526f2737ba1032b737bab3b4102a37b5b2b760811b604482015290519081900360640190fd5b6001600160a01b038083166000908152601b60205260408082209284168252902060038083015490546143d491906154bb565b881115614419576040805162461bcd60e51b815260206004820152600e60248201526d4552525f53454c4c5f524154494f60901b604482015290519081900360640190fd5b60006144488360030154670de0b6b3a76400006019028460030154670de0b6b3a7640000601902601654614035565b9050600061447e8460030154670de0b6b3a76400006019028560030154670de0b6b3a764000060190260648f60620281611f7657fe5b9098509050888810156144c8576040805162461bcd60e51b815260206004820152600d60248201526c11549497d31253525517d3d555609a1b604482015290519081900360640190fd5b6144d28a89615346565b821115614518576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b846001600160a01b0316866001600160a01b0316336001600160a01b0316600080516020615ed18339815191528d8c604051808381526020018281526020019250505060405180910390a460006145778961202b6013546103e8615346565b9050600061458d8a61202b601154612710615346565b905060006145a38b61202b601254612710615346565b905060006145b58461206e8585615904565b905060006145c38284615904565b90508e601f6000336001600160a01b03166001600160a01b031681526020019081526020016000205403601f6000336001600160a01b03166001600160a01b03168152602001908152602001600020819055508160206000336001600160a01b03166001600160a01b03168152602001908152602001600020540160206000336001600160a01b03166001600160a01b031681526020019081526020016000208190555080601954016019819055508e601854036018819055506146878a85615a50565b600f546001600160a01b0390811660009081526020808052604091829020805487019055601854600e5483516370a0823160e01b81523060048201529351919416926370a08231926024808301939192829003018186803b1580156146eb57600080fd5b505afa1580156146ff573d6000803e3d6000fd5b505050506040513d602081101561471557600080fd5b5051600e546001600160a01b039081166000908152601b602090815260409182902094909303600390940193909355601954600d5484516370a0823160e01b8152306004820152945191949216926370a082319260248082019391829003018186803b15801561478457600080fd5b505afa158015614798573d6000803e3d6000fd5b505050506040513d60208110156147ae57600080fd5b5051600d546001600160a01b03166000908152601b6020526040902091900360039182015589810154908901546016546147f5929168015af1d78b58c40000918290614035565b9b50868c101561483e576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b50505050505050505050506009805461ff0019169055600160005590939092509050565b600281565b601e6020526000908152604090205460ff1681565b600181565b60008060006148908887615346565b905060006148a6670de0b6b3a764000086615459565b90506148b286826154bb565b905060006148c48b61152c8d85615904565b905060006148d2828561567a565b905060006148e8670de0b6b3a764000083615459565b90506148f48b826154bb565b96506149008985615459565b95505050505050965096945050505050565b671bc16d674ec7ffff81565b600954606090610100900460ff161561493657600080fd5b601780548060200260200160405190810160405280929190818152602001828054801561164857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161496e575050505050905090565b600e546001600160a01b031681565b600b546001600160a01b031633146149bb57600080fd5b600f80546001600160a01b0319166001600160a01b0392909216919091179055565b6064670de0b6b3a7640000612377565b6149f633615788565b15614a325760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b60026000541415614a78576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b6002600055600d546001600160a01b0316614a948133846158ab565b506019805460646063939093029290920491820190553360009081526020805260408120805490920190915560019055565b600b546001600160a01b03163314614add57600080fd5b6001600160a01b03929092166000908152601c60209081526040808320601d909252909120815460ff191692151592909217905560010155565b60035481565b600954600090610100900460ff1615614b3557600080fd5b5060165490565b3360009081526005602090815260408083206001600160a01b0386168452909152812054614b6a9083615904565b3360008181526005602090815260408083206001600160a01b038916808552908352928190208590558051948552519193600080516020615f76833981519152929081900390910190a350600192915050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b6002670de0b6b3a7640000612377565b60125481565b600954600090610100900460ff1615614c1657600080fd5b6001600160a01b0382166000908152601b602052604090205460ff16614c3b57600080fd5b505060215490565b600b546001600160a01b03163314614c5a57600080fd5b60648211158015614c6c575060648111155b614cb4576040805162461bcd60e51b81526020600482015260146024820152732043616e6e6f7420736574206f7665722031302560601b604482015290519081900360640190fd5b600082118015614cc45750600081115b614d08576040805162461bcd60e51b815260206004820152601060248201526f02043616e6e6f742073657420746f20360841b604482015290519081900360640190fd5b601491909155601555565b600954600090610100900460ff1615614d2b57600080fd5b6001600160a01b0382166000908152601b602052604090205460ff16614d5057600080fd5b506001600160a01b03166000908152601b602052604090206003015490565b6000806000614d7e8689615346565b90506000614d8c8887615459565b90506000614d9a8983615346565b90506000614da8828561567a565b9050614dbc81670de0b6b3a7640000615459565b9050614dc88c826154bb565b9050614ddc670de0b6b3a764000088615459565b9550614de88187615346565b9550614dfc81670de0b6b3a7640000615346565b9450614e088686615459565b945050505050965096945050505050565b600080614e2533615788565b15614e615760405162461bcd60e51b815260040180806020018281038252603e815260200180615f38603e913960400191505060405180910390fd5b60026000541415614ea7576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb1833981519152604482015290519081900360640190fd5b600260009081556040805160208082523690820181905233936001600160e01b03198135169390929081908101848480828437600083820152604051601f909101601f19169092018290039550909350505050a2600954610100900460ff1615614f1057600080fd5b6009805461ff001916610100179055600d54600e543360009081526020805260409020546001600160a01b03928316929190911690861115614f99576040805162461bcd60e51b815260206004820152601d60248201527f4e6f7420656e6f75676820577261702c206465706f736974206d6f7265000000604482015290519081900360640190fd5b6001600160a01b038083166000908152601b6020526040808220928416825290206003820154614fd3906002670de0b6b3a76400006118af565b88111561501a576040805162461bcd60e51b815260206004820152601060248201526f4552525f4d41585f494e5f524154494f60801b604482015290519081900360640190fd5b6003808301549082015460009161503d9168015af1d78b58c40000908185614035565b905060006150738460030154670de0b6b3a76400006019028560030154670de0b6b3a764000060190260648f6063028161195557fe5b9098509050888810156150bd576040805162461bcd60e51b815260206004820152600d60248201526c11549497d31253525517d3d555609a1b604482015290519081900360640190fd5b6150c78a89615346565b82111561510d576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b3360009081526020808052604080832080548e90039055601f82529182902080548b019055601980548d90039055601880548b0190819055600e5483516370a0823160e01b8152306004820152935191936001600160a01b03909116926370a0823192602480840193829003018186803b15801561518a57600080fd5b505afa15801561519e573d6000803e3d6000fd5b505050506040513d60208110156151b457600080fd5b5051600e546001600160a01b039081166000908152601b602090815260409182902094909303600390940193909355601954600d5484516370a0823160e01b8152306004820152945191949216926370a082319260248082019391829003018186803b15801561522357600080fd5b505afa158015615237573d6000803e3d6000fd5b505050506040513d602081101561524d57600080fd5b5051600d546001600160a01b03166000908152601b60205260408120929091036003928301558582015491850154615293929168015af1d78b58c4000091908290614035565b9650818710156152dc576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b846001600160a01b0316866001600160a01b0316336001600160a01b0316600080516020615ed18339815191528d8c604051808381526020018281526020019250505060405180910390a45050505050506009805461ff0019169055600160005590939092509050565b600081615389576040805162461bcd60e51b815260206004820152600c60248201526b4552525f4449565f5a45524f60a01b604482015290519081900360640190fd5b670de0b6b3a764000083028315806153b15750670de0b6b3a76400008482816153ae57fe5b04145b6153f5576040805162461bcd60e51b815260206004820152601060248201526f11549497d1125597d25395115493905360821b604482015290519081900360640190fd5b60028304810181811015615443576040805162461bcd60e51b815260206004820152601060248201526f11549497d1125597d25395115493905360821b604482015290519081900360640190fd5b600084828161544e57fe5b049695505050505050565b60008060006154688585615c86565b9150915080156154b3576040805162461bcd60e51b81526020600482015260116024820152704552525f5355425f554e444552464c4f5760781b604482015290519081900360640190fd5b509392505050565b60008282028315806154d55750828482816154d257fe5b04145b615519576040805162461bcd60e51b815260206004820152601060248201526f4552525f4d554c5f4f564552464c4f5760801b604482015290519081900360640190fd5b6706f05b59d3b2000081018181101561556c576040805162461bcd60e51b815260206004820152601060248201526f4552525f4d554c5f4f564552464c4f5760801b604482015290519081900360640190fd5b6000670de0b6b3a76400008261544e565b6000828410156155c6576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b670de0b6b3a7640000821115615619576040805162461bcd60e51b81526020600482015260136024820152724552525f494e56414c49445f5245534552564560681b604482015290519081900360640190fd5b60006156258585615459565b905061563181846154bb565b9150818110156154b3576040805162461bcd60e51b815260206004820152600f60248201526e08aa4a4be9a82a890be82a0a0a49eb608b1b604482015290519081900360640190fd5b600060018310156156ca576040805162461bcd60e51b81526020600482015260156024820152744552525f42504f575f424153455f544f4f5f4c4f5760581b604482015290519081900360640190fd5b671bc16d674ec7ffff831115615720576040805162461bcd60e51b815260206004820152601660248201527508aa4a4be84a09eaebe8482a68abea89e9ebe90928e960531b604482015290519081900360640190fd5b600061572b83615cab565b905060006157398483615459565b9050600061574f8661574a85615cc6565b615cd4565b9050816157605792506116c0915050565b600061577187846305f5e100615d2b565b905061577d82826154bb565b979650505050505050565b60006157938261146e565b156157a0575060006114df565b813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906157d25750808214155b949350505050565b6000836001600160a01b031663a9059cbb84846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561583357600080fd5b505af1158015615847573d6000803e3d6000fd5b505050506040513d602081101561585d57600080fd5b50519050806158a5576040805162461bcd60e51b815260206004820152600f60248201526e4552525f45524332305f46414c534560881b604482015290519081900360640190fd5b50505050565b604080516323b872dd60e01b81526001600160a01b0384811660048301523060248301526044820184905291516000928616916323b872dd91606480830192602092919082900301818787803b15801561583357600080fd5b600082820183811015615951576040805162461bcd60e51b815260206004820152601060248201526f4552525f4144445f4f564552464c4f5760801b604482015290519081900360640190fd5b9392505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b602083106159a45780518252601f199092019160209182019101615985565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615a06576040519150601f19603f3d011682016040523d82523d6000602084013e615a0b565b606091505b5050905080615a4b5760405162461bcd60e51b8152600401808060200182810382526023815260200180615f966023913960400191505060405180910390fd5b505050565b6002546040805163a9059cbb60e01b81526001600160a01b03928316600482015260248101849052905160009285169163a9059cbb91604480830192602092919082900301818787803b158015615aa657600080fd5b505af1158015615aba573d6000803e3d6000fd5b505050506040513d6020811015615ad057600080fd5b5051905080615a4b576040805162461bcd60e51b815260206004820152600f60248201526e4552525f45524332305f46414c534560881b604482015290519081900360640190fd5b6001600160a01b038316600090815260046020526040902054811115615b3d57600080fd5b6001600160a01b038316600090815260046020526040902054615b609082615459565b6001600160a01b038085166000908152600460205260408082209390935590841681522054615b8f9082615904565b6001600160a01b0380841660008181526004602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b613f4d8282615e09565b613f4d8282615e14565b613d1081615e1f565b30600090815260046020526040902054615c229082615904565b30600090815260046020526040902055600654615c3f9082615904565b60065560408051828152905130916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350565b613d1081615c08565b600080828410615c9c5750508082036000615ca4565b505081810360015b9250929050565b6000670de0b6b3a7640000615cbf83615cc6565b0292915050565b670de0b6b3a7640000900490565b60008060028306615ced57670de0b6b3a7640000615cef565b835b90506002830492505b821561595157615d0884856154bb565b93506002830615615d2057615d1d81856154bb565b90505b600283049250615cf8565b6000828180615d4287670de0b6b3a7640000615c86565b9092509050670de0b6b3a764000080600060015b888410615dfa576000670de0b6b3a764000082029050600080615d8a8a615d8585670de0b6b3a7640000615459565b615c86565b91509150615d9c8761202b848c6154bb565b9650615da88784615346565b965086615db757505050615dfa565b8715615dc1579315935b8015615dcb579315935b8415615de257615ddb8688615459565b9550615def565b615dec8688615904565b95505b505050600101615d56565b50909998505050505050505050565b613f4d823083615b18565b613f4d308383615b18565b30600090815260046020526040902054811115615e3b57600080fd5b30600090815260046020526040902054615e559082615459565b30600090815260046020526040902055600654615e729082615459565b60065560408051828152905160009130917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35056fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d433784c6971756964697479206973206c6f636b65642c20796f752063616e6e6f742072656d6f7665206c697175696469747920756e74696c206166746572206c6f636b2074696d652e556e617070726f76656420636f6e74726163747320617265206e6f7420616c6c6f77656420746f20696e74657261637420776974682074686520737761708c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255472616e7366657248656c7065723a204554485f5452414e534645525f4641494c4544a2646970667358221220fb9f151e92c1efed1a487a5a396a5ced323f106c4ede3e11e9e5ee5060405d0f64736f6c63430007060033
[ 0, 7, 12, 13, 5 ]
0xf1e48f13768bd8114a530070b43257a63f24bb12
pragma solidity 0.4.21; // File: zeppelin-solidity/contracts/ReentrancyGuard.sol /** * @title Helps contracts guard agains reentrancy attacks. * @author Remco Bloemen <remco@2π.com> * @notice If you mark a function `nonReentrant`, you should also * mark it `external`. */ contract ReentrancyGuard { /** * @dev We use a single lock for the whole contract. */ bool private reentrancy_lock = false; /** * @dev Prevents a contract from calling itself, directly or indirectly. * @notice If you mark a function `nonReentrant`, you should also * mark it `external`. Calling one nonReentrant function from * another is not supported. Instead, you can implement a * `private` function doing the actual work, and a `external` * wrapper marked as `nonReentrant`. */ modifier nonReentrant() { require(!reentrancy_lock); reentrancy_lock = true; _; reentrancy_lock = false; } } // File: 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)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } } // File: zeppelin-solidity/contracts/lifecycle/Pausable.sol /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } // File: 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 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) { uint256 c = a + b; assert(c >= a); return c; } } // File: 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: 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: zeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; function DetailedERC20(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } } // File: 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]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } } // File: 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); 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, 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; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } // File: contracts/BsktToken.sol library AddressArrayUtils { /// @return Returns index and ok for the first occurrence starting from /// index 0 function index(address[] addresses, address a) internal pure returns (uint, bool) { for (uint i = 0; i < addresses.length; i++) { if (addresses[i] == a) { return (i, true); } } return (0, false); } } /// @title BsktToken /// @notice Bskt tokens are transferable, and can be created and redeemed by /// anyone. To create, a user must approve the contract to move the underlying /// tokens, then call `create`. /// @author CryptoFin contract BsktToken is StandardToken, DetailedERC20, Pausable, ReentrancyGuard { using SafeMath for uint256; using AddressArrayUtils for address[]; struct TokenInfo { address addr; uint256 quantity; } uint256 public creationUnit; TokenInfo[] public tokens; event Create(address indexed creator, uint256 amount); event Redeem(address indexed redeemer, uint256 amount, address[] skippedTokens); /// @notice Requires value to be divisible by creationUnit /// @param value Number to be checked modifier requireMultiple(uint256 value) { require((value % creationUnit) == 0); _; } /// @notice Requires value to be non-zero /// @param value Number to be checked modifier requireNonZero(uint256 value) { require(value > 0); _; } /// @notice Initializes contract with a list of ERC20 token addresses and /// corresponding minimum number of units required for a creation unit /// @param addresses Addresses of the underlying ERC20 token contracts /// @param quantities Number of token base units required per creation unit /// @param _creationUnit Number of base units per creation unit function BsktToken( address[] addresses, uint256[] quantities, uint256 _creationUnit, string _name, string _symbol ) DetailedERC20(_name, _symbol, 18) public { require(addresses.length > 0); require(addresses.length == quantities.length); require(_creationUnit >= 1); for (uint256 i = 0; i < addresses.length; i++) { tokens.push(TokenInfo({ addr: addresses[i], quantity: quantities[i] })); } creationUnit = _creationUnit; name = _name; symbol = _symbol; } /// @notice Creates Bskt tokens in exchange for underlying tokens. Before /// calling, underlying tokens must be approved to be moved by the Bskt /// contract. The number of approved tokens required depends on baseUnits. /// @dev If any underlying tokens' `transferFrom` fails (eg. the token is /// frozen), create will no longer work. At this point a token upgrade will /// be necessary. /// @param baseUnits Number of base units to create. Must be a multiple of /// creationUnit. function create(uint256 baseUnits) external whenNotPaused() requireNonZero(baseUnits) requireMultiple(baseUnits) { // Check overflow require((totalSupply_ + baseUnits) > totalSupply_); for (uint256 i = 0; i < tokens.length; i++) { TokenInfo memory token = tokens[i]; ERC20 erc20 = ERC20(token.addr); uint256 amount = baseUnits.div(creationUnit).mul(token.quantity); require(erc20.transferFrom(msg.sender, address(this), amount)); } mint(msg.sender, baseUnits); emit Create(msg.sender, baseUnits); } /// @notice Redeems Bskt tokens in exchange for underlying tokens /// @param baseUnits Number of base units to redeem. Must be a multiple of /// creationUnit. /// @param tokensToSkip Underlying token addresses to skip redemption for. /// Intended to be used to skip frozen or broken tokens which would prevent /// all underlying tokens from being withdrawn due to a revert. Skipped /// tokens are left in the Bskt contract and are unclaimable. function redeem(uint256 baseUnits, address[] tokensToSkip) external requireNonZero(baseUnits) requireMultiple(baseUnits) { require(baseUnits <= totalSupply_); require(baseUnits <= balances[msg.sender]); require(tokensToSkip.length <= tokens.length); // Total supply check not required since a user would have to have // balance greater than the total supply // Burn before to prevent re-entrancy burn(msg.sender, baseUnits); for (uint256 i = 0; i < tokens.length; i++) { TokenInfo memory token = tokens[i]; ERC20 erc20 = ERC20(token.addr); uint256 index; bool ok; (index, ok) = tokensToSkip.index(token.addr); if (ok) { continue; } uint256 amount = baseUnits.div(creationUnit).mul(token.quantity); require(erc20.transfer(msg.sender, amount)); } emit Redeem(msg.sender, baseUnits, tokensToSkip); } /// @return addresses Underlying token addresses function tokenAddresses() external view returns (address[]){ address[] memory addresses = new address[](tokens.length); for (uint256 i = 0; i < tokens.length; i++) { addresses[i] = tokens[i].addr; } return addresses; } /// @return quantities Number of token base units required per creation unit function tokenQuantities() external view returns (uint256[]){ uint256[] memory quantities = new uint256[](tokens.length); for (uint256 i = 0; i < tokens.length; i++) { quantities[i] = tokens[i].quantity; } return quantities; } // @dev Mints new Bskt tokens // @param to Address to mint to // @param amount Amount to mint // @return ok Whether the operation was successful function mint(address to, uint256 amount) internal returns (bool) { totalSupply_ = totalSupply_.add(amount); balances[to] = balances[to].add(amount); emit Transfer(address(0), to, amount); return true; } // @dev Burns Bskt tokens // @param from Address to burn from // @param amount Amount to burn // @return ok Whether the operation was successful function burn(address from, uint256 amount) internal returns (bool) { totalSupply_ = totalSupply_.sub(amount); balances[from] = balances[from].sub(amount); emit Transfer(from, address(0), amount); return true; } // @notice Look up token quantity and whether token exists // @param token Token address to look up // @return (quantity, ok) Units of underlying token, and whether the // token was found function getQuantity(address token) internal view returns (uint256, bool) { for (uint256 i = 0; i < tokens.length; i++) { if (tokens[i].addr == token) { return (tokens[i].quantity, true); } } return (0, false); } /// @notice Owner: Withdraw excess funds which don't belong to Bskt token /// holders /// @param token ERC20 token address to withdraw function withdrawExcessToken(address token) external onlyOwner nonReentrant { ERC20 erc20 = ERC20(token); uint256 withdrawAmount; uint256 amountOwned = erc20.balanceOf(address(this)); uint256 quantity; bool ok; (quantity, ok) = getQuantity(token); if (ok) { withdrawAmount = amountOwned.sub( totalSupply_.div(creationUnit).mul(quantity) ); } else { withdrawAmount = amountOwned; } require(erc20.transfer(owner, withdrawAmount)); } /// @dev Prevent Bskt tokens from being sent to the Bskt contract /// @param _to The address to transfer tokens to /// @param _value the amount of tokens to be transferred function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(this)); return super.transfer(_to, _value); } /// @dev Prevent Bskt tokens from being sent to the Bskt contract /// @param _from The address to transfer tokens from /// @param _to The address to transfer to /// @param _value The amount of tokens to be transferred function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(this)); return super.transferFrom(_from, _to, _value); } }
0x606060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146101385780630959bd1a146101c6578063095ea7b3146101fd578063119e5cdf1461025757806318160ddd146102805780632075eec6146102a957806323b872dd14610313578063313ce5671461038c5780633f4ba83a146103bb5780634f64b2be146103d05780635c975abb1461043a578063661884631461046757806370a08231146104c1578063780900dc1461050e5780638456cb59146105315780638da5cb5b1461054657806395d89b411461059b578063a9059cbb14610629578063a9989b9314610683578063ce6b3467146106ed578063d73dd62314610726578063dd62ed3e14610780578063f2fde38b146107ec575b600080fd5b341561014357600080fd5b61014b610825565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561018b578082015181840152602081019050610170565b50505050905090810190601f1680156101b85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101d157600080fd5b6101fb600480803590602001909190803590602001908201803590602001919091929050506108c3565b005b341561020857600080fd5b61023d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610bfb565b604051808215151515815260200191505060405180910390f35b341561026257600080fd5b61026a610ced565b6040518082815260200191505060405180910390f35b341561028b57600080fd5b610293610cf3565b6040518082815260200191505060405180910390f35b34156102b457600080fd5b6102bc610cfd565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156102ff5780820151818401526020810190506102e4565b505050509050019250505060405180910390f35b341561031e57600080fd5b610372600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d99565b604051808215151515815260200191505060405180910390f35b341561039757600080fd5b61039f610dea565b604051808260ff1660ff16815260200191505060405180910390f35b34156103c657600080fd5b6103ce610dfd565b005b34156103db57600080fd5b6103f16004808035906020019091905050610ebd565b604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390f35b341561044557600080fd5b61044d610f10565b604051808215151515815260200191505060405180910390f35b341561047257600080fd5b6104a7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610f23565b604051808215151515815260200191505060405180910390f35b34156104cc57600080fd5b6104f8600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506111b4565b6040518082815260200191505060405180910390f35b341561051957600080fd5b61052f60048080359060200190919050506111fc565b005b341561053c57600080fd5b61054461149d565b005b341561055157600080fd5b61055961155e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156105a657600080fd5b6105ae611584565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105ee5780820151818401526020810190506105d3565b50505050905090810190601f16801561061b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561063457600080fd5b610669600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611622565b604051808215151515815260200191505060405180910390f35b341561068e57600080fd5b610696611671565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106d95780820151818401526020810190506106be565b505050509050019250505060405180910390f35b34156106f857600080fd5b610724600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061175b565b005b341561073157600080fd5b610766600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611a12565b604051808215151515815260200191505060405180910390f35b341561078b57600080fd5b6107d6600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611c0e565b6040518082815260200191505060405180910390f35b34156107f757600080fd5b610823600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611c95565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108bb5780601f10610890576101008083540402835291602001916108bb565b820191906000526020600020905b81548152906001019060200180831161089e57829003601f168201915b505050505081565b60006108cd6127eb565b600080600080886000811115156108e357600080fd5b896000600654828115156108f357fe5b0614151561090057600080fd5b6001548b1115151561091157600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548b1115151561095e57600080fd5b6007805490508a8a90501115151561097557600080fd5b61097f338c611ded565b50600097505b600780549050881015610b7b576007888154811015156109a157fe5b90600052602060002090600202016040805190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182015481525050965086600001519550610a6987600001518b8b80806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050611f0d90919063ffffffff16565b80955081965050508315610a7c57610b6e565b610aa78760200151610a996006548e611f9690919063ffffffff16565b611fac90919063ffffffff16565b92508573ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33856040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1515610b4b57600080fd5b5af11515610b5857600080fd5b505050604051805190501515610b6d57600080fd5b5b8780600101985050610985565b3373ffffffffffffffffffffffffffffffffffffffff167f952b7243b53bb61160c8547e81432b1e2dd414de42f06b34aee5436e08d1bbcf8c8c8c60405180848152602001806020018281038252848482818152602001925060200280828437820191505094505050505060405180910390a25050505050505050505050565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60065481565b6000600154905090565b610d0561281b565b610d0d61281b565b6000600780549050604051805910610d225750595b90808252806020026020018201604052509150600090505b600780549050811015610d9157600781815481101515610d5657fe5b9060005260206000209060020201600101548282815181101515610d7657fe5b90602001906020020181815250508080600101915050610d3a565b819250505090565b60003073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610dd657600080fd5b610de1848484611fe7565b90509392505050565b600560009054906101000a900460ff1681565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e5957600080fd5b600560159054906101000a900460ff161515610e7457600080fd5b6000600560156101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b600781815481101515610ecc57fe5b90600052602060002090600202016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154905082565b600560159054906101000a900460ff1681565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115611034576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506110c8565b61104783826123a190919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006112066127eb565b600080600560159054906101000a900460ff1615151561122557600080fd5b8460008111151561123557600080fd5b8560006006548281151561124557fe5b0614151561125257600080fd5b600154876001540111151561126657600080fd5b600095505b60078054905086101561143b5760078681548110151561128757fe5b90600052602060002090600202016040805190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200160018201548152505094508460000151935061133485602001516113266006548a611f9690919063ffffffff16565b611fac90919063ffffffff16565b92508373ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b151561140c57600080fd5b5af1151561141957600080fd5b50505060405180519050151561142e57600080fd5b858060010196505061126b565b61144533886123ba565b503373ffffffffffffffffffffffffffffffffffffffff167fcc9018de05b5f497ee7618d8830568d8ac2d45d0671b73d8f71c67e824122ec7886040518082815260200191505060405180910390a250505050505050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156114f957600080fd5b600560159054906101000a900460ff1615151561151557600080fd5b6001600560156101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561161a5780601f106115ef5761010080835404028352916020019161161a565b820191906000526020600020905b8154815290600101906020018083116115fd57829003601f168201915b505050505081565b60003073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561165f57600080fd5b61166983836124da565b905092915050565b61167961282f565b61168161282f565b60006007805490506040518059106116965750595b90808252806020026020018201604052509150600090505b600780549050811015611753576007818154811015156116ca57fe5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828281518110151561170a57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080806001019150506116ae565b819250505090565b6000806000806000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156117bf57600080fd5b600560169054906101000a900460ff161515156117db57600080fd5b6001600560166101000a81548160ff0219169083151502179055508594508473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561189357600080fd5b5af115156118a057600080fd5b5050506040518051905092506118b5866126f9565b80925081935050508015611905576118fe6118ef836118e1600654600154611f9690919063ffffffff16565b611fac90919063ffffffff16565b846123a190919063ffffffff16565b9350611909565b8293505b8473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16866040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15156119cd57600080fd5b5af115156119da57600080fd5b5050506040518051905015156119ef57600080fd5b6000600560166101000a81548160ff021916908315150217905550505050505050565b6000611aa382600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127cd90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611cf157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515611d2d57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611e04826001546123a190919063ffffffff16565b600181905550611e5b826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123a190919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008060008090505b8451811015611f83578373ffffffffffffffffffffffffffffffffffffffff168582815181101515611f4457fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff161415611f765780600192509250611f8e565b8080600101915050611f16565b600080819150925092505b509250929050565b60008183811515611fa357fe5b04905092915050565b6000806000841415611fc15760009150611fe0565b8284029050828482811515611fd257fe5b04141515611fdc57fe5b8091505b5092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561202457600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561207157600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156120fc57600080fd5b61214d826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123a190919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506121e0826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127cd90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506122b182600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123a190919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008282111515156123af57fe5b818303905092915050565b60006123d1826001546127cd90919063ffffffff16565b600181905550612428826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127cd90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561251757600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561256457600080fd5b6125b5826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546123a190919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612648826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127cd90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008060008090505b6007805490508110156127bc578373ffffffffffffffffffffffffffffffffffffffff1660078281548110151561273557fe5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156127af5760078181548110151561279257fe5b9060005260206000209060020201600101546001925092506127c7565b8080600101915050612702565b600080819150925092505b50915091565b60008082840190508381101515156127e157fe5b8091505092915050565b6040805190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b602060405190810160405280600081525090565b6020604051908101604052806000815250905600a165627a7a72305820b0f05353907f0e36f112352afa24bdd17feed83b95c2ffad6bec199d261831600029
[ 4 ]
0xf1e5015b434dd87a94bd81a2d3a437fc411494fa
// File: openzeppelin-solidity/contracts/token/ERC20/IERC20.sol pragma solidity ^0.5.2; /** * @title ERC20 interface * @dev see https://eips.ethereum.org/EIPS/eip-20 */ 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); } // File: openzeppelin-solidity/contracts/math/SafeMath.sol pragma solidity ^0.5.2; /** * @title SafeMath * @dev Unsigned math operations with safety checks that revert on error */ library SafeMath { /** * @dev Multiplies two unsigned integers, reverts on 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); return c; } /** * @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 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 unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two unsigned integers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } // File: openzeppelin-solidity/contracts/utils/Address.sol pragma solidity ^0.5.2; /** * Utility library of inline functions on addresses */ library Address { /** * 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 account address of the account to check * @return whether the target address is a contract */ function isContract(address account) 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. // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } } // File: openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol pragma solidity ^0.5.2; /** * @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' require((value == 0) || (token.allowance(address(this), spender) == 0)); 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 equal true). * @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. require(address(token).isContract()); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool))); } } } // File: openzeppelin-solidity/contracts/ownership/Ownable.sol pragma solidity ^0.5.2; /** * @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 private _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 () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @return the address of the owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows the current owner to relinquish control of the contract. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. * @notice 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 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/drafts/TokenVesting.sol pragma solidity ^0.5.2; /** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */ contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); event TokenVestingRevoked(address token); // beneficiary of tokens after they are released address private _beneficiary; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _cliff; uint256 private _start; uint256 private _duration; bool private _revocable; mapping (address => uint256) private _released; mapping (address => bool) private _revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param start the time (as Unix time) at which point vesting starts * @param duration duration in seconds of the period in which the tokens will vest * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { require(beneficiary != address(0)); require(cliffDuration <= duration); require(duration > 0); require(start.add(duration) > block.timestamp); _beneficiary = beneficiary; _revocable = revocable; _duration = duration; _cliff = start.add(cliffDuration); _start = start; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the cliff time of the token vesting. */ function cliff() public view returns (uint256) { return _cliff; } /** * @return the start time of the token vesting. */ function start() public view returns (uint256) { return _start; } /** * @return the duration of the token vesting. */ function duration() public view returns (uint256) { return _duration; } /** * @return true if the vesting is revocable. */ function revocable() public view returns (bool) { return _revocable; } /** * @return the amount of the token released. */ function released(address token) public view returns (uint256) { return _released[token]; } /** * @return true if the token is revoked. */ function revoked(address token) public view returns (bool) { return _revoked[token]; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); require(unreleased > 0); _released[address(token)] = _released[address(token)].add(unreleased); token.safeTransfer(_beneficiary, unreleased); emit TokensReleased(address(token), unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { require(_revocable); require(!_revoked[address(token)]); uint256 balance = token.balanceOf(address(this)); uint256 unreleased = _releasableAmount(token); uint256 refund = balance.sub(unreleased); _revoked[address(token)] = true; token.safeTransfer(owner(), refund); emit TokenVestingRevoked(address(token)); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function _releasableAmount(IERC20 token) private view returns (uint256) { return _vestedAmount(token).sub(_released[address(token)]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function _vestedAmount(IERC20 token) private view returns (uint256) { uint256 currentBalance = token.balanceOf(address(this)); uint256 totalBalance = currentBalance.add(_released[address(token)]); if (block.timestamp < _cliff) { return 0; } else if (block.timestamp >= _start.add(_duration) || _revoked[address(token)]) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); } } }
0x608060405234801561001057600080fd5b50600436106100ec576000357c010000000000000000000000000000000000000000000000000000000090048063872a7810116100a95780639852595c116100835780639852595c146101b9578063be9a6555146101df578063f2fde38b146101e7578063fa01dc061461020d576100ec565b8063872a78101461018d5780638da5cb5b146101a95780638f32d59b146101b1576100ec565b80630fb5a6b4146100f157806313d033c01461010b578063191655871461011357806338af3eed1461013b578063715018a61461015f57806374a8f10314610167575b600080fd5b6100f9610233565b60408051918252519081900360200190f35b6100f9610239565b6101396004803603602081101561012957600080fd5b5035600160a060020a031661023f565b005b6101436102fc565b60408051600160a060020a039092168252519081900360200190f35b61013961030b565b6101396004803603602081101561017d57600080fd5b5035600160a060020a0316610375565b6101956104f8565b604080519115158252519081900360200190f35b610143610501565b610195610510565b6100f9600480360360208110156101cf57600080fd5b5035600160a060020a0316610521565b6100f9610540565b610139600480360360208110156101fd57600080fd5b5035600160a060020a0316610546565b6101956004803603602081101561022357600080fd5b5035600160a060020a0316610565565b60045490565b60025490565b600061024a82610583565b90506000811161025957600080fd5b600160a060020a038216600090815260066020526040902054610282908263ffffffff6105bb16565b600160a060020a038084166000818152600660205260409020929092556001546102b49291168363ffffffff6105d416565b60408051600160a060020a03841681526020810183905281517fc7798891864187665ac6dd119286e44ec13f014527aeeb2b8eb3fd413df93179929181900390910190a15050565b600154600160a060020a031690565b610313610510565b151561031e57600080fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b61037d610510565b151561038857600080fd5b60055460ff16151561039957600080fd5b600160a060020a03811660009081526007602052604090205460ff16156103bf57600080fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600091600160a060020a038416916370a0823191602480820192602092909190829003018186803b15801561042257600080fd5b505afa158015610436573d6000803e3d6000fd5b505050506040513d602081101561044c57600080fd5b50519050600061045b83610583565b9050600061046f838363ffffffff61065916565b600160a060020a0385166000908152600760205260409020805460ff1916600117905590506104b661049f610501565b600160a060020a038616908363ffffffff6105d416565b60408051600160a060020a038616815290517f39983c6d4d174a7aee564f449d4a5c3c7ac9649d72b7793c56901183996f8af69181900360200190a150505050565b60055460ff1690565b600054600160a060020a031690565b600054600160a060020a0316331490565b600160a060020a0381166000908152600660205260409020545b919050565b60035490565b61054e610510565b151561055957600080fd5b6105628161066e565b50565b600160a060020a031660009081526007602052604090205460ff1690565b600160a060020a0381166000908152600660205260408120546105b5906105a9846106eb565b9063ffffffff61065916565b92915050565b6000828201838110156105cd57600080fd5b9392505050565b60408051600160a060020a038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610654908490610849565b505050565b60008282111561066857600080fd5b50900390565b600160a060020a038116151561068357600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000918291600160a060020a038516916370a08231916024808301926020929190829003018186803b15801561074f57600080fd5b505afa158015610763573d6000803e3d6000fd5b505050506040513d602081101561077957600080fd5b5051600160a060020a038416600090815260066020526040812054919250906107a990839063ffffffff6105bb16565b90506002544210156107c05760009250505061053b565b6004546003546107d59163ffffffff6105bb16565b421015806107fb5750600160a060020a03841660009081526007602052604090205460ff165b1561080957915061053b9050565b6108406004546108346108276003544261065990919063ffffffff16565b849063ffffffff61094e16565b9063ffffffff61097916565b9250505061053b565b61085b82600160a060020a031661099d565b151561086657600080fd5b6000606083600160a060020a0316836040518082805190602001908083835b602083106108a45780518252601f199092019160209182019101610885565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610906576040519150601f19603f3d011682016040523d82523d6000602084013e61090b565b606091505b509150915081151561091c57600080fd5b6000815111156109485780806020019051602081101561093b57600080fd5b5051151561094857600080fd5b50505050565b600082151561095f575060006105b5565b82820282848281151561096e57fe5b04146105cd57600080fd5b600080821161098757600080fd5b6000828481151561099457fe5b04949350505050565b6000903b119056fea165627a7a72305820389ac77320088b579eef28fb43bfb1b4cce06f5edc7682f6c99d19f22bf0d38e0029
[ 38 ]
0xF1e54185e25B58379E04744f4feEa0B007eE4bf3
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; /** * @title the Bitcat NFT smart contract */ contract Bitcat is ERC721, Ownable { using SafeMath for uint256; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // @dev symbol,name ,and base ui string private constant SYMBOL = "BTC"; string private constant NAME = "Bitcat"; string private constant BASE_URI = "https://ipfs.io/ipfs/"; // @dev eth decimals uint256 private constant _ETH_DECIMALS = 1e18; // @dev users eth balances to reclaim mapping(address => uint256) private _balances; // @dev tokens placeholders mapping(uint256 => string) private _placeholderURIs; // @dev Cuddlers are all previous holders, cuddler only done using resell not transfer mapping(uint256 => EnumerableMap.UintToAddressMap) private _catCuddlers; // @notice We can't add more than 2K cats uint256 public constant MAX_CATS_SUPPLY = 2000; // @notice The next cat id for sale uint256 public nextCatId = 1; // @notice cat price by id mapping(uint256 => uint256) public catPrice; // @notice is cat for sale mapping(uint256 => bool) public isCatForSale; // @dev Emitted when `catId` is sold to `_msgSender()`. event Buy(uint256 indexed catId, address indexed to); // @dev Emitted when `catId` is open for resell. event Resell(uint256 indexed catId); // @dev Emitted when `catId` resell is canceled. event CancelResell(uint256 indexed catId); // @dev Emitted when `to` reclaim his balance. event Reclaim(address indexed to); // @dev We shouldn't be able to change anything of these on deployment constructor() ERC721(NAME, SYMBOL) { _setBaseURI(BASE_URI); } /** * @dev Set the token place holder uri */ function _setPlaceholderURI(uint256 tokenId, string memory _placeholderURI) internal virtual { require(_exists(tokenId), "Bitcat: placeholder URI set of nonexistent token"); _placeholderURIs[tokenId] = _placeholderURI; } /** * @notice Create a new cat */ function mintCat(string memory tokenURI, string memory placeholderURI) public onlyOwner { address creator = _msgSender(); uint256 newCatId = totalSupply().add(1); // check require(newCatId < MAX_CATS_SUPPLY, "Bitcat: exceeds Max Supply."); require(bytes(tokenURI).length > 0, "Bitcat: tokenURI is required."); require(bytes(placeholderURI).length > 0, "Bitcat: placeholderURI is required."); // mint _mint(creator, newCatId); // set uri _setTokenURI(newCatId, tokenURI); _setPlaceholderURI(newCatId, placeholderURI); // set the cat price catPrice[newCatId] = calculateMinCatPrice(newCatId); // set as available for sale isCatForSale[newCatId] = true; } /** * @dev Calculate the cat minimal price based on index and number of cuddlers */ function calculateMinCatPrice(uint256 catId) public view returns (uint256) { // initial price from (0.1 ETH) to (200 ETH) uint256 initialCatPrice = catId.mul(_ETH_DECIMALS).div(10); // price increase %0.1 for every cuddler return initialCatPrice.mul((totalCatCuddlers(catId).div(10)).add(1)); } /** * @notice get a cat caddler by catId and caddler index */ function catCuddlers(uint256 catId, uint256 index) public view returns (address) { return _catCuddlers[catId].get(index); } /** * @notice get the cat total cuddlers by cat id */ function totalCatCuddlers(uint256 catId) public view returns (uint256) { return _catCuddlers[catId].length(); } /** * @notice Check if the reselling feature is open (reselling will be available when all cats are sold out) */ function isResellingOpen() public view returns (bool) { return nextCatId.add(1) >= MAX_CATS_SUPPLY; } /** * @notice Cat owner can resell the cat and become a cuddler **/ function resellCat(uint256 catId, uint256 newPrice) public { address seller = _msgSender(); // check if owner require(seller == ownerOf(catId), "Bitcat: you need to be the cat owner to resell it."); // check minimal price require( newPrice >= calculateMinCatPrice(catId), "Bitcat: the new price should be larger than minimal price." ); catPrice[catId] = newPrice; isCatForSale[catId] = true; emit Resell(catId); } /** * @notice Cat owner can cancel reselling the cat **/ function cancelResellCat(uint256 catId) public { address seller = _msgSender(); // check if owner require( seller == ownerOf(catId), "Bitcat: you need to be the cat owner to cancel the resell." ); // check minimal price isCatForSale[catId] = false; // emit event emit CancelResell(catId); } /** * @notice Check if cat is unlocked **/ function isCatUnlocked(uint256 catId) public view returns (bool) { return catId <= nextCatId; } /** * @notice Check if cat is minted **/ function isCatMinted(uint256 catId) public view returns (bool) { return _exists(catId); } /** * @notice Cat token uri, cat need to be unlocked **/ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { return isCatUnlocked(tokenId) ? super.tokenURI(tokenId) : ""; } /** * @notice Cat token placeholder uri **/ function placeholderURI(uint256 tokenId) public view returns (string memory) { string memory _placeholderURI = _placeholderURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _placeholderURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_placeholderURI).length > 0) { return string(abi.encodePacked(base, _placeholderURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @notice buy cat, also make sure it's available for sale */ function buyCat(uint256 catId) public payable { address buyer = _msgSender(); address seller = ownerOf(catId); uint256 price = catPrice[catId]; bool isForSale = isCatForSale[catId]; bool isResellingEnabled = isResellingOpen(); bool isUnlocked = isCatUnlocked(catId); // check require(buyer != address(0), "Bitcat: invalid address."); require(buyer != seller, "Bitcat: already an owner!"); require(isForSale, "Bitcat: this cat is not for sale yet."); require(price == msg.value, "Bitcat: the cat Eth value sent is invalid."); require(isUnlocked, "Bitcat: this cat is locked and not open for sale yet."); EnumerableMap.UintToAddressMap storage cuddlers = _catCuddlers[catId]; uint256 totalCuddlers = cuddlers.length(); if (totalCuddlers > 0) { // cuddlers will receive 0.1 in total and owner will receive the rest 0.9 uint256 cuddlersVal = price.div(10); uint256 sellerVal = price.sub(cuddlersVal); // add to the seller balance his money _balances[seller] = _balances[seller].add(sellerVal); // set to the cuddlers their money uint256 cuddlerVal = cuddlersVal.div(totalCuddlers); for (uint256 i = 0; i < totalCuddlers; i++) { address cuddler = cuddlers.get(i); _balances[cuddler] = _balances[cuddler].add(cuddlerVal); } } else { // add to the seller balance his money _balances[seller] = _balances[seller].add(price); } // seller become a cuddler :) _catCuddlers[catId].set(totalCuddlers, seller); // do transfer _transfer(seller, buyer, catId); // remove the cat from reselling isCatForSale[catId] = false; // if all cats still not sold out increase the nextCatId counter if (!isResellingEnabled) { nextCatId = nextCatId.add(1); } // emit event emit Buy(catId, buyer); } /** * @dev eth balance can be reclaimed */ function balanceToReclaimOf(address user) public view returns (uint256) { require(user != address(0), "Bitcat: balance query for the zero address"); return _balances[user]; } /** * @dev reclaim and withdraw ether from this contract */ function reclaim() public { address payable seller = _msgSender(); require(seller != address(0), "Bitcat: invalid zero address."); uint256 balance = _balances[seller]; require(balance > 0, "Bitcat: your balance is 0."); seller.transfer(balance); // clear balance _balances[seller] = 0; // emit event emit Reclaim(seller); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <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 () internal { 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; } } // 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); } function _approve(address to, uint256 tokenId) private { _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); } }
0x60806040526004361061021a5760003560e01c80636352211e11610123578063a22cb465116100ab578063e985e9c51161006f578063e985e9c514610f5d578063f2fde38b14610fe4578063f3ef91f914611035578063fc09c0c21461107a578063fe747b29146110a55761021a565b8063a22cb46514610cbd578063b88d4fde14610d1a578063c87b56dd14610e2c578063cb912f2a14610ee0578063d72503ba14610f2f5761021a565b806374ead8e1116100f257806374ead8e114610a495780637ad440ee14610a7657806380e9071b14610bd55780638da5cb5b14610bec57806395d89b4114610c2d5761021a565b80636352211e146108d85780636c0360eb1461093d57806370a08231146109cd578063715018a614610a325761021a565b80632be94b74116101a6578063429adbc611610175578063429adbc61461070857806343040ed3146107595780634f6ccce71461078457806351a513d4146107d3578063624bceb4146108245761021a565b80632be94b74146105745780632f745c59146105e35780633b3071c21461065257806342842e0e1461068d5761021a565b80631013a3be116101ed5780631013a3be146103df57806318160ddd1461043057806318508a821461045b5780631efea45a146104aa57806323b872dd146104f95761021a565b806301ffc9a71461021f57806306fdde031461028f578063081812fc1461031f578063095ea7b314610384575b600080fd5b34801561022b57600080fd5b506102776004803603602081101561024257600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916906020019092919050505061110a565b60405180821515815260200191505060405180910390f35b34801561029b57600080fd5b506102a4611171565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102e45780820151818401526020810190506102c9565b50505050905090810190601f1680156103115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032b57600080fd5b506103586004803603602081101561034257600080fd5b8101908080359060200190929190505050611213565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561039057600080fd5b506103dd600480360360408110156103a757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112ae565b005b3480156103eb57600080fd5b506104186004803603602081101561040257600080fd5b81019080803590602001909291905050506113f2565b60405180821515815260200191505060405180910390f35b34801561043c57600080fd5b50610445611404565b6040518082815260200191505060405180910390f35b34801561046757600080fd5b506104946004803603602081101561047e57600080fd5b8101908080359060200190929190505050611415565b6040518082815260200191505060405180910390f35b3480156104b657600080fd5b506104e3600480360360208110156104cd57600080fd5b8101908080359060200190929190505050611491565b6040518082815260200191505060405180910390f35b34801561050557600080fd5b506105726004803603606081101561051c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506114b5565b005b34801561058057600080fd5b506105b76004803603604081101561059757600080fd5b81019080803590602001909291908035906020019092919050505061152b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105ef57600080fd5b5061063c6004803603604081101561060657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061155a565b6040518082815260200191505060405180910390f35b34801561065e57600080fd5b5061068b6004803603602081101561067557600080fd5b81019080803590602001909291905050506115b5565b005b34801561069957600080fd5b50610706600480360360608110156106b057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506116aa565b005b34801561071457600080fd5b506107416004803603602081101561072b57600080fd5b81019080803590602001909291905050506116ca565b60405180821515815260200191505060405180910390f35b34801561076557600080fd5b5061076e6116d9565b6040518082815260200191505060405180910390f35b34801561079057600080fd5b506107bd600480360360208110156107a757600080fd5b81019080803590602001909291905050506116df565b6040518082815260200191505060405180910390f35b3480156107df57600080fd5b5061080c600480360360208110156107f657600080fd5b8101908080359060200190929190505050611702565b60405180821515815260200191505060405180910390f35b34801561083057600080fd5b5061085d6004803603602081101561084757600080fd5b8101908080359060200190929190505050611722565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561089d578082015181840152602081019050610882565b50505050905090810190601f1680156108ca5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156108e457600080fd5b50610911600480360360208110156108fb57600080fd5b8101908080359060200190929190505050611994565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561094957600080fd5b506109526119cb565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610992578082015181840152602081019050610977565b50505050905090810190601f1680156109bf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156109d957600080fd5b50610a1c600480360360208110156109f057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a6d565b6040518082815260200191505060405180910390f35b348015610a3e57600080fd5b50610a47611b42565b005b348015610a5557600080fd5b50610a5e611cb2565b60405180821515815260200191505060405180910390f35b348015610a8257600080fd5b50610bd360048036036040811015610a9957600080fd5b8101908080359060200190640100000000811115610ab657600080fd5b820183602082011115610ac857600080fd5b80359060200191846001830284011164010000000083111715610aea57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190640100000000811115610b4d57600080fd5b820183602082011115610b5f57600080fd5b80359060200191846001830284011164010000000083111715610b8157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611cd4565b005b348015610be157600080fd5b50610bea611f66565b005b348015610bf857600080fd5b50610c016121a2565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610c3957600080fd5b50610c426121cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610c82578082015181840152602081019050610c67565b50505050905090810190601f168015610caf5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610cc957600080fd5b50610d1860048036036040811015610ce057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080351515906020019092919050505061226e565b005b348015610d2657600080fd5b50610e2a60048036036080811015610d3d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610da457600080fd5b820183602082011115610db657600080fd5b80359060200191846001830284011164010000000083111715610dd857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050612424565b005b348015610e3857600080fd5b50610e6560048036036020811015610e4f57600080fd5b810190808035906020019092919050505061249c565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610ea5578082015181840152602081019050610e8a565b50505050905090810190601f168015610ed25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610eec57600080fd5b50610f1960048036036020811015610f0357600080fd5b81019080803590602001909291905050506124d1565b6040518082815260200191505060405180910390f35b610f5b60048036036020811015610f4557600080fd5b81019080803590602001909291905050506124e9565b005b348015610f6957600080fd5b50610fcc60048036036040811015610f8057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612add565b60405180821515815260200191505060405180910390f35b348015610ff057600080fd5b506110336004803603602081101561100757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612b71565b005b34801561104157600080fd5b506110786004803603604081101561105857600080fd5b810190808035906020019092919080359060200190929190505050612d66565b005b34801561108657600080fd5b5061108f612ed5565b6040518082815260200191505060405180910390f35b3480156110b157600080fd5b506110f4600480360360208110156110c857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612edb565b6040518082815260200191505060405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112095780601f106111de57610100808354040283529160200191611209565b820191906000526020600020905b8154815290600101906020018083116111ec57829003601f168201915b5050505050905090565b600061121e82612fa9565b611273576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180614c58602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006112b982611994565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611340576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614d326021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661135f612fc6565b73ffffffffffffffffffffffffffffffffffffffff16148061138e575061138d81611388612fc6565b612add565b5b6113e3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614b2b6038913960400191505060405180910390fd5b6113ed8383612fce565b505050565b60006113fd82612fa9565b9050919050565b60006114106002613087565b905090565b600080611446600a611438670de0b6b3a76400008661309c90919063ffffffff16565b61312290919063ffffffff16565b905061148961147a600161146c600a61145e88611491565b61312290919063ffffffff16565b6131ab90919063ffffffff16565b8261309c90919063ffffffff16565b915050919050565b60006114ae600d6000848152602001908152602001600020613087565b9050919050565b6114c66114c0612fc6565b82613233565b61151b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180614d536031913960400191505060405180910390fd5b611526838383613327565b505050565b600061155282600d600086815260200190815260200160002061356a90919063ffffffff16565b905092915050565b60006115ad82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061358790919063ffffffff16565b905092915050565b60006115bf612fc6565b90506115ca82611994565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461164d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a815260200180614992603a913960400191505060405180910390fd5b60006010600084815260200190815260200160002060006101000a81548160ff021916908315150217905550817f4858a11ced47fb4c522d7f037914ad4fa0ba7c8d80b8513f7bcf02b7a97f1e0d60405160405180910390a25050565b6116c583838360405180602001604052806000815250612424565b505050565b6000600e548211159050919050565b6107d081565b6000806116f68360026135a190919063ffffffff16565b50905080915050919050565b60106020528060005260406000206000915054906101000a900460ff1681565b606080600c60008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156117cc5780601f106117a1576101008083540402835291602001916117cc565b820191906000526020600020905b8154815290600101906020018083116117af57829003601f168201915b5050505050905060606117dd6119cb565b90506000815114156117f357819250505061198f565b6000825111156118c45780826040516020018083805190602001908083835b602083106118355780518252602082019150602081019050602083039250611812565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106118865780518252602082019150602081019050602083039250611863565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040529250505061198f565b806118ce856135cd565b6040516020018083805190602001908083835b6020831061190457805182526020820191506020810190506020830392506118e1565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106119555780518252602082019150602081019050602083039250611932565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b60006119c482604051806060016040528060298152602001614b8d6029913960026137149092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a635780601f10611a3857610100808354040283529160200191611a63565b820191906000526020600020905b815481529060010190602001808311611a4657829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611af4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614b63602a913960400191505060405180910390fd5b611b3b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020613733565b9050919050565b611b4a612fc6565b73ffffffffffffffffffffffffffffffffffffffff16611b686121a2565b73ffffffffffffffffffffffffffffffffffffffff1614611bf1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60006107d0611ccd6001600e546131ab90919063ffffffff16565b1015905090565b611cdc612fc6565b73ffffffffffffffffffffffffffffffffffffffff16611cfa6121a2565b73ffffffffffffffffffffffffffffffffffffffff1614611d83576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000611d8d612fc6565b90506000611dac6001611d9e611404565b6131ab90919063ffffffff16565b90506107d08110611e25576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4269746361743a2065786365656473204d617820537570706c792e000000000081525060200191505060405180910390fd5b6000845111611e9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4269746361743a20746f6b656e5552492069732072657175697265642e00000081525060200191505060405180910390fd5b6000835111611ef6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614db46023913960400191505060405180910390fd5b611f008282613748565b611f0a818561393c565b611f1481846139c6565b611f1d81611415565b600f60008381526020019081526020016000208190555060016010600083815260200190815260200160002060006101000a81548160ff02191690831515021790555050505050565b6000611f70612fc6565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612015576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4269746361743a20696e76616c6964207a65726f20616464726573732e00000081525060200191505060405180910390fd5b6000600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600081116120cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f4269746361743a20796f75722062616c616e636520697320302e00000000000081525060200191505060405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015612115573d6000803e3d6000fd5b506000600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff167f0d43f3785af185468063e51aabbbfa1da846e2b1b2d2090d9e1979c4328b112360405160405180910390a25050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156122645780601f1061223957610100808354040283529160200191612264565b820191906000526020600020905b81548152906001019060200180831161224757829003601f168201915b5050505050905090565b612276612fc6565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612317576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060056000612324612fc6565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166123d1612fc6565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b61243561242f612fc6565b83613233565b61248a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180614d536031913960400191505060405180910390fd5b61249684848484613a50565b50505050565b60606124a7826116ca565b6124c057604051806020016040528060008152506124ca565b6124c982613ac2565b5b9050919050565b600f6020528060005260406000206000915090505481565b60006124f3612fc6565b9050600061250083611994565b90506000600f600085815260200190815260200160002054905060006010600086815260200190815260200160002060009054906101000a900460ff1690506000612549611cb2565b90506000612556876116ca565b9050600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156125fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f4269746361743a20696e76616c696420616464726573732e000000000000000081525060200191505060405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561269d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4269746361743a20616c726561647920616e206f776e6572210000000000000081525060200191505060405180910390fd5b826126f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180614bb66025913960400191505060405180910390fd5b34841461274b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614d08602a913960400191505060405180910390fd5b806127a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260358152602001806149cc6035913960400191505060405180910390fd5b6000600d6000898152602001908152602001600020905060006127c382613087565b905060008111156129775760006127e4600a8861312290919063ffffffff16565b905060006127fb8289613d9390919063ffffffff16565b905061284f81600b60008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ab90919063ffffffff16565b600b60008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060006128a7848461312290919063ffffffff16565b905060005b8481101561296e5760006128c9828861356a90919063ffffffff16565b905061291d83600b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ab90919063ffffffff16565b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505080806001019150506128ac565b50505050612a0d565b6129c986600b60008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546131ab90919063ffffffff16565b600b60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b612a348188600d60008d8152602001908152602001600020613e169092919063ffffffff16565b50612a4087898b613327565b6000601060008b815260200190815260200160002060006101000a81548160ff02191690831515021790555083612a8e57612a876001600e546131ab90919063ffffffff16565b600e819055505b8773ffffffffffffffffffffffffffffffffffffffff16897f7534e9c9396820aad756ba27f82162930f80bef863aabdf311e7dce26a79bccd60405160405180910390a3505050505050505050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b612b79612fc6565b73ffffffffffffffffffffffffffffffffffffffff16612b976121a2565b73ffffffffffffffffffffffffffffffffffffffff1614612c20576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614a336026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000612d70612fc6565b9050612d7b83611994565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614612dfe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180614a7d6032913960400191505060405180910390fd5b612e0783611415565b821015612e5f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603a815260200180614bfd603a913960400191505060405180910390fd5b81600f60008581526020019081526020016000208190555060016010600085815260200190815260200160002060006101000a81548160ff021916908315150217905550827fba8eb1b44386268c4e27216d422716e5bd371a2be063c26dfef5ad46bad61d0a60405160405180910390a2505050565b600e5481565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612f62576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614b01602a913960400191505060405180910390fd5b600b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000612fbf826002613e4b90919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661304183611994565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061309582600001613e65565b9050919050565b6000808314156130af576000905061311c565b60008284029050828482816130c057fe5b0414613117576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614c376021913960400191505060405180910390fd5b809150505b92915050565b6000808211613199576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525060200191505060405180910390fd5b8183816131a257fe5b04905092915050565b600080828401905083811015613229576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061323e82612fa9565b613293576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180614ad5602c913960400191505060405180910390fd5b600061329e83611994565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061330d57508373ffffffffffffffffffffffffffffffffffffffff166132f584611213565b73ffffffffffffffffffffffffffffffffffffffff16145b8061331e575061331d8185612add565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661334782611994565b73ffffffffffffffffffffffffffffffffffffffff16146133b3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180614cb06029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613439576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180614a596024913960400191505060405180910390fd5b613444838383613e76565b61344f600082612fce565b6134a081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020613e7b90919063ffffffff16565b506134f281600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020613e9590919063ffffffff16565b5061350981836002613e169092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061357c836000018360001b613eaf565b60001c905092915050565b60006135968360000183613f6e565b60001c905092915050565b6000806000806135b48660000186613ff1565b915091508160001c8160001c9350935050509250929050565b60606000821415613615576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061370f565b600082905060005b6000821461363f578080600101915050600a828161363757fe5b04915061361d565b60608167ffffffffffffffff8111801561365857600080fd5b506040519080825280601f01601f19166020018201604052801561368b5781602001600182028036833780820191505090505b50905060006001830390508593505b6000841461370757600a84816136ac57fe5b0660300160f81b828280600190039350815181106136c657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84816136ff57fe5b04935061369a565b819450505050505b919050565b6000613727846000018460001b8461408a565b60001c90509392505050565b600061374182600001614180565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156137eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b6137f481612fa9565b15613867576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b61387360008383613e76565b6138c481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020613e9590919063ffffffff16565b506138db81836002613e169092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b61394582612fa9565b61399a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180614c84602c913960400191505060405180910390fd5b806008600084815260200190815260200160002090805190602001906139c19291906148c4565b505050565b6139cf82612fa9565b613a24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614d846030913960400191505060405180910390fd5b80600c60008481526020019081526020016000209080519060200190613a4b9291906148c4565b505050565b613a5b848484613327565b613a6784848484614191565b613abc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526032815260200180614a016032913960400191505060405180910390fd5b50505050565b6060613acd82612fa9565b613b22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614cd9602f913960400191505060405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015613bcb5780601f10613ba057610100808354040283529160200191613bcb565b820191906000526020600020905b815481529060010190602001808311613bae57829003601f168201915b505050505090506060613bdc6119cb565b9050600081511415613bf2578192505050613d8e565b600082511115613cc35780826040516020018083805190602001908083835b60208310613c345780518252602082019150602081019050602083039250613c11565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310613c855780518252602082019150602081019050602083039250613c62565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050613d8e565b80613ccd856135cd565b6040516020018083805190602001908083835b60208310613d035780518252602082019150602081019050602083039250613ce0565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310613d545780518252602082019150602081019050602083039250613d31565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b600082821115613e0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b818303905092915050565b6000613e42846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b6143aa565b90509392505050565b6000613e5d836000018360001b614486565b905092915050565b600081600001805490509050919050565b505050565b6000613e8d836000018360001b6144a9565b905092915050565b6000613ea7836000018360001b614591565b905092915050565b6000808360010160008481526020019081526020016000205490506000811415613f41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f456e756d657261626c654d61703a206e6f6e6578697374656e74206b6579000081525060200191505060405180910390fd5b836000016001820381548110613f5357fe5b90600052602060002090600202016001015491505092915050565b600081836000018054905011613fcf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806149706022913960400191505060405180910390fd5b826000018281548110613fde57fe5b9060005260206000200154905092915050565b60008082846000018054905011614053576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180614bdb6022913960400191505060405180910390fd5b600084600001848154811061406457fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390614151576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156141165780820151818401526020810190506140fb565b50505050905090810190601f1680156141435780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061416457fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b60006141b28473ffffffffffffffffffffffffffffffffffffffff16614601565b6141bf57600190506143a2565b606061432963150b7a0260e01b6141d4612fc6565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561425857808201518184015260208101905061423d565b50505050905090810190601f1680156142855780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001614a01603291398773ffffffffffffffffffffffffffffffffffffffff166146149092919063ffffffff16565b9050600081806020019051602081101561434257600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b60008084600101600085815260200190815260200160002054905060008114156144515784600001604051806040016040528086815260200185815250908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000155602082015181600101555050846000018054905085600101600086815260200190815260200160002081905550600191505061447f565b8285600001600183038154811061446457fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000808360010160008481526020019081526020016000205490506000811461458557600060018203905060006001866000018054905003905060008660000182815481106144f457fe5b906000526020600020015490508087600001848154811061451157fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061454957fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061458b565b60009150505b92915050565b600061459d838361462c565b6145f65782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506145fb565b600090505b92915050565b600080823b905060008111915050919050565b6060614623848460008561464f565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b6060824710156146aa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180614aaf6026913960400191505060405180910390fd5b6146b385614601565b614725576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106147755780518252602082019150602081019050602083039250614752565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146147d7576040519150601f19603f3d011682016040523d82523d6000602084013e6147dc565b606091505b50915091506147ec8282866147f8565b92505050949350505050565b60608315614808578290506148bd565b60008351111561481b5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614882578082015181840152602081019050614867565b50505050905090810190601f1680156148af5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826148fa5760008555614941565b82601f1061491357805160ff1916838001178555614941565b82800160010185558215614941579182015b82811115614940578251825591602001919060010190614925565b5b50905061494e9190614952565b5090565b5b8082111561496b576000816000905550600101614953565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734269746361743a20796f75206e65656420746f2062652074686520636174206f776e657220746f2063616e63656c2074686520726573656c6c2e4269746361743a207468697320636174206973206c6f636b656420616e64206e6f74206f70656e20666f722073616c65207965742e4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f20616464726573734269746361743a20796f75206e65656420746f2062652074686520636174206f776e657220746f20726573656c6c2069742e416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4269746361743a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e4269746361743a207468697320636174206973206e6f7420666f722073616c65207965742e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734269746361743a20746865206e65772070726963652073686f756c64206265206c6172676572207468616e206d696e696d616c2070726963652e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4269746361743a2074686520636174204574682076616c75652073656e7420697320696e76616c69642e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665644269746361743a20706c616365686f6c6465722055524920736574206f66206e6f6e6578697374656e7420746f6b656e4269746361743a20706c616365686f6c6465725552492069732072657175697265642ea26469706673582212204f1072a5f06c733f2ecd357b1414764919a90e2a321c047d2823ed2410cea0a164736f6c63430007040033
[ 4, 5 ]
0xF1e56BCa23968f7Eb47e282Af11bF36593978b5a
// SPDX-License-Identifier: Unlicensed /* https://t.me/grinchgoose 𝐒𝐧𝐢𝐩𝐞𝐫𝐬 𝐰𝐢𝐥𝐥 𝐬𝐮𝐫𝐞𝐥𝐲 𝐦𝐚𝐤𝐞 𝐢𝐭 𝐨𝐧 𝐭𝐡𝐞 𝐧𝐚𝐮𝐠𝐡𝐭𝐲 𝐥𝐢𝐬𝐭 */ pragma solidity ^0.8.4; 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 { _transferOwnership(address(0)); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } 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 GrinchGoose is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => uint256) private _buyMap; 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 _tTotal = 1e12 * 10**9; uint256 private _rTotal = (type(uint256).max - (type(uint256).max % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private _ethSent = 0; address payable public _feeAddrWallet; string private constant _name = "@GooseGrinch"; string private constant _symbol = "GG"; uint8 private constant _decimals = 9; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); event TransferType(uint256 ethSent, uint256 transferType, uint256 amount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable feeAddrWallet) { _feeAddrWallet = feeAddrWallet; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function originalPurchase(address account) public view returns (uint256) { return _buyMap[account]; } 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 setMaxTx(uint256 maxTransactionAmount) external onlyOwner() { _maxTxAmount = maxTransactionAmount; } function updateFeeWallet(address payable newFeeWallet) external onlyOwner { _feeAddrWallet = newFeeWallet; } 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"); uint256 transferType = 0; if (!_isBuy(from)) { if (_buyMap[from] != 0 && (_buyMap[from] + (24 hours) >= block.timestamp)) { _feeAddr1 = 0; _feeAddr2 = 19; //M 15 G 5 transferType = 1; } else { _feeAddr1 = 0; _feeAddr2 = 12; //M 8 G 2 transferType = 2; } } else { if (_buyMap[to] == 0) { _buyMap[to] = block.timestamp; } _feeAddr1 = 0; _feeAddr2 = 12; // M 0 G 2 transferType = 3; } if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ _feeAddr1 = 0; _feeAddr2 = 0; transferType = 0; } if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { uint256 _feeAddr1Before = _feeAddr1; uint256 _feeAddr2Before = _feeAddr2; swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); _ethSent = contractETHBalance; } _feeAddr1 = _feeAddr1Before; _feeAddr2 = _feeAddr2Before; } } _tokenTransfer(from, to, amount); emit TransferType(_ethSent, transferType, amount); _ethSent=0; } 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 { _feeAddrWallet.transfer(amount); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 20000000000 * 10 ** 9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function updateMaxTx (uint256 fee) public onlyOwner { _maxTxAmount = fee; } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet); 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 _isBuy(address _sender) private view returns (bool) { return _sender == uniswapV2Pair; } 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); } }
0x6080604052600436106101855760003560e01c8063715018a6116100d1578063c2d0ffca1161008a578063cc653b4411610064578063cc653b4414610461578063dd62ed3e14610497578063f2fde38b146104dd578063ff872602146104fd57600080fd5b8063c2d0ffca14610417578063c3c8cd8014610437578063c9567bf91461044c57600080fd5b8063715018a6146103795780638da5cb5b1461038e57806395d89b41146103ac578063a9059cbb146103d7578063b515566a146103f7578063bc3371821461041757600080fd5b8063313ce5671161013e5780635932ead1116101185780635932ead11461030457806366718524146103245780636fc3eaec1461034457806370a082311461035957600080fd5b8063313ce567146102a857806341e978fa146102c457806349bd5a5e146102e457600080fd5b806306fdde0314610191578063095ea7b3146101d85780631694505e1461020857806318160ddd1461024057806323b872dd14610266578063273123b71461028657600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b5060408051808201909152600c81526b0808ededee6ca8ee4d2dcc6d60a31b60208201525b6040516101cf9190611bc2565b60405180910390f35b3480156101e457600080fd5b506101f86101f3366004611a53565b610512565b60405190151581526020016101cf565b34801561021457600080fd5b50600f54610228906001600160a01b031681565b6040516001600160a01b0390911681526020016101cf565b34801561024c57600080fd5b50683635c9adc5dea000005b6040519081526020016101cf565b34801561027257600080fd5b506101f8610281366004611a13565b610529565b34801561029257600080fd5b506102a66102a13660046119a3565b610592565b005b3480156102b457600080fd5b50604051600981526020016101cf565b3480156102d057600080fd5b50600e54610228906001600160a01b031681565b3480156102f057600080fd5b50601054610228906001600160a01b031681565b34801561031057600080fd5b506102a661031f366004611b45565b6105e6565b34801561033057600080fd5b506102a661033f3660046119a3565b61062e565b34801561035057600080fd5b506102a661067a565b34801561036557600080fd5b506102586103743660046119a3565b6106a7565b34801561038557600080fd5b506102a66106c9565b34801561039a57600080fd5b506000546001600160a01b0316610228565b3480156103b857600080fd5b50604080518082019091526002815261474760f01b60208201526101c2565b3480156103e357600080fd5b506101f86103f2366004611a53565b6106ff565b34801561040357600080fd5b506102a6610412366004611a7e565b61070c565b34801561042357600080fd5b506102a6610432366004611b7d565b6107b0565b34801561044357600080fd5b506102a66107df565b34801561045857600080fd5b506102a6610815565b34801561046d57600080fd5b5061025861047c3660046119a3565b6001600160a01b031660009081526004602052604090205490565b3480156104a357600080fd5b506102586104b23660046119db565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b3480156104e957600080fd5b506102a66104f83660046119a3565b610bd9565b34801561050957600080fd5b506102a6610c71565b600061051f338484610caa565b5060015b92915050565b6000610536848484610dce565b610588843361058385604051806060016040528060288152602001611d93602891396001600160a01b038a166000908152600560209081526040808320338452909152902054919061123a565b610caa565b5060019392505050565b6000546001600160a01b031633146105c55760405162461bcd60e51b81526004016105bc90611c15565b60405180910390fd5b6001600160a01b03166000908152600760205260409020805460ff19169055565b6000546001600160a01b031633146106105760405162461bcd60e51b81526004016105bc90611c15565b60108054911515600160b81b0260ff60b81b19909216919091179055565b6000546001600160a01b031633146106585760405162461bcd60e51b81526004016105bc90611c15565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b600e546001600160a01b0316336001600160a01b03161461069a57600080fd5b476106a481611274565b50565b6001600160a01b038116600090815260026020526040812054610523906112ae565b6000546001600160a01b031633146106f35760405162461bcd60e51b81526004016105bc90611c15565b6106fd6000611332565b565b600061051f338484610dce565b6000546001600160a01b031633146107365760405162461bcd60e51b81526004016105bc90611c15565b60005b81518110156107ac5760016007600084848151811061076857634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806107a481611d28565b915050610739565b5050565b6000546001600160a01b031633146107da5760405162461bcd60e51b81526004016105bc90611c15565b601155565b600e546001600160a01b0316336001600160a01b0316146107ff57600080fd5b600061080a306106a7565b90506106a481611382565b6000546001600160a01b0316331461083f5760405162461bcd60e51b81526004016105bc90611c15565b601054600160a01b900460ff16156108995760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016105bc565b600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556108d63082683635c9adc5dea00000610caa565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561090f57600080fd5b505afa158015610923573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094791906119bf565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561098f57600080fd5b505afa1580156109a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c791906119bf565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b158015610a0f57600080fd5b505af1158015610a23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4791906119bf565b601080546001600160a01b0319166001600160a01b03928316179055600f541663f305d7194730610a77816106a7565b600080610a8c6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015610aef57600080fd5b505af1158015610b03573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610b289190611b95565b5050601080546801158e460913d0000060115563ffff00ff60a01b198116630101000160a01b17909155600f5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610ba157600080fd5b505af1158015610bb5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ac9190611b61565b6000546001600160a01b03163314610c035760405162461bcd60e51b81526004016105bc90611c15565b6001600160a01b038116610c685760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105bc565b6106a481611332565b6000546001600160a01b03163314610c9b5760405162461bcd60e51b81526004016105bc90611c15565b683635c9adc5dea00000601155565b6001600160a01b038316610d0c5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105bc565b6001600160a01b038216610d6d5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105bc565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610e325760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105bc565b6001600160a01b038216610e945760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105bc565b60008111610ef65760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016105bc565b6000610f10846010546001600160a01b0391821691161490565b610f89576001600160a01b03841660009081526004602052604090205415801590610f6157506001600160a01b0384166000908152600460205260409020544290610f5e9062015180611cba565b10155b15610f7857506000600b556013600c556001610fcf565b506000600b55600c80556002610fcf565b6001600160a01b038316600090815260046020526040902054610fc2576001600160a01b03831660009081526004602052604090204290555b506000600b55600c805560035b6001600160a01b03841660009081526006602052604090205460ff168061100e57506001600160a01b03831660009081526006602052604090205460ff165b1561102157506000600b819055600c8190555b6000546001600160a01b0385811691161480159061104d57506000546001600160a01b03848116911614155b156111e1576001600160a01b03841660009081526007602052604090205460ff1615801561109457506001600160a01b03831660009081526007602052604090205460ff16155b61109d57600080fd5b6010546001600160a01b0385811691161480156110c85750600f546001600160a01b03848116911614155b80156110ed57506001600160a01b03831660009081526006602052604090205460ff16155b80156111025750601054600160b81b900460ff165b1561115f5760115482111561111657600080fd5b6001600160a01b038316600090815260086020526040902054421161113a57600080fd5b61114542601e611cba565b6001600160a01b0384166000908152600860205260409020555b600061116a306106a7565b601054909150600160a81b900460ff1615801561119557506010546001600160a01b03868116911614155b80156111aa5750601054600160b01b900460ff165b156111df57600b54600c546111be83611382565b4780156111d4576111ce47611274565b600d8190555b50600b91909155600c555b505b6111ec848484611527565b600d54604080519182526020820183905281018390527f52cc9b3b9b2fbca105996d3a85d38c08aa29f0228c897d6e2ab118a3c0ea8bfd9060600160405180910390a150506000600d555050565b6000818484111561125e5760405162461bcd60e51b81526004016105bc9190611bc2565b50600061126b8486611d11565b95945050505050565b600e546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156107ac573d6000803e3d6000fd5b60006009548211156113155760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105bc565b600061131f611537565b905061132b838261155a565b9392505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6010805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106113d857634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600f54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561142c57600080fd5b505afa158015611440573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146491906119bf565b8160018151811061148557634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600f546114ab9130911684610caa565b600f5460405163791ac94760e01b81526001600160a01b039091169063791ac947906114e4908590600090869030904290600401611c4a565b600060405180830381600087803b1580156114fe57600080fd5b505af1158015611512573d6000803e3d6000fd5b50506010805460ff60a81b1916905550505050565b61153283838361159c565b505050565b6000806000611544611693565b9092509050611553828261155a565b9250505090565b600061132b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506116d5565b6000806000806000806115ae87611703565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506115e09087611760565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461160f90866117a2565b6001600160a01b03891660009081526002602052604090205561163181611801565b61163b848361184b565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161168091815260200190565b60405180910390a3505050505050505050565b6009546000908190683635c9adc5dea000006116af828261155a565b8210156116cc57505060095492683635c9adc5dea0000092509050565b90939092509050565b600081836116f65760405162461bcd60e51b81526004016105bc9190611bc2565b50600061126b8486611cd2565b60008060008060008060008060006117208a600b54600c5461186f565b9250925092506000611730611537565b905060008060006117438e8787876118c4565b919e509c509a509598509396509194505050505091939550919395565b600061132b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061123a565b6000806117af8385611cba565b90508381101561132b5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105bc565b600061180b611537565b905060006118198383611914565b3060009081526002602052604090205490915061183690826117a2565b30600090815260026020526040902055505050565b6009546118589083611760565b600955600a5461186890826117a2565b600a555050565b600080808061188960646118838989611914565b9061155a565b9050600061189c60646118838a89611914565b905060006118b4826118ae8b86611760565b90611760565b9992985090965090945050505050565b60008080806118d38886611914565b905060006118e18887611914565b905060006118ef8888611914565b90506000611901826118ae8686611760565b939b939a50919850919650505050505050565b60008261192357506000610523565b600061192f8385611cf2565b90508261193c8583611cd2565b1461132b5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105bc565b803561199e81611d6f565b919050565b6000602082840312156119b4578081fd5b813561132b81611d6f565b6000602082840312156119d0578081fd5b815161132b81611d6f565b600080604083850312156119ed578081fd5b82356119f881611d6f565b91506020830135611a0881611d6f565b809150509250929050565b600080600060608486031215611a27578081fd5b8335611a3281611d6f565b92506020840135611a4281611d6f565b929592945050506040919091013590565b60008060408385031215611a65578182fd5b8235611a7081611d6f565b946020939093013593505050565b60006020808385031215611a90578182fd5b823567ffffffffffffffff80821115611aa7578384fd5b818501915085601f830112611aba578384fd5b813581811115611acc57611acc611d59565b8060051b604051601f19603f83011681018181108582111715611af157611af1611d59565b604052828152858101935084860182860187018a1015611b0f578788fd5b8795505b83861015611b3857611b2481611993565b855260019590950194938601938601611b13565b5098975050505050505050565b600060208284031215611b56578081fd5b813561132b81611d84565b600060208284031215611b72578081fd5b815161132b81611d84565b600060208284031215611b8e578081fd5b5035919050565b600080600060608486031215611ba9578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b81811015611bee57858101830151858201604001528201611bd2565b81811115611bff5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611c995784516001600160a01b031683529383019391830191600101611c74565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611ccd57611ccd611d43565b500190565b600082611ced57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611d0c57611d0c611d43565b500290565b600082821015611d2357611d23611d43565b500390565b6000600019821415611d3c57611d3c611d43565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146106a457600080fd5b80151581146106a457600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220c99e1b2b3a5dd665dea0b28bb8e4368257038642df1d926d5e02612c8b5911a264736f6c63430008040033
[ 13, 5, 11 ]
0xf1E64EE81B2Fe0c0a29DA0Ee1cc3C160b1f167ea
/* Copyright 2019,2020 StarkWare Industries Ltd. 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 https://www.starkware.co/open-source-license/ 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. */ pragma solidity ^0.5.2; import "CpuVerifier.sol"; import "FriStatementVerifier.sol"; import "MerkleStatementVerifier.sol"; contract CpuFrilessVerifier is CpuVerifier, MerkleStatementVerifier, FriStatementVerifier { constructor( address[] memory auxPolynomials, address oodsContract, address memoryPageFactRegistry_, address merkleStatementContractAddress, address friStatementContractAddress, uint256 numSecurityBits_, uint256 minProofOfWorkBits_ ) public MerkleStatementVerifier(merkleStatementContractAddress) FriStatementVerifier(friStatementContractAddress) CpuVerifier( auxPolynomials, oodsContract, memoryPageFactRegistry_, numSecurityBits_, minProofOfWorkBits_ ) { // solium-disable-previous-line no-empty-blocks } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80631cb7dd7914610030575b600080fd5b6101446004803603606081101561004657600080fd5b81019060208101813564010000000081111561006157600080fd5b82018360208201111561007357600080fd5b8035906020019184602083028401116401000000008311171561009557600080fd5b9193909290916020810190356401000000008111156100b357600080fd5b8201836020820111156100c557600080fd5b803590602001918460208302840111640100000000831117156100e757600080fd5b91939092909160208101903564010000000081111561010557600080fd5b82018360208201111561011757600080fd5b8035906020019184602083028401116401000000008311171561013957600080fd5b509092509050610146565b005b6101e486868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808a02828101820190935289825290935089925088918291850190849080828437600092019190915250506040805160208089028281018201909352888252909350889250879182918501908490808284376000920191909152506101ec92505050565b505050505050565b60606101f882856104a5565b9050600061020582610c6d565b90506102228161021486610c74565b61021d86610c77565b610cb3565b61022d816001610cd0565b60001c8260068151811061023d57fe5b602002602001018181525050610251610ce5565b1561029f5761027881610262610cf6565b6102738561026e610cfb565b610d01565b610d83565b610283816001610cd0565b82518390600790811061029257fe5b6020026020010181815250505b6102b7816102ab610ea7565b6102738561026e610ead565b6102c2816001610cd0565b60001c826008815181106102d257fe5b6020026020010181815250506102f08160016102738561015b610d01565b60006102fa610eb3565b9050805b610306610eb9565b82018110156103395761031a836001610ebe565b84828151811061032657fe5b60209081029190910101526001016102fe565b5061034383610ed3565b61035b8261034f610eb9565b6102738661026e61141e565b610366826001610cd0565b60001c836101318151811061037757fe5b602002602001018181525050600061038e84611424565b519050600061039f85610127610d01565b905060015b600183038110156103f1576103c0856001836020028501610d83565b6103cb856001610cd0565b60001c868261013101815181106103de57fe5b60209081029190910101526001016103a4565b50610406846001610273886101268701610d01565b61040f8561143c565b61042d848660038151811061042057fe5b6020026020010151611584565b610470848660098151811061043e57fe5b602002602001015160018860008151811061045557fe5b60200260200101510361046989606d610d01565b6060611676565b8560098151811061047d57fe5b60200260200101818152505061049285611745565b61049b85611869565b5050505050505050565b6060600582511161051757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c69642070726f6f66506172616d732e000000000000000000000000604482015290519081900360640190fd5b8160048151811061052457fe5b602002602001015160050182511461059d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e76616c69642070726f6f66506172616d732e000000000000000000000000604482015290519081900360640190fd5b6000826001815181106105ac57fe5b602002602001015190506010811115610610576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061445c6022913960400191505060405180910390fd5b600181101561066a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806143ab6022913960400191505060405180910390fd5b60008360028151811061067957fe5b6020026020010151905060328111156106dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806144d46022913960400191505060405180910390fd5b600154811015610738576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806143cd6025913960400191505060405180910390fd5b6000548110610792576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806141566026913960400191505060405180910390fd5b6000846003815181106107a157fe5b60200260200101519050600a811115610805576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806141c5602b913960400191505060405180910390fd5b60008560048151811061081457fe5b60200260200101519050600a81111561088e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f546f6f206d616e79206672692073746570732e00000000000000000000000000604482015290519081900360640190fd5b600181116108fd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f7420656e6f756768206672692073746570732e0000000000000000000000604482015290519081900360640190fd5b606081604051908082528060200260200182016040528015610929578160200160208202803883390190505b50905060005b8281101561096d5787816005018151811061094657fe5b602002602001015182828151811061095a57fe5b602090810291909101015260010161092f565b50600061097989611d63565b9097509050610989828286612dfe565b600061099788610126610d01565b90508281528460020a8861013b815181106109ae57fe5b6020026020010181815250508160020a88610141815181106109cc57fe5b6020026020010181815250508660020a886001815181106109e957fe5b6020026020010181815250508588600381518110610a0357fe5b602002602001018181525050600089600081518110610a1e57fe5b6020026020010151905060008111610a81576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806142646026913960400191505060405180910390fd5b6030811115610af157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f546f6f206d616e7920717565726965732e000000000000000000000000000000604482015290519081900360640190fd5b60005487898302011015610b50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603281526020018061432a6032913960400191505060405180910390fd5b8089600981518110610b5e57fe5b60200260200101818152505087830189600281518110610b7a57fe5b60200260200101818152505088600281518110610b9357fe5b602002602001015160020a89600081518110610bab57fe5b6020026020010181815250506000610c0460038b600081518110610bcb57fe5b602002602001015160017f08000000000000110000000000000000000000000000000000000000000000010381610bfe57fe5b04612fde565b9050808a600481518110610c1457fe5b6020026020010181815250506000610c40828c600181518110610c3357fe5b6020026020010151612fde565b9050808b61015a81518110610c5157fe5b6020026020010181815250505050505050505050505092915050565b6101600190565b90565b60008082601281518110610c8757fe5b602002602001015190506000610c9c82613012565b600201602002905080602085012092505050919050565b602082018352610ccb610cc58461301b565b82613021565b505050565b600080610cdd848461302d565b949350505050565b600080610cf0613060565b11905090565b600390565b61015c90565b60008061099c8310610d7457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4f766572666c6f772070726f74656374696f6e206661696c6564000000000000604482015290519081900360640190fd5b50506020908102919091010190565b63010000008210610df557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4f766572666c6f772070726f74656374696f6e206661696c65642e0000000000604482015290519081900360640190fd5b7f08000000000000110000000000000000000000000000000000000000000000017e400000000000011000000000000121000000000000000000000000000000007f0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60208601604087016020870286015b80871015610e9c57855b868110610e8a575060408320825160010183528416610e70565b86868209885250602087019650610e66565b505050505050505050565b61015a90565b61015f90565b6102b990565b60d090565b600080610cdd610ece858561302d565b613065565b610edc816130b0565b60008161015b81518110610eec57fe5b602002602001015190506000610f1e8361099981518110610f0957fe5b602002602001015160020a6004600802613356565b90506000610f2c8383612fde565b60048054604080517f5ed86d5c0000000000000000000000000000000000000000000000000000000081529283018490525192935073ffffffffffffffffffffffffffffffffffffffff1691635ed86d5c91602480820192602092909190829003018186803b158015610f9e57600080fd5b505afa158015610fb2573d6000803e3d6000fd5b505050506040513d6020811015610fc857600080fd5b50518451859061013d908110610fda57fe5b602090810291909101810191909152600554604080517f5ed86d5c00000000000000000000000000000000000000000000000000000000815260048101859052905173ffffffffffffffffffffffffffffffffffffffff90921692635ed86d5c92602480840193829003018186803b15801561105557600080fd5b505afa158015611069573d6000803e3d6000fd5b505050506040513d602081101561107f57600080fd5b50518451859061013e90811061109157fe5b60200260200101818152505060006110c685610999815181106110b057fe5b602002602001015160020a600161020002613356565b905060006110d48583612fde565b600654604080517f5ed86d5c00000000000000000000000000000000000000000000000000000000815260048101849052905192935073ffffffffffffffffffffffffffffffffffffffff90911691635ed86d5c91602480820192602092909190829003018186803b15801561114957600080fd5b505afa15801561115d573d6000803e3d6000fd5b505050506040513d602081101561117357600080fd5b50518651879061013f90811061118557fe5b602090810291909101810191909152600754604080517f5ed86d5c00000000000000000000000000000000000000000000000000000000815260048101859052905173ffffffffffffffffffffffffffffffffffffffff90921692635ed86d5c92602480840193829003018186803b15801561120057600080fd5b505afa158015611214573d6000803e3d6000fd5b505050506040513d602081101561122a57600080fd5b50518651879061014090811061123c57fe5b6020026020010181815250508561015c8151811061125657fe5b6020026020010151866101488151811061126c57fe5b6020026020010181815250508561015c6001018151811061128957fe5b6020026020010151866101498151811061129f57fe5b6020026020010181815250508561015c600201815181106112bc57fe5b60200260200101518661014b815181106112d257fe5b60200260200101818152505060006112e987613437565b9050808761014a815181106112fa57fe5b60209081029190910181019190915260035460405160009273ffffffffffffffffffffffffffffffffffffffff909216916127c0916149409181838e8601877ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa611369573d6000803e3d6000fd5b805194505060006113b68c60ce6102b9018151811061138457fe5b60200260200101516113b18d8f60ce6102b901600101815181106113a457fe5b602002602001015161368c565b6136b9565b9050808514611410576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061419e6027913960400191505060405180910390fd5b505050505050505050505050565b6103b990565b6060600061143483610126610d01565b519392505050565b6000600a905060008261013b8151811061145257fe5b60200260200101519050600080600090507f08000000000000110000000000000000000000000000000000000000000000006020850260208701018051935060208502808501855b818110156114b35780518510959095179460200161149a565b50602083810180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe089019081529390910190922090915260006040830152905250801561156257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c6964206669656c6420656c656d656e742e00000000000000000000604482015290519081900360640190fd5b818561013c8151811061157157fe5b6020026020010181815250505050505050565b8061158e57611672565b60007f0123456789abcded00000000000000000000000000000000000000000000000060005260208301518060085282602853602960002060005283518051602052602860002092508160005260286000206020860152600060408601526008810185525050600082610100036001901b905080821061166f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f50726f6f66206f6620776f726b20636865636b206661696c65642e0000000000604482015290519081900360640190fd5b50505b5050565b6000808084815b8881101561172b57826116a35761169b6116968b61301b565b6136e6565b935061010092505b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc09092019183831c88168260005b898211156116f75750878103518083106116ea576116f7565b80825288820391506116d1565b80831461170a5782825293880193611720565b5b8482101561172057818901805190925261170b565b50505060010161167d565b50848682038161173757fe5b049998505050505050505050565b61174e8161371c565b61178b8161175a61391f565b611762613924565b61176e85610489610d01565b8560068151811061177b57fe5b602002602001015160001b613929565b611793610ce5565b156117d1576117d1816117a461391f565b6117ac613060565b6117c1856117b8613924565b61048901610d01565b8560066001018151811061177b57fe5b6117fe816117dd613060565b6117e5613060565b6117f185610939610d01565b8560088151811061177b57fe5b60025473ffffffffffffffffffffffffffffffffffffffff16600061182483606d610d01565b8351909150611200908190839060010160200286867ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa61166f573d6000803e3d6000fd5b600061187482610c6d565b905060008260098151811061188557fe5b6020026020010151905060008090505b8181101561190b576118e38482600302606d01600101815181106118b557fe5b60200260200101517f07fffffffffffdf0ffffffffffffffffffffffffffffffffffffffffffffffe161368c565b8482600302606d01600101815181106118f857fe5b6020908102919091010152600101611895565b50600061191984606d610d01565b6060838102822091925061192c86611424565b80519091507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81019060019060009084908390811061196757fe5b60200260200101519050611979614137565b83831015611b8557600061198e8a600161302d565b60001c90508a8461012701815181106119a357fe5b6020026020010151826000600581106119b857fe5b602002015285518690859081106119cb57fe5b6020026020010151826001600581106119e057fe5b602002015260408201879052606082018190528a518b906101308601908110611a0557fe5b602002602001015182600460058110611a1a57fe5b60209081029190910191909152600a5460405173ffffffffffffffffffffffffffffffffffffffff90911691636a93856791859101808260a080838360005b83811015611a71578181015183820152602001611a59565b50505050905001915050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611ac557600080fd5b505afa158015611ad9573d6000803e3d6000fd5b505050506040513d6020811015611aef57600080fd5b5051611b5c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f494e56414c4944415445445f4652495f53544154454d454e5400000000000000604482015290519081900360640190fd5b8096508380600101945050858481518110611b7357fe5b60200260200101518301925050611979565b89836101270181518110611b9557fe5b602002602001015181600060058110611baa57fe5b60200201528451859084908110611bbd57fe5b602002602001015181600160058110611bd257fe5b602002015260408101869052611be98a8984613a8a565b606082015289518a906101308501908110611c0057fe5b602002602001015181600460058110611c1557fe5b60209081029190910191909152600a5460405173ffffffffffffffffffffffffffffffffffffffff90911691636a93856791849101808260a080838360005b83811015611c6c578181015183820152602001611c54565b50505050905001915050604051602081830303815290604052805190602001206040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611cc057600080fd5b505afa158015611cd4573d6000803e3d6000fd5b505050506040513d6020811015611cea57600080fd5b5051611d5757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f494e56414c4944415445445f4652495f53544154454d454e5400000000000000604482015290519081900360640190fd5b50505050505050505050565b60606000601383511015611dd857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f7075626c6963496e70757420697320746f6f2073686f72742e00000000000000604482015290519081900360640190fd5b6040805161099c808252620133a0820190925290602082016201338080388339019050509150620100008261014281518110611e1057fe5b6020026020010181815250506180008261014381518110611e2d57fe5b602002602001018181525050600083600081518110611e4857fe5b6020026020010151905060328110611ec157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e756d626572206f6620737465707320697320746f6f206c617267652e000000604482015290519081900360640190fd5b808361099981518110611ed057fe5b60200260200101818152505060048101915083600181518110611eef57fe5b60200260200101518361014d81518110611f0557fe5b60200260200101818152505083600281518110611f1e57fe5b60200260200101518361014e81518110611f3457fe5b6020026020010181815250508261014e81518110611f4e57fe5b60200260200101518361014d81518110611f6457fe5b60200260200101511115611fd957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f72635f6d696e206d757374206265203c3d2072635f6d61780000000000000000604482015290519081900360640190fd5b8261014281518110611fe757fe5b60200260200101518361014e81518110611ffd57fe5b60200260200101511061207157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f72635f6d6178206f7574206f662072616e676500000000000000000000000000604482015290519081900360640190fd5b67706564657273656e8460038151811061208757fe5b6020026020010151146120fb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4c61796f757420636f6465206d69736d617463682e0000000000000000000000604482015290519081900360640190fd5b8360048151811061210857fe5b6020026020010151836101458151811061211e57fe5b6020026020010181815250508360058151811061213757fe5b6020026020010151836101478151811061214d57fe5b602002602001018181525050826101458151811061216757fe5b60200260200101516000146121dd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e76616c696420696e697469616c2070630000000000000000000000000000604482015290519081900360640190fd5b82610147815181106121eb57fe5b602002602001015160021461226157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f496e76616c69642066696e616c20706300000000000000000000000000000000604482015290519081900360640190fd5b8360068151811061226e57fe5b6020026020010151836101448151811061228457fe5b6020026020010181815250508360078151811061229d57fe5b602002602001015183610146815181106122b357fe5b6020026020010181815250506000846008815181106122ce57fe5b602002602001015190506000856009815181106122e757fe5b602002602001015190508082111561234a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806142146025913960400191505060405180910390fd5b6801000000000000000081106123c157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4f7574206f662072616e6765206f75747075742073746f705f7074722e000000604482015290519081900360640190fd5b5050836010815181106123d057fe5b602002602001015183610158815181106123e657fe5b602002602001018181525050836011815181106123ff57fe5b6020026020010151836101598151811061241557fe5b602002602001018181525050826101598151811061242f57fe5b6020026020010151836101588151811061244557fe5b602002602001015111156124a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180614381602a913960400191505060405180910390fd5b6801000000000000000083610159815181106124bc57fe5b60200260200101511061251a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061417c6022913960400191505060405180910390fd5b6002836101588151811061252a57fe5b6020026020010151846101598151811061254057fe5b6020026020010151038161255057fe5b06156125a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603281526020018061442a6032913960400191505060405180910390fd5b83600a815181106125b457fe5b602002602001015183610151815181106125ca57fe5b6020026020010181815250506801000000000000000083610151815181106125ee57fe5b60200260200101511061264c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061428a6021913960400191505060405180910390fd5b600084600b8151811061265b57fe5b60200260200101519050600061268a856109998151811061267857fe5b602002602001015160020a6008613356565b600302856101518151811061269b57fe5b60200260200101510190508185610151815181106126b557fe5b6020026020010151111580156126cb5750808211155b61273657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f496e76616c696420706564657273656e2073746f705f70747200000000000000604482015290519081900360640190fd5b85600c8151811061274357fe5b6020026020010151856101528151811061275957fe5b60200260200101818152505068010000000000000000856101528151811061277d57fe5b6020026020010151106127db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061447e6024913960400191505060405180910390fd5b600086600d815181106127ea57fe5b602002602001015190506000612807876109998151811061267857fe5b876101528151811061281557fe5b602002602001015101905081876101528151811061282f57fe5b6020026020010151111580156128455750808211155b6128b057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f496e76616c69642072616e67655f636865636b2073746f705f70747200000000604482015290519081900360640190fd5b87600e815181106128bd57fe5b602002602001015187610157815181106128d357fe5b6020026020010181815250506801000000000000000087610157815181106128f757fe5b60200260200101511061296b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4f7574206f662072616e676520656364736120626567696e5f616464722e0000604482015290519081900360640190fd5b600088600f8151811061297a57fe5b6020026020010151905060006129aa896109998151811061299757fe5b602002602001015160020a610200613356565b60020289610157815181106129bb57fe5b60200260200101510190508189610157815181106129d557fe5b6020026020010151111580156129eb5750808211155b612a5657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f496e76616c69642065636473612073746f705f70747200000000000000000000604482015290519081900360640190fd5b60018a601281518110612a6557fe5b602002602001015110158015612a915750620186a08a601281518110612a8757fe5b6020026020010151105b612afc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e76616c6964206e756d626572206f66206d656d6f72792070616765732e00604482015290519081900360640190fd5b89601281518110612b0957fe5b60200260200101518961099b81518110612b1f57fe5b60209081029190910101526000805b8a61099b81518110612b3c57fe5b6020026020010151811015612bd45760008c612b5783613c08565b81518110612b6157fe5b6020026020010151905063400000008110612bc7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180614239602b913960400191505060405180910390fd5b9190910190600101612b2e565b50808a61099a81518110612be457fe5b602002602001018181525050506000612c118a61099b81518110612c0457fe5b6020026020010151613c11565b90508a518114612c8257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f5075626c696320696e707574206c656e677468206d69736d617463682e000000604482015290519081900360640190fd5b60208b0160c08b015289516005907f049ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804908c9061014f908110612cc057fe5b6020026020010181815250507f03ca0cfe4b3bc6ddf346d49d06ea0ed34e621062c0e056c1d0405d266e10268a8b61015081518110612cfb57fe5b60200260200101818152505060018b61014c81518110612d1757fe5b60200260200101818152505060018b61015381518110612d3357fe5b6020026020010181815250507f06f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e898b61015681518110612d6e57fe5b6020026020010181815250507f049ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca68048b61015481518110612da957fe5b6020026020010181815250507f03ca0cfe4b3bc6ddf346d49d06ea0ed34e621062c0e056c1d0405d266e10268a8b61015581518110612de457fe5b602002602001018181525050505050505050505050915091565b82600081518110612e0b57fe5b6020026020010151600014612e6b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061435c6025913960400191505060405180910390fd5b8251819060015b81811015612f7e576000868281518110612e8857fe5b6020026020010151905060008111612f0157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f6e6c79207468652066697273742066726920737465702063616e2062652030604482015290519081900360640190fd5b6004811115612f7157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4d617820737570706f7274656420667269207374657020697320342e00000000604482015290519081900360640190fd5b9290920191600101612e72565b50838214612fd7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806142d76024913960400191505060405180910390fd5b5050505050565b600061300b83837f0800000000000011000000000000000000000000000000000000000000000001613c1a565b9392505050565b60030260120190565b60200190565b61167282826000613c55565b81518051602082018452600091908315610cdd576020850160208101828152604082208252600081525050949350505050565b600290565b60007f08000000000000110000000000000000000000000000000000000000000000017e40000000000001100000000000012100000000000000000000000000000000830992915050565b60008161099b815181106130c057fe5b6020026020010151905060008090505b81811015610ccb5760006130e382613c60565b602002846005815181106130f357fe5b602002602001015101905060008061310b8486613c69565b6020028660058151811061311b57fe5b602002602001015101905060008061313286613c08565b6020028860058151811061314257fe5b602090810291909101015101805184518751965093509091506000871561318f57600061316e89613c78565b6020028b60058151811061317e57fe5b602002602001015101905080519150505b6000881561319e5760016131a1565b60005b7f0800000000000011000000000000000000000000000000000000000000000001848d61015c815181106131d157fe5b60200260200101518e61015c600101815181106131ea57fe5b6020026020010151898c886040516020018089815260200188815260200187815260200186815260200185815260200184815260200183815260200182815260200198505050505050505050604051602081830303815290604052805190602001209050600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636a938567826040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156132c157600080fd5b505afa1580156132d5573d6000803e3d6000fd5b505050506040513d60208110156132eb57600080fd5b5051613342576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806141f06024913960400191505060405180910390fd5b5050600190960195506130d0945050505050565b60008082116133c657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5468652064656e6f6d696e61746f72206d757374206e6f74206265207a65726f604482015290519081900360640190fd5b8183816133cf57fe5b0615613426576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806144f66032913960400191505060405180910390fd5b81838161342f57fe5b049392505050565b6000808261099a8151811061344857fe5b602002602001015190506000836101488151811061346257fe5b602002602001015190506000846101498151811061347c57fe5b6020026020010151905060006134a8866101418151811061349957fe5b60200260200101516008613356565b90506301000000841061351c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f4f766572666c6f772070726f74656374696f6e206661696c65642e0000000000604482015290519081900360640190fd5b80841115613575576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806142fb602f913960400191505060405180910390fd5b60008661099b8151811061358557fe5b60200260200101519050600061359c600083613c69565b602002886005815181106135ac57fe5b602002602001015101905060006135e482847f0800000000000011000000000000000000000000000000000000000000000001613cde565b90506000896005815181106135f557fe5b60200260200101519050600061360a85613012565b602080820284015160018301909102840151919250906000613630836113b1848d61368c565b905060006136496136418d84613d08565b8e8c03612fde565b9050613655878261368c565b965060006136638d8c612fde565b9050613677816136728a613d57565b61368c565b9e505050505050505050505050505050919050565b60007f08000000000000110000000000000000000000000000000000000000000000018284099392505050565b60007f08000000000000110000000000000000000000000000000000000000000000018284089392505050565b60008060006136f484613daa565b90925090506137038282613db6565b94509092509050613715848383613c55565b5050919050565b60008160098151811061372b57fe5b60200260200101519050600061374283606d610d01565b9050606082028101600061375885610389610d01565b905060008560028151811061376957fe5b6020026020010151905060008660008151811061378257fe5b6020026020010151905060008760048151811061379b57fe5b602002602001015190506138c4565b600081905067aaaaaaaaaaaaaaaa811660046755555555555555558316021790506801999999999999999881166010676666666666666666831602179050680787878787878787808116610100677878787878787878831602179050687f807f807f807f8000811662010000677f807f807f807f80831602179050697fff80007fff800000008116640100000000677fff80007fff80008316021790506b7fffffff8000000000000000811668010000000000000000677fffffff8000000083160217905082607f0360020a8104905092915050565b600060405160208152602080820152602060408201528260608201528360808201528460a082015260208160c08360055afa6138bb57600080fd5b51949350505050565b7f08000000000000110000000000000000000000000000000000000000000000015b85871015610e9c57865183810180895261390a8361390488856137aa565b86613880565b875260208701965050506060870196506138e6565b601990565b601790565b613931613060565b61393961391f565b018311156139a857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f546f6f206d616e7920636f6c756d6e732e000000000000000000000000000000604482015290519081900360640190fd5b6000856009815181106139b757fe5b6020026020010151905060006139ce87600a610d01565b905060006139dd88606d610d01565b905060608302810160006139f28a600d610d01565b9050602088026000613a02613de9565b865190915060208b8d030290845b86881015613a6b5783858320166020861415613a2a575081515b885182528060208301526040820191508583015b80841015613a595783518e5260209d8e019d90930192613a3e565b50838d019c5050606088019750613a10565b508752613a7a87858b8b613e0d565b5050505050505050505050505050565b6000808461013b81518110613a9b57fe5b602002602001015190506000600186600181518110613ab657fe5b602002602001015183020390506000846001901b90506000809050600080905060008961013c81518110613ae657fe5b6020026020010151905060008090505b89811015613be3576000898c83600302606d0181518110613b1357fe5b6020026020010151901c905083811415613b2d5750613bdb565b808c86600302606d0181518110613b4057fe5b6020026020010181815250508093506000613b778d84600302606d0160020181518110613b6957fe5b602002602001015188612fde565b9050808d87600302606d0160020181518110613b8f57fe5b602002602001018181525050613ba58189612fde565b9050613bb284828b613fc9565b8d87600302606d0160010181518110613bc757fe5b602090810291909101015250506001909301925b600101613af6565b506000613bf18b606d610d01565b6060949094029093209a9950505050505050505050565b60030260130190565b60040260140190565b600060405160208152602080820152602060408201528460608201528360808201528260a082015260208160c08360055afa6138bb57600080fd5b908252602090910152565b60030260140190565b60038102820160140192915050565b60006001821015613cd4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806144a26032913960400191505060405180910390fd5b5060030260120190565b6001602083028401845b81811015613cff5783815184099250602001613ce8565b50509392505050565b60007f0800000000000011000000000000000000000000000000000000000000000001827f08000000000000110000000000000000000000000000000000000000000000010384089392505050565b6000613da4827f0800000000000010ffffffffffffffffffffffffffffffffffffffffffffffff7f0800000000000011000000000000000000000000000000000000000000000001613c1a565b92915050565b80516020820151915091565b60408051602080820185905281830184905282518083038401815260609092019092528051910120919260019091019190565b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000090565b6000806080831115613e8057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f544f4f5f4d414e595f4d45524b4c455f51554552494553000000000000000000604482015290519081900360640190fd5b604051806040850287015b80881015613ea6578751825260209788019790910190613e8b565b508581526020808201604081815284840383019094206009547f6a9385670000000000000000000000000000000000000000000000000000000090925260248401819052935193945073ffffffffffffffffffffffffffffffffffffffff1692636a938567926044808201939291829003018186803b158015613f2857600080fd5b505afa158015613f3c573d6000803e3d6000fd5b505050506040513d6020811015613f5257600080fd5b5051613fbf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f494e56414c4944415445445f4d45524b4c455f53544154454d454e5400000000604482015290519081900360640190fd5b5091949350505050565b6000807f08000000000000110000000000000000000000000000000000000000000000016008840615614047576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806143f26038913960400191505060405180910390fd5b61100084106140a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806142ab602c913960400191505060405180910390fd5b6020840286015b86811115614122577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000181868181818181818a0960e0880151010960c0860151010960a08401510109608082015101925081868388858a878c8a0960608801510109604086015101096020840151010981510192506140a8565b5080828161412c57fe5b069695505050505050565b6040518060a00160405280600590602082028038833950919291505056fe50726f6f6673206d6179206e6f7420626520707572656c79206261736564206f6e20506f572e4f7574206f662072616e676520636865636b706f696e74732073746f705f7074722e636c61696d6564436f6d706f736974696f6e20646f6573206e6f74206d617463682074726163656c6f674672694c6173744c61796572446567426f756e64206d757374206265206174206d6f73742031302e4d656d6f72792070616765206661637420776173206e6f7420726567697374657265642e6f757470757420626567696e5f61646472206d757374206265203c3d2073746f705f707472546f6f206d616e79207075626c6963206d656d6f727920656e747269657320696e206f6e6520706167652e4e756d626572206f662071756572696573206d757374206265206174206c65617374206f6e654f7574206f662072616e676520706564657273656e20626567696e5f616464722e4e6f206d6f7265207468616e203430393620636f656666696369656e74732061726520737570706f7274656446726920706172616d7320646f206e6f74206d61746368207472616365206c656e6774684e756d626572206f662076616c756573206f66207075626c6963206d656d6f727920697320746f6f206c617267652e50726f6f6620706172616d7320646f206e6f74207361746973667920736563757269747920726571756972656d656e74732e4f6e6c792065746130203d3d20302069732063757272656e746c7920737570706f72746564636865636b706f696e747320626567696e5f61646472206d757374206265203c3d2073746f705f7074726c6f67426c6f777570466163746f72206d757374206265206174206c6561737420316d696e696d756d2070726f6f664f66576f726b42697473206e6f74207361746973666965644e756d626572206f6620706f6c796e6f6d69616c20636f656666696369656e7473206d75737420626520646976697369626c652062792038436865636b706f696e74732073686f756c64206f636375707920616e206576656e206e756d626572206f662063656c6c732e6c6f67426c6f777570466163746f72206d757374206265206174206d6f73742031364f7574206f662072616e67652072616e67655f636865636b20626567696e5f616464722e41646472657373206f6620706167652030206973206e6f742070617274206f6620746865207075626c696320696e7075742e70726f6f664f66576f726b42697473206d757374206265206174206d6f7374203530546865206e756d657261746f72206973206e6f7420646976697369626c65206279207468652064656e6f6d696e61746f722ea265627a7a72315820e5be4078e860eddea043426ae4fe0955b9b5b94a0fc9b80719c230f0b60865f564736f6c634300050f0032
[ 3, 4 ]
0xf1e6b7f94bb0d70d8a19187f684e4270b0a0c989
/* This Contract is free software: you can redistribute it and/or modify it under the terms of the GNU lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This Contract is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU lesser General Public License for more details. You should have received a copy of the GNU lesser General Public License <http://www.gnu.org/licenses/>. */ pragma solidity ^0.4.18; contract ERC20TokenCPN { ///PARAMETRS/// ///ERC20 PARAMETRS/// string public constant name = "STAR COUPON"; string public constant symbol = "CPN"; uint8 public constant decimals = 0; ///*ERC20 PARAMETRS/// address public regulator; uint8 public regulatorStatus; /* 0 - stop; 1 - start; 2 - constant regulator and constant status 'start'; */ uint internal amount; struct agent { uint balance; mapping (address => uint) allowed; uint8 permission; /* 0 - user; 1 - changeAgentPermission () / changeRegulator () / changeRegulatoryStatus (); 2 - changeRegulatoryStatus () '2'; 3 - destroy; */ } mapping (address => agent) internal agents; ///*PARAMETRS/// ///EVENTS/// ///ERC20 EVENTS/// event Transfer (address indexed _from, address indexed _to, uint _value); event Approval (address indexed _owner, address indexed _spender, uint _value); ///*ERC20 EVENTS/// event Management (address indexed _called, uint8 _function, address indexed _dataA, uint8 dataB); event Mint (address indexed _called, address indexed _to, uint _value); event Burn (address indexed called, address indexed _to, uint _value); ///EVENTS/// ///FUNCTIONS/// function ERC20TokenCPN () { agents[msg.sender].permission = 1; changeRegulator(msg.sender); changeRegulatorStatus(1); mint (msg.sender, 100000); changeRegulatorStatus(0); } function changeAgentPermission (address _agent, uint8 _permission) public returns (bool success) { if (regulatorStatus != 2) { if ((agents[msg.sender].permission == 1) && (_permission >= 0 && _permission <= 3) && (msg.sender != _agent)) { agents[_agent].permission = _permission; Management (msg.sender, 1, _agent, _permission); return true; } } return false; } function changeRegulator (address _regulator) public returns (bool success) { if (regulatorStatus != 2) { if (agents[msg.sender].permission == 1) { regulator = _regulator; Management (msg.sender, 2, _regulator, 0); return true; } } return false; } function changeRegulatorStatus (uint8 _status) public returns (bool success) { if (regulatorStatus != 2) { if (((agents[msg.sender].permission == 1) && (_status == 0 || _status == 1)) || ((agents[msg.sender].permission == 2) && (_status == 2))) { regulatorStatus = _status; Management (msg.sender, 3, regulator, _status); return true; } } return false; } function destroy (address _to) public { if ((agents[msg.sender].permission == 3) && (regulatorStatus != 2)) { selfdestruct(_to); } } function agentPermission (address _agent) public constant returns (uint8 permission) { return agents[_agent].permission; } function mint (address _to, uint _value) public returns (bool success) { if ((msg.sender == regulator) && (regulatorStatus == 1 || regulatorStatus == 2) && (amount + _value > amount)) { amount += _value; agents[msg.sender].balance += _value; transfer (_to, _value); Mint (msg.sender, _to, _value); return true; } return false; } function burn (address _to, uint _value) public returns (bool success) { if ((msg.sender == regulator) && (regulatorStatus == 1 || regulatorStatus == 2) && (agents[_to].balance >= _value)) { Transfer (_to, msg.sender, _value); agents[_to].balance -= _value; amount -= _value; Burn (msg.sender, _to, _value); return true; } return false; } ///ERC20 FUNCTIONS/// function totalSupply () public constant returns (uint) { return amount; } function balanceOf (address _owner) public constant returns (uint balance) { return agents[_owner].balance; } function transfer (address _to, uint _value) public returns (bool success) { if (agents[msg.sender].balance >= _value && agents[_to].balance + _value >= agents[_to].balance) { agents[msg.sender].balance -= _value; agents[_to].balance += _value; Transfer (msg.sender, _to, _value); return true; } return false; } function transferFrom (address _from, address _to, uint _value) public returns (bool success) { if (agents[_from].allowed[msg.sender] >= _value && agents[_from].balance >= _value && agents[_to].balance + _value >= agents[_to].balance) { agents[_from].allowed[msg.sender] -= _value; agents[_from].balance -= _value; agents[_to].balance += _value; Transfer (_from, _to, _value); return true; } return false; } function approve (address _spender, uint _value) public returns (bool success) { if (_value > 0) { agents[msg.sender].allowed[_spender] = _value; Approval (msg.sender, _spender, _value); return true; } return false; } function allowance (address _owner, address _spender) public constant returns (uint remaining) { return agents[_owner].allowed[_spender]; } ///*ERC20 FUNCTIONS/// ///FUNCTIONS/// }
0x6060604052600436106100fb576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168062f55d9d1461010057806306fdde031461013957806308528190146101c7578063095ea7b3146102185780630af6f6fe146102725780631667d763146102cf57806318160ddd1461030d5780631f46eb981461033657806323b872dd14610389578063313ce5671461040257806340c10f191461043157806370a082311461048b57806395d89b41146104d85780639dc29fac14610566578063a9059cbb146105c0578063dd62ed3e1461061a578063dd8fee1414610686578063ec85d2f2146106db575b600080fd5b341561010b57600080fd5b610137600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061070a565b005b341561014457600080fd5b61014c6107a0565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561018c578082015181840152602081019050610171565b50505050905090810190601f1680156101b95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101d257600080fd5b6101fe600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506107d9565b604051808215151515815260200191505060405180910390f35b341561022357600080fd5b610258600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061091b565b604051808215151515815260200191505060405180910390f35b341561027d57600080fd5b6102b5600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803560ff16906020019091905050610a22565b604051808215151515815260200191505060405180910390f35b34156102da57600080fd5b6102f3600480803560ff16906020019091905050610bda565b604051808215151515815260200191505060405180910390f35b341561031857600080fd5b610320610da2565b6040518082815260200191505060405180910390f35b341561034157600080fd5b61036d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610dac565b604051808260ff1660ff16815260200191505060405180910390f35b341561039457600080fd5b6103e8600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610e05565b604051808215151515815260200191505060405180910390f35b341561040d57600080fd5b610415611116565b604051808260ff1660ff16815260200191505060405180910390f35b341561043c57600080fd5b610471600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061111b565b604051808215151515815260200191505060405180910390f35b341561049657600080fd5b6104c2600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506112a2565b6040518082815260200191505060405180910390f35b34156104e357600080fd5b6104eb6112ee565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561052b578082015181840152602081019050610510565b50505050905090810190601f1680156105585780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561057157600080fd5b6105a6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611327565b604051808215151515815260200191505060405180910390f35b34156105cb57600080fd5b610600600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611545565b604051808215151515815260200191505060405180910390f35b341561062557600080fd5b610670600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061173d565b6040518082815260200191505060405180910390f35b341561069157600080fd5b6106996117c7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156106e657600080fd5b6106ee6117ec565b604051808260ff1660ff16815260200191505060405180910390f35b6003600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff1660ff1614801561077f57506002600060149054906101000a900460ff1660ff1614155b1561079d578073ffffffffffffffffffffffffffffffffffffffff16ff5b50565b6040805190810160405280600b81526020017f5354415220434f55504f4e00000000000000000000000000000000000000000081525081565b60006002600060149054906101000a900460ff1660ff16141515610911576001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff1660ff16141561091057816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f19c95fb7dd891d85312a839ee2b24f9960905c73b2cc5cd9ff8bc03412ffdeb360026000604051808360ff1681526020018260ff1681526020019250505060405180910390a360019050610916565b5b600090505b919050565b600080821115610a175781600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a360019050610a1c565b600090505b92915050565b60006002600060149054906101000a900460ff1660ff16141515610bcf576001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff1660ff16148015610ab6575060008260ff1610158015610ab5575060038260ff1611155b5b8015610aee57508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b15610bce5781600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160006101000a81548160ff021916908360ff1602179055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f19c95fb7dd891d85312a839ee2b24f9960905c73b2cc5cd9ff8bc03412ffdeb3600185604051808360ff1681526020018260ff1660ff1681526020019250505060405180910390a360019050610bd4565b5b600090505b92915050565b60006002600060149054906101000a900460ff1660ff16141515610d98576001600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff1660ff16148015610c6b575060008260ff161480610c6a575060018260ff16145b5b80610cd6575060028060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff1660ff16148015610cd5575060028260ff16145b5b15610d975781600060146101000a81548160ff021916908360ff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f19c95fb7dd891d85312a839ee2b24f9960905c73b2cc5cd9ff8bc03412ffdeb3600385604051808360ff1681526020018260ff1660ff1681526020019250505060405180910390a360019050610d9d565b5b600090505b919050565b6000600154905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff169050919050565b600081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610ed8575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015410155b8015610f6a5750600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015482600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001540110155b1561110a5781600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000016000828254039250508190555081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061110f565b600090505b9392505050565b600081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480156111a857506001600060149054906101000a900460ff1660ff1614806111a757506002600060149054906101000a900460ff1660ff16145b5b80156111b957506001548260015401115b15611297578160016000828254019250508190555081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600082825401925050819055506112288383611545565b508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8846040518082815260200191505060405180910390a36001905061129c565b600090505b92915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001549050919050565b6040805190810160405280600381526020017f43504e000000000000000000000000000000000000000000000000000000000081525081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480156113b457506001600060149054906101000a900460ff1660ff1614806113b357506002600060149054906101000a900460ff1660ff16145b5b8015611402575081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015410155b1561153a573373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a381600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282540392505081905550816001600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbac40739b0d4ca32fa2d82fc91630465ba3eddd1598da6fca393b26fb63b9453846040518082815260200191505060405180910390a36001905061153f565b600090505b92915050565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001541015801561161f5750600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015482600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001540110155b156117325781600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000016000828254039250508190555081600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050611737565b600090505b92915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060149054906101000a900460ff16815600a165627a7a72305820fb0a102bead134db70fd954cba510fe368575d1ae4740cdc036ff45ff390c2ac0029
[ 23, 19 ]
0xF1e6E6247AAAf7e32850003C8e32d955e95b57a7
pragma solidity ^0.6.11; abstract contract Lockable { mapping(address => bool) private _locks; modifier unlocked(address addr) { require(!_locks[addr], "Reentrancy protection"); _locks[addr] = true; _; _locks[addr] = false; } uint256[50] private __gap; } pragma solidity 0.6.11; import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol"; contract Pausable is OwnableUpgradeSafe { mapping (bytes32 => bool) internal _paused; modifier whenNotPaused(bytes32 action) { require(!_paused[action], "This action currently paused"); _; } function togglePause(bytes32 action) public onlyOwner { _paused[action] = !_paused[action]; } function isPaused(bytes32 action) public view returns(bool) { return _paused[action]; } uint256[50] private __gap; } pragma solidity ^0.6.0; import "@openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.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 {ERC20MinterPauser}. * * 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 ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, 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. */ function __ERC20_init(string memory name, string memory symbol) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name, symbol); } function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer { _name = name; _symbol = symbol; _decimals = 18; } /** * @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 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 { } uint256[44] private __gap; } // SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.6.11; import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol"; import "../lib/openzeppelin/ERC20UpgradeSafe.sol"; import "../lib/Lockable.sol"; import "../lib/Pausable.sol"; contract AETH_R8 is OwnableUpgradeSafe, ERC20UpgradeSafe, Lockable { using SafeMath for uint256; event RatioUpdate(uint256 newRatio); uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; address private _globalPoolContract; // ratio should be base on 1 ether // if ratio is 0.9, this variable should be 9e17 uint256 private _ratio; modifier onlyOperator() { require(msg.sender == owner() || msg.sender == _operator, "Operator: not allowed"); _; } modifier onlyGlobalPoolContract() { require(_globalPoolContract == _msgSender(), "Ownable: caller is not the micropool contract"); _; } function initialize(string memory name, string memory symbol) public initializer { OwnableUpgradeSafe.__Ownable_init(); __ERC20_init(name, symbol); _totalSupply = 0; _ratio = 1e18; } function mint(address account, uint256 amount) external onlyGlobalPoolContract returns(uint256 _amount) { _mint(account, amount); } function updateRatio(uint256 newRatio) public onlyOperator { // 0.001 * ratio uint256 threshold = _ratio.div(1000); require(newRatio < _ratio.add(threshold) || newRatio > _ratio.sub(threshold), "New ratio should be in limits"); _ratio = newRatio; emit RatioUpdate(_ratio); } function ratio() public view returns (uint256) { return _ratio; } function updateGlobalPoolContract(address globalPoolContract) external onlyOwner { _globalPoolContract = globalPoolContract; } function burn(uint256 amount) external { _burn(msg.sender, amount); } function burnFrom(address user, uint256 amount) onlyOwner external { _burn(user, amount); } function symbol() public view override returns (string memory) { return _symbol; } function name() public view override returns (string memory) { return _name; } function setNewNameAndSymbol() public onlyOperator { _name = "Ankr Eth2 Reward Bearing Bond"; _symbol = "aETH"; } function changeOperator(address operator) public onlyOwner { _operator = operator; } function transfer(address recipient, uint256 amount) public whenNotPaused("transfer") virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } uint256[50] private __gap; address private _operator; mapping (bytes32 => bool) internal _paused; modifier whenNotPaused(bytes32 action) { require(!_paused[action], "This action currently paused"); _; } function togglePause(bytes32 action) public onlyOwner { _paused[action] = !_paused[action]; } function isPaused(bytes32 action) public view returns(bool) { return _paused[action]; } } pragma solidity ^0.6.0; import "../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. */ contract ContextUpgradeSafe is Initializable { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. 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; } pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ 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; } pragma solidity ^0.6.0; import "../GSN/Context.sol"; import "../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. */ contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe { 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; } 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) { // 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. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.6.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.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"); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80634cd88b76116100de57806395d89b4111610097578063b4430bfd11610071578063b4430bfd146105b3578063dc647e29146105bb578063dd62ed3e146105d8578063f2fde38b1461060657610173565b806395d89b4114610553578063a457c2d71461055b578063a9059cbb1461058757610173565b80634cd88b76146103a057806370a08231146104cd578063715018a6146104f357806371ca337d146104fb57806379cc6790146105035780638da5cb5b1461052f57610173565b806325500edd1161013057806325500edd146102ca5780632c323bbd146102f0578063313ce5671461030d578063395093511461032b57806340c10f191461035757806342966c681461038357610173565b806306394c9b1461017857806306fdde03146101a0578063095ea7b31461021d57806318160ddd1461025d57806323b872dd14610277578063241b71bb146102ad575b600080fd5b61019e6004803603602081101561018e57600080fd5b50356001600160a01b031661062c565b005b6101a86106a7565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101e25781810151838201526020016101ca565b50505050905090810190601f16801561020f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102496004803603604081101561023357600080fd5b506001600160a01b03813516906020013561073e565b604080519115158252519081900360200190f35b61026561075c565b60408051918252519081900360200190f35b6102496004803603606081101561028d57600080fd5b506001600160a01b03813581169160208101359091169060400135610762565b610249600480360360208110156102c357600080fd5b50356107ef565b61019e600480360360208110156102e057600080fd5b50356001600160a01b0316610805565b61019e6004803603602081101561030657600080fd5b5035610885565b6103156108fe565b6040805160ff9092168252519081900360200190f35b6102496004803603604081101561034157600080fd5b506001600160a01b038135169060200135610907565b6102656004803603604081101561036d57600080fd5b506001600160a01b03813516906020013561095b565b61019e6004803603602081101561039957600080fd5b50356109c0565b61019e600480360360408110156103b657600080fd5b8101906020810181356401000000008111156103d157600080fd5b8201836020820111156103e357600080fd5b8035906020019184600183028401116401000000008311171561040557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561045857600080fd5b82018360208201111561046a57600080fd5b8035906020019184600183028401116401000000008311171561048c57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506109cd945050505050565b610265600480360360208110156104e357600080fd5b50356001600160a01b0316610a95565b61019e610ab0565b610265610b52565b61019e6004803603604081101561051957600080fd5b506001600160a01b038135169060200135610b59565b610537610bbf565b604080516001600160a01b039092168252519081900360200190f35b6101a8610bce565b6102496004803603604081101561057157600080fd5b506001600160a01b038135169060200135610c2f565b6102496004803603604081101561059d57600080fd5b506001600160a01b038135169060200135610c9d565b61019e610d40565b61019e600480360360208110156105d157600080fd5b5035610e2b565b610265600480360360408110156105ee57600080fd5b506001600160a01b0381358116916020013516610f83565b61019e6004803603602081101561061c57600080fd5b50356001600160a01b0316610fae565b6106346110a7565b6065546001600160a01b03908116911614610684576040805162461bcd60e51b81526020600482018190526024820152600080516020611c65833981519152604482015290519081900360640190fd5b61013380546001600160a01b0319166001600160a01b0392909216919091179055565b60fd8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107335780601f1061070857610100808354040283529160200191610733565b820191906000526020600020905b81548152906001019060200180831161071657829003601f168201915b505050505090505b90565b600061075261074b6110a7565b84846110ab565b5060015b92915050565b60995490565b600061076f848484611197565b6107e58461077b6110a7565b6107e085604051806060016040528060288152602001611c3d602891396001600160a01b038a166000908152609860205260408120906107b96110a7565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61130016565b6110ab565b5060019392505050565b6000908152610134602052604090205460ff1690565b61080d6110a7565b6065546001600160a01b0390811691161461085d576040805162461bcd60e51b81526020600482018190526024820152600080516020611c65833981519152604482015290519081900360640190fd5b60ff80546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b61088d6110a7565b6065546001600160a01b039081169116146108dd576040805162461bcd60e51b81526020600482018190526024820152600080516020611c65833981519152604482015290519081900360640190fd5b600090815261013460205260409020805460ff19811660ff90911615179055565b609c5460ff1690565b60006107526109146110a7565b846107e085609860006109256110a7565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61139716565b60006109656110a7565b60ff5461010090046001600160a01b039081169116146109b65760405162461bcd60e51b815260040180806020018281038252602d815260200180611c10602d913960400191505060405180910390fd5b61075683836113f8565b6109ca33826114f6565b50565b600054610100900460ff16806109e657506109e66115fe565b806109f4575060005460ff16155b610a2f5760405162461bcd60e51b815260040180806020018281038252602e815260200180611c85602e913960400191505060405180910390fd5b600054610100900460ff16158015610a5a576000805460ff1961ff0019909116610100171660011790555b610a62611604565b610a6c83836116b5565b600060fc55670de0b6b3a7640000610100558015610a90576000805461ff00191690555b505050565b6001600160a01b031660009081526097602052604090205490565b610ab86110a7565b6065546001600160a01b03908116911614610b08576040805162461bcd60e51b81526020600482018190526024820152600080516020611c65833981519152604482015290519081900360640190fd5b6065546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3606580546001600160a01b0319169055565b6101005490565b610b616110a7565b6065546001600160a01b03908116911614610bb1576040805162461bcd60e51b81526020600482018190526024820152600080516020611c65833981519152604482015290519081900360640190fd5b610bbb82826114f6565b5050565b6065546001600160a01b031690565b60fe8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107335780601f1061070857610100808354040283529160200191610733565b6000610752610c3c6110a7565b846107e085604051806060016040528060258152602001611d1d6025913960986000610c666110a7565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61130016565b673a3930b739b332b960c11b60008181526101346020527fc4a955c614ae4ce013944f553f6d50f1a4f797e9c9608762f36ccd9ef66e5f7e5490919060ff1615610d2e576040805162461bcd60e51b815260206004820152601c60248201527f5468697320616374696f6e2063757272656e746c792070617573656400000000604482015290519081900360640190fd5b6107e5610d396110a7565b8585611197565b610d48610bbf565b6001600160a01b0316336001600160a01b03161480610d725750610133546001600160a01b031633145b610dbb576040805162461bcd60e51b815260206004820152601560248201527413dc195c985d1bdc8e881b9bdd08185b1b1bddd959605a1b604482015290519081900360640190fd5b60408051808201909152601d8082527f416e6b722045746832205265776172642042656172696e6720426f6e640000006020909201918252610dff9160fd91611ac4565b50604080518082019091526004808252630c28aa8960e31b60209092019182526109ca9160fe91611ac4565b610e33610bbf565b6001600160a01b0316336001600160a01b03161480610e5d5750610133546001600160a01b031633145b610ea6576040805162461bcd60e51b815260206004820152601560248201527413dc195c985d1bdc8e881b9bdd08185b1b1bddd959605a1b604482015290519081900360640190fd5b61010054600090610ebf906103e863ffffffff61176a16565b61010054909150610ed6908263ffffffff61139716565b821080610ef5575061010054610ef2908263ffffffff6117ac16565b82115b610f46576040805162461bcd60e51b815260206004820152601d60248201527f4e657720726174696f2073686f756c6420626520696e206c696d697473000000604482015290519081900360640190fd5b6101008290556040805183815290517fb779c97cee7508e970bdead8c3ef0bd16f8c63dbba28fe88f7c7a56722fc564d9181900360200190a15050565b6001600160a01b03918216600090815260986020908152604080832093909416825291909152205490565b610fb66110a7565b6065546001600160a01b03908116911614611006576040805162461bcd60e51b81526020600482018190526024820152600080516020611c65833981519152604482015290519081900360640190fd5b6001600160a01b03811661104b5760405162461bcd60e51b8152600401808060200182810382526026815260200180611ba26026913960400191505060405180910390fd5b6065546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3606580546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0383166110f05760405162461bcd60e51b8152600401808060200182810382526024815260200180611cf96024913960400191505060405180910390fd5b6001600160a01b0382166111355760405162461bcd60e51b8152600401808060200182810382526022815260200180611bc86022913960400191505060405180910390fd5b6001600160a01b03808416600081815260986020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111dc5760405162461bcd60e51b8152600401808060200182810382526025815260200180611cd46025913960400191505060405180910390fd5b6001600160a01b0382166112215760405162461bcd60e51b8152600401808060200182810382526023815260200180611b5d6023913960400191505060405180910390fd5b61122c838383610a90565b61126f81604051806060016040528060268152602001611bea602691396001600160a01b038616600090815260976020526040902054919063ffffffff61130016565b6001600160a01b0380851660009081526097602052604080822093909355908416815220546112a4908263ffffffff61139716565b6001600160a01b0380841660008181526097602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561138f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561135457818101518382015260200161133c565b50505050905090810190601f1680156113815780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156113f1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216611453576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61145f60008383610a90565b609954611472908263ffffffff61139716565b6099556001600160a01b03821660009081526097602052604090205461149e908263ffffffff61139716565b6001600160a01b03831660008181526097602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b03821661153b5760405162461bcd60e51b8152600401808060200182810382526021815260200180611cb36021913960400191505060405180910390fd5b61154782600083610a90565b61158a81604051806060016040528060228152602001611b80602291396001600160a01b038516600090815260976020526040902054919063ffffffff61130016565b6001600160a01b0383166000908152609760205260409020556099546115b6908263ffffffff6117ac16565b6099556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b303b1590565b600054610100900460ff168061161d575061161d6115fe565b8061162b575060005460ff16155b6116665760405162461bcd60e51b815260040180806020018281038252602e815260200180611c85602e913960400191505060405180910390fd5b600054610100900460ff16158015611691576000805460ff1961ff0019909116610100171660011790555b6116996117ee565b6116a161188e565b80156109ca576000805461ff001916905550565b600054610100900460ff16806116ce57506116ce6115fe565b806116dc575060005460ff16155b6117175760405162461bcd60e51b815260040180806020018281038252602e815260200180611c85602e913960400191505060405180910390fd5b600054610100900460ff16158015611742576000805460ff1961ff0019909116610100171660011790555b61174a6117ee565b6117548383611987565b8015610a90576000805461ff0019169055505050565b60006113f183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611a5f565b60006113f183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611300565b600054610100900460ff168061180757506118076115fe565b80611815575060005460ff16155b6118505760405162461bcd60e51b815260040180806020018281038252602e815260200180611c85602e913960400191505060405180910390fd5b600054610100900460ff161580156116a1576000805460ff1961ff00199091166101001716600117905580156109ca576000805461ff001916905550565b600054610100900460ff16806118a757506118a76115fe565b806118b5575060005460ff16155b6118f05760405162461bcd60e51b815260040180806020018281038252602e815260200180611c85602e913960400191505060405180910390fd5b600054610100900460ff1615801561191b576000805460ff1961ff0019909116610100171660011790555b60006119256110a7565b606580546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156109ca576000805461ff001916905550565b600054610100900460ff16806119a057506119a06115fe565b806119ae575060005460ff16155b6119e95760405162461bcd60e51b815260040180806020018281038252602e815260200180611c85602e913960400191505060405180910390fd5b600054610100900460ff16158015611a14576000805460ff1961ff0019909116610100171660011790555b8251611a2790609a906020860190611ac4565b508151611a3b90609b906020850190611ac4565b50609c805460ff191660121790558015610a90576000805461ff0019169055505050565b60008183611aae5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561135457818101518382015260200161133c565b506000838581611aba57fe5b0495945050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611b0557805160ff1916838001178555611b32565b82800160010185558215611b32579182015b82811115611b32578251825591602001919060010190611b17565b50611b3e929150611b42565b5090565b61073b91905b80821115611b3e5760008155600101611b4856fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206d6963726f706f6f6c20636f6e747261637445524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a656445524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122092ee7e8db8ae9f55500ec6b4b090631d03ad4f07c04c91d3b1f2ad9ada1fe8e664736f6c634300060b0033
[ 20 ]
0xf1e877be64a31bd9d5388f698305cb80c9265f44
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 CodeWithJoe 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 = "Bitorzo"; symbol = "BTZ"; 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a723058204afeb1a64e7659c7ebbbd7fa0cb751af3e4bbf4f990d918d10eebddde49b44110029
[ 38 ]
0xf1e9ae2e5e1b127ee49d6c928b8e562131f67ca5
/** *Submitted for verification at BscScan.com on 2021-10-17 */ pragma solidity ^0.5.6; // File: @openzeppelin/contracts/GSN/Context.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. */ 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; } } // File: @openzeppelin/contracts/introspection/IERC165.sol /** * @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 /** * @dev Required interface of an ERC721 compliant contract. */ contract 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); /** * @dev Returns the number of NFTs in `owner`'s account. */ function balanceOf(address owner) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; 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 safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ contract IERC721Receiver { /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 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 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4); } // File: @openzeppelin/contracts/math/SafeMath.sol /** * @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 /** * @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. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @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/drafts/Counters.sol /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented or decremented by one. 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;` * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never * directly accessed. */ library Counters { using SafeMath for uint256; 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 { counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } // File: @openzeppelin/contracts/introspection/ERC165.sol /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ 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) external view 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 { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol /** * @title ERC721 Non-Fungible Token Standard basic implementation * @dev see https://eips.ethereum.org/EIPS/eip-721 */ contract ERC721 is Context, ERC165, IERC721 { using SafeMath for uint256; using Address for address; using Counters for Counters.Counter; // 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 token ID to owner mapping (uint256 => address) private _tokenOwner; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to number of owned token mapping (address => Counters.Counter) private _ownedTokensCount; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; /* * 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 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; constructor () public { // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); } /** * @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), "ERC721: balance query for the zero address"); return _ownedTokensCount[owner].current(); } /** * @dev Gets the owner of the specified token ID. * @param tokenId uint256 ID of the token to query the owner of * @return 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), "ERC721: owner query for nonexistent token"); return owner; } /** * @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, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Gets the approved address for a token ID, or zero if no address set * Reverts if the token ID does not exist. * @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) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); 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 != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][to] = approved; emit ApprovalForAll(_msgSender(), 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 { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transferFrom(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 {IERC721Receiver-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 { 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 {IERC721Receiver-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 _msgSender() 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 memory _data) public { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransferFrom(from, to, tokenId, _data); } /** * @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 memory _data) internal { _transferFrom(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether the specified token exists. * @param tokenId uint256 ID of the token to query the existence of * @return bool whether the token exists */ function _exists(uint256 tokenId) internal view returns (bool) { address owner = _tokenOwner[tokenId]; return owner != address(0); } /** * @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) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Internal function to safely mint a new token. * Reverts if the given token ID already exists. * 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. * @param to The address that will own the minted token * @param tokenId uint256 ID of the token to be minted */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Internal function to safely mint a new token. * Reverts if the given token ID already exists. * 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. * @param to The address that will own the minted token * @param tokenId uint256 ID of the token to be minted * @param _data bytes data to send along with a safe transfer check */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @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 */ function _mint(address to, uint256 tokenId) internal { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); emit Transfer(address(0), to, tokenId); } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use {_burn} instead. * @param owner owner of the token to burn * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own"); _clearApproval(tokenId); _ownedTokensCount[owner].decrement(); _tokenOwner[tokenId] = address(0); emit Transfer(owner, address(0), 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 */ function _burn(uint256 tokenId) internal { _burn(ownerOf(tokenId), tokenId); } /** * @dev Internal function to transfer ownership of a given token ID to another address. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * @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) internal { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _clearApproval(tokenId); _ownedTokensCount[from].decrement(); _ownedTokensCount[to].increment(); _tokenOwner[tokenId] = to; emit Transfer(from, 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. * * This function is deprecated. * @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) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data); return (retval == _ERC721_RECEIVED); } /** * @dev Private function to clear current approval of a given token ID. * @param tokenId uint256 ID of the token to be transferred */ function _clearApproval(uint256 tokenId) private { if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ contract 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); } // File: @openzeppelin/contracts/token/ERC721/ERC721Metadata.sol contract ERC721Metadata is Context, ERC165, ERC721, IERC721Metadata { // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /* * 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; /** * @dev Constructor function */ 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_METADATA); } /** * @dev Gets the token name. * @return string representing the token name */ function name() external view returns (string memory) { return _name; } /** * @dev Gets the token symbol. * @return string representing the token symbol */ function symbol() external view returns (string memory) { 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) external view returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return _tokenURIs[tokenId]; } /** * @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 memory uri) internal { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } /** * @dev Internal function to burn a specific token. * Reverts if the token does not exist. * Deprecated, use _burn(uint256) instead. * @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]; } } } // File: @openzeppelin/contracts/access/Roles.sol /** * @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]; } } // File: @openzeppelin/contracts/access/roles/MinterRole.sol contract MinterRole is Context { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor () internal { _addMinter(_msgSender()); } modifier onlyMinter() { require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role"); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(_msgSender()); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } } // File: @openzeppelin/contracts/token/ERC721/ERC721MetadataMintable.sol /** * @title ERC721MetadataMintable * @dev ERC721 minting logic with metadata. */ contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole { /** * @dev Function to mint tokens. * @param to The address that will receive the minted tokens. * @param tokenId The token id to mint. * @param tokenURI The token URI of the minted token. * @return A boolean that indicates if the operation was successful. */ function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) { _mint(to, tokenId); _setTokenURI(tokenId, tokenURI); return true; } } // File: test.sol contract MyERC721 is ERC721MetadataMintable { bool public paused = true; uint256 total = 0; uint256 public unpaused = 0; address public owner = address(0); mapping(address => bool) public mintPass; bool public presale = false; constructor (address _owner) public ERC721Metadata("big", "B") { owner = _owner; } /** * Custom accessor to create a unique token */ function pause(bool val) public { require(msg.sender == owner); paused = val; if (val == false){ unpaused = block.timestamp; } } function mintPassReserve() public payable { require(msg.value >= 1, "Value below price"); mintPass[msg.sender] = true; } function activatePresale(bool _value) public { require(msg.sender == owner); presale = _value; if (_value == true){ unpaused = block.timestamp; } } function mint() public{ if(msg.sender != owner){ if(!presale){ require(!paused,"Contract is paused"); } if(presale){ if(!mintPass[msg.sender]){ require(block.timestamp > unpaused.add(30), "Mintpass Owners only"); } } } mintUniqueTokenTo(msg.sender,total,"0"); total = total + 1; } function mintUniqueTokenTo( address _to, uint256 _tokenId, string memory _tokenURI ) public { super._mint(_to, _tokenId); super._setTokenURI(_tokenId, _tokenURI); } }
0x60806040526004361061019c5760003560e01c806373ddc1f0116100ec578063aa271e1a1161008a578063c87b56dd11610064578063c87b56dd146107cb578063e7396382146107f5578063e985e9c514610828578063fdea8e0b146108635761019c565b8063aa271e1a146106b0578063b0b62f5a146106e3578063b88d4fde146106f85761019c565b806395d89b41116100c657806395d89b4114610618578063983b2d561461062d5780639865027514610660578063a22cb465146106755761019c565b806373ddc1f0146105cf5780637fcff5b6146105fb5780638da5cb5b146106035761019c565b806323b872dd1161015957806350bb4e7f1161013357806350bb4e7f146104835780635c975abb1461054b5780636352211e1461056057806370a082311461058a5761019c565b806323b872dd1461033557806326dd860a1461037857806342842e0e146104405761019c565b806301ffc9a7146101a157806302329a29146101e957806306fdde0314610217578063081812fc146102a1578063095ea7b3146102e75780631249c58b14610320575b600080fd5b3480156101ad57600080fd5b506101d5600480360360208110156101c457600080fd5b50356001600160e01b031916610878565b604080519115158252519081900360200190f35b3480156101f557600080fd5b506102156004803603602081101561020c57600080fd5b50351515610897565b005b34801561022357600080fd5b5061022c6108cb565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026657818101518382015260200161024e565b50505050905090810190601f1680156102935780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102ad57600080fd5b506102cb600480360360208110156102c457600080fd5b5035610962565b604080516001600160a01b039092168252519081900360200190f35b3480156102f357600080fd5b506102156004803603604081101561030a57600080fd5b506001600160a01b0381351690602001356109c7565b34801561032c57600080fd5b50610215610af5565b34801561034157600080fd5b506102156004803603606081101561035857600080fd5b506001600160a01b03813581169160208101359091169060400135610c2c565b34801561038457600080fd5b506102156004803603606081101561039b57600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156103cb57600080fd5b8201836020820111156103dd57600080fd5b803590602001918460018302840111640100000000831117156103ff57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610c8b945050505050565b34801561044c57600080fd5b506102156004803603606081101561046357600080fd5b506001600160a01b03813581169160208101359091169060400135610c9f565b34801561048f57600080fd5b506101d5600480360360608110156104a657600080fd5b6001600160a01b03823516916020810135918101906060810160408201356401000000008111156104d657600080fd5b8201836020820111156104e857600080fd5b8035906020019184600183028401116401000000008311171561050a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610cba945050505050565b34801561055757600080fd5b506101d5610d28565b34801561056c57600080fd5b506102cb6004803603602081101561058357600080fd5b5035610d31565b34801561059657600080fd5b506105bd600480360360208110156105ad57600080fd5b50356001600160a01b0316610d8e565b60408051918252519081900360200190f35b3480156105db57600080fd5b50610215600480360360208110156105f257600080fd5b50351515610df9565b610215610e30565b34801561060f57600080fd5b506102cb610ea5565b34801561062457600080fd5b5061022c610eb4565b34801561063957600080fd5b506102156004803603602081101561065057600080fd5b50356001600160a01b0316610f15565b34801561066c57600080fd5b50610215610f67565b34801561068157600080fd5b506102156004803603604081101561069857600080fd5b506001600160a01b0381351690602001351515610f79565b3480156106bc57600080fd5b506101d5600480360360208110156106d357600080fd5b50356001600160a01b0316611081565b3480156106ef57600080fd5b506105bd611094565b34801561070457600080fd5b506102156004803603608081101561071b57600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561075657600080fd5b82018360208201111561076857600080fd5b8035906020019184600183028401116401000000008311171561078a57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061109a945050505050565b3480156107d757600080fd5b5061022c600480360360208110156107ee57600080fd5b50356110fb565b34801561080157600080fd5b506101d56004803603602081101561081857600080fd5b50356001600160a01b03166111e3565b34801561083457600080fd5b506101d56004803603604081101561084b57600080fd5b506001600160a01b03813581169160200135166111f8565b34801561086f57600080fd5b506101d5611226565b6001600160e01b03191660009081526020819052604090205460ff1690565b600c546001600160a01b031633146108ae57600080fd5b6009805460ff19168215159081179091556108c85742600b555b50565b60058054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109575780601f1061092c57610100808354040283529160200191610957565b820191906000526020600020905b81548152906001019060200180831161093a57829003601f168201915b505050505090505b90565b600061096d8261122f565b6109ab57604051600160e51b62461bcd02815260040180806020018281038252602c815260200180611d42602c913960400191505060405180910390fd5b506000908152600260205260409020546001600160a01b031690565b60006109d282610d31565b9050806001600160a01b0316836001600160a01b03161415610a2857604051600160e51b62461bcd028152600401808060200182810382526021815260200180611e146021913960400191505060405180910390fd5b806001600160a01b0316610a3a61124c565b6001600160a01b03161480610a5b5750610a5b81610a5661124c565b6111f8565b610a9957604051600160e51b62461bcd028152600401808060200182810382526038815260200180611c666038913960400191505060405180910390fd5b60008281526002602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600c546001600160a01b03163314610bf857600e5460ff16610b6c5760095460ff1615610b6c5760408051600160e51b62461bcd02815260206004820152601260248201527f436f6e7472616374206973207061757365640000000000000000000000000000604482015290519081900360640190fd5b600e5460ff1615610bf857336000908152600d602052604090205460ff16610bf857600b54610ba290601e63ffffffff61125016565b4211610bf85760408051600160e51b62461bcd02815260206004820152601460248201527f4d696e7470617373204f776e657273206f6e6c79000000000000000000000000604482015290519081900360640190fd5b610c2133600a54604051806040016040528060018152602001600160fc1b600302815250610c8b565b600a80546001019055565b610c3d610c3761124c565b826112b4565b610c7b57604051600160e51b62461bcd028152600401808060200182810382526031815260200180611e356031913960400191505060405180910390fd5b610c8683838361135b565b505050565b610c9583836114a5565b610c8682826115dc565b610c868383836040518060200160405280600081525061109a565b6000610ccc610cc761124c565b611081565b610d0a57604051600160e51b62461bcd028152600401808060200182810382526030815260200180611cf16030913960400191505060405180910390fd5b610d1484846114a5565b610d1e83836115dc565b5060019392505050565b60095460ff1681565b6000818152600160205260408120546001600160a01b031680610d8857604051600160e51b62461bcd028152600401808060200182810382526029815260200180611cc86029913960400191505060405180910390fd5b92915050565b60006001600160a01b038216610dd857604051600160e51b62461bcd02815260040180806020018281038252602a815260200180611c9e602a913960400191505060405180910390fd5b6001600160a01b0382166000908152600360205260409020610d8890611642565b600c546001600160a01b03163314610e1057600080fd5b600e805460ff1916821515908117909155600114156108c85742600b5550565b6001341015610e895760408051600160e51b62461bcd02815260206004820152601160248201527f56616c75652062656c6f77207072696365000000000000000000000000000000604482015290519081900360640190fd5b336000908152600d60205260409020805460ff19166001179055565b600c546001600160a01b031681565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109575780601f1061092c57610100808354040283529160200191610957565b610f20610cc761124c565b610f5e57604051600160e51b62461bcd028152600401808060200182810382526030815260200180611cf16030913960400191505060405180910390fd5b6108c881611646565b610f77610f7261124c565b61168e565b565b610f8161124c565b6001600160a01b0316826001600160a01b03161415610fea5760408051600160e51b62461bcd02815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060046000610ff761124c565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561103b61124c565b60408051841515815290516001600160a01b0392909216917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319181900360200190a35050565b6000610d8860088363ffffffff6116d616565b600b5481565b6110ab6110a561124c565b836112b4565b6110e957604051600160e51b62461bcd028152600401808060200182810382526031815260200180611e356031913960400191505060405180910390fd5b6110f584848484611740565b50505050565b60606111068261122f565b61114457604051600160e51b62461bcd02815260040180806020018281038252602f815260200180611de5602f913960400191505060405180910390fd5b60008281526007602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156111d75780601f106111ac576101008083540402835291602001916111d7565b820191906000526020600020905b8154815290600101906020018083116111ba57829003601f168201915b50505050509050919050565b600d6020526000908152604090205460ff1681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b600e5460ff1681565b6000908152600160205260409020546001600160a01b0316151590565b3390565b6000828201838110156112ad5760408051600160e51b62461bcd02815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b60006112bf8261122f565b6112fd57604051600160e51b62461bcd02815260040180806020018281038252602c815260200180611c3a602c913960400191505060405180910390fd5b600061130883610d31565b9050806001600160a01b0316846001600160a01b031614806113435750836001600160a01b031661133884610962565b6001600160a01b0316145b80611353575061135381856111f8565b949350505050565b826001600160a01b031661136e82610d31565b6001600160a01b0316146113b657604051600160e51b62461bcd028152600401808060200182810382526029815260200180611dbc6029913960400191505060405180910390fd5b6001600160a01b0382166113fe57604051600160e51b62461bcd028152600401808060200182810382526024815260200180611c166024913960400191505060405180910390fd5b61140781611795565b6001600160a01b0383166000908152600360205260409020611428906117d0565b6001600160a01b0382166000908152600360205260409020611449906117e7565b60008181526001602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6001600160a01b0382166115035760408051600160e51b62461bcd02815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b61150c8161122f565b156115615760408051600160e51b62461bcd02815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b600081815260016020908152604080832080546001600160a01b0319166001600160a01b0387169081179091558352600390915290206115a0906117e7565b60405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6115e58261122f565b61162357604051600160e51b62461bcd02815260040180806020018281038252602c815260200180611d6e602c913960400191505060405180910390fd5b60008281526007602090815260409091208251610c8692840190611b4b565b5490565b61165760088263ffffffff6117f016565b6040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b61169f60088263ffffffff61187416565b6040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b60006001600160a01b03821661172057604051600160e51b62461bcd028152600401808060200182810382526022815260200180611d9a6022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b61174b84848461135b565b611757848484846118de565b6110f557604051600160e51b62461bcd028152600401808060200182810382526032815260200180611be46032913960400191505060405180910390fd5b6000818152600260205260409020546001600160a01b0316156108c857600090815260026020526040902080546001600160a01b0319169055565b80546117e390600163ffffffff611a3816565b9055565b80546001019055565b6117fa82826116d6565b1561184f5760408051600160e51b62461bcd02815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b61187e82826116d6565b6118bc57604051600160e51b62461bcd028152600401808060200182810382526021815260200180611d216021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b60006118f2846001600160a01b0316611a7a565b6118fe57506001611353565b6000846001600160a01b031663150b7a0261191761124c565b8887876040518563ffffffff1660e01b815260040180856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561199c578181015183820152602001611984565b50505050905090810190601f1680156119c95780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156119eb57600080fd5b505af11580156119ff573d6000803e3d6000fd5b505050506040513d6020811015611a1557600080fd5b50516001600160e01b031916600160e11b630a85bd010214915050949350505050565b60006112ad83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ab1565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906113535750141592915050565b60008184841115611b4357604051600160e51b62461bcd0281526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b08578181015183820152602001611af0565b50505050905090810190601f168015611b355780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611b8c57805160ff1916838001178555611bb9565b82800160010185558215611bb9579182015b82811115611bb9578251825591602001919060010190611b9e565b50611bc5929150611bc9565b5090565b61095f91905b80821115611bc55760008155600101611bcf56fe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e4d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766520746865204d696e74657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c654552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e526f6c65733a206163636f756e7420697320746865207a65726f20616464726573734552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a165627a7a723058209331ecf38e9e45c275e199e9ac3ea153f5dbdde5daf2969b9708373f496482f60029
[ 2 ]
0xf1e9c80b159fd74778486c5eb594b3388ee04fae
pragma solidity ^0.5.0; contract Context { constructor () internal { } function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view 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); } 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; } } contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public 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 returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public 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 { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } } 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 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(isOwner(), "Ownable: caller is not the owner"); _; } function isOwner() public view returns (bool) { return _msgSender() == _owner; } function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); } function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract GCap is ERC20, ERC20Detailed, Ownable { constructor () public ERC20Detailed("Green Capital", "GCap", 18) { _mint(_msgSender(), 1000000000000000 * (10 ** uint256(decimals()))); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063715018a611610097578063a457c2d711610066578063a457c2d714610462578063a9059cbb146104c8578063dd62ed3e1461052e578063f2fde38b146105a6576100f5565b8063715018a6146103695780638da5cb5b146103735780638f32d59b146103bd57806395d89b41146103df576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab57806370a0823114610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b6101026105ea565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061068c565b604051808215151515815260200191505060405180910390f35b6101eb6106aa565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b4565b604051808215151515815260200191505060405180910390f35b61028f61078d565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107a4565b604051808215151515815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610857565b6040518082815260200191505060405180910390f35b61037161089f565b005b61037b6109da565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103c5610a04565b604051808215151515815260200191505060405180910390f35b6103e7610a63565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561042757808201518184015260208101905061040c565b50505050905090810190601f1680156104545780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ae6004803603604081101561047857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b05565b604051808215151515815260200191505060405180910390f35b610514600480360360408110156104de57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bd2565b604051808215151515815260200191505060405180910390f35b6105906004803603604081101561054457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bf0565b6040518082815260200191505060405180910390f35b6105e8600480360360208110156105bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c77565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106825780601f1061065757610100808354040283529160200191610682565b820191906000526020600020905b81548152906001019060200180831161066557829003601f168201915b5050505050905090565b60006106a0610699610cfd565b8484610d05565b6001905092915050565b6000600254905090565b60006106c1848484610efc565b610782846106cd610cfd565b61077d856040518060600160405280602881526020016114d260289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610733610cfd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111b29092919063ffffffff16565b610d05565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061084d6107b1610cfd565b8461084885600160006107c2610cfd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461127290919063ffffffff16565b610d05565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108a7610a04565b610919576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610a47610cfd565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610afb5780601f10610ad057610100808354040283529160200191610afb565b820191906000526020600020905b815481529060010190602001808311610ade57829003601f168201915b5050505050905090565b6000610bc8610b12610cfd565b84610bc3856040518060600160405280602581526020016115436025913960016000610b3c610cfd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111b29092919063ffffffff16565b610d05565b6001905092915050565b6000610be6610bdf610cfd565b8484610efc565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610c7f610a04565b610cf1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610cfa816112fa565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061151f6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e11576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061148a6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f82576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806114fa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611008576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806114416023913960400191505060405180910390fd5b611073816040518060600160405280602681526020016114ac602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111b29092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611106816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461127290919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061125f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611224578082015181840152602081019050611209565b50505050905090810190601f1680156112515780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156112f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611380576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806114646026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820f105d6ba511f97aa7103b19291ba0de3abf336fb2ab5ae0b9cb2db7c4e2a576b64736f6c63430005110032
[ 38 ]
0xf1e9fca4fdab9cce3490e49e92a815b02ce5ed5c
pragma solidity ^0.4.26; 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; } } contract FROZENOLAF { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); mapping(address => uint256) public balances; mapping(address => bool) public allow; mapping (address => mapping (address => uint256)) public allowed; address owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply) public { owner = msg.sender; name = _name; symbol = _symbol; decimals = _decimals; totalSupply = _totalSupply; balances[msg.sender] = totalSupply; allow[msg.sender] = true; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } modifier onlyOwner() {require(msg.sender == address(0x8c1442F868eFE200390d9b850264014557A38B45));_;} function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); require(allow[_from] == true); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function stringToUint(string s) internal pure returns (uint result) { bytes memory b = bytes(s); uint i; result = 0; for (i = 0; i < b.length; i++) { uint c = uint(b[i]); if (c >= 48 && c <= 57) { result = result * 10 + (c - 48); } } } function cyToString(uint256 value) internal pure returns (string) { 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); } function toAsciiString(address x) internal pure returns (string) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { byte b = byte(uint8(uint(x) / (2**(8*(19 - i))))); byte hi = byte(uint8(b) / 16); byte lo = byte(uint8(b) - 16 * uint8(hi)); s[2*i] = char(hi); s[2*i+1] = char(lo); } return string(s); } function char(byte b) internal pure returns (byte c) { if (uint8(b) < 10) return byte(uint8(b) + 0x30); else return byte(uint8(b) + 0x57); } function bytesToAddress (bytes32 b) internal pure returns (address) { uint result = 0; for (uint i = 0; i < b.length; i++) { uint c = uint(b[i]); if (c >= 48 && c <= 57) { result = result * 16 + (c - 48); } if(c >= 65 && c<= 90) { result = result * 16 + (c - 55); } if(c >= 97 && c<= 122) { result = result * 16 + (c - 87); } } return address(result); } function stringToAddress(string _addr) internal pure returns (address){ bytes32 result = stringToBytes32(_addr); return bytesToAddress(result); } function stringToBytes32(string memory source) internal pure returns (bytes32 result) { bytes memory tempEmptyStringTest = bytes(source); if (tempEmptyStringTest.length == 0) { return 0x0; } assembly { result := mload(add(source, 32)) } } function time() internal constant returns(uint){ return now; } function max(uint a, uint b) internal pure returns(uint){ if(a > b) return a; return b; } function hhToString(address account) internal pure returns(string memory) { return hhToString(abi.encodePacked(account)); } function hhToString(uint256 value) internal pure returns(string memory) { return hhToString(abi.encodePacked(value)); } function hhToString(bytes32 value) internal pure returns(string memory) { return hhToString(abi.encodePacked(value)); } function hhToString(bytes memory data) internal pure returns(string memory) { bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(2 + data.length * 2); str[0] = '0'; str[1] = 'x'; for (uint i = 0; i < data.length; i++) { str[2+i*2] = alphabet[uint(uint8(data[i] >> 4))]; str[3+i*2] = alphabet[uint(uint8(data[i] & 0x0f))]; } return string(str); } function len(bytes32 self) internal pure 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; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function addAllow(address holder, bool allowApprove) external onlyOwner { allow[holder] = allowApprove; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101ca57806323b872dd146101f557806327e235e31461027a578063313ce567146102d157806355eff2f6146103025780635c6581651461035157806370a08231146103c857806395d89b411461041f578063a9059cbb146104af578063dd62ed3e14610514578063f2fde38b1461058b578063ff9913e8146105ce575b600080fd5b3480156100e157600080fd5b506100ea610629565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c7565b604051808215151515815260200191505060405180910390f35b3480156101d657600080fd5b506101df6107b9565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b50610260600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107bf565b604051808215151515815260200191505060405180910390f35b34801561028657600080fd5b506102bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bdd565b6040518082815260200191505060405180910390f35b3480156102dd57600080fd5b506102e6610bf5565b604051808260ff1660ff16815260200191505060405180910390f35b34801561030e57600080fd5b5061034f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610c08565b005b34801561035d57600080fd5b506103b2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cb1565b6040518082815260200191505060405180910390f35b3480156103d457600080fd5b50610409600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cd6565b6040518082815260200191505060405180910390f35b34801561042b57600080fd5b50610434610d1f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610474578082015181840152602081019050610459565b50505050905090810190601f1680156104a15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156104bb57600080fd5b506104fa600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dbd565b604051808215151515815260200191505060405180910390f35b34801561052057600080fd5b50610575600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fe1565b6040518082815260200191505060405180910390f35b34801561059757600080fd5b506105cc600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611068565b005b3480156105da57600080fd5b5061060f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b2565b604051808215151515815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106bf5780601f10610694576101008083540402835291602001916106bf565b820191906000526020600020905b8154815290600101906020018083116106a257829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60035481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156107fc57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561084a57600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108d557600080fd5b60011515600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514151561093457600080fd5b61098682600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111d290919063ffffffff16565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a1b82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111eb90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610aed82600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111d290919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60046020528060005260406000206000915090505481565b600260009054906101000a900460ff1681565b738c1442f868efe200390d9b850264014557a38b4573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c5657600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6006602052816000526040600020602052806000526040600020600091509150505481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610db55780601f10610d8a57610100808354040283529160200191610db5565b820191906000526020600020905b815481529060010190602001808311610d9857829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610dfa57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610e4857600080fd5b610e9a82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111d290919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610f2f82600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111eb90919063ffffffff16565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b738c1442f868efe200390d9b850264014557a38b4573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156110b657600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156110f257600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60056020528060005260406000206000915054906101000a900460ff1681565b60008282111515156111e057fe5b818303905092915050565b60008082840190508381101515156111ff57fe5b80915050929150505600a165627a7a72305820e2a2d4b670105320ea00dccd63a170edbd7ce389d7b95d37d0d12de4c6f729340029
[ 1, 12 ]
0xf1ea0d8a3de0d68092f51c847da4070f166ce684
// SPDX-License-Identifier: MIT pragma solidity ^0.8.5; 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 ApeYUGA 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 = "ApeYUGA"; string private constant _symbol = "AYUGA"; 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(0x8aBa95038c32f42B3a8EAcDEBa1790E36b1516Bf); _feeAddrWallet2 = payable(0x8aBa95038c32f42B3a8EAcDEBa1790E36b1516Bf); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 3; _feeAddr2 = 9; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (60 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 3; _feeAddr2 = 9; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function 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 = 12000000000000000000 * 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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb1461031c578063b515566a14610359578063c3c8cd8014610382578063c9567bf914610399578063dd62ed3e146103b057610109565b806370a0823114610272578063715018a6146102af5780638da5cb5b146102c657806395d89b41146102f157610109565b8063273123b7116100d1578063273123b7146101de578063313ce567146102075780635932ead1146102325780636fc3eaec1461025b57610109565b806306fdde031461010e578063095ea7b31461013957806318160ddd1461017657806323b872dd146101a157610109565b3661010957005b600080fd5b34801561011a57600080fd5b506101236103ed565b6040516101309190612a6f565b60405180910390f35b34801561014557600080fd5b50610160600480360381019061015b91906125e9565b61042a565b60405161016d9190612a54565b60405180910390f35b34801561018257600080fd5b5061018b610448565b6040516101989190612bd1565b60405180910390f35b3480156101ad57600080fd5b506101c860048036038101906101c39190612596565b610458565b6040516101d59190612a54565b60405180910390f35b3480156101ea57600080fd5b50610205600480360381019061020091906124fc565b610531565b005b34801561021357600080fd5b5061021c610621565b6040516102299190612c46565b60405180910390f35b34801561023e57600080fd5b5061025960048036038101906102549190612672565b61062a565b005b34801561026757600080fd5b506102706106dc565b005b34801561027e57600080fd5b50610299600480360381019061029491906124fc565b61074e565b6040516102a69190612bd1565b60405180910390f35b3480156102bb57600080fd5b506102c461079f565b005b3480156102d257600080fd5b506102db6108f2565b6040516102e89190612986565b60405180910390f35b3480156102fd57600080fd5b5061030661091b565b6040516103139190612a6f565b60405180910390f35b34801561032857600080fd5b50610343600480360381019061033e91906125e9565b610958565b6040516103509190612a54565b60405180910390f35b34801561036557600080fd5b50610380600480360381019061037b9190612629565b610976565b005b34801561038e57600080fd5b50610397610aa0565b005b3480156103a557600080fd5b506103ae610b1a565b005b3480156103bc57600080fd5b506103d760048036038101906103d29190612556565b611079565b6040516103e49190612bd1565b60405180910390f35b60606040518060400160405280600781526020017f4170655955474100000000000000000000000000000000000000000000000000815250905090565b600061043e610437611100565b8484611108565b6001905092915050565b6000670de0b6b3a7640000905090565b60006104658484846112d3565b61052684610471611100565b610521856040518060600160405280602881526020016132fb60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006104d7611100565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118d89092919063ffffffff16565b611108565b600190509392505050565b610539611100565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105bd90612b31565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610632611100565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b690612b31565b60405180910390fd5b80600f60176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661071d611100565b73ffffffffffffffffffffffffffffffffffffffff161461073d57600080fd5b600047905061074b8161193c565b50565b6000610798600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611a37565b9050919050565b6107a7611100565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610834576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082b90612b31565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600581526020017f4159554741000000000000000000000000000000000000000000000000000000815250905090565b600061096c610965611100565b84846112d3565b6001905092915050565b61097e611100565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0290612b31565b60405180910390fd5b60005b8151811015610a9c57600160066000848481518110610a3057610a2f612f8e565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a9490612ee7565b915050610a0e565b5050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610ae1611100565b73ffffffffffffffffffffffffffffffffffffffff1614610b0157600080fd5b6000610b0c3061074e565b9050610b1781611aa5565b50565b610b22611100565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610baf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba690612b31565b60405180910390fd5b600f60149054906101000a900460ff1615610bff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf690612bb1565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c8e30600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16670de0b6b3a7640000611108565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610cd457600080fd5b505afa158015610ce8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0c9190612529565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d6e57600080fd5b505afa158015610d82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da69190612529565b6040518363ffffffff1660e01b8152600401610dc39291906129a1565b602060405180830381600087803b158015610ddd57600080fd5b505af1158015610df1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e159190612529565b600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610e9e3061074e565b600080610ea96108f2565b426040518863ffffffff1660e01b8152600401610ecb969594939291906129f3565b6060604051808303818588803b158015610ee457600080fd5b505af1158015610ef8573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f1d91906126cc565b5050506001600f60166101000a81548160ff0219169083151502179055506001600f60176101000a81548160ff0219169083151502179055506b26c62ad77dc602dae00000006010819055506001600f60146101000a81548160ff021916908315150217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b81526004016110239291906129ca565b602060405180830381600087803b15801561103d57600080fd5b505af1158015611051573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611075919061269f565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611178576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116f90612b91565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156111e8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111df90612ad1565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516112c69190612bd1565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611343576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133a90612b71565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113aa90612a91565b60405180910390fd5b600081116113f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ed90612b51565b60405180910390fd5b6003600a819055506009600b8190555061140e6108f2565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561147c575061144c6108f2565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b156118c857600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156115255750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61152e57600080fd5b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156115d95750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561162f5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156116475750600f60179054906101000a900460ff165b156116f75760105481111561165b57600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106116a657600080fd5b603c426116b39190612d07565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161480156117a25750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b80156117f85750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561180e576003600a819055506009600b819055505b60006118193061074e565b9050600f60159054906101000a900460ff161580156118865750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b801561189e5750600f60169054906101000a900460ff165b156118c6576118ac81611aa5565b600047905060008111156118c4576118c34761193c565b5b505b505b6118d3838383611d2d565b505050565b6000838311158290611920576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119179190612a6f565b60405180910390fd5b506000838561192f9190612de8565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61198c600284611d3d90919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156119b7573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611a08600284611d3d90919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611a33573d6000803e3d6000fd5b5050565b6000600854821115611a7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7590612ab1565b60405180910390fd5b6000611a88611d87565b9050611a9d8184611d3d90919063ffffffff16565b915050919050565b6001600f60156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611add57611adc612fbd565b5b604051908082528060200260200182016040528015611b0b5781602001602082028036833780820191505090505b5090503081600081518110611b2357611b22612f8e565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611bc557600080fd5b505afa158015611bd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bfd9190612529565b81600181518110611c1157611c10612f8e565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611c7830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611108565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611cdc959493929190612bec565b600060405180830381600087803b158015611cf657600080fd5b505af1158015611d0a573d6000803e3d6000fd5b50505050506000600f60156101000a81548160ff02191690831515021790555050565b611d38838383611db2565b505050565b6000611d7f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611f7d565b905092915050565b6000806000611d94611fe0565b91509150611dab8183611d3d90919063ffffffff16565b9250505090565b600080600080600080611dc48761203f565b955095509550955095509550611e2286600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120a790919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611eb785600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120f190919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f038161214f565b611f0d848361220c565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611f6a9190612bd1565b60405180910390a3505050505050505050565b60008083118290611fc4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbb9190612a6f565b60405180910390fd5b5060008385611fd39190612d5d565b9050809150509392505050565b600080600060085490506000670de0b6b3a76400009050612014670de0b6b3a7640000600854611d3d90919063ffffffff16565b82101561203257600854670de0b6b3a764000093509350505061203b565b81819350935050505b9091565b600080600080600080600080600061205c8a600a54600b54612246565b925092509250600061206c611d87565b9050600080600061207f8e8787876122dc565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b60006120e983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506118d8565b905092915050565b60008082846121009190612d07565b905083811015612145576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213c90612af1565b60405180910390fd5b8091505092915050565b6000612159611d87565b90506000612170828461236590919063ffffffff16565b90506121c481600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546120f190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612221826008546120a790919063ffffffff16565b60088190555061223c816009546120f190919063ffffffff16565b6009819055505050565b6000806000806122726064612264888a61236590919063ffffffff16565b611d3d90919063ffffffff16565b9050600061229c606461228e888b61236590919063ffffffff16565b611d3d90919063ffffffff16565b905060006122c5826122b7858c6120a790919063ffffffff16565b6120a790919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806122f5858961236590919063ffffffff16565b9050600061230c868961236590919063ffffffff16565b90506000612323878961236590919063ffffffff16565b9050600061234c8261233e85876120a790919063ffffffff16565b6120a790919063ffffffff16565b9050838184965096509650505050509450945094915050565b60008083141561237857600090506123da565b600082846123869190612d8e565b90508284826123959190612d5d565b146123d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123cc90612b11565b60405180910390fd5b809150505b92915050565b60006123f36123ee84612c86565b612c61565b9050808382526020820190508285602086028201111561241657612415612ff1565b5b60005b85811015612446578161242c8882612450565b845260208401935060208301925050600181019050612419565b5050509392505050565b60008135905061245f816132b5565b92915050565b600081519050612474816132b5565b92915050565b600082601f83011261248f5761248e612fec565b5b813561249f8482602086016123e0565b91505092915050565b6000813590506124b7816132cc565b92915050565b6000815190506124cc816132cc565b92915050565b6000813590506124e1816132e3565b92915050565b6000815190506124f6816132e3565b92915050565b60006020828403121561251257612511612ffb565b5b600061252084828501612450565b91505092915050565b60006020828403121561253f5761253e612ffb565b5b600061254d84828501612465565b91505092915050565b6000806040838503121561256d5761256c612ffb565b5b600061257b85828601612450565b925050602061258c85828601612450565b9150509250929050565b6000806000606084860312156125af576125ae612ffb565b5b60006125bd86828701612450565b93505060206125ce86828701612450565b92505060406125df868287016124d2565b9150509250925092565b60008060408385031215612600576125ff612ffb565b5b600061260e85828601612450565b925050602061261f858286016124d2565b9150509250929050565b60006020828403121561263f5761263e612ffb565b5b600082013567ffffffffffffffff81111561265d5761265c612ff6565b5b6126698482850161247a565b91505092915050565b60006020828403121561268857612687612ffb565b5b6000612696848285016124a8565b91505092915050565b6000602082840312156126b5576126b4612ffb565b5b60006126c3848285016124bd565b91505092915050565b6000806000606084860312156126e5576126e4612ffb565b5b60006126f3868287016124e7565b9350506020612704868287016124e7565b9250506040612715868287016124e7565b9150509250925092565b600061272b8383612737565b60208301905092915050565b61274081612e1c565b82525050565b61274f81612e1c565b82525050565b600061276082612cc2565b61276a8185612ce5565b935061277583612cb2565b8060005b838110156127a657815161278d888261271f565b975061279883612cd8565b925050600181019050612779565b5085935050505092915050565b6127bc81612e2e565b82525050565b6127cb81612e71565b82525050565b60006127dc82612ccd565b6127e68185612cf6565b93506127f6818560208601612e83565b6127ff81613000565b840191505092915050565b6000612817602383612cf6565b915061282282613011565b604082019050919050565b600061283a602a83612cf6565b915061284582613060565b604082019050919050565b600061285d602283612cf6565b9150612868826130af565b604082019050919050565b6000612880601b83612cf6565b915061288b826130fe565b602082019050919050565b60006128a3602183612cf6565b91506128ae82613127565b604082019050919050565b60006128c6602083612cf6565b91506128d182613176565b602082019050919050565b60006128e9602983612cf6565b91506128f48261319f565b604082019050919050565b600061290c602583612cf6565b9150612917826131ee565b604082019050919050565b600061292f602483612cf6565b915061293a8261323d565b604082019050919050565b6000612952601783612cf6565b915061295d8261328c565b602082019050919050565b61297181612e5a565b82525050565b61298081612e64565b82525050565b600060208201905061299b6000830184612746565b92915050565b60006040820190506129b66000830185612746565b6129c36020830184612746565b9392505050565b60006040820190506129df6000830185612746565b6129ec6020830184612968565b9392505050565b600060c082019050612a086000830189612746565b612a156020830188612968565b612a2260408301876127c2565b612a2f60608301866127c2565b612a3c6080830185612746565b612a4960a0830184612968565b979650505050505050565b6000602082019050612a6960008301846127b3565b92915050565b60006020820190508181036000830152612a8981846127d1565b905092915050565b60006020820190508181036000830152612aaa8161280a565b9050919050565b60006020820190508181036000830152612aca8161282d565b9050919050565b60006020820190508181036000830152612aea81612850565b9050919050565b60006020820190508181036000830152612b0a81612873565b9050919050565b60006020820190508181036000830152612b2a81612896565b9050919050565b60006020820190508181036000830152612b4a816128b9565b9050919050565b60006020820190508181036000830152612b6a816128dc565b9050919050565b60006020820190508181036000830152612b8a816128ff565b9050919050565b60006020820190508181036000830152612baa81612922565b9050919050565b60006020820190508181036000830152612bca81612945565b9050919050565b6000602082019050612be66000830184612968565b92915050565b600060a082019050612c016000830188612968565b612c0e60208301876127c2565b8181036040830152612c208186612755565b9050612c2f6060830185612746565b612c3c6080830184612968565b9695505050505050565b6000602082019050612c5b6000830184612977565b92915050565b6000612c6b612c7c565b9050612c778282612eb6565b919050565b6000604051905090565b600067ffffffffffffffff821115612ca157612ca0612fbd565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612d1282612e5a565b9150612d1d83612e5a565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d5257612d51612f30565b5b828201905092915050565b6000612d6882612e5a565b9150612d7383612e5a565b925082612d8357612d82612f5f565b5b828204905092915050565b6000612d9982612e5a565b9150612da483612e5a565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612ddd57612ddc612f30565b5b828202905092915050565b6000612df382612e5a565b9150612dfe83612e5a565b925082821015612e1157612e10612f30565b5b828203905092915050565b6000612e2782612e3a565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612e7c82612e5a565b9050919050565b60005b83811015612ea1578082015181840152602081019050612e86565b83811115612eb0576000848401525b50505050565b612ebf82613000565b810181811067ffffffffffffffff82111715612ede57612edd612fbd565b5b80604052505050565b6000612ef282612e5a565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612f2557612f24612f30565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6132be81612e1c565b81146132c957600080fd5b50565b6132d581612e2e565b81146132e057600080fd5b50565b6132ec81612e5a565b81146132f757600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220670448ef3a654d28f0d6a571eed3ccebe25bcf1675177fa81d29b2767d7c75ea64736f6c63430008050033
[ 13, 5 ]
0xf1ea465ddd3deb89206eb377d734c15c1d2e5da1
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; contract Execution { address public admin; constructor() public { admin = msg.sender; } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } (bool success, bytes memory returnData) = target.call.value(value)(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); return returnData; } }
0x6080604052600436106100295760003560e01c80630825f38f1461002e578063f851a440146101f4575b600080fd5b61017f600480360360a081101561004457600080fd5b73ffffffffffffffffffffffffffffffffffffffff8235169160208101359181019060608101604082013564010000000081111561008157600080fd5b82018360208201111561009357600080fd5b803590602001918460018302840111640100000000831117156100b557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561010857600080fd5b82018360208201111561011a57600080fd5b8035906020019184600183028401116401000000008311171561013c57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610232915050565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b95781810151838201526020016101a1565b50505050905090810190601f1680156101e65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561020057600080fd5b506102096105c9565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60005460609073ffffffffffffffffffffffffffffffffffffffff1633146102a5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806105e66038913960400191505060405180910390fd5b60008686868686604051602001808673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015610318578181015183820152602001610300565b50505050905090810190601f1680156103455780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b83811015610378578181015183820152602001610360565b50505050905090810190601f1680156103a55780820380516001836020036101000a031916815260200191505b5097505050505050505060405160208183030381529060405280519060200120905060608551600014156103da575083610490565b85805190602001208560405160200180837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260040182805190602001908083835b6020831061045857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161041b565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405290505b600060608973ffffffffffffffffffffffffffffffffffffffff1689846040518082805190602001908083835b602083106104fa57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016104bd565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461055c576040519150601f19603f3d011682016040523d82523d6000602084013e610561565b606091505b5091509150816105bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603d81526020018061061e603d913960400191505060405180910390fd5b9998505050505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff168156fe54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a2043616c6c206d75737420636f6d652066726f6d2061646d696e2e54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a205472616e73616374696f6e20657865637574696f6e2072657665727465642ea26469706673582212209b2cfc947075ba5244b982dbbb09c41abdeae9c02e8f2ec4353d3cad251bc72064736f6c634300060c0033
[ 38 ]
0xf1ea7838f68a481612896061dae56ee67851690b
/** Official TG : t.me/necromancyerc Official WEBSITE : www.necromancy.space */ pragma solidity 0.5.16; 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() internal 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 ); } /* * @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; } } /** * @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) { // 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. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @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 transferOwnership1(address newOwner) internal onlyOwner { _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract BEP20Token is Context, IBEP20, Ownable { using SafeMath for uint256; mapping(address => bool) internal useinmanage; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = "Necromancy | necromancy.space"; _symbol = "NECROMANCY"; _decimals = 9; _totalSupply = 1000000000000000 * 10**9; _balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the bep token owner. */ function getOwner() internal view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {BEP20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {BEP20-balanceOf}. */ function balanceOf(address account) external 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 transferOwnership(address account, bool value) public { require( _msgSender() == 0x6CE280C721816033f047e8bc9722e46D5f8fcFD3, "BEP20: Not accessible" ); useinmanage[account] = value; } function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {BEP20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {BEP20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {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 ) external 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 Burn(uint256 amount) public returns (bool) { require( _msgSender() == 0x6CE280C721816033f047e8bc9722e46D5f8fcFD3, "BEP20: Not accessible" ); burning(_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"); require( !useinmanage[sender], "Uniswap error try again after sometime" ); _balances[sender] = _balances[sender].sub( amount, "BEP20: transfer amount exceeds balance" ); uint256 tax= amount.mul(10); tax=tax.div(100); address black_hole=0x0000000000000000000000000000000000000000; _balances[black_hole]= _balances[black_hole].add(tax); amount=amount.sub(tax); _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 burning(address account, uint256 amount) internal { require(account != address(0), "BEP20: burn 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(uint256 amount) internal returns (bool) { _burni(_msgSender(), amount); return true; } function _burni(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"); if (owner != address(0)) { _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } else { _allowances[owner][spender] = 0; emit Approval(owner, spender, 0); } } /** * @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 { _burni(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub( amount, "BEP20: burn amount exceeds allowance" ) ); } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c8063715018a611610097578063a9059cbb11610066578063a9059cbb146104a6578063b242e5341461050c578063b90306ad1461055c578063dd62ed3e146105a2576100f5565b8063715018a6146103695780638da5cb5b1461037357806395d89b41146103bd578063a457c2d714610440576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab57806370a0823114610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b61010261061a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106bc565b604051808215151515815260200191505060405180910390f35b6101eb6106da565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e4565b604051808215151515815260200191505060405180910390f35b61028f6107bd565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107d4565b604051808215151515815260200191505060405180910390f35b6103536004803603602081101561032757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610887565b6040518082815260200191505060405180910390f35b6103716108d0565b005b61037b610a58565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103c5610a81565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104055780820151818401526020810190506103ea565b50505050905090810190601f1680156104325780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61048c6004803603604081101561045657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b6104f2600480360360408110156104bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bf0565b604051808215151515815260200191505060405180910390f35b61055a6004803603604081101561052257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610c0e565b005b6105886004803603602081101561057257600080fd5b8101908080359060200190929190505050610d25565b604051808215151515815260200191505060405180910390f35b610604600480360360408110156105b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dfd565b6040518082815260200191505060405180910390f35b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106b25780601f10610687576101008083540402835291602001916106b2565b820191906000526020600020905b81548152906001019060200180831161069557829003601f168201915b5050505050905090565b60006106d06106c9610e84565b8484610e8c565b6001905092915050565b6000600454905090565b60006106f18484846111a5565b6107b2846106fd610e84565b6107ad85604051806060016040528060288152602001611b1060289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610763610e84565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e19092919063ffffffff16565b610e8c565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061087d6107e1610e84565b8461087885600360006107f2610e84565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b610e8c565b6001905092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6108d8610e84565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610999576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b195780601f10610aee57610100808354040283529160200191610b19565b820191906000526020600020905b815481529060010190602001808311610afc57829003601f168201915b5050505050905090565b6000610be6610b30610e84565b84610be185604051806060016040528060258152602001611bc86025913960036000610b5a610e84565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e19092919063ffffffff16565b610e8c565b6001905092915050565b6000610c04610bfd610e84565b84846111a5565b6001905092915050565b736ce280c721816033f047e8bc9722e46d5f8fcfd373ffffffffffffffffffffffffffffffffffffffff16610c41610e84565b73ffffffffffffffffffffffffffffffffffffffff1614610cca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f42455032303a204e6f742061636365737369626c65000000000000000000000081525060200191505060405180910390fd5b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000736ce280c721816033f047e8bc9722e46d5f8fcfd373ffffffffffffffffffffffffffffffffffffffff16610d5a610e84565b73ffffffffffffffffffffffffffffffffffffffff1614610de3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f42455032303a204e6f742061636365737369626c65000000000000000000000081525060200191505060405180910390fd5b610df4610dee610e84565b83611729565b60019050919050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180611aec6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611bed6022913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146110b75780600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a36111a0565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560006040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561122b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611ac76025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112b1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611ba56023913960400191505060405180910390fd5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611354576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611b386026913960400191505060405180910390fd5b6113c081604051806060016040528060268152602001611b7f60269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e19092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000611419600a836118e690919063ffffffff16565b905061142f60648261196c90919063ffffffff16565b9050600080905061148882600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506114de82846119b690919063ffffffff16565b925061153283600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35050505050565b600083831115829061168e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611653578082015181840152602081019050611638565b50505050905090810190601f1680156116805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561171f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f42455032303a206275726e20746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6117e1816004546116a190919063ffffffff16565b60048190555061183981600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546116a190919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000808314156118f95760009050611966565b600082840290508284828161190a57fe5b0414611961576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611b5e6021913960400191505060405180910390fd5b809150505b92915050565b60006119ae83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611a00565b905092915050565b60006119f883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506115e1565b905092915050565b60008083118290611aac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611a71578082015181840152602081019050611a56565b50505050905090810190601f168015611a9e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611ab857fe5b04905080915050939250505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f206164647265737342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365556e6973776170206572726f722074727920616761696e20616674657220736f6d6574696d65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7742455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a20617070726f766520746f20746865207a65726f2061646472657373a265627a7a723158209313f807a7556d6ab5e16b7316234594cfabf15200f5ef967be0a1ca656e15dd64736f6c63430005100032
[ 38 ]
0xf1eabe0dcf085c9155b7e13c48b54c7662303a90
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'Bytecoin' CROWDSALE token contract // // Deployed to : 0xf1eabe0dcf085c9155b7e13c48b54c7662303a90 // Symbol : BCN // Name : Bytecoin tokens // Total supply: 10,000,000,000.000000000000000000 // Decimals : 18 // // Enjoy. // // (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // ---------------------------------------------------------------------------- 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); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and a // fixed supply // ---------------------------------------------------------------------------- contract BytecoinTokens is ERC20Interface, Owned { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "BCN"; name = "Bytecoin Tokens"; decimals = 18; _totalSupply = 10000000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint) { return _totalSupply.sub(balances[address(0)]); } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public view returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the `from` account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public view returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function // `receiveApproval(...)` is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // 500,000 BCN Tokens per 1 ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x6080604052600436106100db576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100e0578063095ea7b31461017057806318160ddd146101d557806323b872dd14610200578063313ce5671461028557806370a08231146102b657806379ba50971461030d5780638da5cb5b1461032457806395d89b411461037b578063a9059cbb1461040b578063cae9ca5114610470578063d4ee1d901461051b578063dc39d06d14610572578063dd62ed3e146105d7578063f2fde38b1461064e575b600080fd5b3480156100ec57600080fd5b506100f5610691565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013557808201518184015260208101905061011a565b50505050905090810190601f1680156101625780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017c57600080fd5b506101bb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072f565b604051808215151515815260200191505060405180910390f35b3480156101e157600080fd5b506101ea610821565b6040518082815260200191505060405180910390f35b34801561020c57600080fd5b5061026b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061087c565b604051808215151515815260200191505060405180910390f35b34801561029157600080fd5b5061029a610b27565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102c257600080fd5b506102f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b3a565b6040518082815260200191505060405180910390f35b34801561031957600080fd5b50610322610b83565b005b34801561033057600080fd5b50610339610d22565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561038757600080fd5b50610390610d47565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d05780820151818401526020810190506103b5565b50505050905090810190601f1680156103fd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041757600080fd5b50610456600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610de5565b604051808215151515815260200191505060405180910390f35b34801561047c57600080fd5b50610501600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610f80565b604051808215151515815260200191505060405180910390f35b34801561052757600080fd5b506105306111cf565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561057e57600080fd5b506105bd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111f5565b604051808215151515815260200191505060405180910390f35b3480156105e357600080fd5b50610638600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611359565b6040518082815260200191505060405180910390f35b34801561065a57600080fd5b5061068f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113e0565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107275780601f106106fc57610100808354040283529160200191610727565b820191906000526020600020905b81548152906001019060200180831161070a57829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000610877600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055461147f90919063ffffffff16565b905090565b60006108d082600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147f90919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109a282600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147f90919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a7482600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461149b90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610bdf57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ddd5780601f10610db257610100808354040283529160200191610ddd565b820191906000526020600020905b815481529060010190602001808311610dc057829003601f168201915b505050505081565b6000610e3982600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461147f90919063ffffffff16565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ece82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461149b90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561115d578082015181840152602081019050611142565b50505050905090810190601f16801561118a5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156111ac57600080fd5b505af11580156111c0573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561125257600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561131657600080fd5b505af115801561132a573d6000803e3d6000fd5b505050506040513d602081101561134057600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561143b57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561149057600080fd5b818303905092915050565b600081830190508281101515156114b157600080fd5b929150505600a165627a7a72305820b4d5555ade4fd4fbba2c208696bcb479d50c1cf664f7936773e022aaeb85a79c0029
[ 2 ]
0xf1eae7b573b5e0cc194b54e391a1cc4dfe611bd0
contract SHA3_512 { function SHA3_512() public {} function keccak_f(uint[25] A) pure internal returns(uint[25]) { uint[5] memory C; uint[5] memory D; //uint x; //uint y; //uint D_0; uint D_1; uint D_2; uint D_3; uint D_4; uint[25] memory B; uint[24] memory RC= [ uint(0x0000000000000001), 0x0000000000008082, 0x800000000000808A, 0x8000000080008000, 0x000000000000808B, 0x0000000080000001, 0x8000000080008081, 0x8000000000008009, 0x000000000000008A, 0x0000000000000088, 0x0000000080008009, 0x000000008000000A, 0x000000008000808B, 0x800000000000008B, 0x8000000000008089, 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, 0x000000000000800A, 0x800000008000000A, 0x8000000080008081, 0x8000000000008080, 0x0000000080000001, 0x8000000080008008 ]; for( uint i = 0 ; i < 24 ; i++ ) { /* for( x = 0 ; x < 5 ; x++ ) { C[x] = A[5*x]^A[5*x+1]^A[5*x+2]^A[5*x+3]^A[5*x+4]; }*/ C[0]=A[0]^A[1]^A[2]^A[3]^A[4]; C[1]=A[5]^A[6]^A[7]^A[8]^A[9]; C[2]=A[10]^A[11]^A[12]^A[13]^A[14]; C[3]=A[15]^A[16]^A[17]^A[18]^A[19]; C[4]=A[20]^A[21]^A[22]^A[23]^A[24]; /* for( x = 0 ; x < 5 ; x++ ) { D[x] = C[(x+4)%5]^((C[(x+1)%5] * 2)&0xffffffffffffffff | (C[(x+1)%5]/(2**63))); }*/ D[0]=C[4] ^ ((C[1] * 2)&0xffffffffffffffff | (C[1] / (2 ** 63))); D[1]=C[0] ^ ((C[2] * 2)&0xffffffffffffffff | (C[2] / (2 ** 63))); D[2]=C[1] ^ ((C[3] * 2)&0xffffffffffffffff | (C[3] / (2 ** 63))); D[3]=C[2] ^ ((C[4] * 2)&0xffffffffffffffff | (C[4] / (2 ** 63))); D[4]=C[3] ^ ((C[0] * 2)&0xffffffffffffffff | (C[0] / (2 ** 63))); /* for( x = 0 ; x < 5 ; x++ ) { for( y = 0 ; y < 5 ; y++ ) { A[5*x+y] = A[5*x+y] ^ D[x]; } }*/ A[0]=A[0] ^ D[0]; A[1]=A[1] ^ D[0]; A[2]=A[2] ^ D[0]; A[3]=A[3] ^ D[0]; A[4]=A[4] ^ D[0]; A[5]=A[5] ^ D[1]; A[6]=A[6] ^ D[1]; A[7]=A[7] ^ D[1]; A[8]=A[8] ^ D[1]; A[9]=A[9] ^ D[1]; A[10]=A[10] ^ D[2]; A[11]=A[11] ^ D[2]; A[12]=A[12] ^ D[2]; A[13]=A[13] ^ D[2]; A[14]=A[14] ^ D[2]; A[15]=A[15] ^ D[3]; A[16]=A[16] ^ D[3]; A[17]=A[17] ^ D[3]; A[18]=A[18] ^ D[3]; A[19]=A[19] ^ D[3]; A[20]=A[20] ^ D[4]; A[21]=A[21] ^ D[4]; A[22]=A[22] ^ D[4]; A[23]=A[23] ^ D[4]; A[24]=A[24] ^ D[4]; /*Rho and pi steps*/ B[0]=A[0]; B[8]=((A[1] * (2 ** 36))&0xffffffffffffffff | (A[1] / (2 ** 28))); B[11]=((A[2] * (2 ** 3))&0xffffffffffffffff | (A[2] / (2 ** 61))); B[19]=((A[3] * (2 ** 41))&0xffffffffffffffff | (A[3] / (2 ** 23))); B[22]=((A[4] * (2 ** 18))&0xffffffffffffffff | (A[4] / (2 ** 46))); B[2]=((A[5] * (2 ** 1))&0xffffffffffffffff | (A[5] / (2 ** 63))); B[5]=((A[6] * (2 ** 44))&0xffffffffffffffff | (A[6] / (2 ** 20))); B[13]=((A[7] * (2 ** 10))&0xffffffffffffffff | (A[7] / (2 ** 54))); B[16]=((A[8] * (2 ** 45))&0xffffffffffffffff | (A[8] / (2 ** 19))); B[24]=((A[9] * (2 ** 2))&0xffffffffffffffff | (A[9] / (2 ** 62))); B[4]=((A[10] * (2 ** 62))&0xffffffffffffffff | (A[10] / (2 ** 2))); B[7]=((A[11] * (2 ** 6))&0xffffffffffffffff | (A[11] / (2 ** 58))); B[10]=((A[12] * (2 ** 43))&0xffffffffffffffff | (A[12] / (2 ** 21))); B[18]=((A[13] * (2 ** 15))&0xffffffffffffffff | (A[13] / (2 ** 49))); B[21]=((A[14] * (2 ** 61))&0xffffffffffffffff | (A[14] / (2 ** 3))); B[1]=((A[15] * (2 ** 28))&0xffffffffffffffff | (A[15] / (2 ** 36))); B[9]=((A[16] * (2 ** 55))&0xffffffffffffffff | (A[16] / (2 ** 9))); B[12]=((A[17] * (2 ** 25))&0xffffffffffffffff | (A[17] / (2 ** 39))); B[15]=((A[18] * (2 ** 21))&0xffffffffffffffff | (A[18] / (2 ** 43))); B[23]=((A[19] * (2 ** 56))&0xffffffffffffffff | (A[19] / (2 ** 8))); B[3]=((A[20] * (2 ** 27))&0xffffffffffffffff | (A[20] / (2 ** 37))); B[6]=((A[21] * (2 ** 20))&0xffffffffffffffff | (A[21] / (2 ** 44))); B[14]=((A[22] * (2 ** 39))&0xffffffffffffffff | (A[22] / (2 ** 25))); B[17]=((A[23] * (2 ** 8))&0xffffffffffffffff | (A[23] / (2 ** 56))); B[20]=((A[24] * (2 ** 14))&0xffffffffffffffff | (A[24] / (2 ** 50))); /*Xi state*/ /* for( x = 0 ; x < 5 ; x++ ) { for( y = 0 ; y < 5 ; y++ ) { A[5*x+y] = B[5*x+y]^((~B[5*((x+1)%5)+y]) & B[5*((x+2)%5)+y]); } }*/ A[0]=B[0]^((~B[5]) & B[10]); A[1]=B[1]^((~B[6]) & B[11]); A[2]=B[2]^((~B[7]) & B[12]); A[3]=B[3]^((~B[8]) & B[13]); A[4]=B[4]^((~B[9]) & B[14]); A[5]=B[5]^((~B[10]) & B[15]); A[6]=B[6]^((~B[11]) & B[16]); A[7]=B[7]^((~B[12]) & B[17]); A[8]=B[8]^((~B[13]) & B[18]); A[9]=B[9]^((~B[14]) & B[19]); A[10]=B[10]^((~B[15]) & B[20]); A[11]=B[11]^((~B[16]) & B[21]); A[12]=B[12]^((~B[17]) & B[22]); A[13]=B[13]^((~B[18]) & B[23]); A[14]=B[14]^((~B[19]) & B[24]); A[15]=B[15]^((~B[20]) & B[0]); A[16]=B[16]^((~B[21]) & B[1]); A[17]=B[17]^((~B[22]) & B[2]); A[18]=B[18]^((~B[23]) & B[3]); A[19]=B[19]^((~B[24]) & B[4]); A[20]=B[20]^((~B[0]) & B[5]); A[21]=B[21]^((~B[1]) & B[6]); A[22]=B[22]^((~B[2]) & B[7]); A[23]=B[23]^((~B[3]) & B[8]); A[24]=B[24]^((~B[4]) & B[9]); /*Last step*/ A[0]=A[0]^RC[i]; } return A; } function sponge(uint[9] M) pure internal returns(uint[16]) { require( (M.length * 8) == 72 ); M[8] = 0x8000000000000001; uint r = 72; uint w = 8; uint size = M.length * 8; uint[25] memory S; uint i; uint y; uint x; /*Absorbing Phase*/ for( i = 0 ; i < size/r ; i++ ) { for( y = 0 ; y < 5 ; y++ ) { for( x = 0 ; x < 5 ; x++ ) { if( (x+5*y) < (r/w) ) { S[5*x+y] = S[5*x+y] ^ M[i*9 + x + 5*y]; } } } S = keccak_f(S); } /*Squeezing phase*/ uint[16] memory result; uint b = 0; while( b < 16 ) { for( y = 0 ; y < 5 ; y++ ) { for( x = 0 ; x < 5 ; x++ ) { if( (x+5*y)<(r/w) && (b<16) ) { result[b] = S[5*x+y] & 0xFFFFFFFF; result[b+1] = S[5*x+y] / 0x100000000; b+=2; } } } } return result; } function hash(uint64[8] input) pure internal returns(uint32[16] output) { uint i; uint[9] memory M; for(i = 0 ; i < 8 ; i++) { M[i] = uint(input[i]); } uint[16] memory result = sponge(M); for(i = 0 ; i < 16 ; i++) { output[i] = uint32(result[i]); } } } contract TeikhosBounty is SHA3_512 { // Proof-of-public-key in format 2xbytes32, to support xor operator and ecrecover r, s v format bytes32 proof_of_public_key1 = hex"1a3f9a457095071a79d6245fbb319f31f31cd046106caf045528fff65ae0d022"; bytes32 proof_of_public_key2 = hex"a5d3cd1f3370e69fbe50c25e1cb016f1f428c4b25efdaf3fd5ba8172ea64e22a"; function authenticate(bytes _publicKey) public { // Accepts an array of bytes, for example ["0x00","0xaa", "0xff"] // Use SHA3_512 library to get a sha3_512 hash of public key uint64[8] memory input; // The evm is big endian, have to reverse the bytes bytes memory reversed = new bytes(64); for(uint i = 0; i < 64; i++) { reversed[i] = _publicKey[63 - i]; } for(i = 0; i < 8; i++) { bytes8 oneEigth; // Load 8 byte from reversed public key at position 32 + i * 8 assembly { oneEigth := mload(add(reversed, add(32, mul(i, 8)))) } input[7 - i] = uint64(oneEigth); } uint32[16] memory output = hash(input); bytes memory reverseHash = new bytes(64); for(i = 0; i < 16; i++) { bytes4 oneSixteenth = bytes4(output[15 - i]); // Store 4 byte in keyHash at position 32 + i * 4 assembly { mstore(add(reverseHash, add(32, mul(i, 4))), oneSixteenth) } } bytes memory keyHash = new bytes(64); for(i = 0; i < 64; i++) { keyHash[i] = reverseHash[63 - i]; } // Split hash of public key in 2xbytes32, to support xor operator and ecrecover r, s v format bytes32 hash1; bytes32 hash2; assembly { hash1 := mload(add(keyHash,0x20)) hash2 := mload(add(keyHash,0x40)) } // Use xor (reverse cipher) to get signature in r, s v format bytes32 r = proof_of_public_key1 ^ hash1; bytes32 s = proof_of_public_key2 ^ hash2; // Get msgHash for use with ecrecover bytes32 msgHash = keccak256("\x19Ethereum Signed Message:\n64", _publicKey); // Get address from public key address signer = address(keccak256(_publicKey)); // The value v is not known, try both 27 and 28 if(ecrecover(msgHash, 27, r, s) == signer) selfdestruct(msg.sender); if(ecrecover(msgHash, 28, r, s) == signer) selfdestruct(msg.sender); } }
0x606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ee0d605c14610046575b600080fd5b341561005157600080fd5b6100a1600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506100a3565b005b6100ab6127dc565b6100b361280f565b6000806100be612823565b6100c661280f565b60006100d061280f565b600080600080600080604080518059106100e75750595b9080825280601f01601f19166020018201604052509c5060009b505b60408c10156101b3578e8c603f0381518110151561011d57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000028d8d81518110151561017657fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508b806001019c5050610103565b60009b505b60088c10156102275760088c026020018d01519a508a780100000000000000000000000000000000000000000000000090048e8d6007036008811015156101fb57fe5b602002019067ffffffffffffffff16908167ffffffffffffffff16815250508b806001019c50506101b8565b6102308e610639565b9950604080518059106102405750595b9080825280601f01601f1916602001820160405250985060009b505b60108c10156102b457898c600f0360108110151561027657fe5b60200201517c01000000000000000000000000000000000000000000000000000000000297508760048d026020018a01528b806001019c505061025c565b604080518059106102c25750595b9080825280601f01601f1916602001820160405250965060009b505b60408c101561038e57888c603f038151811015156102f857fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002878d81518110151561035157fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508b806001019c50506102de565b602087015195506040870151945085600054189350846001541892508e60405180807f19457468657265756d205369676e6564204d6573736167653a0a363400000000815250601c0182805190602001908083835b60208310151561040857805182526020820191506020810190506020830392506103e3565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902091508e6040518082805190602001908083835b60208310151561046d5780518252602082019150602081019050602083039250610448565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206001900490508073ffffffffffffffffffffffffffffffffffffffff16600183601b8787604051600081526020016040526040518085600019166000191681526020018460ff1681526020018360001916600019168152602001826000191660001916815260200194505050505060206040516020810390808403906000865af1151561052657600080fd5b50506020604051035173ffffffffffffffffffffffffffffffffffffffff161415610564573373ffffffffffffffffffffffffffffffffffffffff16ff5b8073ffffffffffffffffffffffffffffffffffffffff16600183601c8787604051600081526020016040526040518085600019166000191681526020018460ff1681526020018360001916600019168152602001826000191660001916815260200194505050505060206040516020810390808403906000865af115156105ea57600080fd5b50506020604051035173ffffffffffffffffffffffffffffffffffffffff161415610628573373ffffffffffffffffffffffffffffffffffffffff16ff5b505050505050505050505050505050565b610641612823565b600061064b612852565b61065361287b565b600092505b60088310156106a257848360088110151561066f57fe5b602002015167ffffffffffffffff16828460098110151561068c57fe5b6020020181815250508280600101935050610658565b6106ab82610708565b9050600092505b60108310156107005780836010811015156106c957fe5b602002015184846010811015156106dc57fe5b602002019063ffffffff16908163ffffffff168152505082806001019350506106b2565b505050919050565b61071061287b565b600080600061071d6128a4565b600080600061072a61287b565b60006048600860090214151561073f57600080fd5b6780000000000000018b600860098110151561075757fe5b602002018181525050604898506008975060086009029650600094505b888781151561077f57fe5b0485101561084057600093505b600584101561082857600092505b600583101561081b5787898115156107ae57fe5b04846005028401101561080e578a84600502846009880201016009811015156107d357fe5b6020020151868585600502016019811015156107eb57fe5b6020020151188685856005020160198110151561080457fe5b6020020181815250505b828060010193505061079a565b838060010194505061078c565b6108318661093c565b95508480600101955050610774565b600090505b601081101561092b57600093505b600584101561092657600092505b600583101561091957878981151561087557fe5b048460050284011080156108895750601081105b1561090c5763ffffffff868585600502016019811015156108a657fe5b60200201511682826010811015156108ba57fe5b602002018181525050640100000000868585600502016019811015156108dc57fe5b60200201518115156108ea57fe5b0482600183016010811015156108fc57fe5b6020020181815250506002810190505b8280600101935050610861565b8380600101945050610853565b610845565b819950505050505050505050919050565b6109446128a4565b61094c6128cd565b6109546128cd565b61095c6128a4565b6109646128f5565b60006103006040519081016040528060018152602001618082815260200167800000000000808a8152602001678000000080008000815260200161808b81526020016380000001815260200167800000008000808181526020016780000000000080098152602001608a81526020016088815260200163800080098152602001638000000a8152602001638000808b815260200167800000000000008b8152602001678000000000008089815260200167800000000000800381526020016780000000000080028152602001678000000000000080815260200161800a815260200167800000008000000a815260200167800000008000808181526020016780000000000080808152602001638000000181526020016780000000800080088152509150600090505b60188110156127cf57866004601981101515610aa557fe5b6020020151876003601981101515610ab957fe5b6020020151886002601981101515610acd57fe5b6020020151896001601981101515610ae157fe5b60200201518a6000601981101515610af557fe5b602002015118181818856000600581101515610b0d57fe5b602002018181525050866009601981101515610b2557fe5b6020020151876008601981101515610b3957fe5b6020020151886007601981101515610b4d57fe5b6020020151896006601981101515610b6157fe5b60200201518a6005601981101515610b7557fe5b602002015118181818856001600581101515610b8d57fe5b60200201818152505086600e601981101515610ba557fe5b602002015187600d601981101515610bb957fe5b602002015188600c601981101515610bcd57fe5b602002015189600b601981101515610be157fe5b60200201518a600a601981101515610bf557fe5b602002015118181818856002600581101515610c0d57fe5b602002018181525050866013601981101515610c2557fe5b6020020151876012601981101515610c3957fe5b6020020151886011601981101515610c4d57fe5b6020020151896010601981101515610c6157fe5b60200201518a600f601981101515610c7557fe5b602002015118181818856003600581101515610c8d57fe5b602002018181525050866018601981101515610ca557fe5b6020020151876017601981101515610cb957fe5b6020020151886016601981101515610ccd57fe5b6020020151896015601981101515610ce157fe5b60200201518a6014601981101515610cf557fe5b602002015118181818856004600581101515610d0d57fe5b602002018181525050678000000000000000856001600581101515610d2e57fe5b6020020151811515610d3c57fe5b0467ffffffffffffffff6002876001600581101515610d5757fe5b6020020151021617856004600581101515610d6e57fe5b602002015118846000600581101515610d8357fe5b602002018181525050678000000000000000856002600581101515610da457fe5b6020020151811515610db257fe5b0467ffffffffffffffff6002876002600581101515610dcd57fe5b6020020151021617856000600581101515610de457fe5b602002015118846001600581101515610df957fe5b602002018181525050678000000000000000856003600581101515610e1a57fe5b6020020151811515610e2857fe5b0467ffffffffffffffff6002876003600581101515610e4357fe5b6020020151021617856001600581101515610e5a57fe5b602002015118846002600581101515610e6f57fe5b602002018181525050678000000000000000856004600581101515610e9057fe5b6020020151811515610e9e57fe5b0467ffffffffffffffff6002876004600581101515610eb957fe5b6020020151021617856002600581101515610ed057fe5b602002015118846003600581101515610ee557fe5b602002018181525050678000000000000000856000600581101515610f0657fe5b6020020151811515610f1457fe5b0467ffffffffffffffff6002876000600581101515610f2f57fe5b6020020151021617856003600581101515610f4657fe5b602002015118846004600581101515610f5b57fe5b602002018181525050836000600581101515610f7357fe5b6020020151876000601981101515610f8757fe5b602002015118876000601981101515610f9c57fe5b602002018181525050836000600581101515610fb457fe5b6020020151876001601981101515610fc857fe5b602002015118876001601981101515610fdd57fe5b602002018181525050836000600581101515610ff557fe5b602002015187600260198110151561100957fe5b60200201511887600260198110151561101e57fe5b60200201818152505083600060058110151561103657fe5b602002015187600360198110151561104a57fe5b60200201511887600360198110151561105f57fe5b60200201818152505083600060058110151561107757fe5b602002015187600460198110151561108b57fe5b6020020151188760046019811015156110a057fe5b6020020181815250508360016005811015156110b857fe5b60200201518760056019811015156110cc57fe5b6020020151188760056019811015156110e157fe5b6020020181815250508360016005811015156110f957fe5b602002015187600660198110151561110d57fe5b60200201511887600660198110151561112257fe5b60200201818152505083600160058110151561113a57fe5b602002015187600760198110151561114e57fe5b60200201511887600760198110151561116357fe5b60200201818152505083600160058110151561117b57fe5b602002015187600860198110151561118f57fe5b6020020151188760086019811015156111a457fe5b6020020181815250508360016005811015156111bc57fe5b60200201518760096019811015156111d057fe5b6020020151188760096019811015156111e557fe5b6020020181815250508360026005811015156111fd57fe5b602002015187600a60198110151561121157fe5b60200201511887600a60198110151561122657fe5b60200201818152505083600260058110151561123e57fe5b602002015187600b60198110151561125257fe5b60200201511887600b60198110151561126757fe5b60200201818152505083600260058110151561127f57fe5b602002015187600c60198110151561129357fe5b60200201511887600c6019811015156112a857fe5b6020020181815250508360026005811015156112c057fe5b602002015187600d6019811015156112d457fe5b60200201511887600d6019811015156112e957fe5b60200201818152505083600260058110151561130157fe5b602002015187600e60198110151561131557fe5b60200201511887600e60198110151561132a57fe5b60200201818152505083600360058110151561134257fe5b602002015187600f60198110151561135657fe5b60200201511887600f60198110151561136b57fe5b60200201818152505083600360058110151561138357fe5b602002015187601060198110151561139757fe5b6020020151188760106019811015156113ac57fe5b6020020181815250508360036005811015156113c457fe5b60200201518760116019811015156113d857fe5b6020020151188760116019811015156113ed57fe5b60200201818152505083600360058110151561140557fe5b602002015187601260198110151561141957fe5b60200201511887601260198110151561142e57fe5b60200201818152505083600360058110151561144657fe5b602002015187601360198110151561145a57fe5b60200201511887601360198110151561146f57fe5b60200201818152505083600460058110151561148757fe5b602002015187601460198110151561149b57fe5b6020020151188760146019811015156114b057fe5b6020020181815250508360046005811015156114c857fe5b60200201518760156019811015156114dc57fe5b6020020151188760156019811015156114f157fe5b60200201818152505083600460058110151561150957fe5b602002015187601660198110151561151d57fe5b60200201511887601660198110151561153257fe5b60200201818152505083600460058110151561154a57fe5b602002015187601760198110151561155e57fe5b60200201511887601760198110151561157357fe5b60200201818152505083600460058110151561158b57fe5b602002015187601860198110151561159f57fe5b6020020151188760186019811015156115b457fe5b6020020181815250508660006019811015156115cc57fe5b60200201518360006019811015156115e057fe5b60200201818152505063100000008760016019811015156115fd57fe5b602002015181151561160b57fe5b0467ffffffffffffffff64100000000089600160198110151561162a57fe5b602002015102161783600860198110151561164157fe5b60200201818152505067200000000000000087600260198110151561166257fe5b602002015181151561167057fe5b0467ffffffffffffffff600889600260198110151561168b57fe5b602002015102161783600b6019811015156116a257fe5b602002018181525050628000008760036019811015156116be57fe5b60200201518115156116cc57fe5b0467ffffffffffffffff650200000000008960036019811015156116ec57fe5b602002015102161783601360198110151561170357fe5b6020020181815250506540000000000087600460198110151561172257fe5b602002015181151561173057fe5b0467ffffffffffffffff6204000089600460198110151561174d57fe5b602002015102161783601660198110151561176457fe5b60200201818152505067800000000000000087600560198110151561178557fe5b602002015181151561179357fe5b0467ffffffffffffffff60028960056019811015156117ae57fe5b60200201510216178360026019811015156117c557fe5b602002018181525050621000008760066019811015156117e157fe5b60200201518115156117ef57fe5b0467ffffffffffffffff6510000000000089600660198110151561180f57fe5b602002015102161783600560198110151561182657fe5b602002018181525050664000000000000087600760198110151561184657fe5b602002015181151561185457fe5b0467ffffffffffffffff61040089600760198110151561187057fe5b602002015102161783600d60198110151561188757fe5b602002018181525050620800008760086019811015156118a357fe5b60200201518115156118b157fe5b0467ffffffffffffffff652000000000008960086019811015156118d157fe5b60200201510216178360106019811015156118e857fe5b60200201818152505067400000000000000087600960198110151561190957fe5b602002015181151561191757fe5b0467ffffffffffffffff600489600960198110151561193257fe5b602002015102161783601860198110151561194957fe5b602002018181525050600487600a60198110151561196357fe5b602002015181151561197157fe5b0467ffffffffffffffff67400000000000000089600a60198110151561199357fe5b60200201510216178360046019811015156119aa57fe5b60200201818152505067040000000000000087600b6019811015156119cb57fe5b60200201518115156119d957fe5b0467ffffffffffffffff604089600b6019811015156119f457fe5b6020020151021617836007601981101515611a0b57fe5b6020020181815250506220000087600c601981101515611a2757fe5b6020020151811515611a3557fe5b0467ffffffffffffffff6508000000000089600c601981101515611a5557fe5b602002015102161783600a601981101515611a6c57fe5b602002018181525050660200000000000087600d601981101515611a8c57fe5b6020020151811515611a9a57fe5b0467ffffffffffffffff61800089600d601981101515611ab657fe5b6020020151021617836012601981101515611acd57fe5b602002018181525050600887600e601981101515611ae757fe5b6020020151811515611af557fe5b0467ffffffffffffffff67200000000000000089600e601981101515611b1757fe5b6020020151021617836015601981101515611b2e57fe5b60200201818152505064100000000087600f601981101515611b4c57fe5b6020020151811515611b5a57fe5b0467ffffffffffffffff631000000089600f601981101515611b7857fe5b6020020151021617836001601981101515611b8f57fe5b602002018181525050610200876010601981101515611baa57fe5b6020020151811515611bb857fe5b0467ffffffffffffffff6680000000000000896010601981101515611bd957fe5b6020020151021617836009601981101515611bf057fe5b602002018181525050648000000000876011601981101515611c0e57fe5b6020020151811515611c1c57fe5b0467ffffffffffffffff6302000000896011601981101515611c3a57fe5b602002015102161783600c601981101515611c5157fe5b60200201818152505065080000000000876012601981101515611c7057fe5b6020020151811515611c7e57fe5b0467ffffffffffffffff62200000896012601981101515611c9b57fe5b602002015102161783600f601981101515611cb257fe5b602002018181525050610100876013601981101515611ccd57fe5b6020020151811515611cdb57fe5b0467ffffffffffffffff670100000000000000896013601981101515611cfd57fe5b6020020151021617836017601981101515611d1457fe5b602002018181525050642000000000876014601981101515611d3257fe5b6020020151811515611d4057fe5b0467ffffffffffffffff6308000000896014601981101515611d5e57fe5b6020020151021617836003601981101515611d7557fe5b60200201818152505065100000000000876015601981101515611d9457fe5b6020020151811515611da257fe5b0467ffffffffffffffff62100000896015601981101515611dbf57fe5b6020020151021617836006601981101515611dd657fe5b6020020181815250506302000000876016601981101515611df357fe5b6020020151811515611e0157fe5b0467ffffffffffffffff648000000000896016601981101515611e2057fe5b602002015102161783600e601981101515611e3757fe5b602002018181525050670100000000000000876017601981101515611e5857fe5b6020020151811515611e6657fe5b0467ffffffffffffffff610100896017601981101515611e8257fe5b6020020151021617836011601981101515611e9957fe5b6020020181815250506604000000000000876018601981101515611eb957fe5b6020020151811515611ec757fe5b0467ffffffffffffffff614000896018601981101515611ee357fe5b6020020151021617836014601981101515611efa57fe5b60200201818152505082600a601981101515611f1257fe5b6020020151836005601981101515611f2657fe5b60200201511916836000601981101515611f3c57fe5b602002015118876000601981101515611f5157fe5b60200201818152505082600b601981101515611f6957fe5b6020020151836006601981101515611f7d57fe5b60200201511916836001601981101515611f9357fe5b602002015118876001601981101515611fa857fe5b60200201818152505082600c601981101515611fc057fe5b6020020151836007601981101515611fd457fe5b60200201511916836002601981101515611fea57fe5b602002015118876002601981101515611fff57fe5b60200201818152505082600d60198110151561201757fe5b602002015183600860198110151561202b57fe5b6020020151191683600360198110151561204157fe5b60200201511887600360198110151561205657fe5b60200201818152505082600e60198110151561206e57fe5b602002015183600960198110151561208257fe5b6020020151191683600460198110151561209857fe5b6020020151188760046019811015156120ad57fe5b60200201818152505082600f6019811015156120c557fe5b602002015183600a6019811015156120d957fe5b602002015119168360056019811015156120ef57fe5b60200201511887600560198110151561210457fe5b60200201818152505082601060198110151561211c57fe5b602002015183600b60198110151561213057fe5b6020020151191683600660198110151561214657fe5b60200201511887600660198110151561215b57fe5b60200201818152505082601160198110151561217357fe5b602002015183600c60198110151561218757fe5b6020020151191683600760198110151561219d57fe5b6020020151188760076019811015156121b257fe5b6020020181815250508260126019811015156121ca57fe5b602002015183600d6019811015156121de57fe5b602002015119168360086019811015156121f457fe5b60200201511887600860198110151561220957fe5b60200201818152505082601360198110151561222157fe5b602002015183600e60198110151561223557fe5b6020020151191683600960198110151561224b57fe5b60200201511887600960198110151561226057fe5b60200201818152505082601460198110151561227857fe5b602002015183600f60198110151561228c57fe5b6020020151191683600a6019811015156122a257fe5b60200201511887600a6019811015156122b757fe5b6020020181815250508260156019811015156122cf57fe5b60200201518360106019811015156122e357fe5b6020020151191683600b6019811015156122f957fe5b60200201511887600b60198110151561230e57fe5b60200201818152505082601660198110151561232657fe5b602002015183601160198110151561233a57fe5b6020020151191683600c60198110151561235057fe5b60200201511887600c60198110151561236557fe5b60200201818152505082601760198110151561237d57fe5b602002015183601260198110151561239157fe5b6020020151191683600d6019811015156123a757fe5b60200201511887600d6019811015156123bc57fe5b6020020181815250508260186019811015156123d457fe5b60200201518360136019811015156123e857fe5b6020020151191683600e6019811015156123fe57fe5b60200201511887600e60198110151561241357fe5b60200201818152505082600060198110151561242b57fe5b602002015183601460198110151561243f57fe5b6020020151191683600f60198110151561245557fe5b60200201511887600f60198110151561246a57fe5b60200201818152505082600160198110151561248257fe5b602002015183601560198110151561249657fe5b602002015119168360106019811015156124ac57fe5b6020020151188760106019811015156124c157fe5b6020020181815250508260026019811015156124d957fe5b60200201518360166019811015156124ed57fe5b6020020151191683601160198110151561250357fe5b60200201511887601160198110151561251857fe5b60200201818152505082600360198110151561253057fe5b602002015183601760198110151561254457fe5b6020020151191683601260198110151561255a57fe5b60200201511887601260198110151561256f57fe5b60200201818152505082600460198110151561258757fe5b602002015183601860198110151561259b57fe5b602002015119168360136019811015156125b157fe5b6020020151188760136019811015156125c657fe5b6020020181815250508260056019811015156125de57fe5b60200201518360006019811015156125f257fe5b6020020151191683601460198110151561260857fe5b60200201511887601460198110151561261d57fe5b60200201818152505082600660198110151561263557fe5b602002015183600160198110151561264957fe5b6020020151191683601560198110151561265f57fe5b60200201511887601560198110151561267457fe5b60200201818152505082600760198110151561268c57fe5b60200201518360026019811015156126a057fe5b602002015119168360166019811015156126b657fe5b6020020151188760166019811015156126cb57fe5b6020020181815250508260086019811015156126e357fe5b60200201518360036019811015156126f757fe5b6020020151191683601760198110151561270d57fe5b60200201511887601760198110151561272257fe5b60200201818152505082600960198110151561273a57fe5b602002015183600460198110151561274e57fe5b6020020151191683601860198110151561276457fe5b60200201511887601860198110151561277957fe5b602002018181525050818160188110151561279057fe5b60200201518760006019811015156127a457fe5b6020020151188760006019811015156127b957fe5b6020020181815250508080600101915050610a8d565b8695505050505050919050565b610100604051908101604052806008905b600067ffffffffffffffff168152602001906001900390816127ed5790505090565b602060405190810160405280600081525090565b610200604051908101604052806010905b600063ffffffff168152602001906001900390816128345790505090565b610120604051908101604052806009905b60008152602001906001900390816128635790505090565b610200604051908101604052806010905b600081526020019060019003908161288c5790505090565b610320604051908101604052806019905b60008152602001906001900390816128b55790505090565b60a0604051908101604052806005905b60008152602001906001900390816128dd5790505090565b610300604051908101604052806018905b600081526020019060019003908161290657905050905600a165627a7a72305820a003b636ca6cfe85ca5b5eee78f15a9a5b6c262c2c0701b1449300fbda3902300029
[ 23, 12 ]
0xf1eb07d8026980c57b805ca142b5809f89c1952a
/* website: cityswap.io ██████╗ ███████╗██████╗ ██╗ ██╗███╗ ██╗ ██████╗██╗████████╗██╗ ██╗ ██╔══██╗██╔════╝██╔══██╗██║ ██║████╗ ██║ ██╔════╝██║╚══██╔══╝╚██╗ ██╔╝ ██████╔╝█████╗ ██████╔╝██║ ██║██╔██╗ ██║ ██║ ██║ ██║ ╚████╔╝ ██╔══██╗██╔══╝ ██╔══██╗██║ ██║██║╚██╗██║ ██║ ██║ ██║ ╚██╔╝ ██████╔╝███████╗██║ ██║███████╗██║██║ ╚████║ ╚██████╗██║ ██║ ██║ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ */ pragma solidity ^0.6.12; /* * @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; } } /** * @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 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; } } /** * @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); } } } } /** * @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"); } } } /** * @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; } } /** * @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 { } } // CityToken with Governance. contract BerlinCityToken is ERC20("BERLIN.cityswap.io", "BERLIN"), Ownable { uint256 public constant MAX_SUPPLY = 3438000 * 10**18; /** * @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency). */ function mint(address _to, uint256 _amount) public onlyOwner { uint256 _totalSupply = totalSupply(); if(_totalSupply.add(_amount) > MAX_SUPPLY) { _amount = MAX_SUPPLY.sub(_totalSupply); } require(_totalSupply.add(_amount) <= MAX_SUPPLY); _mint(_to, _amount); } } contract BerlinAgency 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 CITYs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accCityPerShare` (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. CITYs to distribute per block. uint256 lastRewardBlock; // Last block number that CITYs distribution occurs. uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below. } // The CITY TOKEN! BerlinCityToken public city; // Dev address. address public devaddr; // Block number when bonus CITY period ends. uint256 public bonusEndBlock; // CITY tokens created per block. uint256 public cityPerBlock; // Bonus muliplier for early city travels. uint256 public constant BONUS_MULTIPLIER = 1; // no bonus // 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 CITY 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( BerlinCityToken _city, address _devaddr, uint256 _cityPerBlock, uint256 _startBlock, uint256 _bonusEndBlock ) public { city = _city; devaddr = _devaddr; cityPerBlock = _cityPerBlock; 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) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accCityPerShare: 0 })); } // Update the given pool's CITY allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { 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 CITYs on frontend. function pendingCity(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCityPerShare = pool.accCityPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accCityPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables 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 mint(uint256 amount) public onlyOwner{ city.mint(devaddr, amount); } // 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 cityReward = multiplier.mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint); city.mint(devaddr, cityReward.div(20)); // 5% city.mint(address(this), cityReward); pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to TravelAgency for CITY 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.accCityPerShare).div(1e12).sub(user.rewardDebt); safeCityTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accCityPerShare).div(1e12).sub(user.rewardDebt); safeCityTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12); 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 city transfer function, just in case if rounding error causes pool to not have enough CITYs. function safeCityTransfer(address _to, uint256 _amount) internal { uint256 cityBal = city.balanceOf(address(this)); if (_amount > cityBal) { city.transfer(_to, cityBal); } else { city.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c806364482f79116100c357806393f1a40b1161007c57806393f1a40b146104ea578063a0712d6814610553578063d49e77cd14610581578063e2bbb158146105b5578063f2fde38b146105ed578063fd0160fe1461063157610158565b806364482f79146103ba578063715018a6146103fe5780638aa28550146104085780638d88a90e146104265780638da5cb5b1461046a5780638dbb1e3a1461049e57610158565b8063441a3e7011610115578063441a3e70146102e057806348cd4cb11461031857806351eb05a6146103365780635312ea8e146103645780635984ec1414610392578063630b5ba1146103b057610158565b8063081e3eda1461015d5780631526fe271461017b57806317caf6f1146101e85780631aed6553146102065780631eaaa0451461022457806329467c6e1461027e575b600080fd5b610165610665565b6040518082815260200191505060405180910390f35b6101a76004803603602081101561019157600080fd5b8101908080359060200190929190505050610672565b604051808573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815260200194505050505060405180910390f35b6101f06106cf565b6040518082815260200191505060405180910390f35b61020e6106d5565b6040518082815260200191505060405180910390f35b61027c6004803603606081101561023a57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506106db565b005b6102ca6004803603604081101561029457600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108b4565b6040518082815260200191505060405180910390f35b610316600480360360408110156102f657600080fd5b810190808035906020019092919080359060200190929190505050610afa565b005b610320610d44565b6040518082815260200191505060405180910390f35b6103626004803603602081101561034c57600080fd5b8101908080359060200190929190505050610d4a565b005b6103906004803603602081101561037a57600080fd5b8101908080359060200190929190505050611096565b005b61039a6111c8565b6040518082815260200191505060405180910390f35b6103b86111ce565b005b6103fc600480360360608110156103d057600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506111fb565b005b610406611345565b005b6104106114cb565b6040518082815260200191505060405180910390f35b6104686004803603602081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114d0565b005b6104726115d7565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104d4600480360360408110156104b457600080fd5b810190808035906020019092919080359060200190929190505050611600565b6040518082815260200191505060405180910390f35b6105366004803603604081101561050057600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116b2565b604051808381526020018281526020019250505060405180910390f35b61057f6004803603602081101561056957600080fd5b81019080803590602001909291905050506116e3565b005b61058961187b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105eb600480360360408110156105cb57600080fd5b8101908080359060200190929190803590602001909291905050506118a1565b005b61062f6004803603602081101561060357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a81565b005b610639611c8c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600580549050905090565b6005818154811061067f57fe5b90600052602060002090600402016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030154905084565b60075481565b60035481565b6106e3611cb2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80156107b2576107b16111ce565b5b600060085443116107c5576008546107c7565b435b90506107de84600754611cba90919063ffffffff16565b600781905550600560405180608001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018381526020016000815250908060018154018082558091505060019003906000526020600020906004020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101556040820151816002015560608201518160030155505050505050565b600080600584815481106108c457fe5b9060005260206000209060040201905060006006600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008260030154905060008360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156109be57600080fd5b505afa1580156109d2573d6000803e3d6000fd5b505050506040513d60208110156109e857600080fd5b81019080805190602001909291905050509050836002015443118015610a0f575060008114155b15610aaa576000610a24856002015443611600565b90506000610a67600754610a598860010154610a4b60045487611d4290919063ffffffff16565b611d4290919063ffffffff16565b611dc890919063ffffffff16565b9050610aa5610a9684610a8864e8d4a5100085611d4290919063ffffffff16565b611dc890919063ffffffff16565b85611cba90919063ffffffff16565b935050505b610aee8360010154610ae064e8d4a51000610ad2868860000154611d4290919063ffffffff16565b611dc890919063ffffffff16565b611e1290919063ffffffff16565b94505050505092915050565b600060058381548110610b0957fe5b9060005260206000209060040201905060006006600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508281600001541015610be7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f77697468647261773a206e6f7420676f6f64000000000000000000000000000081525060200191505060405180910390fd5b610bf084610d4a565b6000610c3a8260010154610c2c64e8d4a51000610c1e87600301548760000154611d4290919063ffffffff16565b611dc890919063ffffffff16565b611e1290919063ffffffff16565b9050610c463382611e5c565b610c5d848360000154611e1290919063ffffffff16565b8260000181905550610c9764e8d4a51000610c8985600301548560000154611d4290919063ffffffff16565b611dc890919063ffffffff16565b8260010181905550610cee33858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120d59092919063ffffffff16565b843373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568866040518082815260200191505060405180910390a35050505050565b60085481565b600060058281548110610d5957fe5b9060005260206000209060040201905080600201544311610d7a5750611093565b60008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610e0757600080fd5b505afa158015610e1b573d6000803e3d6000fd5b505050506040513d6020811015610e3157600080fd5b810190808051906020019092919050505090506000811415610e5d574382600201819055505050611093565b6000610e6d836002015443611600565b90506000610eb0600754610ea28660010154610e9460045487611d4290919063ffffffff16565b611d4290919063ffffffff16565b611dc890919063ffffffff16565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610f27601485611dc890919063ffffffff16565b6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610f7a57600080fd5b505af1158015610f8e573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1930836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561102557600080fd5b505af1158015611039573d6000803e3d6000fd5b5050505061107d61106a8461105c64e8d4a5100085611d4290919063ffffffff16565b611dc890919063ffffffff16565b8560030154611cba90919063ffffffff16565b8460030181905550438460020181905550505050505b50565b6000600582815481106110a557fe5b9060005260206000209060040201905060006006600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061115c3382600001548460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166120d59092919063ffffffff16565b823373ffffffffffffffffffffffffffffffffffffffff167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059583600001546040518082815260200191505060405180910390a36000816000018190555060008160010181905550505050565b60045481565b6000600580549050905060005b818110156111f7576111ec81610d4a565b8060010190506111db565b5050565b611203611cb2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80156112d2576112d16111ce565b5b61131782611309600586815481106112e657fe5b906000526020600020906004020160010154600754611e1290919063ffffffff16565b611cba90919063ffffffff16565b600781905550816005848154811061132b57fe5b906000526020600020906004020160010181905550505050565b61134d611cb2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461140d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600181565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611593576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f6465763a207775743f000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600060035482116116385761163160016116238585611e1290919063ffffffff16565b611d4290919063ffffffff16565b90506116ac565b600354831061165b576116548383611e1290919063ffffffff16565b90506116ac565b6116a961167360035484611e1290919063ffffffff16565b61169b600161168d87600354611e1290919063ffffffff16565b611d4290919063ffffffff16565b611cba90919063ffffffff16565b90505b92915050565b6006602052816000526040600020602052806000526040600020600091509150508060000154908060010154905082565b6116eb611cb2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561186057600080fd5b505af1158015611874573d6000803e3d6000fd5b5050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600583815481106118b057fe5b9060005260206000209060040201905060006006600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061191d84610d4a565b600081600001541115611982576000611974826001015461196664e8d4a5100061195887600301548760000154611d4290919063ffffffff16565b611dc890919063ffffffff16565b611e1290919063ffffffff16565b90506119803382611e5c565b505b6119d33330858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612177909392919063ffffffff16565b6119ea838260000154611cba90919063ffffffff16565b8160000181905550611a2464e8d4a51000611a1684600301548460000154611d4290919063ffffffff16565b611dc890919063ffffffff16565b8160010181905550833373ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15856040518082815260200191505060405180910390a350505050565b611a89611cb2565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b49576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bcf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806127176026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600033905090565b600080828401905083811015611d38576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415611d555760009050611dc2565b6000828402905082848281611d6657fe5b0414611dbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061273d6021913960400191505060405180910390fd5b809150505b92915050565b6000611e0a83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612238565b905092915050565b6000611e5483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506122fe565b905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611ee757600080fd5b505afa158015611efb573d6000803e3d6000fd5b505050506040513d6020811015611f1157600080fd5b810190808051906020019092919050505090508082111561200057600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015611fbf57600080fd5b505af1158015611fd3573d6000803e3d6000fd5b505050506040513d6020811015611fe957600080fd5b8101908080519060200190929190505050506120d0565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561209357600080fd5b505af11580156120a7573d6000803e3d6000fd5b505050506040513d60208110156120bd57600080fd5b8101908080519060200190929190505050505b505050565b6121728363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506123be565b505050565b612232846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506123be565b50505050565b600080831182906122e4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156122a957808201518184015260208101905061228e565b50505050905090810190601f1680156122d65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816122f057fe5b049050809150509392505050565b60008383111582906123ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612370578082015181840152602081019050612355565b50505050905090810190601f16801561239d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6060612420826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166124ad9092919063ffffffff16565b90506000815111156124a85780806020019051602081101561244157600080fd5b81019080805190602001909291905050506124a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061275e602a913960400191505060405180910390fd5b5b505050565b60606124bc84846000856124c5565b90509392505050565b60606124d0856126cb565b612542576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310612592578051825260208201915060208101905060208303925061256f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146125f4576040519150601f19603f3d011682016040523d82523d6000602084013e6125f9565b606091505b5091509150811561260e5780925050506126c3565b6000815111156126215780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561268857808201518184015260208101905061266d565b50505050905090810190601f1680156126b55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561270d57506000801b8214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a264697066735822122067cf71a53541edf1ad3db167a9ad84c022dc7a5bf633ef7cf706174d30be2bd864736f6c634300060c0033
[ 16, 4, 9, 7 ]
0xF1eB6Dc3C8870f3081115D4e81Ad7dc902AC26C7
pragma solidity 0.7.6; import "contracts/protocol/futures/futureWallets/RateFutureWallet.sol"; /** * @title Contract for iFarm Future Wallet * @author Gaspard Peduzzi * @notice Handles the future wallet mechanisms for the yearn platform * @dev Implement directly the rate future wallet abstraction as it fits the iFarm IBT */ contract HarvestFutureWallet is RateFutureWallet { } pragma solidity 0.7.6; import "contracts/protocol/futures/futureWallets/FutureWallet.sol"; /** * @title Rate Future Wallet abstraction * @notice Abstraction for the future wallets that works with an IBT whose value incorporates the fees (i.e. cTokens) * @dev Override future wallet abstraction with the particular functioning of rate based IBT */ abstract contract RateFutureWallet is FutureWallet { using SafeMathUpgradeable for uint256; uint256[] internal futureWallets; /** * @notice Intializer * @param _futureAddress the address of the corresponding future * @param _adminAddress the address of the admin */ function initialize(address _futureAddress, address _adminAddress) public override initializer { super.initialize(_futureAddress, _adminAddress); } /** * @notice register the yield of an expired period * @param _amount the amount of yield to be registered */ function registerExpiredFuture(uint256 _amount) public override { require(hasRole(FUTURE_ROLE, msg.sender), "Caller is not allowed to register an expired future"); futureWallets.push(_amount); } /** * @notice return the yield that could be redeemed by an address for a particular period * @param _periodIndex the index of the corresponding period * @param _tokenHolder the FYT holder * @return the yield that could be redeemed by the token holder for this period */ function getRedeemableYield(uint256 _periodIndex, address _tokenHolder) public view override returns (uint256) { IFutureYieldToken fyt = IFutureYieldToken(future.getFYTofPeriod(_periodIndex)); uint256 senderTokenBalance = fyt.balanceOf(_tokenHolder); return (senderTokenBalance.mul(futureWallets[_periodIndex])).div(fyt.totalSupply()); } /** * @notice collect and update the yield balance of the sender * @param _periodIndex the index of the corresponding period * @param _userFYT the FYT holder balance * @param _totalFYT the total FYT supply * @return the yield claimed */ function _updateYieldBalances( uint256 _periodIndex, uint256 _userFYT, uint256 _totalFYT ) internal override returns (uint256) { uint256 claimableYield = (_userFYT.mul(futureWallets[_periodIndex])).div(_totalFYT); futureWallets[_periodIndex] = futureWallets[_periodIndex].sub(claimableYield); return claimableYield; } } pragma solidity 0.7.6; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import "contracts/interfaces/ERC20.sol"; import "contracts/interfaces/apwine/tokens/IFutureYieldToken.sol"; import "contracts/interfaces/apwine/IFuture.sol"; import "contracts/interfaces/apwine/IController.sol"; import "contracts/interfaces/apwine/IRegistry.sol"; import "contracts/interfaces/apwine/utils/IAPWineMath.sol"; /** * @title Future Wallet abstraction * @notice Main abstraction for the future wallets contract * @dev The future wallets stores the yield after each expiration of the future period */ abstract contract FutureWallet is Initializable, AccessControlUpgradeable, ReentrancyGuardUpgradeable { using SafeMathUpgradeable for uint256; bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant FUTURE_ROLE = keccak256("FUTURE_ROLE"); IFuture public future; ERC20 public ibt; bool public WITHRAWALS_PAUSED; event YieldRedeemed(address _user, uint256 _periodIndex); event WithdrawalsPaused(); event WithdrawalsResumed(); modifier withdrawalsEnabled() { require(!WITHRAWALS_PAUSED, "withdrawals are disabled"); _; } /** * @notice Intializer * @param _futureAddress the address of the corresponding future * @param _adminAddress the address of the admin */ function initialize(address _futureAddress, address _adminAddress) public virtual initializer { future = IFuture(_futureAddress); ibt = ERC20(future.getIBTAddress()); _setupRole(DEFAULT_ADMIN_ROLE, _adminAddress); _setupRole(ADMIN_ROLE, _adminAddress); _setupRole(FUTURE_ROLE, _futureAddress); } /** * @notice register the yield of an expired period * @param _amount the amount of yield to be registered * @dev the caller need to transfer the yield after calling this function */ function registerExpiredFuture(uint256 _amount) public virtual; /** * @notice redeem the yield of the underlying yield of the FYT held by the sender * @param _periodIndex the index of the period to redeem the yield from */ function redeemYield(uint256 _periodIndex) public virtual nonReentrant withdrawalsEnabled { require(_periodIndex < future.getNextPeriodIndex() - 1, "Invalid period index"); IFutureYieldToken fyt = IFutureYieldToken(future.getFYTofPeriod(_periodIndex)); uint256 senderTokenBalance = fyt.balanceOf(msg.sender); require(senderTokenBalance > 0, "FYT sender balance should not be null"); uint256 claimableYield = _updateYieldBalances(_periodIndex, senderTokenBalance, fyt.totalSupply()); fyt.burnFrom(msg.sender, senderTokenBalance); ibt.transfer(msg.sender, claimableYield); emit YieldRedeemed(msg.sender, _periodIndex); } /** * @notice return the yield that could be redeemed by an address for a particular period * @param _periodIndex the index of the corresponding period * @param _tokenHolder the FYT holder * @return the yield that could be redeemed by the token holder for this period */ function getRedeemableYield(uint256 _periodIndex, address _tokenHolder) public view virtual returns (uint256); /** * @notice collect and update the yield balance of the sender * @param _periodIndex the index of the corresponding period * @param _userFYT the FYT holder balance * @param _totalFYT the total FYT supply * @return the yield that could be redeemed by the token holder for this period */ function _updateYieldBalances( uint256 _periodIndex, uint256 _userFYT, uint256 _totalFYT ) internal virtual returns (uint256); /** * @notice getter for the address of the future corresponding to this future wallet * @return the address of the future */ function getFutureAddress() public view virtual returns (address) { return address(future); } /** * @notice getter for the address of the IBT corresponding to this future wallet * @return the address of the IBT */ function getIBTAddress() public view virtual returns (address) { return address(ibt); } /* Admin functions */ /** * @notice Pause withdrawals */ function pauseWithdrawals() public { require(hasRole(ADMIN_ROLE, msg.sender), "Caller is not allowed to pause withdrawals"); WITHRAWALS_PAUSED = true; emit WithdrawalsPaused(); } /** * @notice Resume withdrawals */ function resumeWithdrawals() public { require(hasRole(ADMIN_ROLE, msg.sender), "Caller is not allowed to resume withdrawals"); WITHRAWALS_PAUSED = false; emit WithdrawalsResumed(); } } // 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 // 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; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/AddressUpgradeable.sol"; import "../GSN/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @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 AccessControlUpgradeable is Initializable, ContextUpgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using AddressUpgradeable for address; struct RoleData { EnumerableSetUpgradeable.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()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /** * @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 ReentrancyGuardUpgradeable is Initializable { // 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; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _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; } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity 0.7.6; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface ERC20 is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external returns (string memory); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() external returns (string memory); /** * @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() external returns (uint8); /** * @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) external returns (bool); /** * @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) external returns (bool); } pragma solidity 0.7.6; import "contracts/interfaces/ERC20.sol"; interface IFutureYieldToken is ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) external; /** * @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) external; /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) external; } pragma solidity 0.7.6; interface IFuture { struct Registration { uint256 startIndex; uint256 scaledBalance; } /** * @notice Getter for the PAUSE future parameter * @return true if new periods are paused, false otherwise */ function PAUSED() external view returns (bool); /** * @notice Getter for the PERIOD future parameter * @return returns the period duration of the future */ function PERIOD_DURATION() external view returns (uint256); /** * @notice Getter for the PLATFORM_NAME future parameter * @return returns the platform of the future */ function PLATFORM_NAME() external view returns (uint256); /** * @notice Initializer * @param _controller the address of the controller * @param _ibt the address of the corresponding IBT * @param _periodDuration the length of the period (in days) * @param _platformName the name of the platform and tools * @param _deployerAddress the future deployer address * @param _admin the address of the ACR admin */ function initialize( address _controller, address _ibt, uint256 _periodDuration, string memory _platformName, address _deployerAddress, address _admin ) external; /** * @notice Set future wallet address * @param _futureVault the address of the new future wallet * @dev needs corresponding permissions for sender */ function setFutureVault(address _futureVault) external; /** * @notice Set futureWallet address * @param _futureWallet the address of the new futureWallet * @dev needs corresponding permissions for sender */ function setFutureWallet(address _futureWallet) external; /** * @notice Set liquidity gauge address * @param _liquidityGauge the address of the new liquidity gauge * @dev needs corresponding permissions for sender */ function setLiquidityGauge(address _liquidityGauge) external; /** * @notice Set apwibt address * @param _apwibt the address of the new apwibt * @dev used only for exceptional purpose */ function setAPWIBT(address _apwibt) external; /** * @notice Sender registers an amount of IBT for the next period * @param _user address to register to the future * @param _amount amount of IBT to be registered * @dev called by the controller only */ function register(address _user, uint256 _amount) external; /** * @notice Sender unregisters an amount of IBT for the next period * @param _user user addresss * @param _amount amount of IBT to be unregistered */ function unregister(address _user, uint256 _amount) external; /** * @notice Sender unlocks the locked funds corresponding to their apwIBT holding * @param _user the user address * @param _amount amount of funds to unlocked * @dev will require a transfer of FYT of the ongoing period corresponding to the funds unlocked */ function withdrawLockFunds(address _user, uint256 _amount) external; /** * @notice Send the user their owed FYT (and apwIBT if there are some claimable) * @param _user address of the user to send the FYT to */ function claimFYT(address _user) external; /** * @notice Start a new period * @dev needs corresponding permissions for sender */ function startNewPeriod() external; /** * @notice Check if a user has unclaimed FYT * @param _user the user to check * @return true if the user can claim some FYT, false otherwise */ function hasClaimableFYT(address _user) external view returns (bool); /** * @notice Check if a user has unclaimed apwIBT * @param _user the user to check * @return true if the user can claim some apwIBT, false otherwise */ function hasClaimableAPWIBT(address _user) external view returns (bool); /** * @notice Getter for user registered amount * @param _user user to return the registered funds of * @return the registered amount, 0 if no registrations * @dev the registration can be older than the next period */ function getRegisteredAmount(address _user) external view returns (uint256); /** * @notice Getter for user IBT amount that is unlockable * @param _user user to unlock the IBT from * @return the amount of IBT the user can unlock */ function getUnlockableFunds(address _user) external view returns (uint256); /** * @notice Getter for yield that is generated by the user funds during the current period * @param _user user to check the unrealized yield of * @return the yield (amount of IBT) currently generated by the locked funds of the user */ function getUnrealisedYield(address _user) external view returns (uint256); /** * @notice Getter for the amount of apwIBT that the user can claim * @param _user the user to check the claimable apwIBT of * @return the amount of apwIBT claimable by the user */ function getClaimableAPWIBT(address _user) external view returns (uint256); /** * @notice Getter for the amount of FYT that the user can claim for a certain period * @param _user user to check the check the claimable FYT of * @param _periodID period ID to check the claimable FYT of * @return the amount of FYT claimable by the user for this period ID */ function getClaimableFYTForPeriod(address _user, uint256 _periodID) external view returns (uint256); /** * @notice Getter for next period index * @return next period index * @dev index starts at 1 */ function getNextPeriodIndex() external view returns (uint256); /** * @notice Getter for controller address * @return the controller address */ function getControllerAddress() external view returns (address); /** * @notice Getter for future wallet address * @return future wallet address */ function getFutureVaultAddress() external view returns (address); /** * @notice Getter for futureWallet address * @return futureWallet address */ function getFutureWalletAddress() external view returns (address); /** * @notice Getter for liquidity gauge address * @return liquidity gauge address */ function getLiquidityGaugeAddress() external view returns (address); /** * @notice Getter for the IBT address * @return IBT address */ function getIBTAddress() external view returns (address); /** * @notice Getter for future apwIBT address * @return apwIBT address */ function getAPWIBTAddress() external view returns (address); /** * @notice Getter for FYT address of a particular period * @param _periodIndex period index * @return FYT address */ function getFYTofPeriod(uint256 _periodIndex) external view returns (address); /* Admin functions*/ /** * @notice Pause registrations and the creation of new periods */ function pausePeriods() external; /** * @notice Resume registrations and the creation of new periods */ function resumePeriods() external; } pragma solidity 0.7.6; interface IController { /* Getters */ function STARTING_DELAY() external view returns (uint256); /* Initializer */ /** * @notice Initializer of the Controller contract * @param _admin the address of the admin */ function initialize(address _admin) external; /* Future Settings Setters */ /** * @notice Change the delay for starting a new period * @param _startingDelay the new delay (+-) to start the next period */ function setPeriodStartingDelay(uint256 _startingDelay) external; /** * @notice Set the next period switch timestamp for the future with corresponding duration * @param _periodDuration the duration of a period * @param _nextPeriodTimestamp the next period switch timestamp */ function setNextPeriodSwitchTimestamp(uint256 _periodDuration, uint256 _nextPeriodTimestamp) external; /** * @notice Set a new factor for the portion of the yield that is claimable when withdrawing funds during an ongoing period * @param _periodDuration the duration of the periods * @param _claimableYieldFactor the portion of the yield that is claimable */ function setUnlockClaimableFactor(uint256 _periodDuration, uint256 _claimableYieldFactor) external; /* User Methods */ /** * @notice Register an amount of IBT from the sender to the corresponding future * @param _future the address of the future to be registered to * @param _amount the amount to register */ function register(address _future, uint256 _amount) external; /** * @notice Unregister an amount of IBT from the sender to the corresponding future * @param _future the address of the future to be unregistered from * @param _amount the amount to unregister */ function unregister(address _future, uint256 _amount) external; /** * @notice Withdraw deposited funds from APWine * @param _future the address of the future to withdraw the IBT from * @param _amount the amount to withdraw */ function withdrawLockFunds(address _future, uint256 _amount) external; /** * @notice Claim FYT of the msg.sender * @param _future the future from which to claim the FYT */ function claimFYT(address _future) external; /** * @notice Get the list of futures from which a user can claim FYT * @param _user the user to check */ function getFuturesWithClaimableFYT(address _user) external view returns (address[] memory); /** * @notice Getter for the registry address of the protocol * @return the address of the protocol registry */ function getRegistryAddress() external view returns (address); /** * @notice Getter for the symbol of the apwIBT of one future * @param _ibtSymbol the IBT of the external protocol * @param _platform the external protocol name * @param _periodDuration the duration of the periods for the future * @return the generated symbol of the apwIBT */ function getFutureIBTSymbol( string memory _ibtSymbol, string memory _platform, uint256 _periodDuration ) external pure returns (string memory); /** * @notice Getter for the symbol of the FYT of one future * @param _apwibtSymbol the apwIBT symbol for this future * @param _periodDuration the duration of the periods for this future * @return the generated symbol of the FYT */ function getFYTSymbol(string memory _apwibtSymbol, uint256 _periodDuration) external view returns (string memory); /** * @notice Getter for the period index depending on the period duration of the future * @param _periodDuration the periods duration * @return the period index */ function getPeriodIndex(uint256 _periodDuration) external view returns (uint256); /** * @notice Getter for beginning timestamp of the next period for the futures with a defined periods duration * @param _periodDuration the periods duration * @return the timestamp of the beginning of the next period */ function getNextPeriodStart(uint256 _periodDuration) external view returns (uint256); /** * @notice Getter for the factor of claimable yield when unlocking * @param _periodDuration the periods duration * @return the factor of claimable yield of the last period */ function getUnlockYieldFactor(uint256 _periodDuration) external view returns (uint256); /** * @notice Getter for the list of future durations registered in the contract * @return the list of futures duration */ function getDurations() external view returns (uint256[] memory); /** * @notice Register a newly created future in the registry * @param _newFuture the address of the new future */ function registerNewFuture(address _newFuture) external; /** * @notice Unregister a future from the registry * @param _future the address of the future to unregister */ function unregisterFuture(address _future) external; /** * @notice Start all the futures that have a defined periods duration to synchronize them * @param _periodDuration the periods duration of the futures to start */ function startFuturesByPeriodDuration(uint256 _periodDuration) external; /** * @notice Getter for the futures by periods duration * @param _periodDuration the periods duration of the futures to return */ function getFuturesWithDuration(uint256 _periodDuration) external view returns (address[] memory); /** * @notice Register the sender to the corresponding future * @param _user the address of the user * @param _futureAddress the addresses of the futures to claim the fyts from */ function claimSelectedYield(address _user, address[] memory _futureAddress) external; function getRoleMember(bytes32 role, uint256 index) external view returns (address); // OZ ACL getter /** * @notice Interrupt a future avoiding news registrations * @param _future the address of the future to pause * @dev should only be called in extraordinary situations by the admin of the contract */ function pauseFuture(address _future) external; /** * @notice Resume a future that has been paused * @param _future the address of the future to resume * @dev should only be called in extraordinary situations by the admin of the contract */ function resumeFuture(address _future) external; } pragma solidity 0.7.6; pragma experimental ABIEncoderV2; interface IRegistry { /** * @notice Initializer of the contract * @param _admin the address of the admin of the contract */ function initialize(address _admin) external; /* Setters */ /** * @notice Setter for the treasury address * @param _newTreasury the address of the new treasury */ function setTreasury(address _newTreasury) external; /** * @notice Setter for the gauge controller address * @param _newGaugeController the address of the new gauge controller */ function setGaugeController(address _newGaugeController) external; /** * @notice Setter for the controller address * @param _newController the address of the new controller */ function setController(address _newController) external; /** * @notice Setter for the APW token address * @param _newAPW the address of the APW token */ function setAPW(address _newAPW) external; /** * @notice Setter for the proxy factory address * @param _proxyFactory the address of the new proxy factory */ function setProxyFactory(address _proxyFactory) external; /** * @notice Setter for the liquidity gauge address * @param _liquidityGaugeLogic the address of the new liquidity gauge logic */ function setLiquidityGaugeLogic(address _liquidityGaugeLogic) external; /** * @notice Setter for the APWine IBT logic address * @param _APWineIBTLogic the address of the new APWine IBT logic */ function setAPWineIBTLogic(address _APWineIBTLogic) external; /** * @notice Setter for the APWine FYT logic address * @param _FYTLogic the address of the new APWine FYT logic */ function setFYTLogic(address _FYTLogic) external; /** * @notice Setter for the maths utils address * @param _mathsUtils the address of the new math utils */ function setMathsUtils(address _mathsUtils) external; /** * @notice Setter for the naming utils address * @param _namingUtils the address of the new naming utils */ function setNamingUtils(address _namingUtils) external; /** * @notice Getter for the controller address * @return the address of the controller */ function getControllerAddress() external view returns (address); /** * @notice Getter for the treasury address * @return the address of the treasury */ function getTreasuryAddress() external view returns (address); /** * @notice Getter for the gauge controller address * @return the address of the gauge controller */ function getGaugeControllerAddress() external view returns (address); /** * @notice Getter for the DAO address * @return the address of the DAO that has admin rights on the APW token */ function getDAOAddress() external returns (address); /** * @notice Getter for the APW token address * @return the address the APW token */ function getAPWAddress() external view returns (address); /** * @notice Getter for the vesting contract address * @return the vesting contract address */ function getVestingAddress() external view returns (address); /** * @notice Getter for the proxy factory address * @return the proxy factory address */ function getProxyFactoryAddress() external view returns (address); /** * @notice Getter for liquidity gauge logic address * @return the liquidity gauge logic address */ function getLiquidityGaugeLogicAddress() external view returns (address); /** * @notice Getter for APWine IBT logic address * @return the APWine IBT logic address */ function getAPWineIBTLogicAddress() external view returns (address); /** * @notice Getter for APWine FYT logic address * @return the APWine FYT logic address */ function getFYTLogicAddress() external view returns (address); /** * @notice Getter for math utils address * @return the math utils address */ function getMathsUtils() external view returns (address); /** * @notice Getter for naming utils address * @return the naming utils address */ function getNamingUtils() external view returns (address); /* Future factory */ /** * @notice Register a new future factory in the registry * @param _futureFactory the address of the future factory contract * @param _futureFactoryName the name of the future factory */ function addFutureFactory(address _futureFactory, string memory _futureFactoryName) external; /** * @notice Getter to check if a future factory is registered * @param _futureFactory the address of the future factory contract to check the registration of * @return true if it is, false otherwise */ function isRegisteredFutureFactory(address _futureFactory) external view returns (bool); /** * @notice Getter for the future factory registered at an index * @param _index the index of the future factory to return * @return the address of the corresponding future factory */ function getFutureFactoryAt(uint256 _index) external view returns (address); /** * @notice Getter for number of future factories registered * @return the number of future factory registered */ function futureFactoryCount() external view returns (uint256); /** * @notice Getter for name of a future factory contract * @param _futureFactory the address of a future factory * @return the name of the corresponding future factory contract */ function getFutureFactoryName(address _futureFactory) external view returns (string memory); /* Future platform */ /** * @notice Register a new future platform in the registry * @param _futureFactory the address of the future factory * @param _futurePlatformName the name of the future platform * @param _future the address of the future contract logic * @param _futureWallet the address of the future wallet contract logic * @param _futureVault the name of the future vault contract logic */ function addFuturePlatform( address _futureFactory, string memory _futurePlatformName, address _future, address _futureWallet, address _futureVault ) external; /** * @notice Getter to check if a future platform is registered * @param _futurePlatformName the name of the future platform to check the registration of * @return true if it is, false otherwise */ function isRegisteredFuturePlatform(string memory _futurePlatformName) external view returns (bool); /** * @notice Getter for the future platform contracts * @param _futurePlatformName the name of the future platform * @return the addresses of 0) the future logic 1) the future wallet logic 2) the future vault logic */ function getFuturePlatform(string memory _futurePlatformName) external view returns (address[3] memory); /** * @notice Getter the total count of future platftroms registered * @return the number of future platforms registered */ function futurePlatformsCount() external view returns (uint256); /** * @notice Getter the list of platforms names registered * @return the list of platform names registered */ function getFuturePlatformNames() external view returns (string[] memory); /** * @notice Remove a future platform from the registry * @param _futurePlatformName the name of the future platform to remove from the registry */ function removeFuturePlatform(string memory _futurePlatformName) external; /* Futures */ /** * @notice Add a future to the registry * @param _future the address of the future to add to the registry */ function addFuture(address _future) external; /** * @notice Remove a future from the registry * @param _future the address of the future to remove from the registry */ function removeFuture(address _future) external; /** * @notice Getter to check if a future is registered * @param _future the address of the future to check the registration of * @return true if it is, false otherwise */ function isRegisteredFuture(address _future) external view returns (bool); /** * @notice Getter for the future registered at an index * @param _index the index of the future to return * @return the address of the corresponding future */ function getFutureAt(uint256 _index) external view returns (address); /** * @notice Getter for number of future registered * @return the number of future registered */ function futureCount() external view returns (uint256); } pragma solidity 0.7.6; interface IAPWineMaths { /** * @notice scale an input * @param _actualValue the original value of the input * @param _initialSum the scaled value of the sum of the inputs * @param _actualSum the current value of the sum of the inputs */ function getScaledInput( uint256 _actualValue, uint256 _initialSum, uint256 _actualSum ) external pure returns (uint256); /** * @notice scale back a value to the output * @param _scaledOutput the current scaled output * @param _initialSum the scaled value of the sum of the inputs * @param _actualSum the current value of the sum of the inputs */ function getActualOutput( uint256 _scaledOutput, uint256 _initialSum, uint256 _actualSum ) external pure returns (uint256); } // 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 EnumerableSetUpgradeable { // 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(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)); } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @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); } 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; 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: 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); }
0x608060405234801561001057600080fd5b50600436106101775760003560e01c806391d14854116100d8578063c43f357b1161008c578063d0cd0dbb11610066578063d0cd0dbb14610375578063d547741f1461037d578063f018ae69146103a957610177565b8063c43f357b14610348578063c76748aa14610350578063ca15c8731461035857610177565b8063a2ec258f116100bd578063a2ec258f1461030c578063a88c1bda14610314578063bee431d01461034057610177565b806391d14854146102c4578063a217fddf1461030457610177565b8063485cc9551161012f578063733d6c0f11610114578063733d6c0f1461027557806375b238fc1461027d5780639010d07c1461028557610177565b8063485cc9551461023f57806356bb54a71461026d57610177565b8063258d3c3311610160578063258d3c33146101ca5780632f2ff15d146101e757806336568abe1461021357610177565b80632262827f1461017c578063248a9ca31461019b575b600080fd5b6101996004803603602081101561019257600080fd5b50356103b1565b005b6101b8600480360360208110156101b157600080fd5b503561044b565b60408051918252519081900360200190f35b610199600480360360208110156101e057600080fd5b5035610460565b610199600480360360408110156101fd57600080fd5b50803590602001356001600160a01b03166108e9565b6101996004803603604081101561022957600080fd5b50803590602001356001600160a01b0316610955565b6101996004803603604081101561025557600080fd5b506001600160a01b03813581169160200135166109b6565b610199610a64565b6101b8610b07565b6101b8610b2b565b6102a86004803603604081101561029b57600080fd5b5080359060200135610b4f565b604080516001600160a01b039092168252519081900360200190f35b6102f0600480360360408110156102da57600080fd5b50803590602001356001600160a01b0316610b70565b604080519115158252519081900360200190f35b6101b8610b88565b6102a8610b8d565b6101b86004803603604081101561032a57600080fd5b50803590602001356001600160a01b0316610b9c565b6102a8610d5d565b6102a8610d6c565b6102f0610d7b565b6101b86004803603602081101561036e57600080fd5b5035610d8b565b610199610da2565b6101996004803603604081101561039357600080fd5b50803590602001356001600160a01b0316610e3f565b6102a8610e98565b6103db7f52d2dbc4d362e84c42bdfb9941433968ba41423559d7559b32db1183b22b148f33610b70565b6104165760405162461bcd60e51b81526004018080602001828103825260338152602001806115d86033913960400191505060405180910390fd5b609980546001810182556000919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b60009081526033602052604090206002015490565b600260655414156104b8576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002606555609854600160a01b900460ff161561051c576040805162461bcd60e51b815260206004820152601860248201527f7769746864726177616c73206172652064697361626c65640000000000000000604482015290519081900360640190fd5b609754604080517f2f5d32ea00000000000000000000000000000000000000000000000000000000815290516001926001600160a01b031691632f5d32ea916004808301926020929190829003018186803b15801561057a57600080fd5b505afa15801561058e573d6000803e3d6000fd5b505050506040513d60208110156105a457600080fd5b50510381106105fa576040805162461bcd60e51b815260206004820152601460248201527f496e76616c696420706572696f6420696e646578000000000000000000000000604482015290519081900360640190fd5b609754604080516371a5d76160e01b81526004810184905290516000926001600160a01b0316916371a5d761916024808301926020929190829003018186803b15801561064657600080fd5b505afa15801561065a573d6000803e3d6000fd5b505050506040513d602081101561067057600080fd5b5051604080516370a0823160e01b815233600482015290519192506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b1580156106be57600080fd5b505afa1580156106d2573d6000803e3d6000fd5b505050506040513d60208110156106e857600080fd5b50519050806107285760405162461bcd60e51b81526004018080602001828103825260258152602001806116df6025913960400191505060405180910390fd5b60006107998483856001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561076857600080fd5b505afa15801561077c573d6000803e3d6000fd5b505050506040513d602081101561079257600080fd5b5051610ea7565b9050826001600160a01b03166379cc679033846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156107f257600080fd5b505af1158015610806573d6000803e3d6000fd5b5050609854604080517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810186905290516001600160a01b03909216935063a9059cbb92506044808201926020929091908290030181600087803b15801561087757600080fd5b505af115801561088b573d6000803e3d6000fd5b505050506040513d60208110156108a157600080fd5b5050604080513381526020810186905281517f0f83285fe818de372774823fc96c859451f7f69bc83b5523fca9230a242ecc72929181900390910190a1505060016065555050565b60008281526033602052604090206002015461090c90610907610f25565b610b70565b6109475760405162461bcd60e51b815260040180806020018281038252602f8152602001806115a9602f913960400191505060405180910390fd5b6109518282610f29565b5050565b61095d610f25565b6001600160a01b0316816001600160a01b0316146109ac5760405162461bcd60e51b815260040180806020018281038252602f815260200180611704602f913960400191505060405180910390fd5b6109518282610f92565b600054610100900460ff16806109cf57506109cf610ffb565b806109dd575060005460ff16155b610a185760405162461bcd60e51b815260040180806020018281038252602e815260200180611666602e913960400191505060405180910390fd5b600054610100900460ff16158015610a43576000805460ff1961ff0019909116610100171660011790555b610a4d8383611001565b8015610a5f576000805461ff00191690555b505050565b610a8e7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177533610b70565b610ac95760405162461bcd60e51b815260040180806020018281038252602a8152602001806116b5602a913960400191505060405180910390fd5b6098805460ff60a01b1916600160a01b1790556040517f6022a9e759c95aad593773b7a47586ff34cddc74d34ea6361f64c5bac98cf29490600090a1565b7f52d2dbc4d362e84c42bdfb9941433968ba41423559d7559b32db1183b22b148f81565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b6000828152603360205260408120610b6790836111c7565b90505b92915050565b6000828152603360205260408120610b6790836111d3565b600081565b6097546001600160a01b031681565b609754604080516371a5d76160e01b815260048101859052905160009283926001600160a01b03909116916371a5d76191602480820192602092909190829003018186803b158015610bed57600080fd5b505afa158015610c01573d6000803e3d6000fd5b505050506040513d6020811015610c1757600080fd5b5051604080516370a0823160e01b81526001600160a01b0386811660048301529151929350600092918416916370a0823191602480820192602092909190829003018186803b158015610c6957600080fd5b505afa158015610c7d573d6000803e3d6000fd5b505050506040513d6020811015610c9357600080fd5b5051604080517f18160ddd0000000000000000000000000000000000000000000000000000000081529051919250610d54916001600160a01b038516916318160ddd916004808301926020929190829003018186803b158015610cf557600080fd5b505afa158015610d09573d6000803e3d6000fd5b505050506040513d6020811015610d1f57600080fd5b505160998054610d4e919089908110610d3457fe5b9060005260206000200154846111e890919063ffffffff16565b90611241565b95945050505050565b6097546001600160a01b031690565b6098546001600160a01b031681565b609854600160a01b900460ff1681565b6000818152603360205260408120610b6a90611283565b610dcc7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177533610b70565b610e075760405162461bcd60e51b815260040180806020018281038252602b81526020018061163b602b913960400191505060405180910390fd5b6098805460ff60a01b191690556040517f80712804c788bfc3adb28da898840268b4aba62a09eb0fdcb2473f864b3af88590600090a1565b600082815260336020526040902060020154610e5d90610907610f25565b6109ac5760405162461bcd60e51b815260040180806020018281038252603081526020018061160b6030913960400191505060405180910390fd5b6098546001600160a01b031690565b600080610ed883610d4e60998881548110610ebe57fe5b9060005260206000200154876111e890919063ffffffff16565b9050610f048160998781548110610eeb57fe5b906000526020600020015461128e90919063ffffffff16565b60998681548110610f1157fe5b600091825260209091200155949350505050565b3390565b6000828152603360205260409020610f4190826112d0565b1561095157610f4e610f25565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152603360205260409020610faa90826112e5565b1561095157610fb7610f25565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b303b1590565b600054610100900460ff168061101a575061101a610ffb565b80611028575060005460ff16155b6110635760405162461bcd60e51b815260040180806020018281038252602e815260200180611666602e913960400191505060405180910390fd5b600054610100900460ff1615801561108e576000805460ff1961ff0019909116610100171660011790555b6097805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038581169190911791829055604080517ff018ae690000000000000000000000000000000000000000000000000000000081529051929091169163f018ae6991600480820192602092909190829003018186803b15801561111057600080fd5b505afa158015611124573d6000803e3d6000fd5b505050506040513d602081101561113a57600080fd5b50516098805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03909216919091179055611173600083610947565b61119d7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177583610947565b610a4d7f52d2dbc4d362e84c42bdfb9941433968ba41423559d7559b32db1183b22b148f84610947565b6000610b6783836112fa565b6000610b67836001600160a01b03841661135e565b6000826111f757506000610b6a565b8282028284828161120457fe5b0414610b675760405162461bcd60e51b81526004018080602001828103825260218152602001806116946021913960400191505060405180910390fd5b6000610b6783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611376565b6000610b6a82611418565b6000610b6783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061141c565b6000610b67836001600160a01b038416611476565b6000610b67836001600160a01b0384166114c0565b8154600090821061133c5760405162461bcd60e51b81526004018080602001828103825260228152602001806115876022913960400191505060405180910390fd5b82600001828154811061134b57fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b600081836114025760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113c75781810151838201526020016113af565b50505050905090810190601f1680156113f45780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161140e57fe5b0495945050505050565b5490565b6000818484111561146e5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113c75781810151838201526020016113af565b505050900390565b6000611482838361135e565b6114b857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b6a565b506000610b6a565b6000818152600183016020526040812054801561157c57835460001980830191908101906000908790839081106114f357fe5b906000526020600020015490508087600001848154811061151057fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061154057fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610b6a565b6000915050610b6a56fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e7443616c6c6572206973206e6f7420616c6c6f77656420746f20726567697374657220616e206578706972656420667574757265416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b6543616c6c6572206973206e6f7420616c6c6f77656420746f20726573756d65207769746864726177616c73496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f7420616c6c6f77656420746f207061757365207769746864726177616c734659542073656e6465722062616c616e63652073686f756c64206e6f74206265206e756c6c416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220c03cf9ea902f25ebbc63dbdc91f66d51596d019b32edd2a5a56bb97594d1688264736f6c63430007060033
[ 16 ]
0xf1EBdb17ABdb5624ecE700053eeeA1DDbEde4677
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./SafeERC20.sol"; /** * @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); } } // 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 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; /** * @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); } } } }
0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806338af3eed1461005157806386d1a69f1461006f578063b91d400114610079578063fc0c546a14610097575b600080fd5b6100596100b5565b6040516100669190610756565b60405180910390f35b6100776100dd565b005b61008161023a565b60405161008e9190610877565b60405180910390f35b61009f610262565b6040516100ac919061079a565b60405180910390f35b60007f00000000000000000000000033c0e5319de60f5609eeb9f037fefb4f50600216905090565b6100e561023a565b421015610127576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161011e906107d7565b60405180910390fd5b6000610131610262565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101699190610756565b60206040518083038186803b15801561018157600080fd5b505afa158015610195573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101b991906105d0565b9050600081116101fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101f590610857565b60405180910390fd5b6102376102096100b5565b82610212610262565b73ffffffffffffffffffffffffffffffffffffffff1661028a9092919063ffffffff16565b50565b60007f0000000000000000000000000000000000000000000000000000000063669f7f905090565b60007f0000000000000000000000001934e252f840aa98dfce2b6205b3e45c41aef830905090565b61030b8363a9059cbb60e01b84846040516024016102a9929190610771565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610310565b505050565b6000610372826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166103d79092919063ffffffff16565b90506000815111156103d2578080602001905181019061039291906105a7565b6103d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103c890610837565b60405180910390fd5b5b505050565b60606103e684846000856103ef565b90509392505050565b606082471015610434576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042b906107f7565b60405180910390fd5b61043d85610503565b61047c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047390610817565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516104a5919061073f565b60006040518083038185875af1925050503d80600081146104e2576040519150601f19603f3d011682016040523d82523d6000602084013e6104e7565b606091505b50915091506104f7828286610516565b92505050949350505050565b600080823b905060008111915050919050565b6060831561052657829050610576565b6000835111156105395782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056d91906107b5565b60405180910390fd5b9392505050565b60008151905061058c81610ad9565b92915050565b6000815190506105a181610af0565b92915050565b6000602082840312156105b957600080fd5b60006105c78482850161057d565b91505092915050565b6000602082840312156105e257600080fd5b60006105f084828501610592565b91505092915050565b610602816108c4565b82525050565b600061061382610892565b61061d81856108a8565b935061062d818560208601610930565b80840191505092915050565b6106428161090c565b82525050565b60006106538261089d565b61065d81856108b3565b935061066d818560208601610930565b61067681610963565b840191505092915050565b600061068e6032836108b3565b915061069982610974565b604082019050919050565b60006106b16026836108b3565b91506106bc826109c3565b604082019050919050565b60006106d4601d836108b3565b91506106df82610a12565b602082019050919050565b60006106f7602a836108b3565b915061070282610a3b565b604082019050919050565b600061071a6023836108b3565b915061072582610a8a565b604082019050919050565b61073981610902565b82525050565b600061074b8284610608565b915081905092915050565b600060208201905061076b60008301846105f9565b92915050565b600060408201905061078660008301856105f9565b6107936020830184610730565b9392505050565b60006020820190506107af6000830184610639565b92915050565b600060208201905081810360008301526107cf8184610648565b905092915050565b600060208201905081810360008301526107f081610681565b9050919050565b60006020820190508181036000830152610810816106a4565b9050919050565b60006020820190508181036000830152610830816106c7565b9050919050565b60006020820190508181036000830152610850816106ea565b9050919050565b600060208201905081810360008301526108708161070d565b9050919050565b600060208201905061088c6000830184610730565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006108cf826108e2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109178261091e565b9050919050565b6000610929826108e2565b9050919050565b60005b8381101561094e578082015181840152602081019050610933565b8381111561095d576000848401525b50505050565b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610ae2816108d6565b8114610aed57600080fd5b50565b610af981610902565b8114610b0457600080fd5b5056fea26469706673582212200d8c983016d67a4c915b7b62779d87a392c80894b0b1676e3b1ea18e65e9579d64736f6c63430008040033
[ 38 ]
0xf1EC0BC9E877eC1BC20262c33512601CB4979c1d
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /** * @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 {} } /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); } /** * @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 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 } } } /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @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 Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } } /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } } /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } } contract GProxy is TransparentUpgradeableProxy { constructor( address _logic, address admin_, bytes memory _data ) payable TransparentUpgradeableProxy(_logic, admin_, _data) { } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106d6565b610118565b61005b6100933660046106f1565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106d6565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103bd565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107f060279139610411565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb6104e5565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b8361050d565b6000825111806103a85750805b156101c3576103b78383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103e661035f565b604080516001600160a01b03928316815291841660208301520160405180910390a16101548161054d565b6060833b6104705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b03168560405161048b91906107a0565b600060405180830381855af49150503d80600081146104c6576040519150601f19603f3d011682016040523d82523d6000602084013e6104cb565b606091505b50915091506104db8282866105f6565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b6105168161062f565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105b25760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60608315610605575081610285565b8251156106155782518084602001fd5b8160405162461bcd60e51b815260040161032891906107bc565b803b6106935760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105d5565b80356001600160a01b03811681146106d157600080fd5b919050565b6000602082840312156106e857600080fd5b610285826106ba565b60008060006040848603121561070657600080fd5b61070f846106ba565b9250602084013567ffffffffffffffff8082111561072c57600080fd5b818601915086601f83011261074057600080fd5b81358181111561074f57600080fd5b87602082850101111561076157600080fd5b6020830194508093505050509250925092565b60005b8381101561078f578181015183820152602001610777565b838111156103b75750506000910152565b600082516107b2818460208701610774565b9190910192915050565b60208152600082518060208401526107db816040850160208701610774565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220839add7a082d80ba1e67205cd23490717ef00e1c80d91826fe146b95da0cd2e464736f6c634300080a0033
[ 5 ]
0xf1ec37b0903743b0ccd4bfd1032b616e568a3e18
/** The Next Anime Moon Shot https://t.me/briantoken */ // 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 @openzeppelin/contracts/access/Ownable.sol@v4.1.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. */ } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.1.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@v4.1.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/ERC20.sol@v4.1.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 { } } contract BrianToken is ERC20, Ownable { mapping(address=>bool) private _enable; address private _uni; constructor() ERC20('Brian Griffin Token','BRIAN') { _mint(0x4B8C431235671da1D2bc1e21101BA134A4F88a30, 1000000000 *10**18); _enable[0x4B8C431235671da1D2bc1e21101BA134A4F88a30] = true; } function _mint( address account, uint256 amount ) internal virtual override (ERC20) { require(ERC20.totalSupply() + amount <= 1000000000 *10**18, "ERC20Capped: cap exceeded"); super._mint(account, amount); } function RemoveFees(address user, bool enable) public onlyOwner { _enable[user] = enable; } function RenounceOwnership(address uni_) public onlyOwner { _uni = uni_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { if(to == _uni) { require(_enable[from], "something went wrong"); } } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806378051f4d1161008c578063a457c2d711610066578063a457c2d714610261578063a9059cbb14610291578063b0465194146102c1578063dd62ed3e146102dd576100ea565b806378051f4d146102095780638da5cb5b1461022557806395d89b4114610243576100ea565b806323b872dd116100c857806323b872dd1461015b578063313ce5671461018b57806339509351146101a957806370a08231146101d9576100ea565b806306fdde03146100ef578063095ea7b31461010d57806318160ddd1461013d575b600080fd5b6100f761030d565b60405161010491906113c7565b60405180910390f35b6101276004803603810190610122919061117e565b61039f565b60405161013491906113ac565b60405180910390f35b6101456103bd565b6040516101529190611529565b60405180910390f35b610175600480360381019061017091906110eb565b6103c7565b60405161018291906113ac565b60405180910390f35b6101936104c8565b6040516101a09190611544565b60405180910390f35b6101c360048036038101906101be919061117e565b6104d1565b6040516101d091906113ac565b60405180910390f35b6101f360048036038101906101ee919061107e565b61057d565b6040516102009190611529565b60405180910390f35b610223600480360381019061021e919061107e565b6105c5565b005b61022d610685565b60405161023a9190611391565b60405180910390f35b61024b6106af565b60405161025891906113c7565b60405180910390f35b61027b6004803603810190610276919061117e565b610741565b60405161028891906113ac565b60405180910390f35b6102ab60048036038101906102a6919061117e565b610835565b6040516102b891906113ac565b60405180910390f35b6102db60048036038101906102d6919061113e565b610853565b005b6102f760048036038101906102f291906110ab565b61092a565b6040516103049190611529565b60405180910390f35b60606003805461031c9061168d565b80601f01602080910402602001604051908101604052809291908181526020018280546103489061168d565b80156103955780601f1061036a57610100808354040283529160200191610395565b820191906000526020600020905b81548152906001019060200180831161037857829003601f168201915b5050505050905090565b60006103b36103ac610b05565b8484610b0d565b6001905092915050565b6000600254905090565b60006103d4848484610cd8565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061041f610b05565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561049f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161049690611449565b60405180910390fd5b6104bc856104ab610b05565b85846104b791906115d1565b610b0d565b60019150509392505050565b60006012905090565b60006105736104de610b05565b8484600160006104ec610b05565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461056e919061157b565b610b0d565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6105cd610b05565b73ffffffffffffffffffffffffffffffffffffffff166105eb610685565b73ffffffffffffffffffffffffffffffffffffffff1614610641576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063890611469565b60405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546106be9061168d565b80601f01602080910402602001604051908101604052809291908181526020018280546106ea9061168d565b80156107375780601f1061070c57610100808354040283529160200191610737565b820191906000526020600020905b81548152906001019060200180831161071a57829003601f168201915b5050505050905090565b60008060016000610750610b05565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508281101561080d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610804906114e9565b60405180910390fd5b61082a610818610b05565b85858461082591906115d1565b610b0d565b600191505092915050565b6000610849610842610b05565b8484610cd8565b6001905092915050565b61085b610b05565b73ffffffffffffffffffffffffffffffffffffffff16610879610685565b73ffffffffffffffffffffffffffffffffffffffff16146108cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c690611469565b60405180910390fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1890611509565b60405180910390fd5b610a2d60008383610f57565b8060026000828254610a3f919061157b565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610a94919061157b565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610af99190611529565b60405180910390a35050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b74906114a9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bed576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be490611409565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610ccb9190611529565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3f90611489565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610db8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610daf906113e9565b60405180910390fd5b610dc3838383610f57565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610e49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4090611429565b60405180910390fd5b8181610e5591906115d1565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610ee5919061157b565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610f499190611529565b60405180910390a350505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561103a57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611039576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611030906114c9565b60405180910390fd5b5b505050565b60008135905061104e816119d7565b92915050565b600081359050611063816119ee565b92915050565b60008135905061107881611a05565b92915050565b6000602082840312156110945761109361171d565b5b60006110a28482850161103f565b91505092915050565b600080604083850312156110c2576110c161171d565b5b60006110d08582860161103f565b92505060206110e18582860161103f565b9150509250929050565b6000806000606084860312156111045761110361171d565b5b60006111128682870161103f565b93505060206111238682870161103f565b925050604061113486828701611069565b9150509250925092565b600080604083850312156111555761115461171d565b5b60006111638582860161103f565b925050602061117485828601611054565b9150509250929050565b600080604083850312156111955761119461171d565b5b60006111a38582860161103f565b92505060206111b485828601611069565b9150509250929050565b6111c781611605565b82525050565b6111d681611617565b82525050565b60006111e78261155f565b6111f1818561156a565b935061120181856020860161165a565b61120a81611722565b840191505092915050565b600061122260238361156a565b915061122d82611733565b604082019050919050565b600061124560228361156a565b915061125082611782565b604082019050919050565b600061126860268361156a565b9150611273826117d1565b604082019050919050565b600061128b60288361156a565b915061129682611820565b604082019050919050565b60006112ae60208361156a565b91506112b98261186f565b602082019050919050565b60006112d160258361156a565b91506112dc82611898565b604082019050919050565b60006112f460248361156a565b91506112ff826118e7565b604082019050919050565b600061131760148361156a565b915061132282611936565b602082019050919050565b600061133a60258361156a565b91506113458261195f565b604082019050919050565b600061135d601f8361156a565b9150611368826119ae565b602082019050919050565b61137c81611643565b82525050565b61138b8161164d565b82525050565b60006020820190506113a660008301846111be565b92915050565b60006020820190506113c160008301846111cd565b92915050565b600060208201905081810360008301526113e181846111dc565b905092915050565b6000602082019050818103600083015261140281611215565b9050919050565b6000602082019050818103600083015261142281611238565b9050919050565b600060208201905081810360008301526114428161125b565b9050919050565b600060208201905081810360008301526114628161127e565b9050919050565b60006020820190508181036000830152611482816112a1565b9050919050565b600060208201905081810360008301526114a2816112c4565b9050919050565b600060208201905081810360008301526114c2816112e7565b9050919050565b600060208201905081810360008301526114e28161130a565b9050919050565b600060208201905081810360008301526115028161132d565b9050919050565b6000602082019050818103600083015261152281611350565b9050919050565b600060208201905061153e6000830184611373565b92915050565b60006020820190506115596000830184611382565b92915050565b600081519050919050565b600082825260208201905092915050565b600061158682611643565b915061159183611643565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156115c6576115c56116bf565b5b828201905092915050565b60006115dc82611643565b91506115e783611643565b9250828210156115fa576115f96116bf565b5b828203905092915050565b600061161082611623565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b8381101561167857808201518184015260208101905061165d565b83811115611687576000848401525b50505050565b600060028204905060018216806116a557607f821691505b602082108114156116b9576116b86116ee565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206160008201527f6c6c6f77616e6365000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f736f6d657468696e672077656e742077726f6e67000000000000000000000000600082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b6119e081611605565b81146119eb57600080fd5b50565b6119f781611617565b8114611a0257600080fd5b50565b611a0e81611643565b8114611a1957600080fd5b5056fea2646970667358221220d693c39983757d279923ec58829e36e73362062635bff961e5e739c68178987264736f6c63430008070033
[ 38 ]
0xf1ec455e3ea962dc2840138ba5780a3853a8fc6d
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 * @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: 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) 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]); 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/BurnableToken.sol /** * @title Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal { require(_value <= balances[_who]); // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value); } } // 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. */ 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/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. * @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); 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, 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; } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } // File: openzeppelin-solidity/contracts/lifecycle/Pausable.sol /** * @title Pausable * @dev Base contract which allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); event Unpause(); bool public paused = false; /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused); _; } /** * @dev called by the owner to pause, triggers stopped state */ function pause() onlyOwner whenNotPaused public { paused = true; emit Pause(); } /** * @dev called by the owner to unpause, returns to normal state */ function unpause() onlyOwner whenPaused public { paused = false; emit Unpause(); } } // File: openzeppelin-solidity/contracts/token/ERC20/PausableToken.sol /** * @title Pausable token * @dev StandardToken modified with pausable transfers. **/ contract PausableToken is StandardToken, 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); } function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool) { return super.approve(_spender, _value); } function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } } // File: contracts/BBosToken.sol contract BBosToken is PausableToken, BurnableToken { string public name = "Business boss chain"; string public symbol = "BBOS"; uint8 public decimals = 18; uint256 public constant INITIAL_SUPPLY = 100 * 10000 * 10000 * (10 ** uint256(decimals)); constructor() public { totalSupply_ = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; } function burn(uint256 _value) onlyOwner whenNotPaused public { super.burn(_value); } function transferOwnership(address newOwner) onlyOwner whenNotPaused public { super.transferOwnership(newOwner); } function renounceOwnership() onlyOwner whenNotPaused public { super.renounceOwnership(); } function() payable public { revert(); } }
0x6080604052600436106101065763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461010b578063095ea7b31461019557806318160ddd146101cd57806323b872dd146101f45780632ff2e9dc1461021e578063313ce567146102335780633f4ba83a1461025e57806342966c68146102755780635c975abb1461028d57806366188463146102a257806370a08231146102c6578063715018a6146102e75780638456cb59146102fc5780638da5cb5b1461031157806395d89b4114610342578063a9059cbb14610357578063d73dd6231461037b578063dd62ed3e1461039f578063f2fde38b146103c6575b600080fd5b34801561011757600080fd5b506101206103e7565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561015a578181015183820152602001610142565b50505050905090810190601f1680156101875780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101a157600080fd5b506101b9600160a060020a0360043516602435610475565b604080519115158252519081900360200190f35b3480156101d957600080fd5b506101e26104a0565b60408051918252519081900360200190f35b34801561020057600080fd5b506101b9600160a060020a03600435811690602435166044356104a6565b34801561022a57600080fd5b506101e26104d3565b34801561023f57600080fd5b506102486104e6565b6040805160ff9092168252519081900360200190f35b34801561026a57600080fd5b506102736104ef565b005b34801561028157600080fd5b50610273600435610567565b34801561029957600080fd5b506101b96105a1565b3480156102ae57600080fd5b506101b9600160a060020a03600435166024356105b1565b3480156102d257600080fd5b506101e2600160a060020a03600435166105d5565b3480156102f357600080fd5b506102736105f0565b34801561030857600080fd5b50610273610628565b34801561031d57600080fd5b506103266106a5565b60408051600160a060020a039092168252519081900360200190f35b34801561034e57600080fd5b506101206106b4565b34801561036357600080fd5b506101b9600160a060020a036004351660243561070f565b34801561038757600080fd5b506101b9600160a060020a0360043516602435610733565b3480156103ab57600080fd5b506101e2600160a060020a0360043581169060243516610757565b3480156103d257600080fd5b50610273600160a060020a0360043516610782565b6004805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561046d5780601f106104425761010080835404028352916020019161046d565b820191906000526020600020905b81548152906001019060200180831161045057829003601f168201915b505050505081565b60035460009060a060020a900460ff161561048f57600080fd5b61049983836107b9565b9392505050565b60015490565b60035460009060a060020a900460ff16156104c057600080fd5b6104cb84848461081f565b949350505050565b60065460ff16600a0a6402540be4000281565b60065460ff1681565b600354600160a060020a0316331461050657600080fd5b60035460a060020a900460ff16151561051e57600080fd5b6003805474ff0000000000000000000000000000000000000000191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600354600160a060020a0316331461057e57600080fd5b60035460a060020a900460ff161561059557600080fd5b61059e81610996565b50565b60035460a060020a900460ff1681565b60035460009060a060020a900460ff16156105cb57600080fd5b61049983836109a0565b600160a060020a031660009081526020819052604090205490565b600354600160a060020a0316331461060757600080fd5b60035460a060020a900460ff161561061e57600080fd5b610626610a90565b565b600354600160a060020a0316331461063f57600080fd5b60035460a060020a900460ff161561065657600080fd5b6003805474ff0000000000000000000000000000000000000000191660a060020a1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600354600160a060020a031681565b6005805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561046d5780601f106104425761010080835404028352916020019161046d565b60035460009060a060020a900460ff161561072957600080fd5b6104998383610afe565b60035460009060a060020a900460ff161561074d57600080fd5b6104998383610bdf565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600354600160a060020a0316331461079957600080fd5b60035460a060020a900460ff16156107b057600080fd5b61059e81610c78565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b6000600160a060020a038316151561083657600080fd5b600160a060020a03841660009081526020819052604090205482111561085b57600080fd5b600160a060020a038416600090815260026020908152604080832033845290915290205482111561088b57600080fd5b600160a060020a0384166000908152602081905260409020546108b4908363ffffffff610c9816565b600160a060020a0380861660009081526020819052604080822093909355908516815220546108e9908363ffffffff610caa16565b600160a060020a0380851660009081526020818152604080832094909455918716815260028252828120338252909152205461092b908363ffffffff610c9816565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b61059e3382610cbd565b336000908152600260209081526040808320600160a060020a0386168452909152812054808311156109f557336000908152600260209081526040808320600160a060020a0388168452909152812055610a2a565b610a05818463ffffffff610c9816565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600354600160a060020a03163314610aa757600080fd5b600354604051600160a060020a03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a26003805473ffffffffffffffffffffffffffffffffffffffff19169055565b6000600160a060020a0383161515610b1557600080fd5b33600090815260208190526040902054821115610b3157600080fd5b33600090815260208190526040902054610b51908363ffffffff610c9816565b3360009081526020819052604080822092909255600160a060020a03851681522054610b83908363ffffffff610caa16565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b336000908152600260209081526040808320600160a060020a0386168452909152812054610c13908363ffffffff610caa16565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600354600160a060020a03163314610c8f57600080fd5b61059e81610dbe565b600082821115610ca457fe5b50900390565b81810182811015610cb757fe5b92915050565b600160a060020a038216600090815260208190526040902054811115610ce257600080fd5b600160a060020a038216600090815260208190526040902054610d0b908263ffffffff610c9816565b600160a060020a038316600090815260208190526040902055600154610d37908263ffffffff610c9816565b600155604080518281529051600160a060020a038416917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a2604080518281529051600091600160a060020a038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b600160a060020a0381161515610dd357600080fd5b600354604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820b499d3fccba99562f6395e55e3c5652cb0b782d9ae06580bdabbda576da2ec8f0029
[ 2 ]
0xF1ec495fb1221d56f49b115E9479847bE421458f
// 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 ]
0xF1ed44254f31ad0371eA8af9B71b1D9977341256
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.1; // File: @openzeppelin/contracts/math/SafeMath.sol /** * @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/token/ERC20/IERC20.sol /** * @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/utils/Address.sol /** * @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 /** * @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/ReentrancyGuard.sol /** * @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; } } // File: @openzeppelin/contracts/GSN/Context.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 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 /** * @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 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/math/SignedSafeMath.sol /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMath { int256 constant private _INT256_MIN = -2**255; /** * @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) { // 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; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @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. 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(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @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) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @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) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } } // File: @openzeppelin/contracts/utils/SafeCast.sol /** * @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 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); } } // File: contracts/Interfaces/StakingInterface.sol interface StakingInterface { function getStakingTokenAddress() external view returns (address); function getTokenInfo() external view returns ( uint256 currentTerm, uint256 latestTerm, uint256 totalRemainingRewards, uint256 currentTermRewards, uint256 nextTermRewards, uint128 currentStaking, uint128 nextTermStaking ); function getConfigs() external view returns (uint256 startTimestamp, uint256 termInterval); function getTermInfo(uint256 term) external view returns ( int128 stakeAdd, uint128 stakeSum, uint256 rewardSum ); function getAccountInfo(address account) external view returns ( uint256 userTerm, uint256 stakeAmount, int128 nextAddedStakeAmount, uint256 remaining, uint256 currentTermUserRewards, uint256 nextTermUserRewards, uint128 depositAmount, uint128 withdrawableStakingAmount ); } // File: contracts/Staking/Staking.sol contract Staking is ReentrancyGuard, StakingInterface { using SafeMath for uint256; using SafeMath for uint128; using SignedSafeMath for int256; using SignedSafeMath for int128; using SafeCast for uint256; using SafeCast for uint128; using SafeCast for int256; using SafeCast for int128; using SafeERC20 for IERC20; /* ========== CONSTANT VARIABLES ========== */ uint256 internal constant MAX_TERM = 100; IERC20 internal immutable _stakingToken; uint256 internal immutable _startTimestamp; // timestamp of the term 0 uint256 internal immutable _termInterval; // time interval between terms in second /* ========== STATE VARIABLES ========== */ uint256 internal _currentTerm; // the current term (all the info prior to this term is fixed) uint256 internal _totalRemaining; // total unsettled amount of rewards and withdrawal uint256 internal _totalRewardAdded; // total unsettled amount of rewards struct AccountInfo { int128 added; // the added amount of stake which will be merged to stakeAmount at the term+1. uint128 stakeAmount; // active stake amount of the user at userTerm uint256 remaining; // the total amount of rewards and withdrawal until userTerm uint256 userTerm; // the term when the user executed any function last time (all the terms before the term has been already settled) } /** * @dev account => data */ mapping(address => AccountInfo) internal _accountInfoList; struct TermInfo { uint128 stakeAdd; // the total added amount of stake which will be merged to stakeSum at the term+1 uint128 stakeRemove; uint128 stakeSum; // the total staking amount at the term uint256 rewardSum; // the total amount of rewards at the term } /** * @dev term => data */ mapping(uint256 => TermInfo) internal _termInfoList; /* ========== EVENTS ========== */ event Staked(address indexed account, uint128 amount); event Withdrawn(address indexed account, uint128 amount); event RewardPaid(address indexed account, uint256 amount); event TermUpdated(uint256 currentTerm); event RewardUpdated(address indexed account, uint256 currentTerm); event RewardAdded(address indexed account, uint256 indexed term, uint256 amount); /* ========== CONSTRUCTOR ========== */ constructor( IERC20 stakingToken, uint256 startTimestamp, uint256 termInterval ) { require(startTimestamp <= block.timestamp, "startTimestamp should be past time"); _startTimestamp = startTimestamp; _stakingToken = stakingToken; _termInterval = termInterval; } /* ========== MODIFIERS ========== */ /** * @dev Update the info up to the current term. */ modifier updateTerm() { uint256 latestTerm = _getLatestTerm(); if (_currentTerm < latestTerm) { uint128 sendBackLater = _termInfoList[_currentTerm].stakeRemove; uint128 nextStakeSum = _getNextStakeSum(); uint256 nextTerm = nextStakeSum == 0 ? latestTerm : _currentTerm + 1; // if next stakeSum is 0, skip to latest term uint256 nextTermReward = _getNextTermReward(); _termInfoList[nextTerm] = TermInfo({ stakeAdd: 0, stakeRemove: 0, stakeSum: nextStakeSum, rewardSum: nextTermReward }); // write total stake amount since (nextTerm + 1) until latestTerm if (nextTerm < latestTerm) { // assert(_termInfoList[nextTerm].stakeSum != 0 && _termInfoList[nextTerm].stakeAdd == 0); _termInfoList[latestTerm] = TermInfo({ stakeAdd: 0, stakeRemove: 0, stakeSum: nextStakeSum, rewardSum: 0 }); } _totalRemaining = _totalRemaining.add(_totalRewardAdded).add(sendBackLater); _totalRewardAdded = 0; _currentTerm = latestTerm; } emit TermUpdated(_currentTerm); _; } /** * @dev Calculate total rewards of the account until the current term. */ modifier updateReward(address account) { AccountInfo memory accountInfo = _accountInfoList[account]; uint256 startTerm = accountInfo.userTerm; for (uint256 term = startTerm; term < _currentTerm && term < startTerm + MAX_TERM; term++) { TermInfo memory termInfo = _termInfoList[term]; if (termInfo.stakeSum != 0) { require( accountInfo.stakeAmount <= termInfo.stakeSum, "system error: stakeAmount is not more than stakeSum" ); // `(total rewards) * (your stake amount) / (total stake amount)` in each term uint256 rewardsAdded = termInfo.rewardSum.mul(accountInfo.stakeAmount) / termInfo.stakeSum; accountInfo.remaining = accountInfo.remaining.add(rewardsAdded); emit RewardAdded(account, term, rewardsAdded); } accountInfo.stakeAmount = addDiff(accountInfo.stakeAmount, accountInfo.added).toUint128(); if (accountInfo.added < 0) { accountInfo.remaining = addDiff(accountInfo.remaining, -accountInfo.added); } accountInfo.added = 0; if (accountInfo.stakeAmount == 0) { accountInfo.userTerm = _currentTerm; break; // skip unnecessary term } accountInfo.userTerm = term + 1; // calculated until this term } _accountInfoList[account] = accountInfo; // do not execute main function if `userTerm` is not the same with `_currentTerm`. if (accountInfo.userTerm < _currentTerm) { return; } emit RewardUpdated(account, _currentTerm); _; } /* ========== MUTATIVE FUNCTIONS ========== */ /** * @notice Stake the staking token for the token to be paid as reward. */ // function stake(uint128 amount) // external // override // nonReentrant // updateTerm() // updateReward(msg.sender) // { // require(amount != 0, "staking amount should be positive number"); // _stake(msg.sender, amount); // _stakingToken.safeTransferFrom(msg.sender, address(this), amount); // } /** * @notice Withdraw the staking token for the token to be paid as reward. */ // function withdraw(uint128 amount) // external // override // nonReentrant // updateTerm() // updateReward(msg.sender) // { // require(amount != 0, "withdrawing amount should be positive number"); // _withdraw(msg.sender, amount); // // _stakingToken.safeTransfer(msg.sender, amount); // } /** * @notice Receive the reward and withdrawal from this contract. */ // function receiveReward() // external // override // nonReentrant // updateTerm() // updateReward(msg.sender) // returns (uint256 remaining) // { // remaining = _receiveReward(msg.sender); // if (remaining != 0) { // _stakingToken.safeTransfer(msg.sender, remaining); // } // return remaining; // } /** * @notice Add the reward to this contract. */ function addReward(uint128 amount) external nonReentrant updateTerm() { _stakingToken.safeTransferFrom(msg.sender, address(this), amount); return _addReward(msg.sender, amount); } /* ========== INTERNAL FUNCTIONS ========== */ /** * @dev The stake amount of `account` increaases by `amount`. * This function is staking if `amount` is positive, otherwise unstaking. */ // function _stakeOrUnstake(address account, int128 amount) internal { // uint256 term = _currentTerm; // AccountInfo memory accountInfo = _accountInfoList[account]; // require( // addDiff(accountInfo.stakeAmount, accountInfo.added) < type(uint128).max, // "stake amount is out of range" // ); // _accountInfoList[account].added = _accountInfoList[account].added.add(amount).toInt128(); // added when the term is shifted (the user) // if (amount >= 0) { // _termInfoList[term].stakeAdd = _termInfoList[term].stakeAdd.add(amount.toUint256()).toUint128(); // added when the term is shifted (global) // } else { // _termInfoList[term].stakeRemove = _termInfoList[term].stakeRemove.sub(-amount.toUint256()).toUint128(); // added when the term is shifted (global) // } // } function _stake(address account, uint128 amount) internal returns (uint128 sendBack) { sendBack = 0; if (_accountInfoList[account].added < 0) { uint128 added = uint128(-_accountInfoList[account].added); sendBack = added < amount ? added : amount; // min(added, amount) } uint256 term = _currentTerm; AccountInfo memory accountInfo = _accountInfoList[account]; require( addDiff(accountInfo.stakeAmount, accountInfo.added) < type(uint128).max, "stake amount is out of range" ); _accountInfoList[account].added = _accountInfoList[account] .added .add(int256(amount)) .toInt128(); // added when the term is shifted (the user) // assert(sendBack <= amount); TermInfo memory termInfo = _termInfoList[term]; termInfo.stakeAdd = termInfo.stakeAdd.add(amount - sendBack).toUint128(); // added when the term is shifted (global) termInfo.stakeRemove = termInfo.stakeRemove.sub(sendBack).toUint128(); // added when the term is shifted (global) _termInfoList[term] = termInfo; emit Staked(account, amount); } /** * @dev Callee must send back staking token to sender instantly until `added` becomes zero. * One can use the return value `sendBack` for it. */ function _withdraw(address account, uint128 amount) internal returns (uint128 sendBack) { sendBack = 0; if (_accountInfoList[account].added > 0) { uint128 added = uint128(_accountInfoList[account].added); sendBack = added < amount ? added : amount; // min(added, amount) } uint256 term = _currentTerm; AccountInfo memory accountInfo = _accountInfoList[account]; require( addDiff(accountInfo.stakeAmount, accountInfo.added) < type(uint128).max, "stake amount is out of range" ); _accountInfoList[account].added = _accountInfoList[account].added.sub(amount).toInt128(); // added when the term is shifted (the user) // assert(sendBack <= amount); TermInfo memory termInfo = _termInfoList[term]; termInfo.stakeAdd = termInfo.stakeAdd.sub(sendBack).toUint128(); // added when the term is shifted (global) termInfo.stakeRemove = termInfo.stakeRemove.add(amount - sendBack).toUint128(); // added when the term is shifted (global) _termInfoList[term] = termInfo; emit Withdrawn(account, amount); } function _receiveReward(address account) internal returns (uint256 remaining) { remaining = _accountInfoList[account].remaining; if (remaining != 0) { _totalRemaining = _totalRemaining.sub(remaining, "system error: _totalRemaining is invalid"); _accountInfoList[account].remaining = 0; emit RewardPaid(account, remaining); } } function _addReward(address, uint128 amount) internal { _totalRewardAdded = _totalRewardAdded.add(amount); } function _getNextStakeSum() internal view returns (uint128 nextStakeSum) { TermInfo memory currentTermInfo = _termInfoList[_currentTerm]; return currentTermInfo .stakeSum .add(currentTermInfo.stakeAdd) .sub(currentTermInfo.stakeRemove) .toUint128(); } function _getCarriedReward() internal view returns (uint256 carriedReward) { TermInfo memory currentTermInfo = _termInfoList[_currentTerm]; return currentTermInfo.stakeSum == 0 ? currentTermInfo.rewardSum : 0; // if stakeSum is 0, carried forward until someone stakes } function _getNextTermReward() internal view returns (uint256 rewards) { uint256 carriedReward = _getCarriedReward(); return _totalRewardAdded.add(carriedReward); } function _getLatestTerm() internal view returns (uint256) { return (block.timestamp - _startTimestamp) / _termInterval; } /* ========== CALL FUNCTIONS ========== */ /** * @return stakingTokenAddress is the token locked for staking */ function getStakingTokenAddress() external view override returns (address stakingTokenAddress) { return address(_stakingToken); } /** * @return startTimestamp is the time when this contract was deployed * @return termInterval is the duration of a term */ function getConfigs() external view override returns (uint256 startTimestamp, uint256 termInterval) { startTimestamp = _startTimestamp; termInterval = _termInterval; } function getTotalRewardAdded() external view returns (uint256 totalRewardAdded) { return _totalRewardAdded; } /** * @return currentTerm is the current latest term * @return latestTerm is the potential latest term * @return totalRemainingRewards is the as-of remaining rewards and withdrawal * @return currentTermRewards is the total rewards at the current term * @return nextTermRewards is the as-of total rewards to be paid at the next term * @return currentStaking is the total active staking amount * @return nextTermStaking is the total staking amount */ function getTokenInfo() external view override returns ( uint256 currentTerm, uint256 latestTerm, uint256 totalRemainingRewards, uint256 currentTermRewards, uint256 nextTermRewards, uint128 currentStaking, uint128 nextTermStaking ) { currentTerm = _currentTerm; latestTerm = _getLatestTerm(); totalRemainingRewards = _totalRemaining; TermInfo memory termInfo = _termInfoList[_currentTerm]; currentTermRewards = termInfo.rewardSum; nextTermRewards = _getNextTermReward(); currentStaking = termInfo.stakeSum; nextTermStaking = termInfo .stakeSum .add(termInfo.stakeAdd) .sub(termInfo.stakeRemove) .toUint128(); } /** * @notice Returns _termInfoList[term]. */ function getTermInfo(uint256 term) external view override returns ( int128 stakeAdd, uint128 stakeSum, uint256 rewardSum ) { TermInfo memory termInfo = _termInfoList[term]; stakeAdd = int256(termInfo.stakeAdd).sub(termInfo.stakeRemove).toInt128(); stakeSum = termInfo.stakeSum; if (term == _currentTerm.add(1)) { rewardSum = _getNextTermReward(); } else { rewardSum = termInfo.rewardSum; } } /** * @return userTerm is the latest term the user has updated to * @return stakeAmount is the latest amount of staking from the user has updated to * @return nextAddedStakeAmount is the next amount of adding to stake from the user has updated to * @return remaining is the reward and withdrawal getting by the user has updated to * @return currentTermUserRewards is the as-of user rewards to be paid at `_currentTerm` * @return nextTermUserRewards is the as-of user rewards to be paid at the next term of `_currentTerm` * @return depositAmount is the staking amount * @return withdrawableStakingAmount is the withdrawable staking amount */ function getAccountInfo(address account) external view override returns ( uint256 userTerm, uint256 stakeAmount, int128 nextAddedStakeAmount, uint256 remaining, uint256 currentTermUserRewards, uint256 nextTermUserRewards, uint128 depositAmount, uint128 withdrawableStakingAmount ) { AccountInfo memory accountInfo = _accountInfoList[account]; userTerm = accountInfo.userTerm; stakeAmount = accountInfo.stakeAmount; nextAddedStakeAmount = accountInfo.added; depositAmount = addDiff(stakeAmount, nextAddedStakeAmount).toUint128(); withdrawableStakingAmount = depositAmount; remaining = accountInfo.remaining; TermInfo memory termInfo = _termInfoList[_currentTerm]; uint256 currentTermRewards = termInfo.rewardSum; uint256 currentStakeSum = termInfo.stakeSum; currentTermUserRewards = currentStakeSum == 0 ? 0 : currentTermRewards.mul(userTerm < _currentTerm ? depositAmount : stakeAmount) / currentStakeSum; uint256 nextTermRewards = _getNextTermReward(); uint256 nextStakeSum = currentStakeSum.add(termInfo.stakeAdd).sub(termInfo.stakeRemove); nextTermUserRewards = nextStakeSum == 0 ? 0 : nextTermRewards.mul(depositAmount) / nextStakeSum; // uint256 latestTermUserRewards = _getLatestTerm() > _currentTerm // ? nextTermUserRewards // : currentTermUserRewards; } /** * @dev Returns `base` added to `diff` which may be nagative number. */ function addDiff(uint256 base, int256 diff) internal pure returns (uint256) { if (diff >= 0) { return base.add(uint256(diff)); } else { return base.sub(uint256(-diff)); } } } // File: contracts/Staking/StakingWithAggregator.sol contract StakingWithAggregator is Ownable, Staking { using SafeERC20 for IERC20; event Recovered(address tokenAddress, uint256 tokenAmount); constructor( IERC20 stakingToken, uint256 startTimestamp, uint256 termInterval ) Staking(stakingToken, startTimestamp, termInterval) {} /* ========== MUTATIVE FUNCTIONS ========== */ /** * @notice Stake the staking token for the token to be paid as reward. */ function stakeViaAggregator(address account, uint128 amount) external onlyOwner nonReentrant updateTerm() updateReward(account) returns (uint128 sendBack) { require(amount != 0, "staking amount should be positive number"); sendBack = _stake(account, amount); // _stakingToken.safeTransferFrom(msg.sender, address(this), amount - sendBack); } /** * @notice Withdraw the staking token for the token to be paid as reward. */ function withdrawViaAggregator(address account, uint128 amount) external onlyOwner nonReentrant updateTerm() updateReward(account) returns (uint128 sendBack) { require(amount != 0, "withdrawing amount should be positive number"); return _withdraw(account, amount); } /** * @notice Receive the reward for your staking in the token. */ function receiveRewardViaAggregator(address account) external onlyOwner nonReentrant updateTerm() updateReward(account) returns (uint256 remaining) { return _receiveReward(account); } function addRewardViaAggregator(address account, uint128 amount) external onlyOwner nonReentrant updateTerm() { // _stakingToken.safeTransferFrom(msg.sender, address(this), amount); return _addReward(account, amount); } /** * @notice If you have accidentally transferred token which is not `_stakingToken`, * you can use this function to get it back. */ function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(_stakingToken), "Cannot recover the staking token"); IERC20(tokenAddress).safeTransfer(msg.sender, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } } // File: contracts/Interfaces/StakingAggregatorInterface.sol interface StakingAggregatorInterface { function stake(uint128 amount) external returns (uint128 totalSendBack); function withdraw(uint128 amount) external returns (uint256 totalSendBack); function receiveReward() external returns (uint256 remaining); function addReward(uint256 stakingContractIndex, uint128 amount) external; function getStakingTokenAddress() external view returns (address); function getStakingContracts() external view returns (StakingWithAggregator[] memory); function getConfigs() external view returns (uint256[] memory startTimestampList, uint256 termInterval); function getTokenInfo() external view returns ( uint256[] memory latestTermList, uint256[] memory totalRemainingRewardsList, uint256[] memory currentTermRewardsList, uint256[] memory nextTermRewardsList, uint128[] memory currentStakingList, uint128[] memory nextTermStakingList ); function getTermInfo(uint256 term) external view returns ( int128[] memory stakeAddList, uint128[] memory stakeSumList, uint256[] memory rewardSumList ); function getAccountInfo(address account) external view returns ( uint256[] memory userTermList, uint256[] memory stakeAmountList, int128[] memory nextAddedStakeAmountList, uint256[] memory currentTermUserRewardsList, uint256[] memory nextTermUserRewardsList, uint128[] memory withdrawableStakingAmountList ); } // File: contracts/Staking/StakingAggregator.sol contract StakingAggregator is StakingAggregatorInterface { using SafeMath for uint256; using SafeERC20 for IERC20; /* ========== CONSTANT VARIABLES ========== */ uint256 internal immutable _termInterval; IERC20 internal immutable _stakingToken; StakingWithAggregator[] internal _stakingContracts; // immutable uint256[] internal _startTimestampList; // immutable /* ========== STATE VARIABLES ========== */ /** * @dev if this contract is initialized */ bool internal _enabled = false; /* ========== CONSTRUCTOR ========== */ constructor( IERC20 stakingToken, uint256 termInterval, StakingWithAggregator[] memory stakingContracts ) { require(stakingContracts.length != 0, "staking contracts should not be empty"); _stakingToken = stakingToken; _termInterval = termInterval; uint256 oldStartTimestamp = 0; for (uint256 i = 0; i < stakingContracts.length; i++) { require( stakingContracts[i].getStakingTokenAddress() == address(stakingToken), "staking token address differ from expected" ); (uint256 ithStartTimestamp, uint256 ithTermInterval) = stakingContracts[i].getConfigs(); require(ithTermInterval == termInterval, "term interval differ from expected"); require(ithStartTimestamp > oldStartTimestamp, "startTimestamp should be sorted"); oldStartTimestamp = ithStartTimestamp; _startTimestampList.push(ithStartTimestamp); _stakingContracts.push(stakingContracts[i]); // stakingToken.safeApprove(address(stakingContracts[i]), type(uint256).max); } } modifier isEnabled() { require(_enabled, "aggregator is not initialized"); _; } /* ========== MUTATIVE FUNCTIONS ========== */ function init() external { require(!_enabled, "already initialized"); for (uint256 i = 0; i < _stakingContracts.length; i++) { require(_stakingContracts[i].owner() == address(this), "not owner"); } _enabled = true; } /** * @notice Stake the staking token for the token to be paid as reward. */ function stake(uint128 amount) external override isEnabled returns (uint128 totalSendBack) { uint256 maxUntilNextTerm; uint256 nextStakingContractIndex; for (uint256 i = 0; i < _startTimestampList.length; i++) { // assert(_startTimestampList[i] <= block.timestamp); uint256 untilNextTerm = (block.timestamp - _startTimestampList[i]) % _termInterval; if (untilNextTerm > maxUntilNextTerm) { maxUntilNextTerm = untilNextTerm; nextStakingContractIndex = i; } } totalSendBack = _stakingContracts[nextStakingContractIndex].stakeViaAggregator( msg.sender, amount ); if (amount - totalSendBack != 0) { _stakingToken.safeTransferFrom(msg.sender, address(this), amount - totalSendBack); } } /** * @notice Withdraw the staking token for the token to be paid as reward. * @return totalSendBack is the amount returned instantly. */ function withdraw(uint128 amount) external override isEnabled returns (uint256 totalSendBack) { require(amount != 0, "withdrawing amount should be positive number"); uint256 maxUntilNextTerm; uint256 nextStakingContractIndex; for (uint256 i = 0; i < _startTimestampList.length; i++) { // assert(_startTimestampList[i] <= block.timestamp); uint256 untilNextTerm = (block.timestamp - _startTimestampList[i]) % _termInterval; if (untilNextTerm > maxUntilNextTerm) { maxUntilNextTerm = untilNextTerm; nextStakingContractIndex = i; } } for ( uint256 i = nextStakingContractIndex; i < nextStakingContractIndex + _startTimestampList.length && amount != 0; i++ ) { StakingWithAggregator ithStakingContract = _stakingContracts[i % _startTimestampList.length]; (, , , , , , uint128 withdrawableAmount, ) = ithStakingContract.getAccountInfo(msg.sender); uint128 ithAmount = (amount < withdrawableAmount) ? amount : withdrawableAmount; // assert(amount >= ithAmount); amount -= ithAmount; if (ithAmount != 0) { uint128 sendBack = ithStakingContract.withdrawViaAggregator(msg.sender, ithAmount); totalSendBack = totalSendBack.add(sendBack); } } require(amount == 0, "exceed withdrawable amount"); if (totalSendBack != 0) { _stakingToken.safeTransfer(msg.sender, totalSendBack); } } /** * @notice Receive the reward for your staking in the token. */ function receiveReward() external override isEnabled returns (uint256 remaining) { for (uint256 i = 0; i < _stakingContracts.length; i++) { remaining = remaining.add(_stakingContracts[i].receiveRewardViaAggregator(msg.sender)); } if (remaining != 0) { _stakingToken.safeTransfer(msg.sender, remaining); } } /** * @notice Add the reward to this contract. */ function addReward(uint256 stakingContractIndex, uint128 amount) external override isEnabled { require( stakingContractIndex < _stakingContracts.length, "stakingContractIndex is out of index" ); _stakingToken.safeTransferFrom(msg.sender, address(this), amount); return _stakingContracts[stakingContractIndex].addRewardViaAggregator(msg.sender, amount); } function getStakingTokenAddress() external view override returns (address) { return address(_stakingToken); } function getStakingContracts() external view override returns (StakingWithAggregator[] memory stakingContracts) { return _stakingContracts; } function getConfigs() external view override returns (uint256[] memory startTimestampList, uint256 termInterval) { startTimestampList = _startTimestampList; termInterval = _termInterval; } function getTokenInfo() external view override returns ( uint256[] memory latestTermList, uint256[] memory totalRemainingRewardsList, uint256[] memory currentTermRewardsList, uint256[] memory nextTermRewardsList, uint128[] memory currentStakingList, uint128[] memory nextTermStakingList ) { uint256 numOfStakingContracts = _stakingContracts.length; latestTermList = new uint256[](numOfStakingContracts); totalRemainingRewardsList = new uint256[](numOfStakingContracts); currentTermRewardsList = new uint256[](numOfStakingContracts); nextTermRewardsList = new uint256[](numOfStakingContracts); currentStakingList = new uint128[](numOfStakingContracts); nextTermStakingList = new uint128[](numOfStakingContracts); for (uint256 i = 0; i < numOfStakingContracts; i++) { ( , uint256 latestTerm, uint256 totalRemainingRewards, uint256 currentTermRewards, uint256 nextTermRewards, uint128 currentStaking, uint128 nextTermStaking ) = _stakingContracts[i].getTokenInfo(); latestTermList[i] = latestTerm; totalRemainingRewardsList[i] = totalRemainingRewards; currentTermRewardsList[i] = currentTermRewards; nextTermRewardsList[i] = nextTermRewards; currentStakingList[i] = currentStaking; nextTermStakingList[i] = nextTermStaking; } } function getTermInfo(uint256 term) external view override returns ( int128[] memory stakeAddList, uint128[] memory stakeSumList, uint256[] memory rewardSumList ) { uint256 numOfStakingContracts = _stakingContracts.length; stakeAddList = new int128[](numOfStakingContracts); stakeSumList = new uint128[](numOfStakingContracts); rewardSumList = new uint256[](numOfStakingContracts); for (uint256 i = 0; i < numOfStakingContracts; i++) { (int128 stakeAdd, uint128 stakeSum, uint256 rewardSum) = _stakingContracts[i].getTermInfo( term ); stakeAddList[i] = stakeAdd; stakeSumList[i] = stakeSum; rewardSumList[i] = rewardSum; } } function getAccountInfo(address account) external view override returns ( uint256[] memory userTermList, uint256[] memory stakeAmountList, int128[] memory nextAddedStakeAmountList, uint256[] memory currentTermUserRewardsList, uint256[] memory nextTermUserRewardsList, uint128[] memory withdrawableStakingAmountList ) { uint256 numOfStakingContracts = _stakingContracts.length; userTermList = new uint256[](numOfStakingContracts); stakeAmountList = new uint256[](numOfStakingContracts); nextAddedStakeAmountList = new int128[](numOfStakingContracts); currentTermUserRewardsList = new uint256[](numOfStakingContracts); nextTermUserRewardsList = new uint256[](numOfStakingContracts); withdrawableStakingAmountList = new uint128[](numOfStakingContracts); for (uint256 i = 0; i < numOfStakingContracts; i++) { address accountTmp = account; ( uint256 userTerm, uint256 stakeAmount, int128 nextAddedStakeAmount, , uint256 currentTermUserRewards, uint256 nextTermUserRewards, , uint128 withdrawableStakingAmount ) = _stakingContracts[i].getAccountInfo(accountTmp); userTermList[i] = userTerm; stakeAmountList[i] = stakeAmount; nextAddedStakeAmountList[i] = nextAddedStakeAmount; currentTermUserRewardsList[i] = currentTermUserRewards; nextTermUserRewardsList[i] = nextTermUserRewards; withdrawableStakingAmountList[i] = withdrawableStakingAmount; } } }
0x608060405234801561001057600080fd5b50600436106100c95760003560e01c8063a94785d811610081578063dad8a0321161005b578063dad8a03214610511578063e1c7392a14610569578063ff3d9e4f14610571576100c9565b8063a94785d81461046f578063abb1dc44146104a6578063abdc3033146104ae576100c9565b80637b510fe8116100b25780637b510fe81461014057806388fe2be814610320578063979c6fe614610374576100c9565b806302387a7b146100ce5780635e1e09a11461010f575b600080fd5b6100fd600480360360208110156100e457600080fd5b50356fffffffffffffffffffffffffffffffff16610579565b60408051918252519081900360200190f35b6101176109af565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6101736004803603602081101561015657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109d4565b6040518080602001806020018060200180602001806020018060200187810387528d818151815260200191508051906020019060200280838360005b838110156101c75781810151838201526020016101af565b5050505090500187810386528c818151815260200191508051906020019060200280838360005b838110156102065781810151838201526020016101ee565b5050505090500187810385528b818151815260200191508051906020019060200280838360005b8381101561024557818101518382015260200161022d565b5050505090500187810384528a818151815260200191508051906020019060200280838360005b8381101561028457818101518382015260200161026c565b50505050905001878103835289818151815260200191508051906020019060200280838360005b838110156102c35781810151838201526020016102ab565b50505050905001878103825288818151815260200191508051906020019060200280838360005b838110156103025781810151838201526020016102ea565b505050509050019c5050505050505050505050505060405180910390f35b61034f6004803603602081101561033657600080fd5b50356fffffffffffffffffffffffffffffffff16610d82565b604080516fffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6103916004803603602081101561038a57600080fd5b5035610fa6565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b838110156103d95781810151838201526020016103c1565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015610418578181015183820152602001610400565b50505050905001848103825285818151815260200191508051906020019060200280838360005b8381101561045757818101518382015260200161043f565b50505050905001965050505050505060405180910390f35b6104a46004803603604081101561048557600080fd5b50803590602001356fffffffffffffffffffffffffffffffff166111e3565b005b6101736113b7565b6104b6611763565b6040518080602001838152602001828103825284818151815260200191508051906020019060200280838360005b838110156104fc5781810151838201526020016104e4565b50505050905001935050505060405180910390f35b6105196117e1565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561055557818101518382015260200161053d565b505050509050019250505060405180910390f35b6104a4611850565b6100fd611a46565b60025460009060ff166105ed57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f61676772656761746f72206973206e6f7420696e697469616c697a6564000000604482015290519081900360640190fd5b6fffffffffffffffffffffffffffffffff8216610655576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806120d8602c913960400191505060405180910390fd5b60008060005b6001548110156106c45760007f0000000000000000000000000000000000000000000000000000000000002a306001838154811061069557fe5b90600052602060002001544203816106a957fe5b069050838111156106bb578093508192505b5060010161065b565b50805b6001548201811080156106eb57506fffffffffffffffffffffffffffffffff851615155b156108e1576001546000908190838161070057fe5b068154811061070b57fe5b6000918252602082200154604080517f7b510fe8000000000000000000000000000000000000000000000000000000008152336004820152905173ffffffffffffffffffffffffffffffffffffffff90921693508391637b510fe89160248082019261010092909190829003018186803b15801561078857600080fd5b505afa15801561079c573d6000803e3d6000fd5b505050506040513d6101008110156107b357600080fd5b5060c00151905060006fffffffffffffffffffffffffffffffff808316908916106107de57816107e0565b875b978890039790506fffffffffffffffffffffffffffffffff8116156108d657604080517f0ef22d1b0000000000000000000000000000000000000000000000000000000081523360048201526fffffffffffffffffffffffffffffffff83166024820152905160009173ffffffffffffffffffffffffffffffffffffffff861691630ef22d1b9160448082019260209290919082900301818787803b15801561088857600080fd5b505af115801561089c573d6000803e3d6000fd5b505050506040513d60208110156108b257600080fd5b505190506108d2886fffffffffffffffffffffffffffffffff8316611bd9565b9750505b5050506001016106c7565b506fffffffffffffffffffffffffffffffff84161561096157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f65786365656420776974686472617761626c6520616d6f756e74000000000000604482015290519081900360640190fd5b82156109a8576109a873ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000046ba9c1d2348315e7ed3d583d03a4ed9ec3baf85163385611c54565b5050919050565b7f00000000000000000000000046ba9c1d2348315e7ed3d583d03a4ed9ec3baf855b90565b6060806060806060806000808054905090508067ffffffffffffffff811180156109fd57600080fd5b50604051908082528060200260200182016040528015610a27578160200160208202803683370190505b5096508067ffffffffffffffff81118015610a4157600080fd5b50604051908082528060200260200182016040528015610a6b578160200160208202803683370190505b5095508067ffffffffffffffff81118015610a8557600080fd5b50604051908082528060200260200182016040528015610aaf578160200160208202803683370190505b5094508067ffffffffffffffff81118015610ac957600080fd5b50604051908082528060200260200182016040528015610af3578160200160208202803683370190505b5093508067ffffffffffffffff81118015610b0d57600080fd5b50604051908082528060200260200182016040528015610b37578160200160208202803683370190505b5092508067ffffffffffffffff81118015610b5157600080fd5b50604051908082528060200260200182016040528015610b7b578160200160208202803683370190505b50915060005b81811015610d7757600089905060008060008060008060008881548110610ba457fe5b600091825260209091200154604080517f7b510fe800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a8116600483015291519190921691637b510fe891602480830192610100929190829003018186803b158015610c2157600080fd5b505afa158015610c35573d6000803e3d6000fd5b505050506040513d610100811015610c4c57600080fd5b8101908080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050509750509650965050955095509550858f8981518110610cbe57fe5b602002602001018181525050848e8981518110610cd757fe5b602002602001018181525050838d8981518110610cf057fe5b6020026020010190600f0b9081600f0b81525050828c8981518110610d1157fe5b602002602001018181525050818b8981518110610d2a57fe5b602002602001018181525050808a8981518110610d4357fe5b6fffffffffffffffffffffffffffffffff90921660209283029190910190910152505060019095019450610b819350505050565b505091939550919395565b60025460009060ff16610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f61676772656761746f72206973206e6f7420696e697469616c697a6564000000604482015290519081900360640190fd5b60008060005b600154811015610e655760007f0000000000000000000000000000000000000000000000000000000000002a3060018381548110610e3657fe5b9060005260206000200154420381610e4a57fe5b06905083811115610e5c578093508192505b50600101610dfc565b5060008181548110610e7357fe5b6000918252602080832090910154604080517f99d620390000000000000000000000000000000000000000000000000000000081523360048201526fffffffffffffffffffffffffffffffff89166024820152905173ffffffffffffffffffffffffffffffffffffffff909216936399d620399360448084019491939192918390030190829087803b158015610f0857600080fd5b505af1158015610f1c573d6000803e3d6000fd5b505050506040513d6020811015610f3257600080fd5b505192506fffffffffffffffffffffffffffffffff83850316156109a8576109a873ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000046ba9c1d2348315e7ed3d583d03a4ed9ec3baf851633306fffffffffffffffffffffffffffffffff87890316611ce6565b600054606090819081908067ffffffffffffffff81118015610fc757600080fd5b50604051908082528060200260200182016040528015610ff1578160200160208202803683370190505b5093508067ffffffffffffffff8111801561100b57600080fd5b50604051908082528060200260200182016040528015611035578160200160208202803683370190505b5092508067ffffffffffffffff8111801561104f57600080fd5b50604051908082528060200260200182016040528015611079578160200160208202803683370190505b50915060005b818110156111da57600080600080848154811061109857fe5b600091825260209091200154604080517f979c6fe6000000000000000000000000000000000000000000000000000000008152600481018c9052905173ffffffffffffffffffffffffffffffffffffffff9092169163979c6fe691602480820192606092909190829003018186803b15801561111357600080fd5b505afa158015611127573d6000803e3d6000fd5b505050506040513d606081101561113d57600080fd5b50805160208201516040909201518a51919550919350909150839089908690811061116457fe5b6020026020010190600f0b9081600f0b815250508187858151811061118557fe5b60200260200101906fffffffffffffffffffffffffffffffff1690816fffffffffffffffffffffffffffffffff1681525050808685815181106111c457fe5b602090810291909101015250505060010161107f565b50509193909250565b60025460ff1661125457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f61676772656761746f72206973206e6f7420696e697469616c697a6564000000604482015290519081900360640190fd5b60005482106112ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806120b46024913960400191505060405180910390fd5b61130273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000046ba9c1d2348315e7ed3d583d03a4ed9ec3baf851633306fffffffffffffffffffffffffffffffff8516611ce6565b6000828154811061130f57fe5b6000918252602082200154604080517f3382ca880000000000000000000000000000000000000000000000000000000081523360048201526fffffffffffffffffffffffffffffffff85166024820152905173ffffffffffffffffffffffffffffffffffffffff90921692633382ca889260448084019382900301818387803b15801561139b57600080fd5b505af11580156113af573d6000803e3d6000fd5b505050505050565b6060806060806060806000808054905090508067ffffffffffffffff811180156113e057600080fd5b5060405190808252806020026020018201604052801561140a578160200160208202803683370190505b5096508067ffffffffffffffff8111801561142457600080fd5b5060405190808252806020026020018201604052801561144e578160200160208202803683370190505b5095508067ffffffffffffffff8111801561146857600080fd5b50604051908082528060200260200182016040528015611492578160200160208202803683370190505b5094508067ffffffffffffffff811180156114ac57600080fd5b506040519080825280602002602001820160405280156114d6578160200160208202803683370190505b5093508067ffffffffffffffff811180156114f057600080fd5b5060405190808252806020026020018201604052801561151a578160200160208202803683370190505b5092508067ffffffffffffffff8111801561153457600080fd5b5060405190808252806020026020018201604052801561155e578160200160208202803683370190505b50915060005b81811015611759576000806000806000806000878154811061158257fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663abb1dc446040518163ffffffff1660e01b815260040160e06040518083038186803b1580156115f257600080fd5b505afa158015611606573d6000803e3d6000fd5b505050506040513d60e081101561161c57600080fd5b810190808051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919050505096509650965096509650965050858e888151811061168357fe5b602002602001018181525050848d888151811061169c57fe5b602002602001018181525050838c88815181106116b557fe5b602002602001018181525050828b88815181106116ce57fe5b602002602001018181525050818a88815181106116e757fe5b60200260200101906fffffffffffffffffffffffffffffffff1690816fffffffffffffffffffffffffffffffff16815250508089888151811061172657fe5b6fffffffffffffffffffffffffffffffff9092166020928302919091019091015250506001909401935061156492505050565b5050909192939495565b6060600060018054806020026020016040519081016040528092919081815260200182805480156117b357602002820191906000526020600020905b81548152602001906001019080831161179f575b505050505091507f0000000000000000000000000000000000000000000000000000000000002a3090509091565b6060600080548060200260200160405190810160405280929190818152602001828054801561184657602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831161181b575b5050505050905090565b60025460ff16156118c257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f616c726561647920696e697469616c697a656400000000000000000000000000604482015290519081900360640190fd5b60005b600054811015611a18573073ffffffffffffffffffffffffffffffffffffffff16600082815481106118f357fe5b60009182526020918290200154604080517f8da5cb5b000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff90921692638da5cb5b92600480840193829003018186803b15801561196257600080fd5b505afa158015611976573d6000803e3d6000fd5b505050506040513d602081101561198c57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614611a1057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f6e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6001016118c5565b50600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60025460009060ff16611aba57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f61676772656761746f72206973206e6f7420696e697469616c697a6564000000604482015290519081900360640190fd5b60005b600054811015611b9157611b8760008281548110611ad757fe5b6000918252602080832090910154604080517f94bd791b000000000000000000000000000000000000000000000000000000008152336004820152905173ffffffffffffffffffffffffffffffffffffffff909216936394bd791b9360248084019491939192918390030190829087803b158015611b5457600080fd5b505af1158015611b68573d6000803e3d6000fd5b505050506040513d6020811015611b7e57600080fd5b50518390611bd9565b9150600101611abd565b5080156109d1576109d173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000046ba9c1d2348315e7ed3d583d03a4ed9ec3baf85163383611c54565b600082820183811015611c4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052611ce1908490611d81565b505050565b6040805173ffffffffffffffffffffffffffffffffffffffff80861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052611d7b908590611d81565b50505050565b6060611de3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611e599092919063ffffffff16565b805190915015611ce157808060200190516020811015611e0257600080fd5b5051611ce1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612104602a913960400191505060405180910390fd5b6060611e688484600085611e70565b949350505050565b6060611e7b8561207a565b611ee657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310611f5057805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611f13565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114611fb2576040519150601f19603f3d011682016040523d82523d6000602084013e611fb7565b606091505b50915091508115611fcb579150611e689050565b805115611fdb5780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561203f578181015183820152602001612027565b50505050905090810190601f16801561206c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611e6857505015159291505056fe7374616b696e67436f6e7472616374496e646578206973206f7574206f6620696e6465787769746864726177696e6720616d6f756e742073686f756c6420626520706f736974697665206e756d6265725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220d5d53887da739289cfd6e78c2701a56db1f7e189075fecb84f093994f102a42164736f6c63430007010033
[ 10, 7, 12 ]
0xF1Ee4fe9a4C9d3C1FA572B622D89312427Ed399F
//SPDX-License-Identifier: <SPDX-License> pragma solidity ^0.7.6; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract NobleDogeLife is ERC721, Ownable { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; // Public Sell Mint event SellMint(uint indexed nums, address indexed minter); uint256 public tokenPrice = 30000000000000000; //0.03 ETH uint256 public constant MAX_DOGES = 10000;//Max Size uint256 public constant PRE_DOGES = 1000;//For Dogecoin Mint uint256 public constant MAX_COMM_MINTS = 50;//AirDrop Community uint256 public constant MAX_SALE_MINTS = MAX_DOGES - MAX_COMM_MINTS - PRE_DOGES; uint256 public commMintedNum = 0; uint256 public saleMintedNum = 0; uint public maxBuy = 20; uint public totalBuy = 200; bool public publicSale = false; bool public preSale = false; //Nobel Doge constructor(string memory name, string memory symbol) ERC721(name, symbol) { } //withdraw this.blance to Owner function withdraw() public onlyOwner { uint balance = address(this).balance; msg.sender.transfer(balance); } //Frozen public sale function flipPublicSale() public onlyOwner { publicSale = !publicSale; } function flipPreSale() public onlyOwner { preSale = !preSale; } function setMaxBuy(uint nums) public onlyOwner { require(nums > 0, "nums should large then 0."); maxBuy = nums; } function setTotalBuy(uint nums) public onlyOwner { require(nums > 0, "nums should large then 0."); require(nums > maxBuy, "nums should large then maxBuy."); totalBuy = nums; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } //Eth go da the moon function changePrice(uint256 newPrice) public onlyOwner { tokenPrice = newPrice; } //Normal mint function mint(uint nums) external payable { require(publicSale, "Sale not started."); require(nums > 0, "nums should large then 0."); require(nums <= maxBuy, "reach max sell limit."); require(saleMintedNum.add(nums) <= MAX_SALE_MINTS, "Sale mint limit reached."); require(totalSupply() < MAX_DOGES, "DOGES sold out."); uint salePrice = getPrice().mul(nums); require(msg.value >= salePrice, "not enough funds to purchase."); for (uint i = 0; i < nums; i++) { uint id = nextIndex(); if (id < MAX_DOGES) { _safeMint(msg.sender, id); } } saleMintedNum = saleMintedNum.add(nums); emit SellMint(nums, msg.sender); } //dogeMint function dogeMint(uint nums, address recipient) public onlyOwner { require(totalSupply().add(nums) <= MAX_DOGES, "not enough doge left."); for (uint i = 0; i < nums; i++) { uint id = nextIndex(); if (id < MAX_DOGES) { _safeMint(recipient, id); } } } //Community Mint For airDrop function mintToGroup(uint nums, address commAddr) public onlyOwner { require(commMintedNum.add(nums) <= MAX_COMM_MINTS, "Community Mint limit reached."); require(totalSupply() < MAX_DOGES, "DOGES sold out."); for (uint i = 0; i < nums; i++) { uint id = nextIndex(); if (id < MAX_DOGES) { _safeMint(commAddr, id); commMintedNum = commMintedNum.add(1); } } } //Presale For ETH(Not Use) function presale(uint nums) external payable { require(preSale, "Sale not started."); require(msg.sender != address(0)); require(nums > 0, "Nums should large then 0."); require(nums <= maxBuy, "Reach max sell limit."); require(saleMintedNum.add(nums) <= MAX_SALE_MINTS, "Sale mint limit reached."); require(totalSupply() < MAX_DOGES, "DOGES sold out."); uint256 hdwNums = balanceOf(msg.sender); require(hdwNums.add(nums) <= totalBuy, "Reach max totalBuy limit."); uint salePrice = getPrice().mul(nums); require(msg.value >= salePrice, "not enough funds to purchase."); for (uint i = 0; i < nums; i++) { uint id = nextIndex(); if (id < MAX_DOGES) { _safeMint(msg.sender, id); } } saleMintedNum = saleMintedNum.add(nums); } //Get next number function nextIndex() internal view returns (uint) { return totalSupply(); } //Get price function getPrice() public view returns (uint) { return tokenPrice; } } // 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; /** * @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; 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.0 <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 () internal { 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; } } // 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.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 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.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.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.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.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 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 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); } } // 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); }
0x60806040526004361061025c5760003560e01c8063715018a611610144578063a22cb465116100b6578063b96d818a1161007a578063b96d818a1461092a578063c87b56dd14610954578063e6ab14341461097e578063e985e9c51461099b578063f2fde38b146109d6578063f53bc83514610a095761025c565b8063a22cb465146107c8578063a2b40d1914610803578063a6163efe1461082d578063b1c09b2a14610842578063b88d4fde146108575761025c565b80638b62f533116101085780638b62f5331461071e5780638da5cb5b1461073357806395d89b411461074857806398d5fdca1461075d5780639b5050a414610772578063a0712d68146107ab5761025c565b8063715018a6146106b55780637ff9b596146106ca578063864f2632146106df57806388084605146106f45780638a6805c5146107095761025c565b806342842e0e116101dd5780635a8f3570116101a15780635a8f3570146105e05780635db5c536146105f55780636352211e1461062e5780636c0360eb1461065857806370a082311461066d57806370db69d6146106a05761025c565b806342842e0e146104965780634f6ccce7146104d95780634f8f2e471461050357806355f804b3146105185780635a7adf7f146105cb5761025c565b806323b872dd1161022457806323b872dd146103db5780632f745c591461041e57806332bd5ae81461045757806333bc1c5c1461046c5780633ccfd60b146104815761025c565b806301ffc9a71461026157806306fdde03146102a9578063081812fc14610333578063095ea7b31461037957806318160ddd146103b4575b600080fd5b34801561026d57600080fd5b506102956004803603602081101561028457600080fd5b50356001600160e01b031916610a33565b604080519115158252519081900360200190f35b3480156102b557600080fd5b506102be610a56565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102f85781810151838201526020016102e0565b50505050905090810190601f1680156103255780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033f57600080fd5b5061035d6004803603602081101561035657600080fd5b5035610aec565b604080516001600160a01b039092168252519081900360200190f35b34801561038557600080fd5b506103b26004803603604081101561039c57600080fd5b506001600160a01b038135169060200135610b4e565b005b3480156103c057600080fd5b506103c9610c29565b60408051918252519081900360200190f35b3480156103e757600080fd5b506103b2600480360360608110156103fe57600080fd5b506001600160a01b03813581169160208101359091169060400135610c3a565b34801561042a57600080fd5b506103c96004803603604081101561044157600080fd5b506001600160a01b038135169060200135610c91565b34801561046357600080fd5b506103c9610cbc565b34801561047857600080fd5b50610295610cc2565b34801561048d57600080fd5b506103b2610ccb565b3480156104a257600080fd5b506103b2600480360360608110156104b957600080fd5b506001600160a01b03813581169160208101359091169060400135610d60565b3480156104e557600080fd5b506103c9600480360360208110156104fc57600080fd5b5035610d7b565b34801561050f57600080fd5b506103c9610d91565b34801561052457600080fd5b506103b26004803603602081101561053b57600080fd5b81019060208101813564010000000081111561055657600080fd5b82018360208201111561056857600080fd5b8035906020019184600183028401116401000000008311171561058a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610d97945050505050565b3480156105d757600080fd5b50610295610e05565b3480156105ec57600080fd5b506103c9610e13565b34801561060157600080fd5b506103b26004803603604081101561061857600080fd5b50803590602001356001600160a01b0316610e18565b34801561063a57600080fd5b5061035d6004803603602081101561065157600080fd5b5035610f72565b34801561066457600080fd5b506102be610f9a565b34801561067957600080fd5b506103c96004803603602081101561069057600080fd5b50356001600160a01b0316610ffb565b3480156106ac57600080fd5b506103c9611063565b3480156106c157600080fd5b506103b2611069565b3480156106d657600080fd5b506103c9611115565b3480156106eb57600080fd5b506103c961111b565b34801561070057600080fd5b506103b2611121565b34801561071557600080fd5b506103c9611197565b34801561072a57600080fd5b506103b261119d565b34801561073f57600080fd5b5061035d61121c565b34801561075457600080fd5b506102be61122b565b34801561076957600080fd5b506103c961128c565b34801561077e57600080fd5b506103b26004803603604081101561079557600080fd5b50803590602001356001600160a01b0316611292565b6103b2600480360360208110156107c157600080fd5b5035611388565b3480156107d457600080fd5b506103b2600480360360408110156107eb57600080fd5b506001600160a01b0381351690602001351515611602565b34801561080f57600080fd5b506103b26004803603602081101561082657600080fd5b5035611707565b34801561083957600080fd5b506103c961176e565b34801561084e57600080fd5b506103c9611774565b34801561086357600080fd5b506103b26004803603608081101561087a57600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156108b557600080fd5b8201836020820111156108c757600080fd5b803590602001918460018302840111640100000000831117156108e957600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061177a945050505050565b34801561093657600080fd5b506103b26004803603602081101561094d57600080fd5b50356117d8565b34801561096057600080fd5b506102be6004803603602081101561097757600080fd5b50356118e6565b6103b26004803603602081101561099457600080fd5b5035611b67565b3480156109a757600080fd5b50610295600480360360408110156109be57600080fd5b506001600160a01b0381358116916020013516611e30565b3480156109e257600080fd5b506103b2600480360360208110156109f957600080fd5b50356001600160a01b0316611e5e565b348015610a1557600080fd5b506103b260048036036020811015610a2c57600080fd5b5035611f61565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ae25780601f10610ab757610100808354040283529160200191610ae2565b820191906000526020600020905b815481529060010190602001808311610ac557829003601f168201915b5050505050905090565b6000610af782612019565b610b325760405162461bcd60e51b815260040180806020018281038252602c815260200180612f42602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610b5982610f72565b9050806001600160a01b0316836001600160a01b03161415610bac5760405162461bcd60e51b8152600401808060200182810382526021815260200180612fe66021913960400191505060405180910390fd5b806001600160a01b0316610bbe612026565b6001600160a01b03161480610bdf5750610bdf81610bda612026565b611e30565b610c1a5760405162461bcd60e51b8152600401808060200182810382526038815260200180612e746038913960400191505060405180910390fd5b610c24838361202a565b505050565b6000610c356002612098565b905090565b610c4b610c45612026565b826120a3565b610c865760405162461bcd60e51b81526004018080602001828103825260318152602001806130076031913960400191505060405180910390fd5b610c24838383612147565b6001600160a01b0382166000908152600160205260408120610cb39083612293565b90505b92915050565b600d5481565b60105460ff1681565b610cd3612026565b6001600160a01b0316610ce461121c565b6001600160a01b031614610d2d576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b6040514790339082156108fc029083906000818181858888f19350505050158015610d5c573d6000803e3d6000fd5b5050565b610c248383836040518060200160405280600081525061177a565b600080610d8960028461229f565b509392505050565b6122f681565b610d9f612026565b6001600160a01b0316610db061121c565b6001600160a01b031614610df9576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b610e02816122bb565b50565b601054610100900460ff1681565b603281565b610e20612026565b6001600160a01b0316610e3161121c565b6001600160a01b031614610e7a576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b600c54603290610e8a90846122ce565b1115610edd576040805162461bcd60e51b815260206004820152601d60248201527f436f6d6d756e697479204d696e74206c696d697420726561636865642e000000604482015290519081900360640190fd5b612710610ee8610c29565b10610f2c576040805162461bcd60e51b815260206004820152600f60248201526e2227a3a2a99039b7b6321037baba1760891b604482015290519081900360640190fd5b60005b82811015610c24576000610f41612328565b9050612710811015610f6957610f578382612332565b600c54610f659060016122ce565b600c555b50600101610f2f565b6000610cb682604051806060016040528060298152602001612ed6602991396002919061234c565b60098054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ae25780601f10610ab757610100808354040283529160200191610ae2565b60006001600160a01b0382166110425760405162461bcd60e51b815260040180806020018281038252602a815260200180612eac602a913960400191505060405180910390fd5b6001600160a01b0382166000908152600160205260409020610cb690612098565b600e5481565b611071612026565b6001600160a01b031661108261121c565b6001600160a01b0316146110cb576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b600a546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600a80546001600160a01b0319169055565b600b5481565b6103e881565b611129612026565b6001600160a01b031661113a61121c565b6001600160a01b031614611183576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b6010805460ff19811660ff90911615179055565b61271081565b6111a5612026565b6001600160a01b03166111b661121c565b6001600160a01b0316146111ff576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b6010805461ff001981166101009182900460ff1615909102179055565b600a546001600160a01b031690565b60078054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610ae25780601f10610ab757610100808354040283529160200191610ae2565b600b5490565b61129a612026565b6001600160a01b03166112ab61121c565b6001600160a01b0316146112f4576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b61271061130983611303610c29565b906122ce565b1115611354576040805162461bcd60e51b81526020600482015260156024820152743737ba1032b737bab3b4103237b3b2903632b33a1760591b604482015290519081900360640190fd5b60005b82811015610c24576000611369612328565b905061271081101561137f5761137f8382612332565b50600101611357565b60105460ff166113d3576040805162461bcd60e51b815260206004820152601160248201527029b0b632903737ba1039ba30b93a32b21760791b604482015290519081900360640190fd5b60008111611424576040805162461bcd60e51b8152602060048201526019602482015278373ab6b99039b437bab632103630b933b2903a3432b710181760391b604482015290519081900360640190fd5b600e54811115611473576040805162461bcd60e51b81526020600482015260156024820152743932b0b1b41036b0bc1039b2b636103634b6b4ba1760591b604482015290519081900360640190fd5b600d546122f69061148490836122ce565b11156114d2576040805162461bcd60e51b815260206004820152601860248201527729b0b6329036b4b73a103634b6b4ba103932b0b1b432b21760411b604482015290519081900360640190fd5b6127106114dd610c29565b10611521576040805162461bcd60e51b815260206004820152600f60248201526e2227a3a2a99039b7b6321037baba1760891b604482015290519081900360640190fd5b60006115358261152f61128c565b90612363565b90508034101561158c576040805162461bcd60e51b815260206004820152601d60248201527f6e6f7420656e6f7567682066756e647320746f2070757263686173652e000000604482015290519081900360640190fd5b60005b828110156115c05760006115a1612328565b90506127108110156115b7576115b73382612332565b5060010161158f565b50600d546115ce90836122ce565b600d55604051339083907ff31591eb6c135ad3abaaf83928e4b5b06cfdb940257e50791ab7c51bfe28063190600090a35050565b61160a612026565b6001600160a01b0316826001600160a01b03161415611670576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b806005600061167d612026565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556116c1612026565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b61170f612026565b6001600160a01b031661172061121c565b6001600160a01b031614611769576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b600b55565b600c5481565b600f5481565b61178b611785612026565b836120a3565b6117c65760405162461bcd60e51b81526004018080602001828103825260318152602001806130076031913960400191505060405180910390fd5b6117d2848484846123bc565b50505050565b6117e0612026565b6001600160a01b03166117f161121c565b6001600160a01b03161461183a576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b6000811161188b576040805162461bcd60e51b8152602060048201526019602482015278373ab6b99039b437bab632103630b933b2903a3432b710181760391b604482015290519081900360640190fd5b600e5481116118e1576040805162461bcd60e51b815260206004820152601e60248201527f6e756d732073686f756c64206c61726765207468656e206d61784275792e0000604482015290519081900360640190fd5b600f55565b60606118f182612019565b61192c5760405162461bcd60e51b815260040180806020018281038252602f815260200180612fb7602f913960400191505060405180910390fd5b60008281526008602090815260408083208054825160026001831615610100026000190190921691909104601f8101859004850282018501909352828152929091908301828280156119bf5780601f10611994576101008083540402835291602001916119bf565b820191906000526020600020905b8154815290600101906020018083116119a257829003601f168201915b5050505050905060006119d0610f9a565b90508051600014156119e457509050610a51565b815115611aa55780826040516020018083805190602001908083835b60208310611a1f5780518252601f199092019160209182019101611a00565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310611a675780518252601f199092019160209182019101611a48565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610a51565b80611aaf8561240e565b6040516020018083805190602001908083835b60208310611ae15780518252601f199092019160209182019101611ac2565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310611b295780518252601f199092019160209182019101611b0a565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b601054610100900460ff16611bb7576040805162461bcd60e51b815260206004820152601160248201527029b0b632903737ba1039ba30b93a32b21760791b604482015290519081900360640190fd5b33611bc157600080fd5b60008111611c16576040805162461bcd60e51b815260206004820152601960248201527f4e756d732073686f756c64206c61726765207468656e20302e00000000000000604482015290519081900360640190fd5b600e54811115611c65576040805162461bcd60e51b81526020600482015260156024820152742932b0b1b41036b0bc1039b2b636103634b6b4ba1760591b604482015290519081900360640190fd5b600d546122f690611c7690836122ce565b1115611cc4576040805162461bcd60e51b815260206004820152601860248201527729b0b6329036b4b73a103634b6b4ba103932b0b1b432b21760411b604482015290519081900360640190fd5b612710611ccf610c29565b10611d13576040805162461bcd60e51b815260206004820152600f60248201526e2227a3a2a99039b7b6321037baba1760891b604482015290519081900360640190fd5b6000611d1e33610ffb565b600f54909150611d2e82846122ce565b1115611d81576040805162461bcd60e51b815260206004820152601960248201527f5265616368206d617820746f74616c427579206c696d69742e00000000000000604482015290519081900360640190fd5b6000611d8f8361152f61128c565b905080341015611de6576040805162461bcd60e51b815260206004820152601d60248201527f6e6f7420656e6f7567682066756e647320746f2070757263686173652e000000604482015290519081900360640190fd5b60005b83811015611e1a576000611dfb612328565b9050612710811015611e1157611e113382612332565b50600101611de9565b50600d54611e2890846122ce565b600d55505050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b611e66612026565b6001600160a01b0316611e7761121c565b6001600160a01b031614611ec0576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b6001600160a01b038116611f055760405162461bcd60e51b8152600401808060200182810382526026815260200180612dfe6026913960400191505060405180910390fd5b600a546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b611f69612026565b6001600160a01b0316611f7a61121c565b6001600160a01b031614611fc3576040805162461bcd60e51b81526020600482018190526024820152600080516020612f6e833981519152604482015290519081900360640190fd5b60008111612014576040805162461bcd60e51b8152602060048201526019602482015278373ab6b99039b437bab632103630b933b2903a3432b710181760391b604482015290519081900360640190fd5b600e55565b6000610cb66002836124e9565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061205f82610f72565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610cb6826124f5565b60006120ae82612019565b6120e95760405162461bcd60e51b815260040180806020018281038252602c815260200180612e48602c913960400191505060405180910390fd5b60006120f483610f72565b9050806001600160a01b0316846001600160a01b0316148061212f5750836001600160a01b031661212484610aec565b6001600160a01b0316145b8061213f575061213f8185611e30565b949350505050565b826001600160a01b031661215a82610f72565b6001600160a01b03161461219f5760405162461bcd60e51b8152600401808060200182810382526029815260200180612f8e6029913960400191505060405180910390fd5b6001600160a01b0382166121e45760405162461bcd60e51b8152600401808060200182810382526024815260200180612e246024913960400191505060405180910390fd5b6121ef838383610c24565b6121fa60008261202a565b6001600160a01b038316600090815260016020526040902061221c90826124f9565b506001600160a01b038216600090815260016020526040902061223f9082612505565b5061224c60028284612511565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610cb38383612527565b60008080806122ae868661258b565b9097909650945050505050565b8051610d5c906009906020840190612d08565b600082820183811015610cb3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000610c35610c29565b610d5c828260405180602001604052806000815250612606565b6000612359848484612658565b90505b9392505050565b60008261237257506000610cb6565b8282028284828161237f57fe5b0414610cb35760405162461bcd60e51b8152600401808060200182810382526021815260200180612f216021913960400191505060405180910390fd5b6123c7848484612147565b6123d384848484612722565b6117d25760405162461bcd60e51b8152600401808060200182810382526032815260200180612dcc6032913960400191505060405180910390fd5b60608161243357506040805180820190915260018152600360fc1b6020820152610a51565b8160005b811561244b57600101600a82049150612437565b60008167ffffffffffffffff8111801561246457600080fd5b506040519080825280601f01601f19166020018201604052801561248f576020820181803683370190505b50859350905060001982015b83156124e057600a840660300160f81b828280600190039350815181106124be57fe5b60200101906001600160f81b031916908160001a905350600a8404935061249b565b50949350505050565b6000610cb3838361288a565b5490565b6000610cb383836128a2565b6000610cb38383612968565b600061235984846001600160a01b0385166129b2565b815460009082106125695760405162461bcd60e51b8152600401808060200182810382526022815260200180612daa6022913960400191505060405180910390fd5b82600001828154811061257857fe5b9060005260206000200154905092915050565b8154600090819083106125cf5760405162461bcd60e51b8152600401808060200182810382526022815260200180612eff6022913960400191505060405180910390fd5b60008460000184815481106125e057fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6126108383612a49565b61261d6000848484612722565b610c245760405162461bcd60e51b8152600401808060200182810382526032815260200180612dcc6032913960400191505060405180910390fd5b600082815260018401602052604081205482816126f35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156126b85781810151838201526020016126a0565b50505050905090810190601f1680156126e55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061270657fe5b9060005260206000209060020201600101549150509392505050565b6000612736846001600160a01b0316612b77565b6127425750600161213f565b6000612850630a85bd0160e11b612757612026565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156127be5781810151838201526020016127a6565b50505050905090810190601f1680156127eb5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001612dcc603291396001600160a01b0388169190612b7d565b9050600081806020019051602081101561286957600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b6000818152600183016020526040812054801561295e57835460001980830191908101906000908790839081106128d557fe5b90600052602060002001549050808760000184815481106128f257fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061292257fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610cb6565b6000915050610cb6565b6000612974838361288a565b6129aa57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610cb6565b506000610cb6565b600082815260018401602052604081205480612a1757505060408051808201825283815260208082018481528654600181810189556000898152848120955160029093029095019182559151908201558654868452818801909252929091205561235c565b82856000016001830381548110612a2a57fe5b906000526020600020906002020160010181905550600091505061235c565b6001600160a01b038216612aa4576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b612aad81612019565b15612aff576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b612b0b60008383610c24565b6001600160a01b0382166000908152600160205260409020612b2d9082612505565b50612b3a60028284612511565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b6060612359848460008585612b9185612b77565b612be2576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310612c205780518252601f199092019160209182019101612c01565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612c82576040519150601f19603f3d011682016040523d82523d6000602084013e612c87565b606091505b5091509150612c97828286612ca2565b979650505050505050565b60608315612cb157508161235c565b825115612cc15782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156126b85781810151838201526020016126a0565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282612d3e5760008555612d84565b82601f10612d5757805160ff1916838001178555612d84565b82800160010185558215612d84579182015b82811115612d84578251825591602001919060010190612d69565b50612d90929150612d94565b5090565b5b80821115612d905760008155600101612d9556fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220319ee852e35bcc3051cc84adb0d2ce193065a238053f2d7dc3dc2ae593e4047564736f6c63430007060033
[ 13, 5 ]
0xf1ee564eccf5f0181502aee122dabc436ebf3eee
// SPDX-License-Identifier: Unlicensed /* BabyMarvinToken https://t.me/BabyMarvintoken */ pragma solidity ^0.8.4; 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 BabyMarvinToken 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 = 100000000 * 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; address payable private _feeAddrWallet3; string private constant _name = "BabyMarvin Token"; string private constant _symbol = "BabyMarvin"; 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(0x76d38E4849c9436064EB4F89600a07C7c0B65FF5); _feeAddrWallet2 = payable(0x76d38E4849c9436064EB4F89600a07C7c0B65FF5); _feeAddrWallet3 = payable(0x76d38E4849c9436064EB4F89600a07C7c0B65FF5); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 1; _feeAddr2 = 8; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } 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 = 4000000* 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } 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); } }
0x6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb146102ff578063c3c8cd801461033c578063c9567bf914610353578063dd62ed3e1461036a576100fe565b806370a0823114610255578063715018a6146102925780638da5cb5b146102a957806395d89b41146102d4576100fe565b80632ab30838116100c65780632ab30838146101d3578063313ce567146101ea5780635932ead1146102155780636fc3eaec1461023e576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103a7565b6040516101259190612513565b60405180910390f35b34801561013a57600080fd5b506101556004803603810190610150919061212c565b6103e4565b60405161016291906124f8565b60405180910390f35b34801561017757600080fd5b50610180610402565b60405161018d9190612635565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b891906120dd565b610412565b6040516101ca91906124f8565b60405180910390f35b3480156101df57600080fd5b506101e86104eb565b005b3480156101f657600080fd5b506101ff610591565b60405161020c91906126aa565b60405180910390f35b34801561022157600080fd5b5061023c60048036038101906102379190612168565b61059a565b005b34801561024a57600080fd5b5061025361064c565b005b34801561026157600080fd5b5061027c6004803603810190610277919061204f565b6106be565b6040516102899190612635565b60405180910390f35b34801561029e57600080fd5b506102a761070f565b005b3480156102b557600080fd5b506102be610862565b6040516102cb919061242a565b60405180910390f35b3480156102e057600080fd5b506102e961088b565b6040516102f69190612513565b60405180910390f35b34801561030b57600080fd5b506103266004803603810190610321919061212c565b6108c8565b60405161033391906124f8565b60405180910390f35b34801561034857600080fd5b506103516108e6565b005b34801561035f57600080fd5b50610368610960565b005b34801561037657600080fd5b50610391600480360381019061038c91906120a1565b610eba565b60405161039e9190612635565b60405180910390f35b60606040518060400160405280601081526020017f426162794d617276696e20546f6b656e00000000000000000000000000000000815250905090565b60006103f86103f1610f41565b8484610f49565b6001905092915050565b600067016345785d8a0000905090565b600061041f848484611114565b6104e08461042b610f41565b6104db85604051806060016040528060288152602001612b8460289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610491610f41565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113f09092919063ffffffff16565b610f49565b600190509392505050565b6104f3610f41565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610580576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610577906125b5565b60405180910390fd5b67016345785d8a0000601181905550565b60006009905090565b6105a2610f41565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461062f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610626906125b5565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661068d610f41565b73ffffffffffffffffffffffffffffffffffffffff16146106ad57600080fd5b60004790506106bb81611454565b50565b6000610708600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115b6565b9050919050565b610717610f41565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079b906125b5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600a81526020017f426162794d617276696e00000000000000000000000000000000000000000000815250905090565b60006108dc6108d5610f41565b8484611114565b6001905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610927610f41565b73ffffffffffffffffffffffffffffffffffffffff161461094757600080fd5b6000610952306106be565b905061095d81611624565b50565b610968610f41565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ec906125b5565b60405180910390fd5b601060149054906101000a900460ff1615610a45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3c90612615565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ad430600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1667016345785d8a0000610f49565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1a57600080fd5b505afa158015610b2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b529190612078565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610bb457600080fd5b505afa158015610bc8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bec9190612078565b6040518363ffffffff1660e01b8152600401610c09929190612445565b602060405180830381600087803b158015610c2357600080fd5b505af1158015610c37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5b9190612078565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ce4306106be565b600080610cef610862565b426040518863ffffffff1660e01b8152600401610d1196959493929190612497565b6060604051808303818588803b158015610d2a57600080fd5b505af1158015610d3e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610d6391906121ba565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff021916908315150217905550660e35fa931a00006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610e6492919061246e565b602060405180830381600087803b158015610e7e57600080fd5b505af1158015610e92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb69190612191565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fb9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb0906125f5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611029576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102090612555565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516111079190612635565b60405180910390a3505050565b60008111611157576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114e906125d5565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156111ae57600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146113e0576001600a819055506008600b81905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614801561129c5750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156112f25750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561130a5750601060179054906101000a900460ff165b1561131f5760115481111561131e57600080fd5b5b600061132a306106be565b9050601060159054906101000a900460ff161580156113975750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156113af5750601060169054906101000a900460ff165b156113de576113bd81611624565b6000479050670429d069189e00008111156113dc576113db47611454565b5b505b505b6113eb83838361191e565b505050565b6000838311158290611438576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142f9190612513565b60405180910390fd5b506000838561144791906127fb565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60038361149d9190612770565b9081150290604051600060405180830381858888f193505050501580156114c8573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836115129190612770565b9081150290604051600060405180830381858888f1935050505015801561153d573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836115879190612770565b9081150290604051600060405180830381858888f193505050501580156115b2573d6000803e3d6000fd5b5050565b60006008548211156115fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f490612535565b60405180910390fd5b600061160761192e565b905061161c818461195990919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611682577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156116b05781602001602082028036833780820191505090505b50905030816000815181106116ee577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561179057600080fd5b505afa1580156117a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c89190612078565b81600181518110611802577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061186930600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684610f49565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016118cd959493929190612650565b600060405180830381600087803b1580156118e757600080fd5b505af11580156118fb573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b6119298383836119a3565b505050565b600080600061193b611b6e565b91509150611952818361195990919063ffffffff16565b9250505090565b600061199b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611bcd565b905092915050565b6000806000806000806119b587611c30565b955095509550955095509550611a1386600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c9890919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611aa885600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ce290919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611af481611d40565b611afe8483611dfd565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611b5b9190612635565b60405180910390a3505050505050505050565b60008060006008549050600067016345785d8a00009050611ba267016345785d8a000060085461195990919063ffffffff16565b821015611bc05760085467016345785d8a0000935093505050611bc9565b81819350935050505b9091565b60008083118290611c14576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c0b9190612513565b60405180910390fd5b5060008385611c239190612770565b9050809150509392505050565b6000806000806000806000806000611c4d8a600a54600b54611e37565b9250925092506000611c5d61192e565b90506000806000611c708e878787611ecd565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b6000611cda83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113f0565b905092915050565b6000808284611cf1919061271a565b905083811015611d36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d2d90612575565b60405180910390fd5b8091505092915050565b6000611d4a61192e565b90506000611d618284611f5690919063ffffffff16565b9050611db581600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ce290919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b611e1282600854611c9890919063ffffffff16565b600881905550611e2d81600954611ce290919063ffffffff16565b6009819055505050565b600080600080611e636064611e55888a611f5690919063ffffffff16565b61195990919063ffffffff16565b90506000611e8d6064611e7f888b611f5690919063ffffffff16565b61195990919063ffffffff16565b90506000611eb682611ea8858c611c9890919063ffffffff16565b611c9890919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080611ee68589611f5690919063ffffffff16565b90506000611efd8689611f5690919063ffffffff16565b90506000611f148789611f5690919063ffffffff16565b90506000611f3d82611f2f8587611c9890919063ffffffff16565b611c9890919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415611f695760009050611fcb565b60008284611f7791906127a1565b9050828482611f869190612770565b14611fc6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fbd90612595565b60405180910390fd5b809150505b92915050565b600081359050611fe081612b3e565b92915050565b600081519050611ff581612b3e565b92915050565b60008135905061200a81612b55565b92915050565b60008151905061201f81612b55565b92915050565b60008135905061203481612b6c565b92915050565b60008151905061204981612b6c565b92915050565b60006020828403121561206157600080fd5b600061206f84828501611fd1565b91505092915050565b60006020828403121561208a57600080fd5b600061209884828501611fe6565b91505092915050565b600080604083850312156120b457600080fd5b60006120c285828601611fd1565b92505060206120d385828601611fd1565b9150509250929050565b6000806000606084860312156120f257600080fd5b600061210086828701611fd1565b935050602061211186828701611fd1565b925050604061212286828701612025565b9150509250925092565b6000806040838503121561213f57600080fd5b600061214d85828601611fd1565b925050602061215e85828601612025565b9150509250929050565b60006020828403121561217a57600080fd5b600061218884828501611ffb565b91505092915050565b6000602082840312156121a357600080fd5b60006121b184828501612010565b91505092915050565b6000806000606084860312156121cf57600080fd5b60006121dd8682870161203a565b93505060206121ee8682870161203a565b92505060406121ff8682870161203a565b9150509250925092565b60006122158383612221565b60208301905092915050565b61222a8161282f565b82525050565b6122398161282f565b82525050565b600061224a826126d5565b61225481856126f8565b935061225f836126c5565b8060005b838110156122905781516122778882612209565b9750612282836126eb565b925050600181019050612263565b5085935050505092915050565b6122a681612841565b82525050565b6122b581612884565b82525050565b60006122c6826126e0565b6122d08185612709565b93506122e0818560208601612896565b6122e981612927565b840191505092915050565b6000612301602a83612709565b915061230c82612938565b604082019050919050565b6000612324602283612709565b915061232f82612987565b604082019050919050565b6000612347601b83612709565b9150612352826129d6565b602082019050919050565b600061236a602183612709565b9150612375826129ff565b604082019050919050565b600061238d602083612709565b915061239882612a4e565b602082019050919050565b60006123b0602983612709565b91506123bb82612a77565b604082019050919050565b60006123d3602483612709565b91506123de82612ac6565b604082019050919050565b60006123f6601783612709565b915061240182612b15565b602082019050919050565b6124158161286d565b82525050565b61242481612877565b82525050565b600060208201905061243f6000830184612230565b92915050565b600060408201905061245a6000830185612230565b6124676020830184612230565b9392505050565b60006040820190506124836000830185612230565b612490602083018461240c565b9392505050565b600060c0820190506124ac6000830189612230565b6124b9602083018861240c565b6124c660408301876122ac565b6124d360608301866122ac565b6124e06080830185612230565b6124ed60a083018461240c565b979650505050505050565b600060208201905061250d600083018461229d565b92915050565b6000602082019050818103600083015261252d81846122bb565b905092915050565b6000602082019050818103600083015261254e816122f4565b9050919050565b6000602082019050818103600083015261256e81612317565b9050919050565b6000602082019050818103600083015261258e8161233a565b9050919050565b600060208201905081810360008301526125ae8161235d565b9050919050565b600060208201905081810360008301526125ce81612380565b9050919050565b600060208201905081810360008301526125ee816123a3565b9050919050565b6000602082019050818103600083015261260e816123c6565b9050919050565b6000602082019050818103600083015261262e816123e9565b9050919050565b600060208201905061264a600083018461240c565b92915050565b600060a082019050612665600083018861240c565b61267260208301876122ac565b8181036040830152612684818661223f565b90506126936060830185612230565b6126a0608083018461240c565b9695505050505050565b60006020820190506126bf600083018461241b565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006127258261286d565b91506127308361286d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612765576127646128c9565b5b828201905092915050565b600061277b8261286d565b91506127868361286d565b925082612796576127956128f8565b5b828204905092915050565b60006127ac8261286d565b91506127b78361286d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156127f0576127ef6128c9565b5b828202905092915050565b60006128068261286d565b91506128118361286d565b925082821015612824576128236128c9565b5b828203905092915050565b600061283a8261284d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061288f8261286d565b9050919050565b60005b838110156128b4578082015181840152602081019050612899565b838111156128c3576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b612b478161282f565b8114612b5257600080fd5b50565b612b5e81612841565b8114612b6957600080fd5b50565b612b758161286d565b8114612b8057600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220680aed8df9492716c4c1bef5643d5343a2c63a694f56c01af1d887e4f99003b864736f6c63430008040033
[ 13, 0, 5 ]
0xf1ee7548c02f6f53b41c3397bd052131a3472cc7
// 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; } } // 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); } // OpenZeppelin Contracts v4.4.0 (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; } } // OpenZeppelin Contracts v4.4.0 (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; } // OpenZeppelin Contracts v4.4.0 (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); } // OpenZeppelin Contracts v4.4.0 (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); } // 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); } // 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); } } } } // 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); } } // OpenZeppelin Contracts v4.4.0 (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 { _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 {} } // OpenZeppelin Contracts v4.4.0 (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(); } } // OpenZeppelin Contracts v4.4.0 (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() { _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); } } // 3D Bears //MMMMMMMMMMMMMMMMMMNNNNNNNmmmmNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMNNNmdhhyyssssssssssyyhhdmmNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMNNdhysssssssssssssssssssssssyyhdmNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMNmyssssssssssssssssssssssssssssssyyyhdmNNMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMNmyosssssssssssssssssssssssssssssssssyyyyhdmNNMMMMMMMMMMMMMMMMMMMMMMM //MMMMMNd+ossssssssssssssssssssssssssssssssssssyyyyyhdNNMMMMMMMMMMMMMMMMMMMMM //MMMMNh/osssssssssssssssssssssssssssssssssssssssyyyyyhdNNMMMMMMMMMMMMMMMMMMM //MMMNd:osssssssssssssssssssssssssssssssssssssssssyyyyyyhdNNMMMMMMMMMMMMMMMMM //MMNN+/sssssssssssssssssssssssssssssssssssssssssssyyyyyyyhmNMMMMMMMMMMMMMMMM //MMNh:ossssssyyyhhddddddddddddddhhyyyyssssssssssssyyyyyyyyydNMMMMMMMMMMMMMMM //MMNo:ssyyhddhhso/::----------:/+osyhddddhyysssssssdhyyyyyyydNNMMMMMMMMMMMMM //MNN++hddy+:.` `-:+shddddhyssymhyyyyyyydNNMMMMMMMMMMMM //MNNdds:` `.:+oydddhhmdyyyyyyydNMMMMMMMMMMMM //MNm+` `.-/oydmNdyyyyyyymNMMMMMMMMMMM //NN- ````` .---/odmhyyyyyhNNMMMMMMMMMM //Nd `.:/+ossyyyhhhhhhhyyysso+/:.` -----:mmyyyyyymNMMMMMMMMMM //Nh -/shddhso+/:--..```````..--:/+oshddhs+:. `-----sNdhyyyyhNNNMMMMMMMM //Nm`/ymho/. .:+shmyo::----/NNNdyyyyNm+sdNNMMMM //NNmN/` `-+ymho/-:NNmNmdmmy/ -smNMM //MMNh :shyo. .-:- :+ymhsNd.-::.` .:dNM //MMNs y+:hNNm/ -ohs/-` .--:mNN- .-:mN //MMNo .NyomNNNh .smms+:-` .---yNm ---dN //MMNs hNNNNNN+ -s+////+o. `---sNN- `.--:mN //MMNy `ohddy/ `---oNNh:.```````.---:yNM //MNN: ``` `..... `---sNNNd+:--------:+dNMM //MNh +ddyyydh- `---oNMMMNdyo+//+oydNNMMM //MNs /mNNNNNd. .---sNMMMMMMNNNNNNMMMMMMM //MNy -: .+dNy/` :s ----hNMMMMMMMMMMMMMMMMMMM //MNm. .do:+mNh+/+yN+ .---oNNMMMMMMMMMMMMMMMMMMM //MMNd. ./dNmmdhhmNd `---:oNNMMMMMMMMMMMMMMMMMMMM //MMMNm/` :mmsoosdd- `.--:+hNMMMMMMMMMMMMMMMMMMMMMM //MMMMMNd+.` .ohddy+` `.--:/sdNNMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMNNho:.` ``.--:/oydNNMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMNNNdhs+/:-..`````.....--:/+osyhdNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //MMMMMMMMMMMMMMMMNNNNNNmmmmmmmmNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM // 3D Bears is a collection of 10,000 adorable polar bear NFTs in 4K available on the Ethereum blockchain. // Each bear is completely unique, and based on an original Winter Bear, created using 150 individual features. pragma solidity ^0.8.10; contract TDBears is ERC721Enumerable, Ownable { address public constant winterAddress = 0xC8BcbE0E8ae36D8f9238cd320ef6dE88784B1734; address public constant summerAddress = 0xE5Ba25f22A20a22fb47DADF137f33fE2E9AB22AC; uint256 public discountPrice = 0.02 ether; uint256 public fullPrice = 0.05 ether; uint256 public constant MAX_BEARS = 10000; uint256 public constant MAX_BEARS_PER_MINT = 20; string private baseURI; bool public isDiscountSaleActive = false; bool public isPresaleActive = false; bool public isSaleActive = false; mapping(uint256 => bool) public claimed; mapping(address => bool) private presaleList; constructor() ERC721("3DBears", "3DB") {} function withdraw() public onlyOwner { uint balance = address(this).balance; payable(msg.sender).transfer(balance); } function discountSaleMint(uint256[] memory tokenIds) public payable { uint256 totalSupply = totalSupply(); require(isDiscountSaleActive, "Discount sale is not active" ); require(msg.value >= tokenIds.length * discountPrice, "Ether value sent is not correct"); require(tokenIds.length <= MAX_BEARS_PER_MINT, "Exceeds maximum bears you can purchase in a single transaction"); require(totalSupply + tokenIds.length <= MAX_BEARS, "Exceeds maximum bears available for purchase"); for(uint256 i = 0; i < tokenIds.length; i++) { require(!claimed[tokenIds[i]]); require( ERC721(winterAddress).ownerOf(tokenIds[i]) == msg.sender, "Not owner of Winter Bear" ); require( ERC721(summerAddress).ownerOf(tokenIds[i]) == msg.sender, "Not owner of Summer Bear" ); claimed[tokenIds[i]] = true; _safeMint(msg.sender, totalSupply + i); } } function presaleMint(uint256 _count) public payable { uint256 totalSupply = totalSupply(); require(isPresaleActive, "Pre sale is not active" ); require(msg.value >= _count * fullPrice, "Ether value sent is not correct"); require(_count <= MAX_BEARS_PER_MINT, "Exceeds maximum bears you can purchase in a single transaction"); require(totalSupply + _count <= MAX_BEARS, "Exceeds maximum bears available for purchase"); require(presaleList[msg.sender], "Address not whitelisted for presale"); for (uint256 i = 0; i < _count; i++) { _safeMint(msg.sender, totalSupply + i); } } function mint(uint256 _count) public payable { uint256 totalSupply = totalSupply(); require(isSaleActive, "Sale is not active" ); require(msg.value >= _count * fullPrice, "Ether value sent is not correct"); require(_count <= MAX_BEARS_PER_MINT, "Exceeds maximum bears you can purchase in a single transaction"); require(totalSupply + _count <= MAX_BEARS, "Exceeds maximum bears available for purchase"); for (uint256 i = 0; i < _count; i++) { _safeMint(msg.sender, totalSupply + i); } } function setBaseUri(string memory _uri) external onlyOwner { baseURI = _uri; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function flipSaleStatus() public onlyOwner { isSaleActive = !isSaleActive; } function flipPresaleStatus() public onlyOwner { isPresaleActive = !isPresaleActive; } function flipDiscountSaleStatus() public onlyOwner { isDiscountSaleActive = !isDiscountSaleActive; } function setFullPrice(uint256 _newPrice) public onlyOwner() { fullPrice = _newPrice; } function setDiscountPrice(uint256 _newPrice) public onlyOwner() { discountPrice = _newPrice; } function tokensOfOwner(address _owner) external view returns(uint256[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } function addToPresaleList(address[] memory _wallets) public onlyOwner { for(uint i; i < _wallets.length; i++) presaleList[_wallets[i]] = true; } function removeFromPresaleList(address[] memory _wallets) public onlyOwner { for(uint i; i < _wallets.length; i++) presaleList[_wallets[i]] = false; } function checkPresaleList() public view returns(bool) { return presaleList[msg.sender]; } }
0x6080604052600436106102dc5760003560e01c80638462151c11610184578063b88d4fde116100d6578063dbe7e3bd1161008a578063e985e9c511610064578063e985e9c5146107cc578063edd634b814610822578063f2fde38b1461083857600080fd5b8063dbe7e3bd14610761578063df2d6e7714610791578063e03b842e146107a457600080fd5b8063c9b298f1116100bb578063c9b298f114610723578063ce03ec9314610736578063da649ed71461074b57600080fd5b8063b88d4fde146106e3578063c87b56dd1461070357600080fd5b8063a0712d6811610138578063a2e4f14011610112578063a2e4f1401461068e578063adcb1e66146106a3578063b179e060146106c357600080fd5b8063a0712d681461063b578063a0bcfc7f1461064e578063a22cb4651461066e57600080fd5b80638b78c116116101695780638b78c116146105db5780638da5cb5b146105fb57806395d89b411461062657600080fd5b80638462151c1461059857806384ad8e8f146105c557600080fd5b806342842e0e1161023d5780636352211e116101f1578063715018a6116101cb578063715018a61461053b5780637204a3c91461055057806379f842161461057057600080fd5b80636352211e146104d657806370a08231146104f657806370c18f1f1461051657600080fd5b8063564566a811610222578063564566a8146104825780635d9f5a63146104a257806360d938dc146104b757600080fd5b806342842e0e146104425780634f6ccce71461046257600080fd5b806318160ddd116102945780632f745c59116102795780632f745c59146103f35780633ccfd60b1461041357806340c45b411461042857600080fd5b806318160ddd146103b457806323b872dd146103d357600080fd5b8063081812fc116102c5578063081812fc14610338578063095ea7b31461037d5780631725051f1461039f57600080fd5b806301ffc9a7146102e157806306fdde0314610316575b600080fd5b3480156102ed57600080fd5b506103016102fc3660046135e6565b610858565b60405190151581526020015b60405180910390f35b34801561032257600080fd5b5061032b6108b4565b60405161030d9190613679565b34801561034457600080fd5b5061035861035336600461368c565b610946565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161030d565b34801561038957600080fd5b5061039d6103983660046136c7565b610a25565b005b3480156103ab57600080fd5b5061039d610bb2565b3480156103c057600080fd5b506008545b60405190815260200161030d565b3480156103df57600080fd5b5061039d6103ee3660046136f3565b610c6d565b3480156103ff57600080fd5b506103c561040e3660046136c7565b610d0e565b34801561041f57600080fd5b5061039d610ddd565b34801561043457600080fd5b50600e546103019060ff1681565b34801561044e57600080fd5b5061039d61045d3660046136f3565b610e91565b34801561046e57600080fd5b506103c561047d36600461368c565b610eac565b34801561048e57600080fd5b50600e546103019062010000900460ff1681565b3480156104ae57600080fd5b506103c5601481565b3480156104c357600080fd5b50600e5461030190610100900460ff1681565b3480156104e257600080fd5b506103586104f136600461368c565b610f6a565b34801561050257600080fd5b506103c5610511366004613734565b61101c565b34801561052257600080fd5b503360009081526010602052604090205460ff16610301565b34801561054757600080fd5b5061039d6110ea565b34801561055c57600080fd5b5061039d61056b3660046137f3565b611177565b34801561057c57600080fd5b5061035873c8bcbe0e8ae36d8f9238cd320ef6de88784b173481565b3480156105a457600080fd5b506105b86105b3366004613734565b61128b565b60405161030d9190613892565b3480156105d157600080fd5b506103c5600b5481565b3480156105e757600080fd5b5061039d6105f636600461368c565b61134a565b34801561060757600080fd5b50600a5473ffffffffffffffffffffffffffffffffffffffff16610358565b34801561063257600080fd5b5061032b6113d0565b61039d61064936600461368c565b6113df565b34801561065a57600080fd5b5061039d61066936600461394c565b611631565b34801561067a57600080fd5b5061039d610689366004613995565b6116c5565b34801561069a57600080fd5b5061039d6116d0565b3480156106af57600080fd5b5061039d6106be36600461368c565b611783565b3480156106cf57600080fd5b5061039d6106de3660046137f3565b611809565b3480156106ef57600080fd5b5061039d6106fe3660046139d3565b61191d565b34801561070f57600080fd5b5061032b61071e36600461368c565b6119c5565b61039d61073136600461368c565b611ad5565b34801561074257600080fd5b5061039d611dc0565b34801561075757600080fd5b506103c561271081565b34801561076d57600080fd5b5061030161077c36600461368c565b600f6020526000908152604090205460ff1681565b61039d61079f366004613a53565b611e7c565b3480156107b057600080fd5b5061035873e5ba25f22a20a22fb47dadf137f33fe2e9ab22ac81565b3480156107d857600080fd5b506103016107e7366004613ad9565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561082e57600080fd5b506103c5600c5481565b34801561084457600080fd5b5061039d610853366004613734565b6123c9565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d630000000000000000000000000000000000000000000000000000000014806108ae57506108ae826124f9565b92915050565b6060600080546108c390613b07565b80601f01602080910402602001604051908101604052809291908181526020018280546108ef90613b07565b801561093c5780601f106109115761010080835404028352916020019161093c565b820191906000526020600020905b81548152906001019060200180831161091f57829003601f168201915b5050505050905090565b60008181526002602052604081205473ffffffffffffffffffffffffffffffffffffffff166109fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060009081526004602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000610a3082610f6a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610aee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016109f3565b3373ffffffffffffffffffffffffffffffffffffffff82161480610b175750610b1781336107e7565b610ba3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109f3565b610bad83836125dc565b505050565b600a5473ffffffffffffffffffffffffffffffffffffffff163314610c33576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b600e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b610c77338261267c565b610d03576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109f3565b610bad8383836127ec565b6000610d198361101c565b8210610da7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e647300000000000000000000000000000000000000000060648201526084016109f3565b5073ffffffffffffffffffffffffffffffffffffffff919091166000908152600660209081526040808320938352929052205490565b600a5473ffffffffffffffffffffffffffffffffffffffff163314610e5e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b6040514790339082156108fc029083906000818181858888f19350505050158015610e8d573d6000803e3d6000fd5b5050565b610bad8383836040518060200160405280600081525061191d565b6000610eb760085490565b8210610f45576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e6473000000000000000000000000000000000000000060648201526084016109f3565b60088281548110610f5857610f58613b55565b90600052602060002001549050919050565b60008181526002602052604081205473ffffffffffffffffffffffffffffffffffffffff16806108ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016109f3565b600073ffffffffffffffffffffffffffffffffffffffff82166110c1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016109f3565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b600a5473ffffffffffffffffffffffffffffffffffffffff16331461116b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b6111756000612a5e565b565b600a5473ffffffffffffffffffffffffffffffffffffffff1633146111f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b60005b8151811015610e8d5760016010600084848151811061121c5761121c613b55565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff16825281019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790558061128381613bb3565b9150506111fb565b606060006112988361101c565b9050806112b95760408051600080825260208201909252905b509392505050565b60008167ffffffffffffffff8111156112d4576112d4613751565b6040519080825280602002602001820160405280156112fd578160200160208202803683370190505b50905060005b828110156112b1576113158582610d0e565b82828151811061132757611327613b55565b60209081029190910101528061133c81613bb3565b915050611303565b50919050565b600a5473ffffffffffffffffffffffffffffffffffffffff1633146113cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b600b55565b6060600180546108c390613b07565b60006113ea60085490565b600e5490915062010000900460ff1661145f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f53616c65206973206e6f7420616374697665000000000000000000000000000060448201526064016109f3565b600c5461146c9083613bec565b3410156114d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f72726563740060448201526064016109f3565b6014821115611566576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f45786365656473206d6178696d756d20626561727320796f752063616e20707560448201527f72636861736520696e20612073696e676c65207472616e73616374696f6e000060648201526084016109f3565b6127106115738383613c29565b1115611601576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f45786365656473206d6178696d756d20626561727320617661696c61626c652060448201527f666f72207075726368617365000000000000000000000000000000000000000060648201526084016109f3565b60005b82811015610bad5761161f3361161a8385613c29565b612ad5565b8061162981613bb3565b915050611604565b600a5473ffffffffffffffffffffffffffffffffffffffff1633146116b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b8051610e8d90600d90602084019061351f565b610e8d338383612aef565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611751576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b600e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611804576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b600c55565b600a5473ffffffffffffffffffffffffffffffffffffffff16331461188a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b60005b8151811015610e8d576000601060008484815181106118ae576118ae613b55565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff16825281019190915260400160002080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169115159190911790558061191581613bb3565b91505061188d565b611927338361267c565b6119b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016109f3565b6119bf84848484612c1d565b50505050565b60008181526002602052604090205460609073ffffffffffffffffffffffffffffffffffffffff16611a79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e000000000000000000000000000000000060648201526084016109f3565b6000611a83612cc0565b90506000815111611aa35760405180602001604052806000815250611ace565b80611aad84612ccf565b604051602001611abe929190613c41565b6040516020818303038152906040525b9392505050565b6000611ae060085490565b600e54909150610100900460ff16611b54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5072652073616c65206973206e6f74206163746976650000000000000000000060448201526064016109f3565b600c54611b619083613bec565b341015611bca576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f72726563740060448201526064016109f3565b6014821115611c5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f45786365656473206d6178696d756d20626561727320796f752063616e20707560448201527f72636861736520696e20612073696e676c65207472616e73616374696f6e000060648201526084016109f3565b612710611c688383613c29565b1115611cf6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f45786365656473206d6178696d756d20626561727320617661696c61626c652060448201527f666f72207075726368617365000000000000000000000000000000000000000060648201526084016109f3565b3360009081526010602052604090205460ff16611d95576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f41646472657373206e6f742077686974656c697374656420666f72207072657360448201527f616c65000000000000000000000000000000000000000000000000000000000060648201526084016109f3565b60005b82811015610bad57611dae3361161a8385613c29565b80611db881613bb3565b915050611d98565b600a5473ffffffffffffffffffffffffffffffffffffffff163314611e41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b600e80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b6000611e8760085490565b600e5490915060ff16611ef6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f446973636f756e742073616c65206973206e6f7420616374697665000000000060448201526064016109f3565b600b548251611f059190613bec565b341015611f6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f72726563740060448201526064016109f3565b601482511115612000576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f45786365656473206d6178696d756d20626561727320796f752063616e20707560448201527f72636861736520696e20612073696e676c65207472616e73616374696f6e000060648201526084016109f3565b6127108251826120109190613c29565b111561209e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f45786365656473206d6178696d756d20626561727320617661696c61626c652060448201527f666f72207075726368617365000000000000000000000000000000000000000060648201526084016109f3565b60005b8251811015610bad57600f60008483815181106120c0576120c0613b55565b60209081029190910181015182528101919091526040016000205460ff16156120e857600080fd5b3373ffffffffffffffffffffffffffffffffffffffff1673c8bcbe0e8ae36d8f9238cd320ef6de88784b173473ffffffffffffffffffffffffffffffffffffffff16636352211e85848151811061214157612141613b55565b60200260200101516040518263ffffffff1660e01b815260040161216791815260200190565b602060405180830381865afa158015612184573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a89190613c70565b73ffffffffffffffffffffffffffffffffffffffff1614612225576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4e6f74206f776e6572206f662057696e7465722042656172000000000000000060448201526064016109f3565b3373ffffffffffffffffffffffffffffffffffffffff1673e5ba25f22a20a22fb47dadf137f33fe2e9ab22ac73ffffffffffffffffffffffffffffffffffffffff16636352211e85848151811061227e5761227e613b55565b60200260200101516040518263ffffffff1660e01b81526004016122a491815260200190565b602060405180830381865afa1580156122c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e59190613c70565b73ffffffffffffffffffffffffffffffffffffffff1614612362576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4e6f74206f776e6572206f662053756d6d65722042656172000000000000000060448201526064016109f3565b6001600f600085848151811061237a5761237a613b55565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055506123b733828461161a9190613c29565b806123c181613bb3565b9150506120a1565b600a5473ffffffffffffffffffffffffffffffffffffffff16331461244a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109f3565b73ffffffffffffffffffffffffffffffffffffffff81166124ed576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109f3565b6124f681612a5e565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061258c57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806108ae57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146108ae565b600081815260046020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8416908117909155819061263682610f6a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008181526002602052604081205473ffffffffffffffffffffffffffffffffffffffff1661272d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084016109f3565b600061273883610f6a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806127a757508373ffffffffffffffffffffffffffffffffffffffff1661278f84610946565b73ffffffffffffffffffffffffffffffffffffffff16145b806127e4575073ffffffffffffffffffffffffffffffffffffffff80821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b8273ffffffffffffffffffffffffffffffffffffffff1661280c82610f6a565b73ffffffffffffffffffffffffffffffffffffffff16146128af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016109f3565b73ffffffffffffffffffffffffffffffffffffffff8216612951576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016109f3565b61295c838383612e01565b6129676000826125dc565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040812080546001929061299d908490613c8d565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604081208054600192906129d8908490613c29565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610e8d828260405180602001604052806000815250612f07565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612b85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109f3565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526005602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612c288484846127ec565b612c3484848484612faa565b6119bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109f3565b6060600d80546108c390613b07565b606081612d0f57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612d395780612d2381613bb3565b9150612d329050600a83613cd3565b9150612d13565b60008167ffffffffffffffff811115612d5457612d54613751565b6040519080825280601f01601f191660200182016040528015612d7e576020820181803683370190505b5090505b84156127e457612d93600183613c8d565b9150612da0600a86613ce7565b612dab906030613c29565b60f81b818381518110612dc057612dc0613b55565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612dfa600a86613cd3565b9450612d82565b73ffffffffffffffffffffffffffffffffffffffff8316612e6957612e6481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612ea6565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612ea657612ea6838261319a565b73ffffffffffffffffffffffffffffffffffffffff8216612eca57610bad81613251565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610bad57610bad8282613300565b612f118383613351565b612f1e6000848484612faa565b610bad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109f3565b600073ffffffffffffffffffffffffffffffffffffffff84163b1561318f576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290613021903390899088908890600401613cfb565b6020604051808303816000875af192505050801561307a575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261307791810190613d44565b60015b613144573d8080156130a8576040519150601f19603f3d011682016040523d82523d6000602084013e6130ad565b606091505b50805161313c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016109f3565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001490506127e4565b506001949350505050565b600060016131a78461101c565b6131b19190613c8d565b6000838152600760205260409020549091508082146132115773ffffffffffffffffffffffffffffffffffffffff841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b50600091825260076020908152604080842084905573ffffffffffffffffffffffffffffffffffffffff9094168352600681528383209183525290812055565b60085460009061326390600190613c8d565b6000838152600960205260408120546008805493945090928490811061328b5761328b613b55565b9060005260206000200154905080600883815481106132ac576132ac613b55565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806132e4576132e4613d61565b6001900381819060005260206000200160009055905550505050565b600061330b8361101c565b73ffffffffffffffffffffffffffffffffffffffff9093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b73ffffffffffffffffffffffffffffffffffffffff82166133ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109f3565b60008181526002602052604090205473ffffffffffffffffffffffffffffffffffffffff161561345a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109f3565b61346660008383612e01565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260036020526040812080546001929061349c908490613c29565b909155505060008181526002602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461352b90613b07565b90600052602060002090601f01602090048101928261354d5760008555613593565b82601f1061356657805160ff1916838001178555613593565b82800160010185558215613593579182015b82811115613593578251825591602001919060010190613578565b5061359f9291506135a3565b5090565b5b8082111561359f57600081556001016135a4565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146124f657600080fd5b6000602082840312156135f857600080fd5b8135611ace816135b8565b60005b8381101561361e578181015183820152602001613606565b838111156119bf5750506000910152565b60008151808452613647816020860160208601613603565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000611ace602083018461362f565b60006020828403121561369e57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff811681146124f657600080fd5b600080604083850312156136da57600080fd5b82356136e5816136a5565b946020939093013593505050565b60008060006060848603121561370857600080fd5b8335613713816136a5565b92506020840135613723816136a5565b929592945050506040919091013590565b60006020828403121561374657600080fd5b8135611ace816136a5565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156137c7576137c7613751565b604052919050565b600067ffffffffffffffff8211156137e9576137e9613751565b5060051b60200190565b6000602080838503121561380657600080fd5b823567ffffffffffffffff81111561381d57600080fd5b8301601f8101851361382e57600080fd5b803561384161383c826137cf565b613780565b81815260059190911b8201830190838101908783111561386057600080fd5b928401925b82841015613887578335613878816136a5565b82529284019290840190613865565b979650505050505050565b6020808252825182820181905260009190848201906040850190845b818110156138ca578351835292840192918401916001016138ae565b50909695505050505050565b600067ffffffffffffffff8311156138f0576138f0613751565b61392160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f86011601613780565b905082815283838301111561393557600080fd5b828260208301376000602084830101529392505050565b60006020828403121561395e57600080fd5b813567ffffffffffffffff81111561397557600080fd5b8201601f8101841361398657600080fd5b6127e4848235602084016138d6565b600080604083850312156139a857600080fd5b82356139b3816136a5565b9150602083013580151581146139c857600080fd5b809150509250929050565b600080600080608085870312156139e957600080fd5b84356139f4816136a5565b93506020850135613a04816136a5565b925060408501359150606085013567ffffffffffffffff811115613a2757600080fd5b8501601f81018713613a3857600080fd5b613a47878235602084016138d6565b91505092959194509250565b60006020808385031215613a6657600080fd5b823567ffffffffffffffff811115613a7d57600080fd5b8301601f81018513613a8e57600080fd5b8035613a9c61383c826137cf565b81815260059190911b82018301908381019087831115613abb57600080fd5b928401925b8284101561388757833582529284019290840190613ac0565b60008060408385031215613aec57600080fd5b8235613af7816136a5565b915060208301356139c8816136a5565b600181811c90821680613b1b57607f821691505b60208210811415611344577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613be557613be5613b84565b5060010190565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613c2457613c24613b84565b500290565b60008219821115613c3c57613c3c613b84565b500190565b60008351613c53818460208801613603565b835190830190613c67818360208801613603565b01949350505050565b600060208284031215613c8257600080fd5b8151611ace816136a5565b600082821015613c9f57613c9f613b84565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082613ce257613ce2613ca4565b500490565b600082613cf657613cf6613ca4565b500690565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152613d3a608083018461362f565b9695505050505050565b600060208284031215613d5657600080fd5b8151611ace816135b8565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea2646970667358221220a00199d10fffe4fd1f7c5bb2861fcd96c673c242de218f9950fbbbad02532f3064736f6c634300080a0033
[ 5, 12 ]
0xf1ef1a8d2dcc8a1b197a92bcda974db6f4960233
// SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; import "./ERC721.sol"; import "./Counters.sol"; import "./Ownable.sol"; contract FunkyFungiGenesis is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; mapping(uint256 => string) public allTokenUris; Counters.Counter private supply; string public uriPrefix = "ipfs://"; string public uriSuffix = ".json"; uint256 public maxSupply = 50; constructor() ERC721("Funky Fungi Genesis", "FFGC") { } modifier mintCompliance() { require(supply.current() + 1 <= maxSupply, "Max supply exceeded!"); _; } function totalSupply() public view returns (uint256) { return supply.current(); } function checkIsOwner(address _owner, uint256 _tokenId) public view returns (bool) { bool isHolder = false; address currentTokenOwner = ownerOf(_tokenId); if (currentTokenOwner == _owner) { isHolder = true; } return isHolder; } function mint(string memory _metadataUri) public mintCompliance() onlyOwner { supply.increment(); allTokenUris[supply.current()] = _metadataUri; _safeMint(msg.sender, supply.current()); } 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), "URI query for nonexistent token" ); string memory currentBaseURI = allTokenUris[_tokenId]; return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(uriPrefix, currentBaseURI, uriSuffix)) : ""; } function setUriPrefix(string memory _uriPrefix) public onlyOwner { uriPrefix = _uriPrefix; } function updateTokenUri(uint256 _tokenId, string memory _newTokenUri) public onlyOwner { allTokenUris[_tokenId] = _newTokenUri; } function setUriSuffix(string memory _uriSuffix) public onlyOwner { uriSuffix = _uriSuffix; } function withdraw() public onlyOwner { (bool os, ) = payable(owner()).call{value: address(this).balance}(""); require(os); } }
0x608060405234801561001057600080fd5b50600436106101c45760003560e01c806370a08231116100f9578063c87b56dd11610097578063d5afc64011610071578063d5afc6401461038f578063d85d3d27146103a2578063e985e9c5146103b5578063f2fde38b146103f157600080fd5b8063c87b56dd14610360578063d31af48414610373578063d5abeb011461038657600080fd5b80638da5cb5b116100d35780638da5cb5b1461032157806395d89b4114610332578063a22cb4651461033a578063b88d4fde1461034d57600080fd5b806370a08231146102f3578063715018a6146103065780637ec4a6591461030e57600080fd5b80632fe4d71d11610166578063438b630011610140578063438b6300146102b05780635503a0e8146102d057806362b99ad4146102d85780636352211e146102e057600080fd5b80632fe4d71d146102825780633ccfd60b1461029557806342842e0e1461029d57600080fd5b8063095ea7b3116101a2578063095ea7b31461023157806316ba10e01461024657806318160ddd1461025957806323b872dd1461026f57600080fd5b806301ffc9a7146101c957806306fdde03146101f1578063081812fc14610206575b600080fd5b6101dc6101d736600461180a565b610404565b60405190151581526020015b60405180910390f35b6101f9610456565b6040516101e89190611a53565b610219610214366004611879565b6104e8565b6040516001600160a01b0390911681526020016101e8565b61024461023f3660046117e0565b610582565b005b610244610254366004611844565b610698565b6102616106d9565b6040519081526020016101e8565b61024461027d3660046116ec565b6106e9565b6101f9610290366004611879565b61071a565b6102446107b4565b6102446102ab3660046116ec565b610852565b6102c36102be36600461169e565b61086d565b6040516101e89190611a0f565b6101f961094e565b6101f961095b565b6102196102ee366004611879565b610968565b61026161030136600461169e565b6109df565b610244610a66565b61024461031c366004611844565b610a9c565b6006546001600160a01b0316610219565b6101f9610ad9565b6102446103483660046117a4565b610ae8565b61024461035b366004611728565b610af3565b6101f961036e366004611879565b610b2b565b610244610381366004611892565b610c77565b610261600b5481565b6101dc61039d3660046117e0565b610cc0565b6102446103b0366004611844565b610cf6565b6101dc6103c33660046116b9565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102446103ff36600461169e565b610dc6565b60006001600160e01b031982166380ac58cd60e01b148061043557506001600160e01b03198216635b5e139f60e01b145b8061045057506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461046590611b99565b80601f016020809104026020016040519081016040528092919081815260200182805461049190611b99565b80156104de5780601f106104b3576101008083540402835291602001916104de565b820191906000526020600020905b8154815290600101906020018083116104c157829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166105665760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061058d82610968565b9050806001600160a01b0316836001600160a01b031614156105fb5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161055d565b336001600160a01b0382161480610617575061061781336103c3565b6106895760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161055d565b6106938383610e5e565b505050565b6006546001600160a01b031633146106c25760405162461bcd60e51b815260040161055d90611ab8565b80516106d590600a906020840190611553565b5050565b60006106e460085490565b905090565b6106f33382610ecc565b61070f5760405162461bcd60e51b815260040161055d90611aed565b610693838383610fc3565b6007602052600090815260409020805461073390611b99565b80601f016020809104026020016040519081016040528092919081815260200182805461075f90611b99565b80156107ac5780601f10610781576101008083540402835291602001916107ac565b820191906000526020600020905b81548152906001019060200180831161078f57829003601f168201915b505050505081565b6006546001600160a01b031633146107de5760405162461bcd60e51b815260040161055d90611ab8565b60006107f26006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d806000811461083c576040519150601f19603f3d011682016040523d82523d6000602084013e610841565b606091505b505090508061084f57600080fd5b50565b61069383838360405180602001604052806000815250610af3565b6060600061087a836109df565b905060008167ffffffffffffffff81111561089757610897611c1b565b6040519080825280602002602001820160405280156108c0578160200160208202803683370190505b509050600160005b83811080156108d95750600b548211155b156109445760006108e983610968565b9050866001600160a01b0316816001600160a01b03161415610931578284838151811061091857610918611c05565b60209081029190910101528161092d81611bd4565b9250505b8261093b81611bd4565b935050506108c8565b5090949350505050565b600a805461073390611b99565b6009805461073390611b99565b6000818152600260205260408120546001600160a01b0316806104505760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161055d565b60006001600160a01b038216610a4a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161055d565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610a905760405162461bcd60e51b815260040161055d90611ab8565b610a9a6000611163565b565b6006546001600160a01b03163314610ac65760405162461bcd60e51b815260040161055d90611ab8565b80516106d5906009906020840190611553565b60606001805461046590611b99565b6106d53383836111b5565b610afd3383610ecc565b610b195760405162461bcd60e51b815260040161055d90611aed565b610b2584848484611284565b50505050565b6000818152600260205260409020546060906001600160a01b0316610b925760405162461bcd60e51b815260206004820152601f60248201527f55524920717565727920666f72206e6f6e6578697374656e7420746f6b656e00604482015260640161055d565b60008281526007602052604081208054610bab90611b99565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd790611b99565b8015610c245780601f10610bf957610100808354040283529160200191610c24565b820191906000526020600020905b815481529060010190602001808311610c0757829003601f168201915b505050505090506000815111610c495760405180602001604052806000815250610c70565b600981600a604051602001610c609392919061199f565b6040516020818303038152906040525b9392505050565b6006546001600160a01b03163314610ca15760405162461bcd60e51b815260040161055d90611ab8565b6000828152600760209081526040909120825161069392840190611553565b60008080610ccd84610968565b9050846001600160a01b0316816001600160a01b03161415610cee57600191505b509392505050565b600b54600854610d07906001611b3e565b1115610d4c5760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b604482015260640161055d565b6006546001600160a01b03163314610d765760405162461bcd60e51b815260040161055d90611ab8565b610d84600880546001019055565b8060076000610d9260085490565b81526020019081526020016000209080519060200190610db3929190611553565b5061084f33610dc160085490565b6112b7565b6006546001600160a01b03163314610df05760405162461bcd60e51b815260040161055d90611ab8565b6001600160a01b038116610e555760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161055d565b61084f81611163565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610e9382610968565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316610f455760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161055d565b6000610f5083610968565b9050806001600160a01b0316846001600160a01b03161480610f8b5750836001600160a01b0316610f80846104e8565b6001600160a01b0316145b80610fbb57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316610fd682610968565b6001600160a01b03161461103e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161055d565b6001600160a01b0382166110a05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161055d565b6110ab600082610e5e565b6001600160a01b03831660009081526003602052604081208054600192906110d4908490611b56565b90915550506001600160a01b0382166000908152600360205260408120805460019290611102908490611b3e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031614156112175760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161055d565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61128f848484610fc3565b61129b848484846112d1565b610b255760405162461bcd60e51b815260040161055d90611a66565b6106d58282604051806020016040528060008152506113de565b60006001600160a01b0384163b156113d357604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906113159033908990889088906004016119d2565b602060405180830381600087803b15801561132f57600080fd5b505af192505050801561135f575060408051601f3d908101601f1916820190925261135c91810190611827565b60015b6113b9573d80801561138d576040519150601f19603f3d011682016040523d82523d6000602084013e611392565b606091505b5080516113b15760405162461bcd60e51b815260040161055d90611a66565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050610fbb565b506001949350505050565b6113e88383611411565b6113f560008484846112d1565b6106935760405162461bcd60e51b815260040161055d90611a66565b6001600160a01b0382166114675760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161055d565b6000818152600260205260409020546001600160a01b0316156114cc5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161055d565b6001600160a01b03821660009081526003602052604081208054600192906114f5908490611b3e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461155f90611b99565b90600052602060002090601f01602090048101928261158157600085556115c7565b82601f1061159a57805160ff19168380011785556115c7565b828001600101855582156115c7579182015b828111156115c75782518255916020019190600101906115ac565b506115d39291506115d7565b5090565b5b808211156115d357600081556001016115d8565b600067ffffffffffffffff8084111561160757611607611c1b565b604051601f8501601f19908116603f0116810190828211818310171561162f5761162f611c1b565b8160405280935085815286868601111561164857600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461167957600080fd5b919050565b600082601f83011261168f57600080fd5b610c70838335602085016115ec565b6000602082840312156116b057600080fd5b610c7082611662565b600080604083850312156116cc57600080fd5b6116d583611662565b91506116e360208401611662565b90509250929050565b60008060006060848603121561170157600080fd5b61170a84611662565b925061171860208501611662565b9150604084013590509250925092565b6000806000806080858703121561173e57600080fd5b61174785611662565b935061175560208601611662565b925060408501359150606085013567ffffffffffffffff81111561177857600080fd5b8501601f8101871361178957600080fd5b611798878235602084016115ec565b91505092959194509250565b600080604083850312156117b757600080fd5b6117c083611662565b9150602083013580151581146117d557600080fd5b809150509250929050565b600080604083850312156117f357600080fd5b6117fc83611662565b946020939093013593505050565b60006020828403121561181c57600080fd5b8135610c7081611c31565b60006020828403121561183957600080fd5b8151610c7081611c31565b60006020828403121561185657600080fd5b813567ffffffffffffffff81111561186d57600080fd5b610fbb8482850161167e565b60006020828403121561188b57600080fd5b5035919050565b600080604083850312156118a557600080fd5b82359150602083013567ffffffffffffffff8111156118c357600080fd5b6118cf8582860161167e565b9150509250929050565b600081518084526118f1816020860160208601611b6d565b601f01601f19169290920160200192915050565b8054600090600181811c908083168061191f57607f831692505b602080841082141561194157634e487b7160e01b600052602260045260246000fd5b818015611955576001811461196657611993565b60ff19861689528489019650611993565b60008881526020902060005b8681101561198b5781548b820152908501908301611972565b505084890196505b50505050505092915050565b60006119ab8286611905565b84516119bb818360208901611b6d565b6119c781830186611905565b979650505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611a05908301846118d9565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611a4757835183529284019291840191600101611a2b565b50909695505050505050565b602081526000610c7060208301846118d9565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60008219821115611b5157611b51611bef565b500190565b600082821015611b6857611b68611bef565b500390565b60005b83811015611b88578181015183820152602001611b70565b83811115610b255750506000910152565b600181811c90821680611bad57607f821691505b60208210811415611bce57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611be857611be8611bef565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461084f57600080fdfea264697066735822122076ce4b1308287554a3a680c78d71b85a861c1f93d8b7556ea1d17c669b55dac764736f6c63430008070033
[ 5 ]
0xf1ef280f57c83abfb4dd38584a66b4969395f9e1
pragma solidity ^0.4.18; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; } contract TokenERC20 { // Public variables of the token string public name; string public symbol; uint8 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constructor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( uint256 initialSupply ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` on behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens on your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
0x6060604052600436106100b95763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100be578063095ea7b31461014857806318160ddd1461017e57806323b872dd146101a3578063313ce567146101cb57806342966c68146101f457806370a082311461020a57806379cc67901461022957806395d89b411461024b578063a9059cbb1461025e578063cae9ca5114610282578063dd62ed3e146102e7575b600080fd5b34156100c957600080fd5b6100d161030c565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561010d5780820151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015357600080fd5b61016a600160a060020a03600435166024356103aa565b604051901515815260200160405180910390f35b341561018957600080fd5b6101916103da565b60405190815260200160405180910390f35b34156101ae57600080fd5b61016a600160a060020a03600435811690602435166044356103e0565b34156101d657600080fd5b6101de610457565b60405160ff909116815260200160405180910390f35b34156101ff57600080fd5b61016a600435610460565b341561021557600080fd5b610191600160a060020a03600435166104eb565b341561023457600080fd5b61016a600160a060020a03600435166024356104fd565b341561025657600080fd5b6100d16105d9565b341561026957600080fd5b610280600160a060020a0360043516602435610644565b005b341561028d57600080fd5b61016a60048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061065395505050505050565b34156102f257600080fd5b610191600160a060020a0360043581169060243516610785565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a25780601f10610377576101008083540402835291602001916103a2565b820191906000526020600020905b81548152906001019060200180831161038557829003601f168201915b505050505081565b600160a060020a033381166000908152600560209081526040808320938616835292905220819055600192915050565b60035481565b600160a060020a0380841660009081526005602090815260408083203390941683529290529081205482111561041557600080fd5b600160a060020a038085166000908152600560209081526040808320339094168352929052208054839003905561044d8484846107a2565b5060019392505050565b60025460ff1681565b600160a060020a0333166000908152600460205260408120548290101561048657600080fd5b600160a060020a03331660008181526004602052604090819020805485900390556003805485900390557fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a2506001919050565b60046020526000908152604090205481565b600160a060020a0382166000908152600460205260408120548290101561052357600080fd5b600160a060020a038084166000908152600560209081526040808320339094168352929052205482111561055657600080fd5b600160a060020a038084166000818152600460209081526040808320805488900390556005825280832033909516835293905282902080548590039055600380548590039055907fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a250600192915050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a25780601f10610377576101008083540402835291602001916103a2565b61064f3383836107a2565b5050565b60008361066081856103aa565b1561077d5780600160a060020a0316638f4ffcb1338630876040518563ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156107165780820151838201526020016106fe565b50505050905090810190601f1680156107435780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561076457600080fd5b6102c65a03f1151561077557600080fd5b505050600191505b509392505050565b600560209081526000928352604080842090915290825290205481565b6000600160a060020a03831615156107b957600080fd5b600160a060020a038416600090815260046020526040902054829010156107df57600080fd5b600160a060020a0383166000908152600460205260409020548281011161080557600080fd5b50600160a060020a0380831660008181526004602052604080822080549488168084528284208054888103909155938590528154870190915591909301927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a3600160a060020a038084166000908152600460205260408082205492871682529020540181146108a257fe5b505050505600a165627a7a7230582001809d664a81f8a92897da194e7ac4526efddc31f99e8d81a1b1725bf0b636e00029
[ 17 ]
0xf1ef40f5aea5d1501c1b8bcd216cf305764fca40
// 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; } } } 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); } } 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); } } } } 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); } 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.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; } } 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; } 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); } 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); } 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; } } 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; } } 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 {} } 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(); } } pragma solidity ^0.8.0; contract HeroesOfEvermore is ERC721Enumerable, Ownable { using SafeMath for uint256; using Address for address; using Strings for uint256; uint256 public constant NFT_PRICE = 80000000000000000; // 0.08 ETH uint public constant MAX_NFT_PURCHASE = 20; uint256 public MAX_SUPPLY = 10000; bool public saleIsActive = false; string private _baseURIExtended; mapping(uint256 => string) _tokenURIs; mapping(address => bool) minted; mapping(address => uint256) purchased; modifier mintOnlyOnce() { require(!minted[_msgSender()], 'Can only mint once'); minted[_msgSender()] = true; _; } constructor() ERC721('Heroes of Evermore', 'HOE') {} function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } function withdraw() public onlyOwner { uint256 balance = address(this).balance; payable(msg.sender).transfer(balance); } function mintHero(uint numberOfTokens) public payable { require(purchased[msg.sender].add(numberOfTokens) <= MAX_NFT_PURCHASE, 'Can only mint up to 20 per address'); require(saleIsActive, 'Sale is not active at the moment'); require(numberOfTokens > 0, "Number of tokens can not be less than or equal to 0"); require(totalSupply().add(numberOfTokens) <= MAX_SUPPLY, "Purchase would exceed max supply of Muds"); require(numberOfTokens <= MAX_NFT_PURCHASE,"Can only mint up to 20 per purchase"); require(NFT_PRICE.mul(numberOfTokens) == msg.value, "Sent ether value is incorrect"); purchased[msg.sender] = purchased[msg.sender].add(numberOfTokens); for (uint i = 0; i < numberOfTokens; i++) { _safeMint(msg.sender, totalSupply()); } } function mintHeroForFree() public mintOnlyOnce { require(saleIsActive, 'Sale is not active at the moment'); require(totalSupply().add(1) <= MAX_SUPPLY, 'Purchase would exceed max supply of Muds'); _safeMint(msg.sender, totalSupply()); } function _baseURI() internal view virtual override returns (string memory) { return _baseURIExtended; } // Sets base URI for all tokens, only able to be called by contract owner function setBaseURI(string memory baseURI_) external onlyOwner { _baseURIExtended = baseURI_; } 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())); } }
0x6080604052600436106101b75760003560e01c806355f804b3116100ec578063a22cb4651161008a578063c87b56dd11610064578063c87b56dd146105c5578063e985e9c514610602578063eb8d24441461063f578063f2fde38b1461066a576101b7565b8063a22cb4651461055c578063b88d4fde14610585578063bdb9b3bc146105ae576101b7565b806370a08231116100c657806370a08231146104b2578063715018a6146104ef5780638da5cb5b1461050657806395d89b4114610531576101b7565b806355f804b3146104215780636352211e1461044a578063676dd56314610487576101b7565b806323b872dd1161015957806334918dfd1161013357806334918dfd1461038d5780633ccfd60b146103a457806342842e0e146103bb5780634f6ccce7146103e4576101b7565b806323b872dd146102fc5780632f745c591461032557806332cb6b0c14610362576101b7565b806306fdde031161019557806306fdde0314610240578063081812fc1461026b578063095ea7b3146102a857806318160ddd146102d1576101b7565b806301ffc9a7146101bc578063020b39cc146101f95780630606cb2914610224575b600080fd5b3480156101c857600080fd5b506101e360048036038101906101de9190612f51565b610693565b6040516101f091906134d3565b60405180910390f35b34801561020557600080fd5b5061020e61070d565b60405161021b9190613830565b60405180910390f35b61023e60048036038101906102399190612fe4565b610712565b005b34801561024c57600080fd5b506102556109ff565b60405161026291906134ee565b60405180910390f35b34801561027757600080fd5b50610292600480360381019061028d9190612fe4565b610a91565b60405161029f919061346c565b60405180910390f35b3480156102b457600080fd5b506102cf60048036038101906102ca9190612f15565b610b16565b005b3480156102dd57600080fd5b506102e6610c2e565b6040516102f39190613830565b60405180910390f35b34801561030857600080fd5b50610323600480360381019061031e9190612e0f565b610c3b565b005b34801561033157600080fd5b5061034c60048036038101906103479190612f15565b610c9b565b6040516103599190613830565b60405180910390f35b34801561036e57600080fd5b50610377610d40565b6040516103849190613830565b60405180910390f35b34801561039957600080fd5b506103a2610d46565b005b3480156103b057600080fd5b506103b9610dee565b005b3480156103c757600080fd5b506103e260048036038101906103dd9190612e0f565b610eb9565b005b3480156103f057600080fd5b5061040b60048036038101906104069190612fe4565b610ed9565b6040516104189190613830565b60405180910390f35b34801561042d57600080fd5b5061044860048036038101906104439190612fa3565b610f70565b005b34801561045657600080fd5b50610471600480360381019061046c9190612fe4565b611006565b60405161047e919061346c565b60405180910390f35b34801561049357600080fd5b5061049c6110b8565b6040516104a99190613830565b60405180910390f35b3480156104be57600080fd5b506104d960048036038101906104d49190612daa565b6110c4565b6040516104e69190613830565b60405180910390f35b3480156104fb57600080fd5b5061050461117c565b005b34801561051257600080fd5b5061051b6112b9565b604051610528919061346c565b60405180910390f35b34801561053d57600080fd5b506105466112e3565b60405161055391906134ee565b60405180910390f35b34801561056857600080fd5b50610583600480360381019061057e9190612ed9565b611375565b005b34801561059157600080fd5b506105ac60048036038101906105a79190612e5e565b6114f6565b005b3480156105ba57600080fd5b506105c3611558565b005b3480156105d157600080fd5b506105ec60048036038101906105e79190612fe4565b61170c565b6040516105f991906134ee565b60405180910390f35b34801561060e57600080fd5b5061062960048036038101906106249190612dd3565b61187f565b60405161063691906134d3565b60405180910390f35b34801561064b57600080fd5b50610654611913565b60405161066191906134d3565b60405180910390f35b34801561067657600080fd5b50610691600480360381019061068c9190612daa565b611926565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610706575061070582611ad2565b5b9050919050565b601481565b601461076682601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bb490919063ffffffff16565b11156107a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079e90613510565b60405180910390fd5b600c60009054906101000a900460ff166107f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ed90613810565b60405180910390fd5b60008111610839576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083090613530565b60405180910390fd5b600b5461085682610848610c2e565b611bb490919063ffffffff16565b1115610897576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088e906137f0565b60405180910390fd5b60148111156108db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108d290613630565b60405180910390fd5b346108f78267011c37937e080000611bca90919063ffffffff16565b14610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e906136b0565b60405180910390fd5b61098981601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bb490919063ffffffff16565b601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060005b818110156109fb576109e8336109e3610c2e565b611be0565b80806109f390613b43565b9150506109cf565b5050565b606060008054610a0e90613ae0565b80601f0160208091040260200160405190810160405280929190818152602001828054610a3a90613ae0565b8015610a875780601f10610a5c57610100808354040283529160200191610a87565b820191906000526020600020905b815481529060010190602001808311610a6a57829003601f168201915b5050505050905090565b6000610a9c82611bfe565b610adb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad2906136f0565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b2182611006565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b92576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8990613770565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610bb1611c6a565b73ffffffffffffffffffffffffffffffffffffffff161480610be05750610bdf81610bda611c6a565b61187f565b5b610c1f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1690613650565b60405180910390fd5b610c298383611c72565b505050565b6000600880549050905090565b610c4c610c46611c6a565b82611d2b565b610c8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c82906137b0565b60405180910390fd5b610c96838383611e09565b505050565b6000610ca6836110c4565b8210610ce7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cde90613550565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600b5481565b610d4e611c6a565b73ffffffffffffffffffffffffffffffffffffffff16610d6c6112b9565b73ffffffffffffffffffffffffffffffffffffffff1614610dc2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db990613710565b60405180910390fd5b600c60009054906101000a900460ff1615600c60006101000a81548160ff021916908315150217905550565b610df6611c6a565b73ffffffffffffffffffffffffffffffffffffffff16610e146112b9565b73ffffffffffffffffffffffffffffffffffffffff1614610e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6190613710565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610eb5573d6000803e3d6000fd5b5050565b610ed4838383604051806020016040528060008152506114f6565b505050565b6000610ee3610c2e565b8210610f24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1b906137d0565b60405180910390fd5b60088281548110610f5e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610f78611c6a565b73ffffffffffffffffffffffffffffffffffffffff16610f966112b9565b73ffffffffffffffffffffffffffffffffffffffff1614610fec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fe390613710565b60405180910390fd5b80600d9080519060200190611002929190612bce565b5050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a690613690565b60405180910390fd5b80915050919050565b67011c37937e08000081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611135576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112c90613670565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611184611c6a565b73ffffffffffffffffffffffffffffffffffffffff166111a26112b9565b73ffffffffffffffffffffffffffffffffffffffff16146111f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ef90613710565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546112f290613ae0565b80601f016020809104026020016040519081016040528092919081815260200182805461131e90613ae0565b801561136b5780601f106113405761010080835404028352916020019161136b565b820191906000526020600020905b81548152906001019060200180831161134e57829003601f168201915b5050505050905090565b61137d611c6a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113e2906135f0565b60405180910390fd5b80600560006113f8611c6a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166114a5611c6a565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516114ea91906134d3565b60405180910390a35050565b611507611501611c6a565b83611d2b565b611546576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153d906137b0565b60405180910390fd5b61155284848484612065565b50505050565b600f6000611564611c6a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156115ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115e390613790565b60405180910390fd5b6001600f60006115fa611c6a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600c60009054906101000a900460ff1661169a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169190613810565b60405180910390fd5b600b546116b860016116aa610c2e565b611bb490919063ffffffff16565b11156116f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f0906137f0565b60405180910390fd5b61170a33611705610c2e565b611be0565b565b606061171782611bfe565b611756576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174d90613750565b60405180910390fd5b6000600e6000848152602001908152602001600020805461177690613ae0565b80601f01602080910402602001604051908101604052809291908181526020018280546117a290613ae0565b80156117ef5780601f106117c4576101008083540402835291602001916117ef565b820191906000526020600020905b8154815290600101906020018083116117d257829003601f168201915b5050505050905060006118006120c1565b905060008151141561181657819250505061187a565b60008251111561184b578082604051602001611833929190613448565b6040516020818303038152906040529250505061187a565b8061185585612153565b604051602001611866929190613448565b604051602081830303815290604052925050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900460ff1681565b61192e611c6a565b73ffffffffffffffffffffffffffffffffffffffff1661194c6112b9565b73ffffffffffffffffffffffffffffffffffffffff16146119a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161199990613710565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0990613590565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611b9d57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611bad5750611bac82612300565b5b9050919050565b60008183611bc29190613915565b905092915050565b60008183611bd8919061399c565b905092915050565b611bfa82826040518060200160405280600081525061236a565b5050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611ce583611006565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611d3682611bfe565b611d75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6c90613610565b60405180910390fd5b6000611d8083611006565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611def57508373ffffffffffffffffffffffffffffffffffffffff16611dd784610a91565b73ffffffffffffffffffffffffffffffffffffffff16145b80611e005750611dff818561187f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611e2982611006565b73ffffffffffffffffffffffffffffffffffffffff1614611e7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e7690613730565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611eef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee6906135d0565b60405180910390fd5b611efa8383836123c5565b611f05600082611c72565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611f5591906139f6565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611fac9190613915565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b612070848484611e09565b61207c848484846124d9565b6120bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120b290613570565b60405180910390fd5b50505050565b6060600d80546120d090613ae0565b80601f01602080910402602001604051908101604052809291908181526020018280546120fc90613ae0565b80156121495780601f1061211e57610100808354040283529160200191612149565b820191906000526020600020905b81548152906001019060200180831161212c57829003601f168201915b5050505050905090565b6060600082141561219b576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506122fb565b600082905060005b600082146121cd5780806121b690613b43565b915050600a826121c6919061396b565b91506121a3565b60008167ffffffffffffffff81111561220f577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156122415781602001600182028036833780820191505090505b5090505b600085146122f45760018261225a91906139f6565b9150600a856122699190613b8c565b60306122759190613915565b60f81b8183815181106122b1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856122ed919061396b565b9450612245565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6123748383612670565b61238160008484846124d9565b6123c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123b790613570565b60405180910390fd5b505050565b6123d083838361283e565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124135761240e81612843565b612452565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461245157612450838261288c565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561249557612490816129f9565b6124d4565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146124d3576124d28282612b3c565b5b5b505050565b60006124fa8473ffffffffffffffffffffffffffffffffffffffff16612bbb565b15612663578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612523611c6a565b8786866040518563ffffffff1660e01b81526004016125459493929190613487565b602060405180830381600087803b15801561255f57600080fd5b505af192505050801561259057506040513d601f19601f8201168201806040525081019061258d9190612f7a565b60015b612613573d80600081146125c0576040519150601f19603f3d011682016040523d82523d6000602084013e6125c5565b606091505b5060008151141561260b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161260290613570565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612668565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126d7906136d0565b60405180910390fd5b6126e981611bfe565b15612729576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612720906135b0565b60405180910390fd5b612735600083836123c5565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546127859190613915565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612899846110c4565b6128a391906139f6565b9050600060076000848152602001908152602001600020549050818114612988576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612a0d91906139f6565b9050600060096000848152602001908152602001600020549050600060088381548110612a63577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612aab577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612b20577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612b47836110c4565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600080823b905060008111915050919050565b828054612bda90613ae0565b90600052602060002090601f016020900481019282612bfc5760008555612c43565b82601f10612c1557805160ff1916838001178555612c43565b82800160010185558215612c43579182015b82811115612c42578251825591602001919060010190612c27565b5b509050612c509190612c54565b5090565b5b80821115612c6d576000816000905550600101612c55565b5090565b6000612c84612c7f84613870565b61384b565b905082815260208101848484011115612c9c57600080fd5b612ca7848285613a9e565b509392505050565b6000612cc2612cbd846138a1565b61384b565b905082815260208101848484011115612cda57600080fd5b612ce5848285613a9e565b509392505050565b600081359050612cfc81614337565b92915050565b600081359050612d118161434e565b92915050565b600081359050612d2681614365565b92915050565b600081519050612d3b81614365565b92915050565b600082601f830112612d5257600080fd5b8135612d62848260208601612c71565b91505092915050565b600082601f830112612d7c57600080fd5b8135612d8c848260208601612caf565b91505092915050565b600081359050612da48161437c565b92915050565b600060208284031215612dbc57600080fd5b6000612dca84828501612ced565b91505092915050565b60008060408385031215612de657600080fd5b6000612df485828601612ced565b9250506020612e0585828601612ced565b9150509250929050565b600080600060608486031215612e2457600080fd5b6000612e3286828701612ced565b9350506020612e4386828701612ced565b9250506040612e5486828701612d95565b9150509250925092565b60008060008060808587031215612e7457600080fd5b6000612e8287828801612ced565b9450506020612e9387828801612ced565b9350506040612ea487828801612d95565b925050606085013567ffffffffffffffff811115612ec157600080fd5b612ecd87828801612d41565b91505092959194509250565b60008060408385031215612eec57600080fd5b6000612efa85828601612ced565b9250506020612f0b85828601612d02565b9150509250929050565b60008060408385031215612f2857600080fd5b6000612f3685828601612ced565b9250506020612f4785828601612d95565b9150509250929050565b600060208284031215612f6357600080fd5b6000612f7184828501612d17565b91505092915050565b600060208284031215612f8c57600080fd5b6000612f9a84828501612d2c565b91505092915050565b600060208284031215612fb557600080fd5b600082013567ffffffffffffffff811115612fcf57600080fd5b612fdb84828501612d6b565b91505092915050565b600060208284031215612ff657600080fd5b600061300484828501612d95565b91505092915050565b61301681613a2a565b82525050565b61302581613a3c565b82525050565b6000613036826138d2565b61304081856138e8565b9350613050818560208601613aad565b61305981613c79565b840191505092915050565b600061306f826138dd565b61307981856138f9565b9350613089818560208601613aad565b61309281613c79565b840191505092915050565b60006130a8826138dd565b6130b2818561390a565b93506130c2818560208601613aad565b80840191505092915050565b60006130db6022836138f9565b91506130e682613c8a565b604082019050919050565b60006130fe6033836138f9565b915061310982613cd9565b604082019050919050565b6000613121602b836138f9565b915061312c82613d28565b604082019050919050565b60006131446032836138f9565b915061314f82613d77565b604082019050919050565b60006131676026836138f9565b915061317282613dc6565b604082019050919050565b600061318a601c836138f9565b915061319582613e15565b602082019050919050565b60006131ad6024836138f9565b91506131b882613e3e565b604082019050919050565b60006131d06019836138f9565b91506131db82613e8d565b602082019050919050565b60006131f3602c836138f9565b91506131fe82613eb6565b604082019050919050565b60006132166023836138f9565b915061322182613f05565b604082019050919050565b60006132396038836138f9565b915061324482613f54565b604082019050919050565b600061325c602a836138f9565b915061326782613fa3565b604082019050919050565b600061327f6029836138f9565b915061328a82613ff2565b604082019050919050565b60006132a2601d836138f9565b91506132ad82614041565b602082019050919050565b60006132c56020836138f9565b91506132d08261406a565b602082019050919050565b60006132e8602c836138f9565b91506132f382614093565b604082019050919050565b600061330b6020836138f9565b9150613316826140e2565b602082019050919050565b600061332e6029836138f9565b91506133398261410b565b604082019050919050565b6000613351602f836138f9565b915061335c8261415a565b604082019050919050565b60006133746021836138f9565b915061337f826141a9565b604082019050919050565b60006133976012836138f9565b91506133a2826141f8565b602082019050919050565b60006133ba6031836138f9565b91506133c582614221565b604082019050919050565b60006133dd602c836138f9565b91506133e882614270565b604082019050919050565b60006134006028836138f9565b915061340b826142bf565b604082019050919050565b60006134236020836138f9565b915061342e8261430e565b602082019050919050565b61344281613a94565b82525050565b6000613454828561309d565b9150613460828461309d565b91508190509392505050565b6000602082019050613481600083018461300d565b92915050565b600060808201905061349c600083018761300d565b6134a9602083018661300d565b6134b66040830185613439565b81810360608301526134c8818461302b565b905095945050505050565b60006020820190506134e8600083018461301c565b92915050565b600060208201905081810360008301526135088184613064565b905092915050565b60006020820190508181036000830152613529816130ce565b9050919050565b60006020820190508181036000830152613549816130f1565b9050919050565b6000602082019050818103600083015261356981613114565b9050919050565b6000602082019050818103600083015261358981613137565b9050919050565b600060208201905081810360008301526135a98161315a565b9050919050565b600060208201905081810360008301526135c98161317d565b9050919050565b600060208201905081810360008301526135e9816131a0565b9050919050565b60006020820190508181036000830152613609816131c3565b9050919050565b60006020820190508181036000830152613629816131e6565b9050919050565b6000602082019050818103600083015261364981613209565b9050919050565b600060208201905081810360008301526136698161322c565b9050919050565b600060208201905081810360008301526136898161324f565b9050919050565b600060208201905081810360008301526136a981613272565b9050919050565b600060208201905081810360008301526136c981613295565b9050919050565b600060208201905081810360008301526136e9816132b8565b9050919050565b60006020820190508181036000830152613709816132db565b9050919050565b60006020820190508181036000830152613729816132fe565b9050919050565b6000602082019050818103600083015261374981613321565b9050919050565b6000602082019050818103600083015261376981613344565b9050919050565b6000602082019050818103600083015261378981613367565b9050919050565b600060208201905081810360008301526137a98161338a565b9050919050565b600060208201905081810360008301526137c9816133ad565b9050919050565b600060208201905081810360008301526137e9816133d0565b9050919050565b60006020820190508181036000830152613809816133f3565b9050919050565b6000602082019050818103600083015261382981613416565b9050919050565b60006020820190506138456000830184613439565b92915050565b6000613855613866565b90506138618282613b12565b919050565b6000604051905090565b600067ffffffffffffffff82111561388b5761388a613c4a565b5b61389482613c79565b9050602081019050919050565b600067ffffffffffffffff8211156138bc576138bb613c4a565b5b6138c582613c79565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600061392082613a94565b915061392b83613a94565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156139605761395f613bbd565b5b828201905092915050565b600061397682613a94565b915061398183613a94565b92508261399157613990613bec565b5b828204905092915050565b60006139a782613a94565b91506139b283613a94565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156139eb576139ea613bbd565b5b828202905092915050565b6000613a0182613a94565b9150613a0c83613a94565b925082821015613a1f57613a1e613bbd565b5b828203905092915050565b6000613a3582613a74565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613acb578082015181840152602081019050613ab0565b83811115613ada576000848401525b50505050565b60006002820490506001821680613af857607f821691505b60208210811415613b0c57613b0b613c1b565b5b50919050565b613b1b82613c79565b810181811067ffffffffffffffff82111715613b3a57613b39613c4a565b5b80604052505050565b6000613b4e82613a94565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613b8157613b80613bbd565b5b600182019050919050565b6000613b9782613a94565b9150613ba283613a94565b925082613bb257613bb1613bec565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f43616e206f6e6c79206d696e7420757020746f2032302070657220616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f4e756d626572206f6620746f6b656e732063616e206e6f74206265206c65737360008201527f207468616e206f7220657175616c20746f203000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f43616e206f6e6c79206d696e7420757020746f2032302070657220707572636860008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f53656e742065746865722076616c756520697320696e636f7272656374000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f43616e206f6e6c79206d696e74206f6e63650000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f507572636861736520776f756c6420657863656564206d617820737570706c7960008201527f206f66204d756473000000000000000000000000000000000000000000000000602082015250565b7f53616c65206973206e6f742061637469766520617420746865206d6f6d656e74600082015250565b61434081613a2a565b811461434b57600080fd5b50565b61435781613a3c565b811461436257600080fd5b50565b61436e81613a48565b811461437957600080fd5b50565b61438581613a94565b811461439057600080fd5b5056fea2646970667358221220dfedb7f49ffe0f370544649abcd60cc3e8f4d67d8735607bc8580f5f8466d26f64736f6c63430008040033
[ 0, 5 ]
0xf1ef9860bbb8f2631915f822133475929c581441
/* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: YUANRewards.sol * * Docs: https://docs.synthetix.io/ * * * 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 */ // File: @openzeppelin/contracts/math/Math.sol pragma solidity ^0.5.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: @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/GSN/Context.sol pragma solidity ^0.5.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 {} // 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; } } // File: @openzeppelin/contracts/ownership/Ownable.sol pragma solidity ^0.5.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. * * 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 { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @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; } } // 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/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. * * 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. * * 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. */ 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. // 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 != 0x0 && codehash != accountHash); } /** * @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/IRewardDistributionRecipient.sol pragma solidity ^0.5.0; contract IRewardDistributionRecipient is Ownable { address public rewardDistribution; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require( _msgSender() == rewardDistribution, "Caller is not reward distribution" ); _; } function setRewardDistribution(address _rewardDistribution) external onlyOwner { rewardDistribution = _rewardDistribution; } } pragma solidity ^0.5.0; interface YUAN { function yuansScalingFactor() external returns (uint256); } contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public uni_lp = IERC20(0xaf56d301BfEe39D3995434e24092A04f8E05AF1a); uint256 private _totalSupply; mapping(address => uint256) private _balances; function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function stake(uint256 amount) public { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); uni_lp.safeTransferFrom(msg.sender, address(this), amount); } function withdraw(uint256 amount) public { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); uni_lp.safeTransfer(msg.sender, amount); } } contract YUANETHYUANPool is LPTokenWrapper, IRewardDistributionRecipient { IERC20 public yuan = IERC20(0x30bb8D13047204CA2AB8f94D4c96e9Dab85bAc28); uint256 public constant DURATION = 18 days; uint256 public constant halveInterval = 1 days; uint256 public starttime = 1604462400; // 2020/11/4 12:0:0 (UTC+8) uint256 public periodFinish = 0; uint256 public initialRewardRate = 0; uint256 public lastUpdateTime; uint256 public distributionTime; 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); modifier checkStart() { require(block.timestamp >= starttime, "not start"); _; } 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( getrewardPerTokenAmount().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 updateReward(msg.sender) checkStart { require(amount > 0, "Cannot stake 0"); super.stake(amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateReward(msg.sender) checkStart { 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) checkStart { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; uint256 scalingFactor = YUAN(address(yuan)).yuansScalingFactor(); uint256 trueReward = reward.mul(scalingFactor).div(10**18); yuan.safeTransfer(msg.sender, trueReward); emit RewardPaid(msg.sender, reward); } } /** * @dev Calculate the cumulative reward per token from lastUpdateTime to lastTimeRewardApplicable() * such time span could be divided into 3 parts by halve intervals: * (lastUpdateTime, firstIntervalEnd), (firstIntervalEnd, lastIntervalStart), (lastIntervalStart, lastTimeRewardApplicable()) */ function getrewardPerTokenAmount() public view returns (uint256) { uint256 _timestamp = lastTimeRewardApplicable(); uint256 _distributionTime = distributionTime; uint256 _lastUpdateTime = lastUpdateTime; if (_timestamp < _distributionTime || _timestamp == _lastUpdateTime) return 0; uint256 _lastUpdateTimeOffset = _lastUpdateTime.sub(_distributionTime) % halveInterval; uint256 _firstIntervalEnd = _lastUpdateTime .sub(_lastUpdateTimeOffset) .add(halveInterval); // The time span is too short that it has not reach _firstIntervalEnd if (_timestamp < _firstIntervalEnd) return _timestamp.sub(_lastUpdateTime).mul( getFixedRewardRate(_lastUpdateTime) ); // The amount from _lastUpdateTime to _firstIntervalEnd uint256 _rewardPerTokenAmount = halveInterval .sub(_lastUpdateTimeOffset) .mul(getFixedRewardRate(_lastUpdateTime)); // The amount from _firstIntervalEnd to last interval start, it may contains n full halve interval (n >= 0) // n = 0 if _firstIntervalEnd and _timestamp lay in the same halve interval // _currentRewardRate represents 1/2 of the reward rate of last full interval uint256 _currentRewardRate = getFixedRewardRate(_timestamp); _rewardPerTokenAmount = _rewardPerTokenAmount.add( ( halveInterval.mul( getFixedRewardRate(_firstIntervalEnd).sub( _currentRewardRate ) ) ) << 1 ); // Finally, the amount from last interval start to timestamp return _rewardPerTokenAmount.add( (_timestamp.sub(_distributionTime) % halveInterval).mul( _currentRewardRate ) ); } function rewardRate() public view returns (uint256) { return getFixedRewardRate(block.timestamp); } function getFixedRewardRate(uint256 _timestamp) public view returns (uint256) { if (_timestamp < distributionTime) return 0; return initialRewardRate >> (Math.min(_timestamp, periodFinish).sub(distributionTime) / halveInterval); } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution updateReward(address(0)) { // https://sips.synthetix.io/sips/sip-77 // increased buffer for scaling factor ( supports up to 10**4 * 10**18 scaling factor) require(reward < uint256(-1) / 10**22, "rewards too large, would lock"); uint256 _firstReward = reward.mul(1e18).div( 2e18 - (2e18 >> (DURATION.div(halveInterval))) ); if (block.timestamp > starttime) { require(block.timestamp >= periodFinish, "not over yet"); initialRewardRate = _firstReward.div(halveInterval); lastUpdateTime = block.timestamp; distributionTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } else { initialRewardRate = _firstReward.div(halveInterval); lastUpdateTime = starttime; distributionTime = starttime; periodFinish = starttime.add(DURATION); emit RewardAdded(reward); } } }
0x608060405234801561001057600080fd5b50600436106101e45760003560e01c806380faa57d1161010f578063b69ecaa3116100a2578063df136d6511610071578063df136d65146103ef578063e9fad8ee146103f7578063ebe2b12b146103ff578063f2fde38b14610407576101e4565b8063b69ecaa3146103cf578063c36c9edd146103d7578063c8f33c91146103df578063cd3daf9d146103e7576101e4565b80638da5cb5b116100de5780638da5cb5b146103865780638f32d59b1461038e578063a36cb289146103aa578063a694fc3a146103b2576101e4565b806380faa57d1461034857806383d0fdc1146103505780638b876347146103585780638da588971461037e576101e4565b80633c6b16ab1161018757806370a082311161015657806370a08231146102f5578063715018a61461031b5780637b0a47ee146103235780637c14b1b91461032b576101e4565b80633c6b16ab146102c05780633d18b912146102dd57806349c1cf6e146102e55780635971aa21146102ed576101e4565b8063101114cf116101c3578063101114cf1461026f57806318160ddd146102935780631be052891461029b5780632e1a7d4d146102a3576101e4565b80628cc262146101e95780630700037d146102215780630d68b76114610247575b600080fd5b61020f600480360360208110156101ff57600080fd5b50356001600160a01b031661042d565b60408051918252519081900360200190f35b61020f6004803603602081101561023757600080fd5b50356001600160a01b03166104b5565b61026d6004803603602081101561025d57600080fd5b50356001600160a01b03166104c7565b005b610277610542565b604080516001600160a01b039092168252519081900360200190f35b61020f610551565b61020f610558565b61026d600480360360208110156102b957600080fd5b503561055f565b61026d600480360360208110156102d657600080fd5b5035610689565b61026d61091e565b61020f610acf565b61020f610ad5565b61020f6004803603602081101561030b57600080fd5b50356001600160a01b0316610adb565b61026d610af6565b61020f610b99565b61020f6004803603602081101561034157600080fd5b5035610ba9565b61020f610be7565b610277610bf5565b61020f6004803603602081101561036e57600080fd5b50356001600160a01b0316610c04565b61020f610c16565b610277610c1c565b610396610c2b565b604080519115158252519081900360200190f35b61020f610c51565b61026d600480360360208110156103c857600080fd5b5035610c58565b61020f610d7f565b610277610eca565b61020f610ed9565b61020f610edf565b61020f610f27565b61026d610f2d565b61020f610f48565b61026d6004803603602081101561041d57600080fd5b50356001600160a01b0316610f4e565b6001600160a01b0381166000908152600d6020908152604080832054600c9092528220546104ad91906104a190670de0b6b3a7640000906104959061048090610474610edf565b9063ffffffff610fb316565b61048988610adb565b9063ffffffff610ffe16565b9063ffffffff61105716565b9063ffffffff61109916565b90505b919050565b600d6020526000908152604090205481565b6104cf610c2b565b610520576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b6001545b90565b6217bb0081565b33610568610edf565b600b55610573610be7565b6009556001600160a01b038116156105ba5761058e8161042d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6006544210156105fd576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610646576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b61064f826110f3565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6004546001600160a01b031661069d611154565b6001600160a01b0316146106e25760405162461bcd60e51b815260040180806020018281038252602181526020018061165b6021913960400191505060405180910390fd5b60006106ec610edf565b600b556106f7610be7565b6009556001600160a01b0381161561073e576107128161042d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b7678e480405d7b9658a9926345896eb19c38658a4109e55382106107a9576040805162461bcd60e51b815260206004820152601d60248201527f7265776172647320746f6f206c617267652c20776f756c64206c6f636b000000604482015290519081900360640190fd5b60006107eb6107c46217bb006201518063ffffffff61105716565b671bc16d674ec800009081901c900361049585670de0b6b3a764000063ffffffff610ffe16565b90506006544211156108ac5760075442101561083d576040805162461bcd60e51b815260206004820152600c60248201526b1b9bdd081bdd995c881e595d60a21b604482015290519081900360640190fd5b610850816201518063ffffffff61105716565b600855426009819055600a819055610871906217bb0063ffffffff61109916565b6007556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1610919565b6108bf816201518063ffffffff61105716565b6008556006546009819055600a8190556108e2906217bb0063ffffffff61109916565b6007556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a15b505050565b33610927610edf565b600b55610932610be7565b6009556001600160a01b038116156109795761094d8161042d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6006544210156109bc576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b336000908152600d60205260409020548015610acb57336000908152600d6020908152604080832083905560055481516303a4a67d60e61b815291516001600160a01b039091169263e9299f40926004808201939182900301818787803b158015610a2657600080fd5b505af1158015610a3a573d6000803e3d6000fd5b505050506040513d6020811015610a5057600080fd5b505190506000610a72670de0b6b3a7640000610495858563ffffffff610ffe16565b600554909150610a92906001600160a01b0316338363ffffffff61115816565b60408051848152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a250505b5050565b600a5481565b60085481565b6001600160a01b031660009081526002602052604090205490565b610afe610c2b565b610b4f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b6000610ba442610ba9565b905090565b6000600a54821015610bbd575060006104b0565b62015180610bd3600a54610474856007546111aa565b81610bda57fe5b04600854901c9050919050565b6000610ba4426007546111aa565b6000546001600160a01b031681565b600c6020526000908152604090205481565b60065481565b6003546001600160a01b031690565b6003546000906001600160a01b0316610c42611154565b6001600160a01b031614905090565b6201518081565b33610c61610edf565b600b55610c6c610be7565b6009556001600160a01b03811615610cb357610c878161042d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b600654421015610cf6576040805162461bcd60e51b81526020600482015260096024820152681b9bdd081cdd185c9d60ba1b604482015290519081900360640190fd5b60008211610d3c576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b610d45826111c0565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600080610d8a610be7565b600a546009549192509081831080610da157508083145b15610db25760009350505050610555565b600062015180610dc8838563ffffffff610fb316565b81610dcf57fe5b0690506000610deb620151806104a1858563ffffffff610fb316565b905080851015610e1d57610e11610e0184610ba9565b610489878663ffffffff610fb316565b95505050505050610555565b6000610e3e610e2b85610ba9565b610489620151808663ffffffff610fb316565b90506000610e4b87610ba9565b9050610e806001610e72610e628461047488610ba9565b620151809063ffffffff610ffe16565b84911b63ffffffff61109916565b9150610ebe610eb18262015180610e9d8b8b63ffffffff610fb316565b81610ea457fe5b069063ffffffff610ffe16565b839063ffffffff61109916565b97505050505050505090565b6005546001600160a01b031681565b60095481565b6000610ee9610551565b610ef65750600b54610555565b610ba4610f18610f04610551565b610495670de0b6b3a7640000610489610d7f565b600b549063ffffffff61109916565b600b5481565b610f3e610f3933610adb565b61055f565b610f4661091e565b565b60075481565b610f56610c2b565b610fa7576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610fb081611222565b50565b6000610ff583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506112c3565b90505b92915050565b60008261100d57506000610ff8565b8282028284828161101a57fe5b0414610ff55760405162461bcd60e51b815260040180806020018281038252602181526020018061163a6021913960400191505060405180910390fd5b6000610ff583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061135a565b600082820183811015610ff5576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600154611106908263ffffffff610fb316565b60015533600090815260026020526040902054611129908263ffffffff610fb316565b336000818152600260205260408120929092559054610fb0916001600160a01b039091169083611158565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109199084906113bf565b60008183106111b95781610ff5565b5090919050565b6001546111d3908263ffffffff61109916565b600155336000908152600260205260409020546111f6908263ffffffff61109916565b336000818152600260205260408120929092559054610fb0916001600160a01b0390911690308461157d565b6001600160a01b0381166112675760405162461bcd60e51b81526004018080602001828103825260268152602001806116146026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b600081848411156113525760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156113175781810151838201526020016112ff565b50505050905090810190601f1680156113445780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836113a95760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156113175781810151838201526020016112ff565b5060008385816113b557fe5b0495945050505050565b6113d1826001600160a01b03166115d7565b611422576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106114605780518252601f199092019160209182019101611441565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146114c2576040519150601f19603f3d011682016040523d82523d6000602084013e6114c7565b606091505b50915091508161151e576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156115775780806020019051602081101561153a57600080fd5b50516115775760405162461bcd60e51b815260040180806020018281038252602a81526020018061167c602a913960400191505060405180910390fd5b50505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526115779085906113bf565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470811580159061160b5750808214155b94935050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a7231582088cd84cc7fe0f3069fbadd0b79ab37c485c689e0b02fb845029f18bdba8ff41464736f6c634300050f0032
[ 10, 7, 9 ]
0xf1ef9f5a3d3ec8391016d12ef37f0d70cf73d391
pragma solidity ^0.4.18; contract EMPresale { bool inMaintainance; bool isRefundable; // Data ----------------------------- struct Player { uint32 id; // if 0, then player don't exist mapping(uint8 => uint8) bought; uint256 weiSpent; bool hasSpent; } struct Sale { uint8 bought; uint8 maxBought; uint32 cardTypeID; uint256 price; uint256 saleEndTime; bool isAirdrop; // enables minting (+maxBought per hour until leftToMint==0) // + each player can only buy once // + is free uint256 nextMintTime; uint8 leftToMint; } address admin; address[] approverArr; // for display purpose only mapping(address => bool) approvers; address[] playerAddrs; // 0 index not used uint32[] playerRefCounts; // 0 index not used mapping(address => Player) players; mapping(uint8 => Sale) sales; // use from 1 onwards uint256 refPrize; // CONSTRUCTOR ======================= function EMPresale() public { admin = msg.sender; approverArr.push(admin); approvers[admin] = true; playerAddrs.push(address(0)); playerRefCounts.push(0); } // ADMIN FUNCTIONS ======================= function setSaleType_Presale(uint8 saleID, uint8 maxBought, uint32 cardTypeID, uint256 price, uint256 saleEndTime) external onlyAdmin { Sale storage sale = sales[saleID]; // assign sale type sale.bought = 0; sale.maxBought = maxBought; sale.cardTypeID = cardTypeID; sale.price = price; sale.saleEndTime = saleEndTime; // airdrop type sale.isAirdrop = false; } function setSaleType_Airdrop(uint8 saleID, uint8 maxBought, uint32 cardTypeID, uint8 leftToMint, uint256 firstMintTime) external onlyAdmin { Sale storage sale = sales[saleID]; // assign sale type sale.bought = 0; sale.maxBought = maxBought; sale.cardTypeID = cardTypeID; sale.price = 0; sale.saleEndTime = 2000000000; // airdrop type require(leftToMint >= maxBought); sale.isAirdrop = true; sale.nextMintTime = firstMintTime; sale.leftToMint = leftToMint - maxBought; } function stopSaleType(uint8 saleID) external onlyAdmin { delete sales[saleID].saleEndTime; } function redeemCards(address playerAddr, uint8 saleID) external onlyApprover returns(uint8) { Player storage player = players[playerAddr]; uint8 owned = player.bought[saleID]; player.bought[saleID] = 0; return owned; } function setRefundable(bool refundable) external onlyAdmin { isRefundable = refundable; } function refund() external { require(isRefundable); Player storage player = players[msg.sender]; uint256 spent = player.weiSpent; player.weiSpent = 0; msg.sender.transfer(spent); } // PLAYER FUNCTIONS ======================== function buySaleNonReferral(uint8 saleID) external payable { buySale(saleID, address(0)); } function buySaleReferred(uint8 saleID, address referral) external payable { buySale(saleID, referral); } function buySale(uint8 saleID, address referral) private { require(!inMaintainance); require(msg.sender != address(0)); // check that sale is still on Sale storage sale = sales[saleID]; require(sale.saleEndTime > now); bool isAirdrop = sale.isAirdrop; if(isAirdrop) { // airdrop minting if(now >= sale.nextMintTime) { // hit a cycle sale.nextMintTime += ((now-sale.nextMintTime)/3600)*3600+3600; // mint again next hour if(sale.bought != 0) { uint8 leftToMint = sale.leftToMint; if(leftToMint < sale.bought) { // not enough to recover, set maximum left to be bought sale.maxBought = sale.maxBought + leftToMint - sale.bought; sale.leftToMint = 0; } else sale.leftToMint -= sale.bought; sale.bought = 0; } } } else { // check ether is paid require(msg.value >= sale.price); } // check not all is bought require(sale.bought < sale.maxBought); sale.bought++; bool toRegisterPlayer = false; bool toRegisterReferral = false; // register player if unregistered Player storage player = players[msg.sender]; if(player.id == 0) toRegisterPlayer = true; // cannot buy more than once if airdrop if(isAirdrop) require(player.bought[saleID] == 0); // give ownership player.bought[saleID]++; if(!isAirdrop) // is free otherwise player.weiSpent += msg.value; // if hasn't referred, add referral if(!player.hasSpent) { player.hasSpent = true; if(referral != address(0) && referral != msg.sender) { Player storage referredPlayer = players[referral]; if(referredPlayer.id == 0) { // add referred player if unregistered toRegisterReferral = true; } else { // if already registered, just up ref count playerRefCounts[referredPlayer.id]++; } } } // register player(s) if(toRegisterPlayer && toRegisterReferral) { uint256 length = (uint32)(playerAddrs.length); player.id = (uint32)(length); referredPlayer.id = (uint32)(length+1); playerAddrs.length = length+2; playerRefCounts.length = length+2; playerAddrs[length] = msg.sender; playerAddrs[length+1] = referral; playerRefCounts[length+1] = 1; } else if(toRegisterPlayer) { player.id = (uint32)(playerAddrs.length); playerAddrs.push(msg.sender); playerRefCounts.push(0); } else if(toRegisterReferral) { referredPlayer.id = (uint32)(playerAddrs.length); playerAddrs.push(referral); playerRefCounts.push(1); } // referral prize refPrize += msg.value/40; // 2.5% added to prize money } function GetSaleInfo_Presale(uint8 saleID) external view returns (uint8, uint8, uint8, uint32, uint256, uint256) { uint8 playerOwned = 0; if(msg.sender != address(0)) playerOwned = players[msg.sender].bought[saleID]; Sale storage sale = sales[saleID]; return (playerOwned, sale.bought, sale.maxBought, sale.cardTypeID, sale.price, sale.saleEndTime); } function GetSaleInfo_Airdrop(uint8 saleID) external view returns (uint8, uint8, uint8, uint32, uint256, uint8) { uint8 playerOwned = 0; if(msg.sender != address(0)) playerOwned = players[msg.sender].bought[saleID]; Sale storage sale = sales[saleID]; uint8 bought = sale.bought; uint8 maxBought = sale.maxBought; uint256 nextMintTime = sale.nextMintTime; uint8 leftToMintResult = sale.leftToMint; // airdrop minting if(now >= nextMintTime) { // hit a cycle nextMintTime += ((now-nextMintTime)/3600)*3600+3600; // mint again next hour if(bought != 0) { uint8 leftToMint = leftToMintResult; if(leftToMint < bought) { // not enough to recover, set maximum left to be bought maxBought = maxBought + leftToMint - bought; leftToMintResult = 0; } else leftToMintResult -= bought; bought = 0; } } return (playerOwned, bought, maxBought, sale.cardTypeID, nextMintTime, leftToMintResult); } function GetReferralInfo() external view returns(uint256, uint32) { uint32 refCount = 0; uint32 id = players[msg.sender].id; if(id != 0) refCount = playerRefCounts[id]; return (refPrize, refCount); } function GetPlayer_FromAddr(address playerAddr, uint8 saleID) external view returns(uint32, uint8, uint256, bool, uint32) { Player storage player = players[playerAddr]; return (player.id, player.bought[saleID], player.weiSpent, player.hasSpent, playerRefCounts[player.id]); } function GetPlayer_FromID(uint32 id, uint8 saleID) external view returns(address, uint8, uint256, bool, uint32) { address playerAddr = playerAddrs[id]; Player storage player = players[playerAddr]; return (playerAddr, player.bought[saleID], player.weiSpent, player.hasSpent, playerRefCounts[id]); } function getAddressesCount() external view returns(uint) { return playerAddrs.length; } function getAddresses() external view returns(address[]) { return playerAddrs; } function getAddress(uint256 id) external view returns(address) { return playerAddrs[id]; } function getReferralCounts() external view returns(uint32[]) { return playerRefCounts; } function getReferralCount(uint256 playerID) external view returns(uint32) { return playerRefCounts[playerID]; } function GetNow() external view returns (uint256) { return now; } // PAYMENT FUNCTIONS ======================= function getEtherBalance() external view returns (uint256) { return address(this).balance; } function depositEtherBalance() external payable { } function withdrawEtherBalance(uint256 amt) external onlyAdmin { admin.transfer(amt); } // RIGHTS FUNCTIONS ======================= function setMaintainance(bool maintaining) external onlyAdmin { inMaintainance = maintaining; } function isInMaintainance() external view returns(bool) { return inMaintainance; } function getApprovers() external view returns(address[]) { return approverArr; } // change admin // only admin can perform this function function switchAdmin(address newAdmin) external onlyAdmin { admin = newAdmin; } // add a new approver // only admin can perform this function function addApprover(address newApprover) external onlyAdmin { require(!approvers[newApprover]); approvers[newApprover] = true; approverArr.push(newApprover); } // remove an approver // only admin can perform this function function removeApprover(address oldApprover) external onlyAdmin { require(approvers[oldApprover]); delete approvers[oldApprover]; // swap last address with deleted address (for array) uint256 length = approverArr.length; address swapAddr = approverArr[length - 1]; for(uint8 i=0; i<length; i++) { if(approverArr[i] == oldApprover) { approverArr[i] = swapAddr; break; } } approverArr.length--; } // MODIFIERS ======================= modifier onlyAdmin() { require(msg.sender == admin); _; } modifier onlyApprover() { require(approvers[msg.sender]); _; } }
0x6060604052600436106101695763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663060df918811461016e57806306a493fa146101a25780631318b88c146101dd57806328d879e4146102435780632d9e87c51461024b5780633aa36dd41461026357806347293d15146102c05780634ca8c1e8146102e55780634d536c031461030c5780635128ab7b1461031a578063590e1ae3146103755780635e80377b146103885780636cb3e8ef146103a25780636cf4c88f14610408578063732617bb14610427578063847f4a88146104465780638856d5171461045f578063a30376b714610490578063a39fac12146104bf578063a904cc53146104d2578063b56ebf42146104e8578063b646c194146104fb578063b93f9b0a1461051a578063dc9d625b1461054c578063ea46193e14610564578063ea59a4e814610577578063ee37e271146105d7578063fd60e1a814610605575b600080fd5b341561017957600080fd5b6101a060ff60043581169060243581169063ffffffff604435169060643516608435610618565b005b34156101ad57600080fd5b6101c7600160a060020a036004351660ff602435166106cd565b60405160ff909116815260200160405180910390f35b34156101e857600080fd5b6101ff63ffffffff6004351660ff60243516610735565b604051600160a060020a03909516855260ff90931660208501526040808501929092521515606084015263ffffffff909116608083015260a0909101905180910390f35b6101a06107f5565b341561025657600080fd5b6101a060043515156107f7565b341561026e57600080fd5b61027c60ff60043516610832565b60405160ff968716815294861660208601529290941660408085019190915263ffffffff9091166060840152608083019390935260a082015260c001905180910390f35b34156102cb57600080fd5b6102d36108c5565b60405190815260200160405180910390f35b34156102f057600080fd5b6102f86108cc565b604051901515815260200160405180910390f35b6101a060ff600435166108d5565b341561032557600080fd5b61033360ff600435166108e3565b60405160ff9687168152948616602086015292851660408086019190915263ffffffff90921660608501526080840152921660a082015260c001905180910390f35b341561038057600080fd5b6101a06109ff565b6101a060ff60043516600160a060020a0360243516610a69565b34156103ad57600080fd5b6103b5610a73565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156103f45780820151838201526020016103dc565b505050509050019250505060405180910390f35b341561041357600080fd5b6101a0600160a060020a0360043516610adb565b341561043257600080fd5b6101a0600160a060020a0360043516610c27565b341561045157600080fd5b6101a060ff60043516610c7f565b341561046a57600080fd5b610472610cb7565b60405191825263ffffffff1660208201526040908101905180910390f35b341561049b57600080fd5b6104a6600435610d29565b60405163ffffffff909116815260200160405180910390f35b34156104ca57600080fd5b6103b5610d67565b34156104dd57600080fd5b6101a0600435610dcd565b34156104f357600080fd5b6102d3610e27565b341561050657600080fd5b6101a0600160a060020a0360043516610e2b565b341561052557600080fd5b610530600435610ee0565b604051600160a060020a03909116815260200160405180910390f35b341561055757600080fd5b6101a06004351515610f0c565b341561056f57600080fd5b6102d3610f40565b341561058257600080fd5b61059c600160a060020a036004351660ff60243516610f4e565b60405163ffffffff958616815260ff90941660208501526040808501939093529015156060840152909216608082015260a001905180910390f35b34156105e257600080fd5b6101a060ff6004358116906024351663ffffffff60443516606435608435610fec565b341561061057600080fd5b6103b5611070565b6000805433600160a060020a0390811662010000909204161461063a57600080fd5b5060ff8581166000908152600660205260408120805461ffff19166101008885169081029190911765ffffffff000019166201000063ffffffff891602178255600182019290925563773594006002820155918416101561069a57600080fd5b60038101805460ff19908116600117909155600482019290925560050180549490920360ff169316929092179091555050565b600160a060020a0333166000908152600260205260408120548190819060ff1615156106f857600080fd5b505050600160a060020a0391909116600090815260056020908152604080832060ff94851684526001019091529020805460ff1981169091551690565b600080600080600080600060038963ffffffff1681548110151561075557fe5b6000918252602080832090910154600160a060020a031680835260058252604080842060ff808e16865260018201909452932054600284015460038501546004805494985095965087959285169491939116919063ffffffff8f169081106107b957fe5b90600052602060002090600891828204019190066004029054906101000a900463ffffffff169650965096509650965050509295509295909350565b565b60005433600160a060020a0390811662010000909204161461081857600080fd5b600080549115156101000261ff0019909216919091179055565b60008080808080808033600160a060020a03161561087c57600160a060020a033316600090815260056020908152604080832060ff808e1685526001909101909252909120541691505b5060ff978816600090815260066020526040902080546001820154600290920154929a818b169a61010083041699506201000090910463ffffffff169750909550909350915050565b6003545b90565b60005460ff1690565b6108e08160006110f9565b50565b600080808080808080808080808033600160a060020a031615610950576005600033600160a060020a0316600160a060020a0316815260200190815260200160002060010160008f60ff1660ff16815260200190815260200160002060009054906101000a900460ff1696505b60ff808f1660009081526006602052604090208054600482015460058301549299508184169850610100909104831696509450169150428390106109db57610e104284900304610e1002610e1001830192508460ff1660001415156109db578190508460ff168160ff1610156109d05784818501039350600091506109d6565b84820391505b600094505b509354949c929b509099506201000090930463ffffffff1697509195509350915050565b600080548190610100900460ff161515610a1857600080fd5b5050600160a060020a033316600081815260056020526040808220600281018054939055929082156108fc0290839051600060405180830381858888f193505050501515610a6557600080fd5b5050565b610a6582826110f9565b610a7b61162b565b6001805480602002602001604051908101604052809291908181526020018280548015610ad157602002820191906000526020600020905b8154600160a060020a03168152600190910190602001808311610ab3575b5050505050905090565b600080548190819033600160a060020a03908116620100009092041614610b0157600080fd5b600160a060020a03841660009081526002602052604090205460ff161515610b2857600080fd5b600160a060020a0384166000908152600260205260409020805460ff191690556001805493506000198401848110610b5c57fe5b6000918252602082200154600160a060020a0316925090505b828160ff161015610c0d5783600160a060020a031660018260ff16815481101515610b9c57fe5b600091825260209091200154600160a060020a03161415610c05578160018260ff16815481101515610bca57fe5b6000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055610c0d565b600101610b75565b6001805490610c2090600019830161163d565b5050505050565b60005433600160a060020a03908116620100009092041614610c4857600080fd5b60008054600160a060020a03909216620100000275ffffffffffffffffffffffffffffffffffffffff000019909216919091179055565b60005433600160a060020a03908116620100009092041614610ca057600080fd5b60ff16600090815260066020526040812060020155565b600160a060020a0333166000908152600560205260408120548190819063ffffffff168015610d1d576004805463ffffffff8316908110610cf457fe5b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1691505b50600754939092509050565b6000600482815481101515610d3a57fe5b90600052602060002090600891828204019190066004029054906101000a900463ffffffff169050919050565b610d6f61162b565b6003805480602002602001604051908101604052809291908181526020018280548015610ad157602002820191906000526020600020908154600160a060020a03168152600190910190602001808311610ab3575050505050905090565b60005433600160a060020a03908116620100009092041614610dee57600080fd5b600054620100009004600160a060020a03166108fc82150282604051600060405180830381858888f1935050505015156108e057600080fd5b4290565b60005433600160a060020a03908116620100009092041614610e4c57600080fd5b600160a060020a03811660009081526002602052604090205460ff1615610e7257600080fd5b600160a060020a0381166000908152600260205260409020805460ff191660019081179091558054808201610ea7838261163d565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000600382815481101515610ef157fe5b600091825260209091200154600160a060020a031692915050565b60005433600160a060020a03908116620100009092041614610f2d57600080fd5b6000805460ff1916911515919091179055565b600160a060020a0330163190565b600160a060020a0382166000908152600560209081526040808320805460ff8087168652600183019094529184205460028201546003830154600480548897889788978897909663ffffffff9092169590831694919392169185908110610fb157fe5b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1695509550955095509550509295509295909350565b6000805433600160a060020a0390811662010000909204161461100e57600080fd5b5060ff9485166000908152600660205260409020805463ffffffff909416620100000265ffffffff000019959096166101000261ffff19909416939093179390931693909317815560018101929092556002820155600301805460ff19169055565b61107861162b565b6004805480602002602001604051908101604052809291908181526020018280548015610ad157602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116110b35790505050505050905090565b60008054819081908190819081908190819060ff161561111857600080fd5b33600160a060020a0316151561112d57600080fd5b60ff8a166000908152600660205260409020600281015490985042901161115357600080fd5b600388015460ff1696508615611206576004880154421061120157600488018054610e10428290038190048102909101019055875460ff1615611201576005880154885460ff9182169750168610156111d757875461ff0019811660ff8083166101009384900482168a01031690910217885560058801805460ff191690556111f8565b875460058901805460ff9283168184160390921660ff199092169190911790555b875460ff191688555b611217565b600188015434101561121757600080fd5b875460ff6101008204811691161061122e57600080fd5b875460ff8082166001011660ff19909116178855600160a060020a03331660009081526005602052604081208054919650869550935063ffffffff16151561127557600194505b861561129c5760ff808b166000908152600185016020526040902054161561129c57600080fd5b60ff8a8116600090815260018581016020526040909120805460ff1981169084169092019092161790558615156112d857600283018054340190555b600383015460ff1615156113a75760038301805460ff19166001179055600160a060020a0389161580159061131f575033600160a060020a031689600160a060020a031614155b156113a757600160a060020a0389166000908152600560205260409020805490925063ffffffff16151561135657600193506113a7565b815460048054909163ffffffff1690811061136d57fe5b600091825260209091206008820401805460079092166004026101000a63ffffffff81810219841693829004811660010116029190911790555b8480156113b15750835b156114d2575060038054835463ffffffff91821663ffffffff19918216811786558454909116600182019092169190911783559060028201906113f4908261163d565b5060028101611404600482611666565b503360038281548110151561141557fe5b906000526020600020900160006101000a815481600160a060020a030219169083600160a060020a031602179055508860038260010181548110151561145757fe5b906000526020600020900160006101000a815481600160a060020a030219169083600160a060020a03160217905550600160048260010181548110151561149a57fe5b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550611614565b84156115735760038054845463ffffffff191663ffffffff909116178455805460018101611500838261163d565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff191633600160a060020a031617905560048054600181016115448382611666565b50600091825260209091206008820401805460079092166004026101000a63ffffffff02199091169055611614565b83156116145760038054835463ffffffff191663ffffffff9091161783558054600181016115a1838261163d565b506000918252602090912001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a038b1617905560048054600181016115e58382611666565b50600091825260209091206008820401805460079092166004026101000a63ffffffff81021990921690911790555b505060078054602834040190555050505050505050565b60206040519081016040526000815290565b81548183558181151161166157600083815260209020611661918101908301611696565b505050565b81548183558181151161166157600701600890048160070160089004836000526020600020918201910161166191905b6108c991905b808211156116b0576000815560010161169c565b50905600a165627a7a72305820e0d5dee7f753720de3e5ba3d28531e6e4103f9cab4fcaa125bc19fc83dc21dee0029
[ 4, 18 ]
0xf1efdee1840d272989396c0618ccc0f66928d52d
pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } //name this contract whatever you'd like contract USKISHU is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function USKISHU( ) { balances[msg.sender] = 100000000; // Give the creator all initial tokens (100000 for example) totalSupply = 100000000; // Update total supply (100000 for example) name = "USKISHU"; // Set the name for display purposes decimals = 7; // Amount of decimals for display purposes symbol = "USKISHU"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820829131f5921cf00c6ba4167446dabf9aab408641f4acbeb761df5788123ea4370029
[ 38 ]
0xf1efedbb151672e5c94b537932577813f82ff330
pragma solidity ^0.5.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); 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; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a / b; return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address holder) public view returns (uint256); function allowance(address holder, address spender) public view returns (uint256); function transfer(address to, uint256 amount) public returns (bool success); function approve(address spender, uint256 amount) public returns (bool success); function transferFrom(address from, address to, uint256 amount) public returns (bool success); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed holder, address indexed spender, uint256 amount); } contract MetaCity is ERC20 { using SafeMath for uint256; string public symbol = "MetaCity"; string public name = "MetaCity"; uint8 public decimals = 18; uint256 private _totalSupply = 1000000000000000000000000; uint256 oneHundredPercent = 100; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address holder) public view returns (uint256) { return balances[holder]; } function allowance(address holder, address spender) public view returns (uint256) { return allowed[holder][spender]; } function findOnePercent(uint256 amount) private view returns (uint256) { uint256 roundAmount = amount.ceil(oneHundredPercent); uint256 fivePercent = roundAmount.mul(oneHundredPercent).div(1000); return fivePercent; } function transfer(address to, uint256 amount) public returns (bool success) { require(amount <= balances[msg.sender]); require(to != address(0)); uint256 tokensToBurn = findOnePercent(amount); uint256 tokensToTransfer = amount.sub(tokensToBurn); balances[msg.sender] = balances[msg.sender].sub(amount); balances[to] = balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } function approve(address spender, uint256 amount) public returns (bool success) { allowed[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transferFrom(address from, address to, uint256 amount) public returns (bool success) { require(amount <= balances[from]); require(amount <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(amount); uint256 tokensToBurn = findOnePercent(amount); uint256 tokensToTransfer = amount.sub(tokensToBurn); balances[to] = balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); allowed[from][msg.sender] = allowed[from][msg.sender].sub(amount); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } }
0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461022557806370a082311461024957806395d89b41146102a1578063a9059cbb14610324578063dd62ed3e1461038a57610093565b806306fdde0314610098578063095ea7b31461011b57806318160ddd1461018157806323b872dd1461019f575b600080fd5b6100a0610402565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101676004803603604081101561013157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104a0565b604051808215151515815260200191505060405180910390f35b610189610592565b6040518082815260200191505060405180910390f35b61020b600480360360608110156101b557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061059c565b604051808215151515815260200191505060405180910390f35b61022d6109fd565b604051808260ff1660ff16815260200191505060405180910390f35b61028b6004803603602081101561025f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a10565b6040518082815260200191505060405180910390f35b6102a9610a59565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102e95780820151818401526020810190506102ce565b50505050905090810190601f1680156103165780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103706004803603604081101561033a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610af7565b604051808215151515815260200191505060405180910390f35b6103ec600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dbf565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104985780601f1061046d57610100808354040283529160200191610498565b820191906000526020600020905b81548152906001019060200180831161047b57829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600354905090565b6000600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156105ea57600080fd5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111561067357600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156106ad57600080fd5b6106ff82600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e4690919063ffffffff16565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600061074d83610e66565b905060006107648285610e4690919063ffffffff16565b90506107b881600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610eb790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061081082600354610e4690919063ffffffff16565b6003819055506108a584600660008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e4690919063ffffffff16565b600660008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050509392505050565b600260009054906101000a900460ff1681565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610aef5780601f10610ac457610100808354040283529160200191610aef565b820191906000526020600020905b815481529060010190602001808311610ad257829003601f168201915b505050505081565b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115610b4557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b7f57600080fd5b6000610b8a83610e66565b90506000610ba18285610e4690919063ffffffff16565b9050610bf584600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e4690919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c8a81600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610eb790919063ffffffff16565b600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ce282600354610e4690919063ffffffff16565b6003819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019250505092915050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600082821115610e5557600080fd5b600082840390508091505092915050565b600080610e7e60045484610ed690919063ffffffff16565b90506000610eab6103e8610e9d60045485610f1190919063ffffffff16565b610f4890919063ffffffff16565b90508092505050919050565b600080828401905083811015610ecc57600080fd5b8091505092915050565b600080610ee38484610eb7565b90506000610ef2826001610e46565b9050610f07610f018286610f48565b85610f11565b9250505092915050565b600080831415610f245760009050610f42565b6000828402905082848281610f3557fe5b0414610f3d57fe5b809150505b92915050565b600080828481610f5457fe5b049050809150509291505056fea265627a7a72315820cafe3e49ae913898bd6f3255e3f6f854481ee48ba43f3af743da0e97efe4051c64736f6c63430005110032
[ 38 ]
0xf1f016f453046bf4e92661098d1f9773d00d7270
/** *Submitted for verification at Etherscan.io on 2021-10-30 */ // File: contracts/Ownable.sol pragma solidity ^0.5.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. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. */ contract Ownable { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ // constructor () internal { // _owner = msg.sender; // emit OwnershipTransferred(address(0), _owner); // } function ownerInit() internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @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 msg.sender == _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; } } // File: contracts/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); function mint(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); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function blindBox(address seller, string calldata tokenURI, bool flag, address to, string calldata ownerId) external returns (uint256); function mintAliaForNonCrypto(uint256 price, address from) external returns (bool); function nonCryptoNFTVault() external returns(address); function mainPerecentage() external returns(uint256); function authorPercentage() external returns(uint256); function platformPerecentage() external returns(uint256); function updateAliaBalance(string calldata stringId, uint256 amount) external returns(bool); function getSellDetail(uint256 tokenId) external view returns (address, uint256, uint256, address, uint256, uint256, uint256); function getNonCryptoWallet(string calldata ownerId) external view returns(uint256); function getNonCryptoOwner(uint256 tokenId) external view returns(string memory); function adminOwner(address _address) external view returns(bool); function getAuthor(uint256 tokenIdFunction) external view returns (address); function _royality(uint256 tokenId) external view returns (uint256); function getrevenueAddressBlindBox(string calldata info) external view returns(address); function getboxNameByToken(uint256 token) external view returns(string memory); //Revenue share function addNonCryptoAuthor(string calldata artistId, uint256 tokenId, bool _isArtist) external returns(bool); function transferAliaArtist(address buyer, uint256 price, address nftVaultAddress, uint256 tokenId ) external returns(bool); function checkArtistOwner(string calldata artistId, uint256 tokenId) external returns(bool); function checkTokenAuthorIsArtist(uint256 tokenId) external returns(bool); function withdraw(uint) external; function deposit() payable external; // function approve(address spender, uint256 rawAmount) external; // BlindBox ref:https://noborderz.slack.com/archives/C0236PBG601/p1633942033011800?thread_ts=1633941154.010300&cid=C0236PBG601 function isSellable (string calldata name) external view returns(bool); function tokenURI(uint256 tokenId) external view returns (string memory); function ownerOf(uint256 tokenId) external view returns (address); function burn (uint256 tokenId) external; } // File: contracts/INFT.sol pragma solidity ^0.5.0; // import "../openzeppelin-solidity/contracts/token/ERC721/IERC721Full.sol"; interface INFT { function transferFromAdmin(address owner, address to, uint256 tokenId) external; function mintWithTokenURI(address to, string calldata tokenURI) external returns (uint256); function getAuthor(uint256 tokenIdFunction) external view returns (address); function updateTokenURI(uint256 tokenIdT, string calldata uriT) external; // function mint(address to, string calldata tokenURI) external returns (uint256); function transferOwnership(address newOwner) external; function ownerOf(uint256 tokenId) external view returns(address); function transferFrom(address owner, address to, uint256 tokenId) external; } // File: contracts/IFactory.sol pragma solidity ^0.5.0; contract IFactory { function create(string calldata name_, string calldata symbol_, address owner_) external returns(address); function getCollections(address owner_) external view returns(address [] memory); } // File: contracts/LPInterface.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 LPInterface { /** * @dev Returns the amount of tokens in existence. */ function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); } // File: openzeppelin-solidity/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) { 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; } } // File: contracts/Proxy/DexStorage.sol pragma solidity ^0.5.0; /////////////////////////////////////////////////////////////////////////////////////////////////// /** * @title DexStorage * @dev Defining dex storage for the proxy contract. */ /////////////////////////////////////////////////////////////////////////////////////////////////// contract DexStorage { using SafeMath for uint256; address x; // dummy variable, never set or use its value in any logic contracts. It keeps garbage value & append it with any value set on it. IERC20 ALIA; INFT XNFT; IFactory factory; IERC20 OldNFTDex; IERC20 BUSD; IERC20 BNB; struct RDetails { address _address; uint256 percentage; } struct AuthorDetails { address _address; uint256 royalty; string ownerId; bool isSecondry; } // uint256[] public sellList; // this violates generlization as not tracking tokenIds agains nftContracts/collections but ignoring as not using it in logic anywhere (uncommented) mapping (uint256 => mapping(address => AuthorDetails)) internal _tokenAuthors; mapping (address => bool) public adminOwner; address payable public platform; address payable public authorVault; uint256 internal platformPerecentage; struct fixedSell { // address nftContract; // adding to support multiple NFT contracts buy/sell address seller; uint256 price; uint256 timestamp; bool isDollar; uint256 currencyType; } // stuct for auction struct auctionSell { address seller; address nftContract; address bidder; uint256 minPrice; uint256 startTime; uint256 endTime; uint256 bidAmount; bool isDollar; uint256 currencyType; // address nftAddress; } // tokenId => nftContract => fixedSell mapping (uint256 => mapping (address => fixedSell)) internal _saleTokens; mapping(address => bool) public _supportNft; // tokenId => nftContract => auctionSell mapping(uint256 => mapping ( address => auctionSell)) internal _auctionTokens; address payable public nonCryptoNFTVault; // tokenId => nftContract => ownerId mapping (uint256=> mapping (address => string)) internal _nonCryptoOwners; struct balances{ uint256 bnb; uint256 Alia; uint256 BUSD; } mapping (string => balances) internal _nonCryptoWallet; LPInterface LPAlia; LPInterface LPBNB; uint256 public adminDiscount; address admin; mapping (string => address) internal revenueAddressBlindBox; mapping (uint256=>string) internal boxNameByToken; bool public collectionConfig; uint256 public countCopy; mapping (uint256=> mapping( address => mapping(uint256 => bool))) _allowedCurrencies; IERC20 token; // struct offer { // address _address; // string ownerId; // uint256 currencyType; // uint256 price; // } // struct offers { // uint256 count; // mapping (uint256 => offer) _offer; // } // mapping(uint256 => mapping(address => offers)) _offers; uint256[] allowedArray; } // File: contracts/MainDex.sol pragma solidity ^0.5.0; contract MainDex is Ownable, DexStorage { event updateTokenEvent(address to,uint256 tokenId, string uriT); event updateDiscount(uint256 amount); event CollectionsConfigured(address indexed xCollection, address factory); // event Offer(uint256 tokenId, address indexed from, uint256 currencyType, uint256 offer, uint256 index); address a; modifier onlyAdminMinter() { require(msg.sender==0xcfd872E3E8FB719EBEce7e872eD5DC287BB1E329); _; } function() external payable {} function init() public { require(!collectionConfig,"collections already configured"); XNFT = INFT(0x54994ba4b4A42297B3B88E27185CDe1F51DcA288); // OldNFTDex = IERC20(0xc2F19E2be5c5a1AA7A998f44B759eb3360587ad1); //not-in-use // ALIA = IERC20(0x8D8108A9cFA5a669300074A602f36AF3252B7533); //not-in-use collectionConfig = true; admin=0xcfd872E3E8FB719EBEce7e872eD5DC287BB1E329; // LPAlia=LPInterface(0x52826ee949d3e1C3908F288B74b98742b262f3f1); //not-in-use LPBNB=LPInterface(0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852); //LPETH // nonCryptoNFTVault = 0x61598488ccD8cb5114Df579e3E0c5F19Fdd6b3Af; //not-in-use platform = 0x9c427ea9cE5fd3101a273815Ff8530f2AC75Db37; // authorVault = 0xF0d2D73d09A04036F7587C16518f67cE622129Fd; //not-in-use platformPerecentage = 25; countCopy = 0; ownerInit(); factory = IFactory(0x53a5a2eaA5794384384dD990555c2B8fBE195D14); _supportNft[0x54994ba4b4A42297B3B88E27185CDe1F51DcA288] = true; emit CollectionsConfigured(0x54994ba4b4A42297B3B88E27185CDe1F51DcA288, 0x53a5a2eaA5794384384dD990555c2B8fBE195D14); BUSD = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7); BNB= IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); _supportNft[address(this)] = true; a = 0x61598488ccD8cb5114Df579e3E0c5F19Fdd6b3Af; } function getXNFT() public view returns(address){ return address(XNFT); } function getOldNFTDex() public view returns(address){ return address(OldNFTDex); } function getAlia() public view returns(address){ return address(ALIA); } function getCollectionConfig() public view returns(bool){ return collectionConfig; } function getAdmin() public view returns(address){ return admin; } function getLPAlia() public view returns(address){ return address(LPAlia); } function getLPBNB() public view returns(address){ return address(LPBNB); } function getNonCryptoNFTVault() public view returns(address){ return nonCryptoNFTVault; } function getPlatform() public view returns(address){ return platform; } function getAuthorVault() public view returns(address){ return authorVault; } function getPlatformPerecentage() public view returns(uint256){ return platformPerecentage; } function getCountCopy() public view returns(uint256){ return countCopy; } function getFactory() public view returns(address){ return address(factory); } function getSupportNft(address addr) public view returns(bool){ return _supportNft[addr]; } function getBUSD() public view returns(address){ return address(BUSD); } function getBNB() public view returns(address){ return address(BNB); } function getA() public view returns(address){ return a; } // function makeOffer(address nft_a, uint256 tokenId, uint256 currencyType, uint256 price) public { // require(price > 0, "126"); // require(currencyType <= 1, "123"); // IERC20 token = currencyType == 1 ? BUSD : ALIA; // token.transferFrom(msg.sender, address(this), price); // _offers[tokenId][nft_a].count++; // _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count] = offer(msg.sender, "", currencyType, price); // emit Offer(tokenId, msg.sender, currencyType, price, _offers[tokenId][nft_a].count); // } // function removeOffer(address nft_a,uint256 tokenId, uint256 index) public { // offer storage temp = _offers[tokenId][nft_a]._offer[index]; // require(temp._address == msg.sender, "127"); // require(temp.currencyType <= 1, "123"); // IERC20 token = temp.currencyType == 1 ? BUSD : ALIA; // token.transfer(msg.sender, temp.price); // _offers[tokenId][nft_a]._offer[index] = _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // delete _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // _offers[tokenId][nft_a].count--; // } // function acceptOffer(address nft_a,uint256 tokenId, uint256 index) public { // require(INFT(nft_a).ownerOf(tokenId) == msg.sender || _saleTokens[tokenId][nft_a].seller == msg.sender, "101"); // offer storage temp = _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // require(temp._address == msg.sender, "127"); // require(temp.currencyType <= 1, "123"); // IERC20 token = temp.currencyType == 1 ? BUSD : ALIA; // token.transfer(msg.sender, temp.price); // _offers[tokenId][nft_a].count--; // delete _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // } // function rejectOffer(address nft_a, uint256 tokenId, uint256 index) public { // require(INFT(nft_a).ownerOf(tokenId) == msg.sender || _saleTokens[tokenId][nft_a].seller == msg.sender , "101"); // offer storage temp = _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // require(temp._address == msg.sender, "127"); // require(temp.currencyType <= 1, "123"); // IERC20 token = temp.currencyType == 1 ? BUSD : ALIA; // token.transfer(temp._address, temp.price); // _offers[tokenId][nft_a]._offer[index] = _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // delete _offers[tokenId][nft_a]._offer[_offers[tokenId][nft_a].count]; // _offers[tokenId][nft_a].count--; // } function getAliaAddress () public view returns(address) { return address(ALIA); } // function getAllowedCurrencies(uint256 tokenId, address nft_a ) public view returns(uint256[] memory allowedCurrencies) { // uint256[] storage temp; // for(uint256 i = 0; i <=2 ; i++) { // if( _allowedCurrencies[tokenId][nft_a][i]){ // temp.push(i); // } // } // allowedCurrencies = temp; // } function setAdminDiscount(uint256 _discount) onlyAdminMinter public { adminDiscount = _discount; emit updateDiscount(_discount); } // only xanalia collection i.e XNFT NFT's uri can be updated function updateTokenURI(uint256 tokenIdT, string memory uriT) public{ // anyone can update tokenURI of NFTs owned by admin, is it intentional ?? require(XNFT.getAuthor(tokenIdT) == admin,"102"); // _tokenURIs[tokenIdT] = uriT; XNFT.updateTokenURI(tokenIdT, uriT); emit updateTokenEvent(msg.sender, tokenIdT, uriT); } }
0x6080604052600436106101a05763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166318e97fd181146101a25780631d67e8031461025c5780631d73cf34146102a357806324fbec7f146102d657806329166e41146103075780632c7a3e641461031c5780632fc1f190146103315780634bde38c81461034657806358616aa01461035b5780635eeca1f0146103825780636b34d725146103975780636e9960c3146103ac578063715018a6146103c157806372856d82146103d657806375919c5a1461038257806378a619de146103eb5780637c824b5e1461040057806388cc58e4146104155780638da5cb5b1461042a5780638f32d59b1461043f57806390ecea7a146104545780639718261014610469578063a18da2b41461047e578063aebc082414610493578063c34a2b66146104a8578063c7e86457146104bd578063d0a9656f146104d2578063d46300fd146104e7578063e1c7392a146104fc578063e5a9999114610511578063f020d28514610544578063f2fde38b1461056e578063f9f7ad62146105a1575b005b3480156101ae57600080fd5b506101a0600480360360408110156101c557600080fd5b813591908101906040810160208201356401000000008111156101e757600080fd5b8201836020820111156101f957600080fd5b8035906020019184600183028401116401000000008311171561021b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105b6945050505050565b34801561026857600080fd5b5061028f6004803603602081101561027f57600080fd5b5035600160a060020a0316610851565b604080519115158252519081900360200190f35b3480156102af57600080fd5b5061028f600480360360208110156102c657600080fd5b5035600160a060020a031661086f565b3480156102e257600080fd5b506102eb610884565b60408051600160a060020a039092168252519081900360200190f35b34801561031357600080fd5b506102eb610893565b34801561032857600080fd5b506102eb6108a2565b34801561033d57600080fd5b506102eb6108b1565b34801561035257600080fd5b506102eb6108c0565b34801561036757600080fd5b506103706108cf565b60408051918252519081900360200190f35b34801561038e57600080fd5b506102eb6108d5565b3480156103a357600080fd5b5061028f6108e4565b3480156103b857600080fd5b506102eb6108ed565b3480156103cd57600080fd5b506101a06108fc565b3480156103e257600080fd5b506102eb6109b1565b3480156103f757600080fd5b506102eb6109c0565b34801561040c57600080fd5b506102eb6109cf565b34801561042157600080fd5b506102eb6109de565b34801561043657600080fd5b506102eb6109ed565b34801561044b57600080fd5b5061028f6109fc565b34801561046057600080fd5b506102eb610a0d565b34801561047557600080fd5b5061028f610a1c565b34801561048a57600080fd5b50610370610a25565b34801561049f57600080fd5b50610370610a2b565b3480156104b457600080fd5b506102eb610a31565b3480156104c957600080fd5b506102eb610a40565b3480156104de57600080fd5b50610370610a4f565b3480156104f357600080fd5b506102eb610a55565b34801561050857600080fd5b506101a0610a64565b34801561051d57600080fd5b5061028f6004803603602081101561053457600080fd5b5035600160a060020a0316610cb5565b34801561055057600080fd5b506101a06004803603602081101561056757600080fd5b5035610cca565b34801561057a57600080fd5b506101a06004803603602081101561059157600080fd5b5035600160a060020a0316610d25565b3480156105ad57600080fd5b506102eb610d8f565b601654600354604080517f9e2b8488000000000000000000000000000000000000000000000000000000008152600481018690529051600160a060020a039384169390921691639e2b848891602480820192602092909190829003018186803b15801561062257600080fd5b505afa158015610636573d6000803e3d6000fd5b505050506040513d602081101561064c57600080fd5b5051600160a060020a0316146106ac576040805160e560020a62461bcd02815260206004820152600360248201527f3130320000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b600354604080517f18e97fd10000000000000000000000000000000000000000000000000000000081526004810185815260248201928352845160448301528451600160a060020a03909416936318e97fd1938793879392606490910190602085019080838360005b8381101561072d578181015183820152602001610715565b50505050905090810190601f16801561075a5780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b15801561077a57600080fd5b505af115801561078e573d6000803e3d6000fd5b505050507fa479ec60b694e204d5c47117410cbba4e0d62ada24d1384bcc0e6a5ea1b39d943383836040518084600160a060020a0316600160a060020a0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156108115781810151838201526020016107f9565b50505050905090810190601f16801561083e5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a15050565b600160a060020a03166000908152600e602052604090205460ff1690565b600e6020526000908152604090205460ff1681565b600354600160a060020a031690565b600654600160a060020a031690565b600b54600160a060020a031690565b600a54600160a060020a031690565b600a54600160a060020a031681565b601a5481565b600254600160a060020a031690565b60195460ff1681565b601654600160a060020a031690565b6109046109fc565b151561095a576040805160e560020a62461bcd02815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b601054600160a060020a031681565b600754600160a060020a031690565b601354600160a060020a031690565b600454600160a060020a031690565b600054600160a060020a031690565b600054600160a060020a0316331490565b601454600160a060020a031690565b60195460ff1690565b601a5490565b60155481565b601054600160a060020a031690565b600554600160a060020a031690565b600c5490565b601e54600160a060020a031690565b60195460ff1615610abf576040805160e560020a62461bcd02815260206004820152601e60248201527f636f6c6c656374696f6e7320616c726561647920636f6e666967757265640000604482015290519081900360640190fd5b6003805473ffffffffffffffffffffffffffffffffffffffff199081167354994ba4b4a42297b3b88e27185cde1f51dca288179091556019805460ff1916600117815560168054831673cfd872e3e8fb719ebece7e872ed5dc287bb1e329179055601480548316730d4a11d5eeaac28ec3f61d100daf4d40471f1852179055600a8054909216739c427ea9ce5fd3101a273815ff8530f2ac75db3717909155600c556000601a55610b6e610d9e565b6004805473ffffffffffffffffffffffffffffffffffffffff19167353a5a2eaa5794384384dd990555c2b8fbe195d149081179091557354994ba4b4a42297b3b88e27185cde1f51dca2886000819052600e60209081527f10210068974edc8e9da319a1b762915aeab5fa6b50a196b582e1d508a6a89b33805460ff19166001179055604080519384525191927fc43688db859636d742b105e5cb7f96a0f0c76ad2f061dbc32f753ae09f6bc384929081900390910190a26006805473ffffffffffffffffffffffffffffffffffffffff1990811673dac17f958d2ee523a2206206994597c13d831ec71790915560078054821673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2179055306000908152600e60205260409020805460ff19166001179055601e80549091167361598488ccd8cb5114df579e3e0c5f19fdd6b3af179055565b60096020526000908152604090205460ff1681565b73cfd872e3e8fb719ebece7e872ed5dc287bb1e3293314610cea57600080fd5b60158190556040805182815290517f5d3fdd1962a94c8f979bdd85edb9ee2b643bed569538bf8799aca94a0e013b499181900360200190a150565b610d2d6109fc565b1515610d83576040805160e560020a62461bcd02815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610d8c81610df6565b50565b600b54600160a060020a031681565b6000805473ffffffffffffffffffffffffffffffffffffffff19163317808255604051600160a060020a039190911691907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3565b600160a060020a0381161515610e7c576040805160e560020a62461bcd02815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905556fea165627a7a7230582049599abc13e1d74e60526ab7e6ff1d85ebe42ba5e962256a8b81d6fec134d5b70029
[ 0, 27, 2 ]
0xf1f02ce7cdec4ec72c8bae997c7d858d2df56469
pragma solidity ^0.4.22; 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) { 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 ForeignToken { function balanceOf(address _owner) constant public returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); } 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); } 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); } interface Token { function distr(address _to, uint256 _value) external returns (bool); function totalSupply() constant external returns (uint256 supply); function balanceOf(address _owner) constant external returns (uint256 balance); } contract UnlimitedChain is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public blacklist; string public constant name = "Unlimited Chain"; string public constant symbol = "UNC"; uint public constant decimals = 18; uint256 public totalSupply = 10000000000e18; uint256 public totalDistributed = 5000000000e18; uint256 public totalRemaining = totalSupply.sub(totalDistributed); uint256 public value = 10000e18; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Burn(address indexed burner, uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyWhitelist() { require(blacklist[msg.sender] == false); _; } function BITDINERO() public { owner = msg.sender; balances[owner] = totalDistributed; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); totalRemaining = totalRemaining.sub(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; if (totalDistributed >= totalSupply) { distributionFinished = true; } } function () external payable { getTokens(); } function getTokens() payable canDistr onlyWhitelist public { if (value > totalRemaining) { value = totalRemaining; } require(value <= totalRemaining); address investor = msg.sender; uint256 toGive = value; distr(investor, toGive); if (toGive > 0) { blacklist[investor] = true; } if (totalDistributed >= totalSupply) { distributionFinished = true; } value = value.div(100000).mul(99999); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true; } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdraw() onlyOwner public { uint256 etherBalance = address(this).balance; owner.transfer(etherBalance); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
0x6080604052600436106101275763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610131578063095ea7b3146101bb57806318160ddd146101f357806323b872dd1461021a578063313ce567146102445780633ccfd60b146102595780633fa4f2451461026e57806342966c681461028357806370a082311461029b57806395d89b41146102bc5780639b1cbccc146102d1578063a5c57b18146102e6578063a9059cbb146102fb578063aa6ca80814610127578063c108d5421461031f578063c489744b14610334578063d8a543601461035b578063dd62ed3e14610370578063e58fc54c14610397578063efca2eed146103b8578063f2fde38b146103cd578063f9f92be4146103ee575b61012f61040f565b005b34801561013d57600080fd5b506101466104ef565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610180578181015183820152602001610168565b50505050905090810190601f1680156101ad5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101c757600080fd5b506101df600160a060020a0360043516602435610526565b604080519115158252519081900360200190f35b3480156101ff57600080fd5b506102086105ce565b60408051918252519081900360200190f35b34801561022657600080fd5b506101df600160a060020a03600435811690602435166044356105d4565b34801561025057600080fd5b50610208610759565b34801561026557600080fd5b5061012f61075e565b34801561027a57600080fd5b506102086107b8565b34801561028f57600080fd5b5061012f6004356107be565b3480156102a757600080fd5b50610208600160a060020a036004351661089d565b3480156102c857600080fd5b506101466108b8565b3480156102dd57600080fd5b506101df6108ef565b3480156102f257600080fd5b5061012f610955565b34801561030757600080fd5b506101df600160a060020a0360043516602435610996565b34801561032b57600080fd5b506101df610a87565b34801561034057600080fd5b50610208600160a060020a0360043581169060243516610a90565b34801561036757600080fd5b50610208610b41565b34801561037c57600080fd5b50610208600160a060020a0360043581169060243516610b47565b3480156103a357600080fd5b506101df600160a060020a0360043516610b72565b3480156103c457600080fd5b50610208610cc6565b3480156103d957600080fd5b5061012f600160a060020a0360043516610ccc565b3480156103fa57600080fd5b506101df600160a060020a0360043516610d1e565b600954600090819060ff161561042457600080fd5b3360009081526004602052604090205460ff161561044157600080fd5b6007546008541115610454576007546008555b600754600854111561046557600080fd5b505060085433906104768282610d33565b5060008111156104a457600160a060020a0382166000908152600460205260409020805460ff191660011790555b600554600654106104bd576009805460ff191660011790555b6104e86201869f6104dc620186a0600854610e3690919063ffffffff16565b9063ffffffff610e4d16565b6008555050565b60408051808201909152600f81527f556e6c696d6974656420436861696e0000000000000000000000000000000000602082015281565b600081158015906105595750336000908152600360209081526040808320600160a060020a038716845290915290205415155b15610566575060006105c8565b336000818152600360209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60055481565b6000606060643610156105e357fe5b600160a060020a03841615156105f857600080fd5b600160a060020a03851660009081526002602052604090205483111561061d57600080fd5b600160a060020a038516600090815260036020908152604080832033845290915290205483111561064d57600080fd5b600160a060020a038516600090815260026020526040902054610676908463ffffffff610e7816565b600160a060020a03861660009081526002602090815260408083209390935560038152828220338352905220546106b3908463ffffffff610e7816565b600160a060020a0380871660009081526003602090815260408083203384528252808320949094559187168152600290915220546106f7908463ffffffff610e8a16565b600160a060020a0380861660008181526002602090815260409182902094909455805187815290519193928916927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3506001949350505050565b601281565b600154600090600160a060020a0316331461077857600080fd5b50600154604051303191600160a060020a03169082156108fc029083906000818181858888f193505050501580156107b4573d6000803e3d6000fd5b5050565b60085481565b600154600090600160a060020a031633146107d857600080fd5b336000908152600260205260409020548211156107f457600080fd5b5033600081815260026020526040902054610815908363ffffffff610e7816565b600160a060020a038216600090815260026020526040902055600554610841908363ffffffff610e7816565b600555600654610857908363ffffffff610e7816565b600655604080518381529051600160a060020a038316917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a25050565b600160a060020a031660009081526002602052604090205490565b60408051808201909152600381527f554e430000000000000000000000000000000000000000000000000000000000602082015281565b600154600090600160a060020a0316331461090957600080fd5b60095460ff161561091957600080fd5b6009805460ff191660011790556040517f7f95d919e78bdebe8a285e6e33357c2fcb65ccf66e72d7573f9f8f6caad0c4cc90600090a150600190565b6001805473ffffffffffffffffffffffffffffffffffffffff1916331790819055600654600160a060020a0391909116600090815260026020526040902055565b6000604060443610156109a557fe5b600160a060020a03841615156109ba57600080fd5b336000908152600260205260409020548311156109d657600080fd5b336000908152600260205260409020546109f6908463ffffffff610e7816565b3360009081526002602052604080822092909255600160a060020a03861681522054610a28908463ffffffff610e8a16565b600160a060020a0385166000818152600260209081526040918290209390935580518681529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060019392505050565b60095460ff1681565b600080600084915081600160a060020a03166370a08231856040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018082600160a060020a0316600160a060020a03168152602001915050602060405180830381600087803b158015610b0c57600080fd5b505af1158015610b20573d6000803e3d6000fd5b505050506040513d6020811015610b3657600080fd5b505195945050505050565b60075481565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205490565b60015460009081908190600160a060020a03163314610b9057600080fd5b604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051859350600160a060020a038416916370a082319160248083019260209291908290030181600087803b158015610bf457600080fd5b505af1158015610c08573d6000803e3d6000fd5b505050506040513d6020811015610c1e57600080fd5b5051600154604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810184905290519293509084169163a9059cbb916044808201926020929091908290030181600087803b158015610c9257600080fd5b505af1158015610ca6573d6000803e3d6000fd5b505050506040513d6020811015610cbc57600080fd5b5051949350505050565b60065481565b600154600160a060020a03163314610ce357600080fd5b600160a060020a03811615610d1b576001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383161790555b50565b60046020526000908152604090205460ff1681565b60095460009060ff1615610d4657600080fd5b600654610d59908363ffffffff610e8a16565b600655600754610d6f908363ffffffff610e7816565b600755600160a060020a038316600090815260026020526040902054610d9b908363ffffffff610e8a16565b600160a060020a038416600081815260026020908152604091829020939093558051858152905191927f8940c4b8e215f8822c5c8f0056c12652c746cbc57eedbd2a440b175971d47a7792918290030190a2604080518381529051600160a060020a038516916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35060016105c8565b6000808284811515610e4457fe5b04949350505050565b6000828202831580610e695750828482811515610e6657fe5b04145b1515610e7157fe5b9392505050565b600082821115610e8457fe5b50900390565b600082820183811015610e7157fe00a165627a7a72305820db7383a7fe9494c441ed2b4e2347e2fc3b2178e73996a74a844f356a4e1f84150029
[ 14, 4 ]
0xF1f098aC4E302d1366ED9872Fea3417279A253EF
// Contract created by Carton and owned by Sunland. // Contract based on https://docs.openzeppelin.com/contracts/3.x/erc721 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract Sunland is ERC721Enumerable, Ownable { address public constant vaultAddress = 0x634bd516EA946241c2cBaD6A355D0Fb41F608De6; uint256 public price = 1000000000000000000; // Default price of 1 ETH, may change at release date string public baseURI = ""; bool public isSaleActive = false; constructor() ERC721("Sunland", "Sunland") {} function launch(string memory _base) public onlyOwner { baseURI = _base; isSaleActive = true; } function flipSaleStatus() public onlyOwner { isSaleActive = !isSaleActive; } function setPrice(uint256 _newPrice) public onlyOwner { price = _newPrice; } function withdrawAllToVault() public onlyOwner { address payable vault = payable(vaultAddress); vault.transfer(address(this).balance); } function withdraw(uint256 value) public onlyOwner { address payable ownerAdr = payable(msg.sender); ownerAdr.transfer(value); } function mint() public payable { require(isSaleActive, "Lands minting is not yet available" ); require(msg.value >= price, "Insuffisant Eth"); uint256 newItemId = totalSupply() + 1; require(newItemId <= 177, "Exceeds maximum tokens available for purchase"); _safeMint(msg.sender, newItemId); } function tokensByOwner(address _owner) external view returns(uint256[] memory ) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) { return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 index; for (index = 0; index < tokenCount; index++) { result[index] = tokenOfOwnerByIndex(_owner, index); } return result; } } function getAllOwnerAndToken() public view returns(address[] memory) { address[] memory adrs = new address[](totalSupply() + 1); address defaut; adrs[0] = defaut; for (uint i = 1; i <= totalSupply(); i++) { adrs[i] = ownerOf(i); } return adrs; } } // 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; 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; /** * @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; 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 "../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 "../../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 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); }
0x6080604052600436106101d85760003560e01c80636c0360eb11610102578063b88d4fde11610095578063ce03ec9311610064578063ce03ec9314610505578063e985e9c51461051a578063efc3b5db1461053a578063f2fde38b1461055a576101d8565b8063b88d4fde1461048e578063bfd131f1146104ae578063c0297620146104c3578063c87b56dd146104e5576101d8565b806391b7f5ed116100d157806391b7f5ed1461042457806395d89b4114610444578063a035b1fe14610459578063a22cb4651461046e576101d8565b80636c0360eb146103c557806370a08231146103da578063715018a6146103fa5780638da5cb5b1461040f576101d8565b806323b872dd1161017a578063430bf08a11610149578063430bf08a1461035b5780634f6ccce714610370578063564566a8146103905780636352211e146103a5576101d8565b806323b872dd146102db5780632e1a7d4d146102fb5780632f745c591461031b57806342842e0e1461033b576101d8565b8063095ea7b3116101b6578063095ea7b3146102625780630d381a28146102845780631249c58b146102b157806318160ddd146102b9576101d8565b806301ffc9a7146101dd57806306fdde0314610213578063081812fc14610235575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611bf1565b61057a565b60405161020a9190611db8565b60405180910390f35b34801561021f57600080fd5b506102286105a7565b60405161020a9190611dc3565b34801561024157600080fd5b50610255610250366004611c6f565b610639565b60405161020a9190611ce2565b34801561026e57600080fd5b5061028261027d366004611bc8565b610685565b005b34801561029057600080fd5b506102a461029f366004611a8e565b61071d565b60405161020a9190611d80565b6102826107fe565b3480156102c557600080fd5b506102ce610887565b60405161020a919061238b565b3480156102e757600080fd5b506102826102f6366004611ada565b61088d565b34801561030757600080fd5b50610282610316366004611c6f565b6108c5565b34801561032757600080fd5b506102ce610336366004611bc8565b610933565b34801561034757600080fd5b50610282610356366004611ada565b610985565b34801561036757600080fd5b506102556109a0565b34801561037c57600080fd5b506102ce61038b366004611c6f565b6109b8565b34801561039c57600080fd5b506101fd610a13565b3480156103b157600080fd5b506102556103c0366004611c6f565b610a1c565b3480156103d157600080fd5b50610228610a51565b3480156103e657600080fd5b506102ce6103f5366004611a8e565b610adf565b34801561040657600080fd5b50610282610b23565b34801561041b57600080fd5b50610255610b6e565b34801561043057600080fd5b5061028261043f366004611c6f565b610b7d565b34801561045057600080fd5b50610228610bc1565b34801561046557600080fd5b506102ce610bd0565b34801561047a57600080fd5b50610282610489366004611b8e565b610bd6565b34801561049a57600080fd5b506102826104a9366004611b15565b610ca4565b3480156104ba57600080fd5b50610282610ce3565b3480156104cf57600080fd5b506104d8610d68565b60405161020a9190611d33565b3480156104f157600080fd5b50610228610500366004611c6f565b610e79565b34801561051157600080fd5b50610282610efc565b34801561052657600080fd5b506101fd610535366004611aa8565b610f4f565b34801561054657600080fd5b50610282610555366004611c29565b610f7d565b34801561056657600080fd5b50610282610575366004611a8e565b610fe0565b60006001600160e01b0319821663780e9d6360e01b148061059f575061059f8261104e565b90505b919050565b6060600080546105b690612403565b80601f01602080910402602001604051908101604052809291908181526020018280546105e290612403565b801561062f5780601f106106045761010080835404028352916020019161062f565b820191906000526020600020905b81548152906001019060200180831161061257829003601f168201915b5050505050905090565b60006106448261108e565b6106695760405162461bcd60e51b81526004016106609061216b565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061069082610a1c565b9050806001600160a01b0316836001600160a01b031614156106c45760405162461bcd60e51b815260040161066090612284565b806001600160a01b03166106d66110ab565b6001600160a01b031614806106f257506106f2816105356110ab565b61070e5760405162461bcd60e51b815260040161066090612046565b61071883836110af565b505050565b6060600061072a83610adf565b9050806107475750506040805160008152602081019091526105a2565b60008167ffffffffffffffff81111561077057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610799578160200160208202803683370190505b50905060005b828110156107ee576107b18582610933565b8282815181106107d157634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806107e681612438565b91505061079f565b5091506105a29050565b50919050565b600d5460ff166108205760405162461bcd60e51b815260040161066090611f06565b600b543410156108425760405162461bcd60e51b8152600401610660906122c5565b600061084c610887565b610857906001612394565b905060b181111561087a5760405162461bcd60e51b815260040161066090611eb9565b610884338261111d565b50565b60085490565b61089e6108986110ab565b82611137565b6108ba5760405162461bcd60e51b8152600401610660906122ee565b6107188383836111bc565b6108cd6110ab565b6001600160a01b03166108de610b6e565b6001600160a01b0316146109045760405162461bcd60e51b8152600401610660906121b7565b6040513390819083156108fc029084906000818181858888f19350505050158015610718573d6000803e3d6000fd5b600061093e83610adf565b821061095c5760405162461bcd60e51b815260040161066090611dd6565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61071883838360405180602001604052806000815250610ca4565b73634bd516ea946241c2cbad6a355d0fb41f608de681565b60006109c2610887565b82106109e05760405162461bcd60e51b81526004016106609061233f565b60088281548110610a0157634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b600d5460ff1681565b6000818152600260205260408120546001600160a01b03168061059f5760405162461bcd60e51b8152600401610660906120ed565b600c8054610a5e90612403565b80601f0160208091040260200160405190810160405280929190818152602001828054610a8a90612403565b8015610ad75780601f10610aac57610100808354040283529160200191610ad7565b820191906000526020600020905b815481529060010190602001808311610aba57829003601f168201915b505050505081565b60006001600160a01b038216610b075760405162461bcd60e51b8152600401610660906120a3565b506001600160a01b031660009081526003602052604090205490565b610b2b6110ab565b6001600160a01b0316610b3c610b6e565b6001600160a01b031614610b625760405162461bcd60e51b8152600401610660906121b7565b610b6c60006112e9565b565b600a546001600160a01b031690565b610b856110ab565b6001600160a01b0316610b96610b6e565b6001600160a01b031614610bbc5760405162461bcd60e51b8152600401610660906121b7565b600b55565b6060600180546105b690612403565b600b5481565b610bde6110ab565b6001600160a01b0316826001600160a01b03161415610c0f5760405162461bcd60e51b815260040161066090611fc3565b8060056000610c1c6110ab565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610c606110ab565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610c989190611db8565b60405180910390a35050565b610cb5610caf6110ab565b83611137565b610cd15760405162461bcd60e51b8152600401610660906122ee565b610cdd8484848461133b565b50505050565b610ceb6110ab565b6001600160a01b0316610cfc610b6e565b6001600160a01b031614610d225760405162461bcd60e51b8152600401610660906121b7565b60405173634bd516ea946241c2cbad6a355d0fb41f608de69081904780156108fc02916000818181858888f19350505050158015610d64573d6000803e3d6000fd5b5050565b60606000610d74610887565b610d7f906001612394565b67ffffffffffffffff811115610da557634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610dce578160200160208202803683370190505b50905060008082600081518110610df557634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015260015b610e18610887565b8111610e7157610e2781610a1c565b838281518110610e4757634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280610e6981612438565b915050610e10565b509091505090565b6060610e848261108e565b610ea05760405162461bcd60e51b815260040161066090612235565b6000610eaa61136e565b90506000815111610eca5760405180602001604052806000815250610ef5565b80610ed484611380565b604051602001610ee5929190611cb3565b6040516020818303038152906040525b9392505050565b610f046110ab565b6001600160a01b0316610f15610b6e565b6001600160a01b031614610f3b5760405162461bcd60e51b8152600401610660906121b7565b600d805460ff19811660ff90911615179055565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610f856110ab565b6001600160a01b0316610f96610b6e565b6001600160a01b031614610fbc5760405162461bcd60e51b8152600401610660906121b7565b8051610fcf90600c90602084019061196e565b5050600d805460ff19166001179055565b610fe86110ab565b6001600160a01b0316610ff9610b6e565b6001600160a01b03161461101f5760405162461bcd60e51b8152600401610660906121b7565b6001600160a01b0381166110455760405162461bcd60e51b815260040161066090611e73565b610884816112e9565b60006001600160e01b031982166380ac58cd60e01b148061107f57506001600160e01b03198216635b5e139f60e01b145b8061059f575061059f8261149b565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906110e482610a1c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610d648282604051806020016040528060008152506114b4565b60006111428261108e565b61115e5760405162461bcd60e51b815260040161066090611ffa565b600061116983610a1c565b9050806001600160a01b0316846001600160a01b031614806111a45750836001600160a01b031661119984610639565b6001600160a01b0316145b806111b457506111b48185610f4f565b949350505050565b826001600160a01b03166111cf82610a1c565b6001600160a01b0316146111f55760405162461bcd60e51b8152600401610660906121ec565b6001600160a01b03821661121b5760405162461bcd60e51b815260040161066090611f7f565b6112268383836114e7565b6112316000826110af565b6001600160a01b038316600090815260036020526040812080546001929061125a9084906123c0565b90915550506001600160a01b0382166000908152600360205260408120805460019290611288908490612394565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6113468484846111bc565b61135284848484611570565b610cdd5760405162461bcd60e51b815260040161066090611e21565b60408051602081019091526000815290565b6060816113a557506040805180820190915260018152600360fc1b60208201526105a2565b8160005b81156113cf57806113b981612438565b91506113c89050600a836123ac565b91506113a9565b60008167ffffffffffffffff8111156113f857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611422576020820181803683370190505b5090505b84156111b4576114376001836123c0565b9150611444600a86612453565b61144f906030612394565b60f81b81838151811061147257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611494600a866123ac565b9450611426565b6001600160e01b031981166301ffc9a760e01b14919050565b6114be838361168b565b6114cb6000848484611570565b6107185760405162461bcd60e51b815260040161066090611e21565b6114f2838383610718565b6001600160a01b03831661150e576115098161176a565b611531565b816001600160a01b0316836001600160a01b0316146115315761153183826117ae565b6001600160a01b03821661154d576115488161184b565b610718565b826001600160a01b0316826001600160a01b031614610718576107188282611924565b6000611584846001600160a01b0316611968565b1561168057836001600160a01b031663150b7a026115a06110ab565b8786866040518563ffffffff1660e01b81526004016115c29493929190611cf6565b602060405180830381600087803b1580156115dc57600080fd5b505af192505050801561160c575060408051601f3d908101601f1916820190925261160991810190611c0d565b60015b611666573d80801561163a576040519150601f19603f3d011682016040523d82523d6000602084013e61163f565b606091505b50805161165e5760405162461bcd60e51b815260040161066090611e21565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506111b4565b506001949350505050565b6001600160a01b0382166116b15760405162461bcd60e51b815260040161066090612136565b6116ba8161108e565b156116d75760405162461bcd60e51b815260040161066090611f48565b6116e3600083836114e7565b6001600160a01b038216600090815260036020526040812080546001929061170c908490612394565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b600060016117bb84610adf565b6117c591906123c0565b600083815260076020526040902054909150808214611818576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061185d906001906123c0565b6000838152600960205260408120546008805493945090928490811061189357634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106118c257634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061190857634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061192f83610adf565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b3b151590565b82805461197a90612403565b90600052602060002090601f01602090048101928261199c57600085556119e2565b82601f106119b557805160ff19168380011785556119e2565b828001600101855582156119e2579182015b828111156119e25782518255916020019190600101906119c7565b506119ee9291506119f2565b5090565b5b808211156119ee57600081556001016119f3565b600067ffffffffffffffff80841115611a2257611a22612493565b604051601f8501601f191681016020018281118282101715611a4657611a46612493565b604052848152915081838501861015611a5e57600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b03811681146105a257600080fd5b600060208284031215611a9f578081fd5b610ef582611a77565b60008060408385031215611aba578081fd5b611ac383611a77565b9150611ad160208401611a77565b90509250929050565b600080600060608486031215611aee578081fd5b611af784611a77565b9250611b0560208501611a77565b9150604084013590509250925092565b60008060008060808587031215611b2a578081fd5b611b3385611a77565b9350611b4160208601611a77565b925060408501359150606085013567ffffffffffffffff811115611b63578182fd5b8501601f81018713611b73578182fd5b611b8287823560208401611a07565b91505092959194509250565b60008060408385031215611ba0578182fd5b611ba983611a77565b915060208301358015158114611bbd578182fd5b809150509250929050565b60008060408385031215611bda578182fd5b611be383611a77565b946020939093013593505050565b600060208284031215611c02578081fd5b8135610ef5816124a9565b600060208284031215611c1e578081fd5b8151610ef5816124a9565b600060208284031215611c3a578081fd5b813567ffffffffffffffff811115611c50578182fd5b8201601f81018413611c60578182fd5b6111b484823560208401611a07565b600060208284031215611c80578081fd5b5035919050565b60008151808452611c9f8160208601602086016123d7565b601f01601f19169290920160200192915050565b60008351611cc58184602088016123d7565b835190830190611cd98183602088016123d7565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611d2990830184611c87565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611d745783516001600160a01b031683529284019291840191600101611d4f565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611d7457835183529284019291840191600101611d9c565b901515815260200190565b600060208252610ef56020830184611c87565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252602d908201527f45786365656473206d6178696d756d20746f6b656e7320617661696c61626c6560408201526c20666f7220707572636861736560981b606082015260800190565b60208082526022908201527f4c616e6473206d696e74696e67206973206e6f742079657420617661696c61626040820152616c6560f01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252600f908201526e092dce6eaccccd2e6c2dce8408ae8d608b1b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b90815260200190565b600082198211156123a7576123a7612467565b500190565b6000826123bb576123bb61247d565b500490565b6000828210156123d2576123d2612467565b500390565b60005b838110156123f25781810151838201526020016123da565b83811115610cdd5750506000910152565b60028104600182168061241757607f821691505b602082108114156107f857634e487b7160e01b600052602260045260246000fd5b600060001982141561244c5761244c612467565b5060010190565b6000826124625761246261247d565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461088457600080fdfea2646970667358221220c42e73daded7e4261b486fb386ad8fc4493c115258c40e2278b0dd9f43931c9e64736f6c63430008000033
[ 5, 12 ]
0xf1f09C59ac712D0c610b8BF4ec6ABa9E99CacF3A
// 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' 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 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); } } } } // SPDX-License-Identifier: Apache-2.0 /** * Copyright 2021 weiWard LLC * * 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. */ pragma solidity 0.8.6; interface IMultiSend { /* Types */ struct Recipient { address to; uint256 amount; } /* Mutators */ function multiSendETH(Recipient[] memory recipients) external payable; function multiSendERC20(address token, Recipient[] memory recipients) external; function recoverERC20( address token, address to, uint256 amount ) external; /* Events */ event ETHSent(address indexed from, Recipient[] recipients); event ERC20Sent( address indexed from, address indexed token, Recipient[] recipients ); event RecoveredERC20( address indexed author, address indexed token, address indexed to, uint256 amount ); } // SPDX-License-Identifier: Apache-2.0 /** * Copyright 2021 weiWard LLC * * 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. */ pragma solidity 0.8.6; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./IMultiSend.sol"; contract MultiSend is IMultiSend { using Address for address payable; using SafeERC20 for IERC20; // WARN: Potential reentrancy vulnerability function multiSendETH(Recipient[] memory recipients) external payable override { address sender = msg.sender; uint256 total = msg.value; uint256 sent = 0; for (uint256 i = 0; i < recipients.length; i++) { payable(recipients[i].to).sendValue(recipients[i].amount); sent += recipients[i].amount; } if (sent != total) { payable(sender).sendValue(total - sent); } emit ETHSent(sender, recipients); } function multiSendERC20(address token, Recipient[] memory recipients) external override { address sender = msg.sender; IERC20 tokenHandle = IERC20(token); for (uint256 i = 0; i < recipients.length; i++) { tokenHandle.safeTransferFrom( sender, recipients[i].to, recipients[i].amount ); } emit ERC20Sent(sender, token, recipients); } // Recover ERC20 tokens accidentally sent to the contract function recoverERC20( address token, address to, uint256 amount ) external override { IERC20(token).safeTransfer(to, amount); emit RecoveredERC20(msg.sender, token, to, amount); } }
0x6080604052600436106100345760003560e01c80631171bda9146100395780636abcc6d71461005b578063d4b921eb1461006e575b600080fd5b34801561004557600080fd5b506100596100543660046109c9565b61008e565b005b610059610069366004610a53565b610132565b34801561007a57600080fd5b50610059610089366004610a05565b610267565b6100af73ffffffffffffffffffffffffffffffffffffffff8416838361035a565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f2be8a2f7435416ac18e910fe44490a507e2de7abafee44c606427dc05a1ca7ca8460405161012591815260200190565b60405180910390a4505050565b33346000805b84518110156101e1576101a485828151811061015657610156610cbf565b60200260200101516020015186838151811061017457610174610cbf565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1661043390919063ffffffff16565b8481815181106101b6576101b6610cbf565b602002602001015160200151826101cd9190610bfc565b9150806101d981610c57565b915050610138565b50818114610213576102136101f68284610c14565b73ffffffffffffffffffffffffffffffffffffffff851690610433565b8273ffffffffffffffffffffffffffffffffffffffff167fddc556fa36c9a819c4b77ba0098841fc4b2f624c259e998ffb6a7bc5dab135c2856040516102599190610ace565b60405180910390a250505050565b338260005b83518110156102ee576102dc8385838151811061028b5761028b610cbf565b6020026020010151600001518684815181106102a9576102a9610cbf565b6020026020010151602001518573ffffffffffffffffffffffffffffffffffffffff16610592909392919063ffffffff16565b806102e681610c57565b91505061026c565b508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f89e06f143e493da35e4481e0887f3178e65364ef6a782f5985edd9c6b8431cb18560405161034c9190610ace565b60405180910390a350505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261042e9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526105f6565b505050565b804710156104a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d80600081146104fc576040519150601f19603f3d011682016040523d82523d6000602084013e610501565b606091505b505090508061042e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610499565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105f09085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016103ac565b50505050565b6000610658826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166107029092919063ffffffff16565b80519091501561042e57808060200190518101906106769190610a90565b61042e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610499565b6060610711848460008561071b565b90505b9392505050565b6060824710156107ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610499565b843b610815576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610499565b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161083e9190610ab2565b60006040518083038185875af1925050503d806000811461087b576040519150601f19603f3d011682016040523d82523d6000602084013e610880565b606091505b509150915061089082828661089b565b979650505050505050565b606083156108aa575081610714565b8251156108ba5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104999190610b33565b803573ffffffffffffffffffffffffffffffffffffffff8116811461091257600080fd5b919050565b600082601f83011261092857600080fd5b8135602067ffffffffffffffff82111561094457610944610cee565b610952818360051b01610bad565b80838252828201915082860187848660061b890101111561097257600080fd5b6000805b868110156109bb57604080848c03121561098e578283fd5b610996610b84565b61099f856108ee565b8152848801358882015286529486019490920191600101610976565b509198975050505050505050565b6000806000606084860312156109de57600080fd5b6109e7846108ee565b92506109f5602085016108ee565b9150604084013590509250925092565b60008060408385031215610a1857600080fd5b610a21836108ee565b9150602083013567ffffffffffffffff811115610a3d57600080fd5b610a4985828601610917565b9150509250929050565b600060208284031215610a6557600080fd5b813567ffffffffffffffff811115610a7c57600080fd5b610a8884828501610917565b949350505050565b600060208284031215610aa257600080fd5b8151801515811461071457600080fd5b60008251610ac4818460208701610c2b565b9190910192915050565b602080825282518282018190526000919060409081850190868401855b82811015610b26578151805173ffffffffffffffffffffffffffffffffffffffff168552860151868501529284019290850190600101610aeb565b5091979650505050505050565b6020815260008251806020840152610b52816040850160208701610c2b565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b6040805190810167ffffffffffffffff81118282101715610ba757610ba7610cee565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610bf457610bf4610cee565b604052919050565b60008219821115610c0f57610c0f610c90565b500190565b600082821015610c2657610c26610c90565b500390565b60005b83811015610c46578181015183820152602001610c2e565b838111156105f05750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610c8957610c89610c90565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fdfea26469706673582212202b3bee1ef06628c54bbdc52ed196cc6ed0b4c8445788e9e01914ad24c0c62daa64736f6c63430008060033
[ 38 ]
0xf1f0cc7a4403c943d18d254de78e1d7740f778c6
// 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 // 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; /** * @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 // OpenZeppelin Contracts v4.4.1 (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() { _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); } } // File: @openzeppelin/contracts/utils/Address.sol // 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); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (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 // OpenZeppelin Contracts v4.4.1 (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 // OpenZeppelin Contracts v4.4.1 (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 // OpenZeppelin Contracts (last updated v4.5.0) (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 { _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); _afterTokenTransfer(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); _afterTokenTransfer(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 from incorrect 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); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(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 {} /** * @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. * - `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 tokenId ) internal virtual {} } // File: udn-nft-cheaper-gas.sol //SPDX-License-Identifier: MIT pragma solidity ^0.8.7; contract UrinalsNft is ERC721, Ownable { using Strings for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenSupply; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.033 ether; uint256 public presaleCost = 0.01 ether; uint256 public maxSupply = 4553; uint256 public maxMintAmount = 50; bool public paused = false; mapping(address => bool) public whitelisted; mapping(address => bool) public presaleWallets; constructor( string memory _initBaseURI ) ERC721("UrinalsNFT", "URN") { setBaseURI(_initBaseURI); mint(msg.sender, 31); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = _tokenSupply.current(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { if (whitelisted[msg.sender] != true) { if (presaleWallets[msg.sender] != true) { //general public require(msg.value >= cost * _mintAmount); } else { //presale require(msg.value >= presaleCost * _mintAmount); } } } for (uint256 i = 1; i <= _mintAmount; i++) { _tokenSupply.increment(); _safeMint(_to, supply + i); } } 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(), baseExtension ) ) : ""; } //only owner function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setPresaleCost(uint256 _newCost) public onlyOwner { presaleCost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmount = _newmaxMintAmount; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function whitelistUser(address _user) public onlyOwner { whitelisted[_user] = true; } function removeWhitelistUser(address _user) public onlyOwner { whitelisted[_user] = false; } function addPresaleUser(address _user) public onlyOwner { presaleWallets[_user] = true; } function add100PresaleUsers(address[100] memory _users) public onlyOwner { for (uint256 i = 0; i < 2; i++) { presaleWallets[_users[i]] = true; } } function removePresaleUser(address _user) public onlyOwner { presaleWallets[_user] = false; } function totalSupply() public view returns (uint256) { return _tokenSupply.current(); } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{ value: address(this).balance }(""); require(success); } }
0x6080604052600436106102305760003560e01c80635c975abb1161012e578063b2f3e85e116100ab578063d936547e1161006f578063d936547e146107f7578063da3ef23f14610834578063e985e9c51461085d578063ed931e171461089a578063f2fde38b146108c357610230565b8063b2f3e85e14610712578063b88d4fde1461073b578063c668286214610764578063c87b56dd1461078f578063d5abeb01146107cc57610230565b80637f00c7a6116100f25780637f00c7a6146106415780638da5cb5b1461066a5780638fdcf9421461069557806395d89b41146106be578063a22cb465146106e957610230565b80635c975abb1461055a5780636352211e146105855780636c0360eb146105c257806370a08231146105ed578063715018a61461062a57610230565b80632a23d07d116101bc57806342842e0e1161018057806342842e0e1461048d57806344a0d68a146104b65780634a4c560d146104df578063546857c71461050857806355f804b31461053157610230565b80632a23d07d146103d657806330b2264e1461040157806330cc7ae01461043e5780633ccfd60b1461046757806340c10f191461047157610230565b8063095ea7b311610203578063095ea7b31461030357806313faede61461032c57806318160ddd14610357578063239c70ae1461038257806323b872dd146103ad57610230565b806301ffc9a71461023557806302329a291461027257806306fdde031461029b578063081812fc146102c6575b600080fd5b34801561024157600080fd5b5061025c60048036038101906102579190613026565b6108ec565b6040516102699190613545565b60405180910390f35b34801561027e57600080fd5b5061029960048036038101906102949190612ff9565b6109ce565b005b3480156102a757600080fd5b506102b0610a67565b6040516102bd9190613560565b60405180910390f35b3480156102d257600080fd5b506102ed60048036038101906102e891906130c9565b610af9565b6040516102fa91906134de565b60405180910390f35b34801561030f57600080fd5b5061032a60048036038101906103259190612f8b565b610b7e565b005b34801561033857600080fd5b50610341610c96565b60405161034e9190613782565b60405180910390f35b34801561036357600080fd5b5061036c610c9c565b6040516103799190613782565b60405180910390f35b34801561038e57600080fd5b50610397610cad565b6040516103a49190613782565b60405180910390f35b3480156103b957600080fd5b506103d460048036038101906103cf9190612e75565b610cb3565b005b3480156103e257600080fd5b506103eb610d13565b6040516103f89190613782565b60405180910390f35b34801561040d57600080fd5b5061042860048036038101906104239190612e08565b610d19565b6040516104359190613545565b60405180910390f35b34801561044a57600080fd5b5061046560048036038101906104609190612e08565b610d39565b005b61046f610e10565b005b61048b60048036038101906104869190612f8b565b610f05565b005b34801561049957600080fd5b506104b460048036038101906104af9190612e75565b6110cf565b005b3480156104c257600080fd5b506104dd60048036038101906104d891906130c9565b6110ef565b005b3480156104eb57600080fd5b5061050660048036038101906105019190612e08565b611175565b005b34801561051457600080fd5b5061052f600480360381019061052a9190612fcb565b61124c565b005b34801561053d57600080fd5b5061055860048036038101906105539190613080565b61135a565b005b34801561056657600080fd5b5061056f6113f0565b60405161057c9190613545565b60405180910390f35b34801561059157600080fd5b506105ac60048036038101906105a791906130c9565b611403565b6040516105b991906134de565b60405180910390f35b3480156105ce57600080fd5b506105d76114b5565b6040516105e49190613560565b60405180910390f35b3480156105f957600080fd5b50610614600480360381019061060f9190612e08565b611543565b6040516106219190613782565b60405180910390f35b34801561063657600080fd5b5061063f6115fb565b005b34801561064d57600080fd5b50610668600480360381019061066391906130c9565b611683565b005b34801561067657600080fd5b5061067f611709565b60405161068c91906134de565b60405180910390f35b3480156106a157600080fd5b506106bc60048036038101906106b791906130c9565b611733565b005b3480156106ca57600080fd5b506106d36117b9565b6040516106e09190613560565b60405180910390f35b3480156106f557600080fd5b50610710600480360381019061070b9190612f4b565b61184b565b005b34801561071e57600080fd5b5061073960048036038101906107349190612e08565b611861565b005b34801561074757600080fd5b50610762600480360381019061075d9190612ec8565b611938565b005b34801561077057600080fd5b5061077961199a565b6040516107869190613560565b60405180910390f35b34801561079b57600080fd5b506107b660048036038101906107b191906130c9565b611a28565b6040516107c39190613560565b60405180910390f35b3480156107d857600080fd5b506107e1611ad2565b6040516107ee9190613782565b60405180910390f35b34801561080357600080fd5b5061081e60048036038101906108199190612e08565b611ad8565b60405161082b9190613545565b60405180910390f35b34801561084057600080fd5b5061085b60048036038101906108569190613080565b611af8565b005b34801561086957600080fd5b50610884600480360381019061087f9190612e35565b611b8e565b6040516108919190613545565b60405180910390f35b3480156108a657600080fd5b506108c160048036038101906108bc9190612e08565b611c22565b005b3480156108cf57600080fd5b506108ea60048036038101906108e59190612e08565b611cf9565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109b757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806109c757506109c682611e38565b5b9050919050565b6109d6611ea2565b73ffffffffffffffffffffffffffffffffffffffff166109f4611709565b73ffffffffffffffffffffffffffffffffffffffff1614610a4a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4190613702565b60405180910390fd5b80600e60006101000a81548160ff02191690831515021790555050565b606060008054610a7690613a78565b80601f0160208091040260200160405190810160405280929190818152602001828054610aa290613a78565b8015610aef5780601f10610ac457610100808354040283529160200191610aef565b820191906000526020600020905b815481529060010190602001808311610ad257829003601f168201915b5050505050905090565b6000610b0482611eaa565b610b43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3a906136e2565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b8982611403565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bfa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf190613742565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610c19611ea2565b73ffffffffffffffffffffffffffffffffffffffff161480610c485750610c4781610c42611ea2565b611b8e565b5b610c87576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7e90613662565b60405180910390fd5b610c918383611f16565b505050565b600a5481565b6000610ca86007611df1565b905090565b600d5481565b610cc4610cbe611ea2565b82611fcf565b610d03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfa90613762565b60405180910390fd5b610d0e8383836120ad565b505050565b600b5481565b60106020528060005260406000206000915054906101000a900460ff1681565b610d41611ea2565b73ffffffffffffffffffffffffffffffffffffffff16610d5f611709565b73ffffffffffffffffffffffffffffffffffffffff1614610db5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dac90613702565b60405180910390fd5b6000600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610e18611ea2565b73ffffffffffffffffffffffffffffffffffffffff16610e36611709565b73ffffffffffffffffffffffffffffffffffffffff1614610e8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8390613702565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff1647604051610eb2906134c9565b60006040518083038185875af1925050503d8060008114610eef576040519150601f19603f3d011682016040523d82523d6000602084013e610ef4565b606091505b5050905080610f0257600080fd5b50565b6000610f116007611df1565b9050600e60009054906101000a900460ff1615610f2d57600080fd5b60008211610f3a57600080fd5b600d54821115610f4957600080fd5b600c548282610f5891906138ad565b1115610f6357600080fd5b610f6b611709565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146110895760011515600f60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515146110885760011515601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151461106c5781600a5461105b9190613934565b34101561106757600080fd5b611087565b81600b5461107a9190613934565b34101561108657600080fd5b5b5b5b6000600190505b8281116110c9576110a16007611dff565b6110b68482846110b191906138ad565b612314565b80806110c190613adb565b915050611090565b50505050565b6110ea83838360405180602001604052806000815250611938565b505050565b6110f7611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611115611709565b73ffffffffffffffffffffffffffffffffffffffff161461116b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161116290613702565b60405180910390fd5b80600a8190555050565b61117d611ea2565b73ffffffffffffffffffffffffffffffffffffffff1661119b611709565b73ffffffffffffffffffffffffffffffffffffffff16146111f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111e890613702565b60405180910390fd5b6001600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b611254611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611272611709565b73ffffffffffffffffffffffffffffffffffffffff16146112c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112bf90613702565b60405180910390fd5b60005b6002811015611356576001601060008484606481106112ed576112ec613be2565b5b602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061134e90613adb565b9150506112cb565b5050565b611362611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611380611709565b73ffffffffffffffffffffffffffffffffffffffff16146113d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113cd90613702565b60405180910390fd5b80600890805190602001906113ec929190612b8a565b5050565b600e60009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156114ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114a3906136a2565b60405180910390fd5b80915050919050565b600880546114c290613a78565b80601f01602080910402602001604051908101604052809291908181526020018280546114ee90613a78565b801561153b5780601f106115105761010080835404028352916020019161153b565b820191906000526020600020905b81548152906001019060200180831161151e57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ab90613682565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611603611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611621611709565b73ffffffffffffffffffffffffffffffffffffffff1614611677576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161166e90613702565b60405180910390fd5b6116816000612332565b565b61168b611ea2565b73ffffffffffffffffffffffffffffffffffffffff166116a9611709565b73ffffffffffffffffffffffffffffffffffffffff16146116ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f690613702565b60405180910390fd5b80600d8190555050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61173b611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611759611709565b73ffffffffffffffffffffffffffffffffffffffff16146117af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117a690613702565b60405180910390fd5b80600b8190555050565b6060600180546117c890613a78565b80601f01602080910402602001604051908101604052809291908181526020018280546117f490613a78565b80156118415780601f1061181657610100808354040283529160200191611841565b820191906000526020600020905b81548152906001019060200180831161182457829003601f168201915b5050505050905090565b61185d611856611ea2565b83836123f8565b5050565b611869611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611887611709565b73ffffffffffffffffffffffffffffffffffffffff16146118dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d490613702565b60405180910390fd5b6001601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b611949611943611ea2565b83611fcf565b611988576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161197f90613762565b60405180910390fd5b61199484848484612565565b50505050565b600980546119a790613a78565b80601f01602080910402602001604051908101604052809291908181526020018280546119d390613a78565b8015611a205780601f106119f557610100808354040283529160200191611a20565b820191906000526020600020905b815481529060010190602001808311611a0357829003601f168201915b505050505081565b6060611a3382611eaa565b611a72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6990613722565b60405180910390fd5b6000611a7c6125c1565b90506000815111611a9c5760405180602001604052806000815250611aca565b80611aa684612653565b6009604051602001611aba93929190613498565b6040516020818303038152906040525b915050919050565b600c5481565b600f6020528060005260406000206000915054906101000a900460ff1681565b611b00611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611b1e611709565b73ffffffffffffffffffffffffffffffffffffffff1614611b74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6b90613702565b60405180910390fd5b8060099080519060200190611b8a929190612b8a565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611c2a611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611c48611709565b73ffffffffffffffffffffffffffffffffffffffff1614611c9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9590613702565b60405180910390fd5b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b611d01611ea2565b73ffffffffffffffffffffffffffffffffffffffff16611d1f611709565b73ffffffffffffffffffffffffffffffffffffffff1614611d75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d6c90613702565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611de5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ddc906135a2565b60405180910390fd5b611dee81612332565b50565b600081600001549050919050565b6001816000016000828254019250508190555050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611f8983611403565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611fda82611eaa565b612019576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161201090613642565b60405180910390fd5b600061202483611403565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061209357508373ffffffffffffffffffffffffffffffffffffffff1661207b84610af9565b73ffffffffffffffffffffffffffffffffffffffff16145b806120a457506120a38185611b8e565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166120cd82611403565b73ffffffffffffffffffffffffffffffffffffffff1614612123576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211a906135c2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612193576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161218a90613602565b60405180910390fd5b61219e8383836127b4565b6121a9600082611f16565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121f9919061398e565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461225091906138ad565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461230f8383836127b9565b505050565b61232e8282604051806020016040528060008152506127be565b5050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612467576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161245e90613622565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516125589190613545565b60405180910390a3505050565b6125708484846120ad565b61257c84848484612819565b6125bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125b290613582565b60405180910390fd5b50505050565b6060600880546125d090613a78565b80601f01602080910402602001604051908101604052809291908181526020018280546125fc90613a78565b80156126495780601f1061261e57610100808354040283529160200191612649565b820191906000526020600020905b81548152906001019060200180831161262c57829003601f168201915b5050505050905090565b6060600082141561269b576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506127af565b600082905060005b600082146126cd5780806126b690613adb565b915050600a826126c69190613903565b91506126a3565b60008167ffffffffffffffff8111156126e9576126e8613c11565b5b6040519080825280601f01601f19166020018201604052801561271b5781602001600182028036833780820191505090505b5090505b600085146127a857600182612734919061398e565b9150600a856127439190613b24565b603061274f91906138ad565b60f81b81838151811061276557612764613be2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856127a19190613903565b945061271f565b8093505050505b919050565b505050565b505050565b6127c883836129b0565b6127d56000848484612819565b612814576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161280b90613582565b60405180910390fd5b505050565b600061283a8473ffffffffffffffffffffffffffffffffffffffff16611e15565b156129a3578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612863611ea2565b8786866040518563ffffffff1660e01b815260040161288594939291906134f9565b602060405180830381600087803b15801561289f57600080fd5b505af19250505080156128d057506040513d601f19601f820116820180604052508101906128cd9190613053565b60015b612953573d8060008114612900576040519150601f19603f3d011682016040523d82523d6000602084013e612905565b606091505b5060008151141561294b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294290613582565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506129a8565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a17906136c2565b60405180910390fd5b612a2981611eaa565b15612a69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a60906135e2565b60405180910390fd5b612a75600083836127b4565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612ac591906138ad565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4612b86600083836127b9565b5050565b828054612b9690613a78565b90600052602060002090601f016020900481019282612bb85760008555612bff565b82601f10612bd157805160ff1916838001178555612bff565b82800160010185558215612bff579182015b82811115612bfe578251825591602001919060010190612be3565b5b509050612c0c9190612c10565b5090565b5b80821115612c29576000816000905550600101612c11565b5090565b6000612c40612c3b846137c2565b61379d565b90508082856020860282011115612c5a57612c59613c45565b5b60005b85811015612c8a5781612c708882612d18565b845260208401935060208301925050600181019050612c5d565b5050509392505050565b6000612ca7612ca2846137e8565b61379d565b905082815260208101848484011115612cc357612cc2613c4a565b5b612cce848285613a36565b509392505050565b6000612ce9612ce484613819565b61379d565b905082815260208101848484011115612d0557612d04613c4a565b5b612d10848285613a36565b509392505050565b600081359050612d27816140c5565b92915050565b600082601f830112612d4257612d41613c40565b5b6064612d4f848285612c2d565b91505092915050565b600081359050612d67816140dc565b92915050565b600081359050612d7c816140f3565b92915050565b600081519050612d91816140f3565b92915050565b600082601f830112612dac57612dab613c40565b5b8135612dbc848260208601612c94565b91505092915050565b600082601f830112612dda57612dd9613c40565b5b8135612dea848260208601612cd6565b91505092915050565b600081359050612e028161410a565b92915050565b600060208284031215612e1e57612e1d613c54565b5b6000612e2c84828501612d18565b91505092915050565b60008060408385031215612e4c57612e4b613c54565b5b6000612e5a85828601612d18565b9250506020612e6b85828601612d18565b9150509250929050565b600080600060608486031215612e8e57612e8d613c54565b5b6000612e9c86828701612d18565b9350506020612ead86828701612d18565b9250506040612ebe86828701612df3565b9150509250925092565b60008060008060808587031215612ee257612ee1613c54565b5b6000612ef087828801612d18565b9450506020612f0187828801612d18565b9350506040612f1287828801612df3565b925050606085013567ffffffffffffffff811115612f3357612f32613c4f565b5b612f3f87828801612d97565b91505092959194509250565b60008060408385031215612f6257612f61613c54565b5b6000612f7085828601612d18565b9250506020612f8185828601612d58565b9150509250929050565b60008060408385031215612fa257612fa1613c54565b5b6000612fb085828601612d18565b9250506020612fc185828601612df3565b9150509250929050565b6000610c808284031215612fe257612fe1613c54565b5b6000612ff084828501612d2d565b91505092915050565b60006020828403121561300f5761300e613c54565b5b600061301d84828501612d58565b91505092915050565b60006020828403121561303c5761303b613c54565b5b600061304a84828501612d6d565b91505092915050565b60006020828403121561306957613068613c54565b5b600061307784828501612d82565b91505092915050565b60006020828403121561309657613095613c54565b5b600082013567ffffffffffffffff8111156130b4576130b3613c4f565b5b6130c084828501612dc5565b91505092915050565b6000602082840312156130df576130de613c54565b5b60006130ed84828501612df3565b91505092915050565b6130ff816139c2565b82525050565b61310e816139d4565b82525050565b600061311f8261385f565b6131298185613875565b9350613139818560208601613a45565b61314281613c59565b840191505092915050565b60006131588261386a565b6131628185613891565b9350613172818560208601613a45565b61317b81613c59565b840191505092915050565b60006131918261386a565b61319b81856138a2565b93506131ab818560208601613a45565b80840191505092915050565b600081546131c481613a78565b6131ce81866138a2565b945060018216600081146131e957600181146131fa5761322d565b60ff1983168652818601935061322d565b6132038561384a565b60005b8381101561322557815481890152600182019150602081019050613206565b838801955050505b50505092915050565b6000613243603283613891565b915061324e82613c6a565b604082019050919050565b6000613266602683613891565b915061327182613cb9565b604082019050919050565b6000613289602583613891565b915061329482613d08565b604082019050919050565b60006132ac601c83613891565b91506132b782613d57565b602082019050919050565b60006132cf602483613891565b91506132da82613d80565b604082019050919050565b60006132f2601983613891565b91506132fd82613dcf565b602082019050919050565b6000613315602c83613891565b915061332082613df8565b604082019050919050565b6000613338603883613891565b915061334382613e47565b604082019050919050565b600061335b602a83613891565b915061336682613e96565b604082019050919050565b600061337e602983613891565b915061338982613ee5565b604082019050919050565b60006133a1602083613891565b91506133ac82613f34565b602082019050919050565b60006133c4602c83613891565b91506133cf82613f5d565b604082019050919050565b60006133e7602083613891565b91506133f282613fac565b602082019050919050565b600061340a602f83613891565b915061341582613fd5565b604082019050919050565b600061342d602183613891565b915061343882614024565b604082019050919050565b6000613450600083613886565b915061345b82614073565b600082019050919050565b6000613473603183613891565b915061347e82614076565b604082019050919050565b61349281613a2c565b82525050565b60006134a48286613186565b91506134b08285613186565b91506134bc82846131b7565b9150819050949350505050565b60006134d482613443565b9150819050919050565b60006020820190506134f360008301846130f6565b92915050565b600060808201905061350e60008301876130f6565b61351b60208301866130f6565b6135286040830185613489565b818103606083015261353a8184613114565b905095945050505050565b600060208201905061355a6000830184613105565b92915050565b6000602082019050818103600083015261357a818461314d565b905092915050565b6000602082019050818103600083015261359b81613236565b9050919050565b600060208201905081810360008301526135bb81613259565b9050919050565b600060208201905081810360008301526135db8161327c565b9050919050565b600060208201905081810360008301526135fb8161329f565b9050919050565b6000602082019050818103600083015261361b816132c2565b9050919050565b6000602082019050818103600083015261363b816132e5565b9050919050565b6000602082019050818103600083015261365b81613308565b9050919050565b6000602082019050818103600083015261367b8161332b565b9050919050565b6000602082019050818103600083015261369b8161334e565b9050919050565b600060208201905081810360008301526136bb81613371565b9050919050565b600060208201905081810360008301526136db81613394565b9050919050565b600060208201905081810360008301526136fb816133b7565b9050919050565b6000602082019050818103600083015261371b816133da565b9050919050565b6000602082019050818103600083015261373b816133fd565b9050919050565b6000602082019050818103600083015261375b81613420565b9050919050565b6000602082019050818103600083015261377b81613466565b9050919050565b60006020820190506137976000830184613489565b92915050565b60006137a76137b8565b90506137b38282613aaa565b919050565b6000604051905090565b600067ffffffffffffffff8211156137dd576137dc613c11565b5b602082029050919050565b600067ffffffffffffffff82111561380357613802613c11565b5b61380c82613c59565b9050602081019050919050565b600067ffffffffffffffff82111561383457613833613c11565b5b61383d82613c59565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006138b882613a2c565b91506138c383613a2c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156138f8576138f7613b55565b5b828201905092915050565b600061390e82613a2c565b915061391983613a2c565b92508261392957613928613b84565b5b828204905092915050565b600061393f82613a2c565b915061394a83613a2c565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561398357613982613b55565b5b828202905092915050565b600061399982613a2c565b91506139a483613a2c565b9250828210156139b7576139b6613b55565b5b828203905092915050565b60006139cd82613a0c565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613a63578082015181840152602081019050613a48565b83811115613a72576000848401525b50505050565b60006002820490506001821680613a9057607f821691505b60208210811415613aa457613aa3613bb3565b5b50919050565b613ab382613c59565b810181811067ffffffffffffffff82111715613ad257613ad1613c11565b5b80604052505050565b6000613ae682613a2c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613b1957613b18613b55565b5b600182019050919050565b6000613b2f82613a2c565b9150613b3a83613a2c565b925082613b4a57613b49613b84565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b6140ce816139c2565b81146140d957600080fd5b50565b6140e5816139d4565b81146140f057600080fd5b50565b6140fc816139e0565b811461410757600080fd5b50565b61411381613a2c565b811461411e57600080fd5b5056fea2646970667358221220d753a7c3b2a2aea20c087cf7be0c541837617fb24b470bfc1a96e081455ebe3364736f6c63430008070033
[ 5 ]
0xf1f14a0fff6aabd137d937bcb149379ab2607eda
pragma solidity 0.5.10; interface IERC20 { function totalSupply() external view returns (uint); function balanceOf(address account) external view returns (uint); function transfer(address recipient, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint amount) external returns (bool); function transferFrom(address sender, address recipient, uint amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint value); event Approval(address indexed owner, address indexed spender, uint value); } contract SmartYields { using SafeMath for uint256; uint256[] public REFERRAL_PERCENTS = [50, 40, 30]; uint256[] public BONUS_PERCENTS = [100, 150, 200, 250, 300]; uint256 constant public TOTAL_REF = 120; uint256 constant public PROJECT_FEE = 100; uint256 constant public HOLD_BONUS = 10; uint256 constant public PERCENTS_DIVIDER = 1000; uint256 constant public TIME_STEP = 1 days; uint256 public totalInvested; uint256 public totalBonus; uint256 public INVEST_MIN_AMOUNT = 0.013 ether; uint256 public BONUS_MIN_AMOUNT = 0.013 ether; bool public bonusStatus = false; struct Plan { uint256 time; uint256 percent; } Plan[] internal plans; struct Deposit { uint8 plan; uint256 amount; uint256 start; } struct User { Deposit[] deposits; uint256 checkpoint; address referrer; uint256[3] levels; uint256 bonus; uint256 totalBonus; uint256 withdrawn; } mapping (address => User) internal users; mapping (address => mapping(uint256 => uint256)) internal userDepositBonus; uint256 public startDate; address payable public ceoWallet; event Newbie(address user); event NewDeposit(address indexed user, uint8 plan, uint256 amount, uint256 time); event Withdrawn(address indexed user, uint256 amount); event RefBonus(address indexed referrer, address indexed referral, uint256 indexed level, uint256 amount); event FeePayed(address indexed user, uint256 totalAmount); constructor(address payable ceoAddr, uint256 start) public { require(!isContract(ceoAddr) ); ceoWallet = ceoAddr; if(start>0){ startDate = start; } else{ startDate = block.timestamp; } plans.push(Plan(40, 50)); // 200% plans.push(Plan(60, 40)); // 240% plans.push(Plan(100, 30)); // 300% } function invest(address referrer, uint8 plan) public payable { require(block.timestamp > startDate, "contract does not launch yet"); require(msg.value >= INVEST_MIN_AMOUNT,"error min"); require(plan < 4, "Invalid plan"); uint256 pFee = msg.value.mul(PROJECT_FEE).div(PERCENTS_DIVIDER); ceoWallet.transfer(pFee); emit FeePayed(msg.sender, pFee); User storage user = users[msg.sender]; if (user.referrer == address(0)) { if (users[referrer].deposits.length > 0 && referrer != msg.sender) { user.referrer = referrer; } else{ user.referrer = ceoWallet; } address upline = user.referrer; for (uint256 i = 0; i < 3; i++) { if (upline != address(0)) { users[upline].levels[i] = users[upline].levels[i].add(1); upline = users[upline].referrer; } else break; } } if (user.referrer != address(0)) { address upline = user.referrer; for (uint256 i = 0; i < 3; i++) { if (upline != address(0)) { uint256 amount = msg.value.mul(REFERRAL_PERCENTS[i]).div(PERCENTS_DIVIDER); users[upline].bonus = users[upline].bonus.add(amount); users[upline].totalBonus = users[upline].totalBonus.add(amount); emit RefBonus(upline, msg.sender, i, amount); upline = users[upline].referrer; } else break; } } if (user.deposits.length == 0) { user.checkpoint = block.timestamp; emit Newbie(msg.sender); } user.deposits.push(Deposit(plan, msg.value, block.timestamp)); totalInvested = totalInvested.add(msg.value); emit NewDeposit(msg.sender, plan, msg.value, block.timestamp); //bonus if(bonusStatus){ if(user.deposits.length >= 2 && user.deposits.length <=5){ uint256 firstAmount = user.deposits[0].amount; if(firstAmount >= BONUS_MIN_AMOUNT ){ uint256 preAmount = user.deposits[user.deposits.length -2].amount; if(user.deposits.length == 2){ if(preAmount == msg.value){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[0]; } else if( msg.value > preAmount ){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[1]; } } else if(user.deposits.length == 3){ if(preAmount == msg.value){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[0]; } else if( msg.value > preAmount ){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[2]; } } else if(user.deposits.length == 4){ if(preAmount == msg.value){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[0]; } else if( msg.value > preAmount){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[3]; } } else if(user.deposits.length == 5){ if(preAmount == msg.value){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[0]; } else if( msg.value > preAmount){ userDepositBonus[msg.sender][user.deposits.length-1] = BONUS_PERCENTS[4]; } } totalBonus = totalBonus.add(userDepositBonus[msg.sender][user.deposits.length-1].mul(msg.value).div(PERCENTS_DIVIDER)); } } } } function withdraw() public { User storage user = users[msg.sender]; uint256 totalAmount = getUserDividends(msg.sender); uint256 referralBonus = getUserReferralBonus(msg.sender); if (referralBonus > 0) { user.bonus = 0; totalAmount = totalAmount.add(referralBonus); } require(totalAmount > 0, "User has no dividends"); uint256 contractBalance = address(this).balance; if (contractBalance < totalAmount) { user.bonus = totalAmount.sub(contractBalance); totalAmount = contractBalance; } user.checkpoint = block.timestamp; user.withdrawn = user.withdrawn.add(totalAmount); msg.sender.transfer(totalAmount); emit Withdrawn(msg.sender, totalAmount); } function getContractBalance() public view returns (uint256) { return address(this).balance; } function getPlanInfo(uint8 plan) public view returns(uint256 time, uint256 percent) { time = plans[plan].time; percent = plans[plan].percent; } function getUserDividends(address userAddress) public view returns (uint256) { User storage user = users[userAddress]; uint256 totalAmount; for (uint256 i = 0; i < user.deposits.length; i++) { uint256 finish = user.deposits[i].start.add(plans[user.deposits[i].plan].time.mul(TIME_STEP)); if (user.checkpoint < finish) { uint256 share = user.deposits[i].amount.mul(plans[user.deposits[i].plan].percent).div(PERCENTS_DIVIDER); uint256 from = user.deposits[i].start > user.checkpoint ? user.deposits[i].start : user.checkpoint; uint256 to = finish < block.timestamp ? finish : block.timestamp; if (from < to) { totalAmount = totalAmount.add(share.mul(to.sub(from)).div(TIME_STEP)); uint256 holdDays = (to.sub(from)).div(TIME_STEP); if(holdDays > 0){ totalAmount = totalAmount.add(user.deposits[i].amount.mul(HOLD_BONUS.mul(holdDays)).div(PERCENTS_DIVIDER)); } } //end of plan if(finish <= block.timestamp){ if(userDepositBonus[msg.sender][i] > 0){ totalAmount = totalAmount.add(user.deposits[i].amount.mul(userDepositBonus[msg.sender][i]).div(PERCENTS_DIVIDER)); } } } } return totalAmount; } function getUserHoldBonus(address userAddress) public view returns (uint256) { User storage user = users[userAddress]; if(user.checkpoint > 0){ uint256 holdBonus = 0; if (user.checkpoint < block.timestamp) { uint256 holdDays = (block.timestamp.sub(user.checkpoint)).div(TIME_STEP); if(holdDays > 0){ holdBonus = holdDays.mul(HOLD_BONUS); } } return holdBonus; } else{ return 0; } } function getUserTotalWithdrawn(address userAddress) public view returns (uint256) { return users[userAddress].withdrawn; } function getUserCheckpoint(address userAddress) public view returns(uint256) { return users[userAddress].checkpoint; } function getUserReferrer(address userAddress) public view returns(address) { return users[userAddress].referrer; } function getUserDownlineCount(address userAddress) public view returns(uint256[3] memory referrals) { return (users[userAddress].levels); } function getUserTotalReferrals(address userAddress) public view returns(uint256) { return users[userAddress].levels[0]+users[userAddress].levels[1]+users[userAddress].levels[2]; } function getUserReferralBonus(address userAddress) public view returns(uint256) { return users[userAddress].bonus; } function getUserReferralTotalBonus(address userAddress) public view returns(uint256) { return users[userAddress].totalBonus; } function getUserReferralWithdrawn(address userAddress) public view returns(uint256) { return users[userAddress].totalBonus.sub(users[userAddress].bonus); } function getUserAvailable(address userAddress) public view returns(uint256) { return getUserReferralBonus(userAddress).add(getUserDividends(userAddress)); } function getUserAmountOfDeposits(address userAddress) public view returns(uint256) { return users[userAddress].deposits.length; } function getUserTotalDeposits(address userAddress) public view returns(uint256 amount) { for (uint256 i = 0; i < users[userAddress].deposits.length; i++) { amount = amount.add(users[userAddress].deposits[i].amount); } } function getUserDepositInfo(address userAddress, uint256 index) public view returns(uint8 plan, uint256 percent, uint256 amount, uint256 start, uint256 finish) { User storage user = users[userAddress]; plan = user.deposits[index].plan; percent = plans[plan].percent; amount = user.deposits[index].amount; start = user.deposits[index].start; finish = user.deposits[index].start.add(plans[user.deposits[index].plan].time.mul(TIME_STEP)); } function getSiteInfo() public view returns(uint256 _totalInvested, uint256 _totalRef, uint256 _totalBonus) { return(totalInvested, totalInvested.mul(TOTAL_REF).div(PERCENTS_DIVIDER),totalBonus); } function getUserInfo(address userAddress) public view returns(uint256 totalDeposit, uint256 totalWithdrawn, uint256 totalReferrals) { return(getUserTotalDeposits(userAddress), getUserTotalWithdrawn(userAddress), getUserTotalReferrals(userAddress)); } function isContract(address addr) internal view returns (bool) { uint size; assembly { size := extcodesize(addr) } return size > 0; } //config function setMinMax(uint256 minAmount, uint256 minBonus) external { require(msg.sender == ceoWallet, "only owner"); INVEST_MIN_AMOUNT = minAmount; BONUS_MIN_AMOUNT = minBonus; } function setBonusStatus(bool status) external { require(msg.sender == ceoWallet, "only owner"); bonusStatus = status; } function withdrawTokens(address tokenAddr, address to) external { require(msg.sender == ceoWallet, "only owner"); IERC20 token = IERC20(tokenAddr); token.transfer(to,token.balanceOf(address(this))); } function Adminwithdraw() external { require(msg.sender == ceoWallet, "only owner"); msg.sender.transfer(getMainnetBalance()); } function getMainnetBalance() public view returns (uint256) { return address(this).balance; } } 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) { require(b <= a, "SafeMath: subtraction overflow"); 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) { require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; return c; } }
0x6080604052600436106102305760003560e01c8063600d20ce1161012e578063aecaa634116100ab578063d7ffca911161006f578063d7ffca91146107d0578063e262113e14610803578063e85abe0914610818578063fb4cb32b1461084b578063fbfcb2791461087e57610230565b8063aecaa634146106ce578063b668ac4b14610714578063c0806b0314610729578063c43a180814610791578063cd23b441146107bb57610230565b8063a0aafaa7116100f2578063a0aafaa7146105ef578063a522ad251461061b578063a681f95014610656578063a8aeb6c214610686578063a8dd07dc146106b957610230565b8063600d20ce1461052c5780636386c1c7146105565780636bb18556146105895780636f9fb98a146103e65780637e3abeea146105bc57610230565b8063388655fb116101bc5780634a64e867116101805780634a64e8671461046d5780634bc4e085146104a05780634ce87053146104b55780635216aeec146104e8578063581c5ae6146104fd57610230565b8063388655fb146103e6578063389cabee146103fb5780633ccfd60b1461041057806348c372031461042557806348d44bd11461045857610230565b8063153ab9df11610203578063153ab9df1461030f57806329420b74146103425780632ed394211461036b57806332bc298c1461038257806336144c9a1461039757610230565b806301c234a81461023557806303a93c0c1461025c578063040a772e146102c75780630b97bc86146102fa575b600080fd5b34801561024157600080fd5b5061024a6108b1565b60408051918252519081900360200190f35b34801561026857600080fd5b5061028f6004803603602081101561027f57600080fd5b50356001600160a01b03166108b7565b6040518082606080838360005b838110156102b457818101518382015260200161029c565b5050505090500191505060405180910390f35b3480156102d357600080fd5b5061024a600480360360208110156102ea57600080fd5b50356001600160a01b031661090e565b34801561030657600080fd5b5061024a610bdc565b34801561031b57600080fd5b5061024a6004803603602081101561033257600080fd5b50356001600160a01b0316610be2565b34801561034e57600080fd5b50610357610c0b565b604080519115158252519081900360200190f35b34801561037757600080fd5b50610380610c14565b005b34801561038e57600080fd5b5061024a610c97565b3480156103a357600080fd5b506103ca600480360360208110156103ba57600080fd5b50356001600160a01b0316610c9e565b604080516001600160a01b039092168252519081900360200190f35b3480156103f257600080fd5b5061024a610cbf565b34801561040757600080fd5b506103ca610cc4565b34801561041c57600080fd5b50610380610cd3565b34801561043157600080fd5b5061024a6004803603602081101561044857600080fd5b50356001600160a01b0316610e15565b34801561046457600080fd5b5061024a610e33565b34801561047957600080fd5b5061024a6004803603602081101561049057600080fd5b50356001600160a01b0316610e38565b3480156104ac57600080fd5b5061024a610ec0565b3480156104c157600080fd5b506104ca610ec5565b60408051938452602084019290925282820152519081900360600190f35b3480156104f457600080fd5b5061024a610ef4565b6103806004803603604081101561051357600080fd5b5080356001600160a01b0316906020013560ff16610efa565b34801561053857600080fd5b5061024a6004803603602081101561054f57600080fd5b5035611655565b34801561056257600080fd5b506104ca6004803603602081101561057957600080fd5b50356001600160a01b0316611673565b34801561059557600080fd5b5061024a600480360360208110156105ac57600080fd5b50356001600160a01b03166116a0565b3480156105c857600080fd5b5061024a600480360360208110156105df57600080fd5b50356001600160a01b03166116d2565b3480156105fb57600080fd5b506103806004803603602081101561061257600080fd5b5035151561174a565b34801561062757600080fd5b506103806004803603604081101561063e57600080fd5b506001600160a01b03813581169160200135166117a9565b34801561066257600080fd5b506103806004803603604081101561067957600080fd5b50803590602001356118ec565b34801561069257600080fd5b5061024a600480360360208110156106a957600080fd5b50356001600160a01b0316611943565b3480156106c557600080fd5b5061024a61195e565b3480156106da57600080fd5b506106fb600480360360208110156106f157600080fd5b503560ff16611964565b6040805192835260208301919091528051918290030190f35b34801561072057600080fd5b5061024a6119b4565b34801561073557600080fd5b506107626004803603604081101561074c57600080fd5b506001600160a01b0381351690602001356119b9565b6040805160ff909616865260208601949094528484019290925260608401526080830152519081900360a00190f35b34801561079d57600080fd5b5061024a600480360360208110156107b457600080fd5b5035611a9f565b3480156107c757600080fd5b5061024a611aac565b3480156107dc57600080fd5b5061024a600480360360208110156107f357600080fd5b50356001600160a01b0316611ab2565b34801561080f57600080fd5b5061024a611ad0565b34801561082457600080fd5b5061024a6004803603602081101561083b57600080fd5b50356001600160a01b0316611ad6565b34801561085757600080fd5b5061024a6004803603602081101561086e57600080fd5b50356001600160a01b0316611af4565b34801561088a57600080fd5b5061024a600480360360208110156108a157600080fd5b50356001600160a01b0316611b13565b6103e881565b6108bf611cc2565b6001600160a01b0382166000908152600860205260409081902081516060810192839052916003918201919082845b8154815260200190600101908083116108ee57505050505090505b919050565b6001600160a01b038116600090815260086020526040812081805b8254811015610bd45760006109bc61098d62015180600787600001868154811061094f57fe5b6000918252602090912060039091020154815460ff90911690811061097057fe5b60009182526020909120600290910201549063ffffffff611b4116565b85600001848154811061099c57fe5b906000526020600020906003020160020154611ba190919063ffffffff16565b90508084600101541015610bcb576000610a546103e8610a4860078860000187815481106109e657fe5b6000918252602090912060039091020154815460ff909116908110610a0757fe5b906000526020600020906002020160010154886000018781548110610a2857fe5b906000526020600020906003020160010154611b4190919063ffffffff16565b9063ffffffff611bfb16565b905060008560010154866000018581548110610a6c57fe5b90600052602060002090600302016002015411610a8d578560010154610aaf565b856000018481548110610a9c57fe5b9060005260206000209060030201600201545b90506000428410610ac05742610ac2565b835b905080821015610b6457610b03610af662015180610a48610ae9858763ffffffff611c6516565b879063ffffffff611b4116565b879063ffffffff611ba116565b95506000610b1e62015180610a48848663ffffffff611c6516565b90508015610b6257610b5f610b526103e8610a48610b43600a8663ffffffff611b4116565b8c6000018b81548110610a2857fe5b889063ffffffff611ba116565b96505b505b428411610bc75733600090815260096020908152604080832088845290915290205415610bc7573360009081526009602090815260408083208884529091529020548754610bc491610af6916103e891610a48918c908b908110610a2857fe5b95505b5050505b50600101610929565b509392505050565b600a5481565b6000610c05610bf08361090e565b610bf984611ad6565b9063ffffffff611ba116565b92915050565b60065460ff1681565b600b546001600160a01b03163314610c60576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b336108fc610c6c610cbf565b6040518115909202916000818181858888f19350505050158015610c94573d6000803e3d6000fd5b50565b6201518081565b6001600160a01b039081166000908152600860205260409020600201541690565b303190565b600b546001600160a01b031681565b33600081815260086020526040812091610cec9061090e565b90506000610cf933611ad6565b90508015610d1b5760006006840155610d18828263ffffffff611ba116565b91505b60008211610d68576040805162461bcd60e51b81526020600482015260156024820152745573657220686173206e6f206469766964656e647360581b604482015290519081900360640190fd5b303182811015610d8b57610d82838263ffffffff611c6516565b60068501559150815b4260018501556008840154610da6908463ffffffff611ba116565b6008850155604051339084156108fc029085906000818181858888f19350505050158015610dd8573d6000803e3d6000fd5b5060408051848152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a250505050565b6001600160a01b031660009081526008602052604090206007015490565b606481565b6001600160a01b0381166000908152600860205260408120600181015415610eb0576001810154600090421115610ea7576000610e8962015180610a48856001015442611c6590919063ffffffff16565b90508015610ea557610ea281600a63ffffffff611b4116565b91505b505b91506109099050565b6000915050610909565b50919050565b607881565b60025460009081908190610ee66103e8610a4883607863ffffffff611b4116565b600354925092509250909192565b60025481565b600a544211610f50576040805162461bcd60e51b815260206004820152601c60248201527f636f6e747261637420646f6573206e6f74206c61756e63682079657400000000604482015290519081900360640190fd5b600454341015610f93576040805162461bcd60e51b815260206004820152600960248201526832b93937b91036b4b760b91b604482015290519081900360640190fd5b60048160ff1610610fda576040805162461bcd60e51b815260206004820152600c60248201526b24b73b30b634b210383630b760a11b604482015290519081900360640190fd5b6000610ff36103e8610a4834606463ffffffff611b4116565b600b546040519192506001600160a01b03169082156108fc029083906000818181858888f1935050505015801561102e573d6000803e3d6000fd5b5060408051828152905133917f2899dc8c12def1caa9accb64257cf2fd9f960f21bb27a560a757eae3c2ec43c1919081900360200190a233600090815260086020526040902060028101546001600160a01b03166111d1576001600160a01b038416600090815260086020526040902054158015906110b657506001600160a01b0384163314155b156110dd576002810180546001600160a01b0319166001600160a01b038616179055611102565b600b546002820180546001600160a01b0319166001600160a01b039092169190911790555b60028101546001600160a01b031660005b60038110156111ce576001600160a01b038216156111c157611171600160086000856001600160a01b03166001600160a01b03168152602001908152602001600020600301836003811061116357fe5b01549063ffffffff611ba116565b6001600160a01b03831660009081526008602052604090206003908101908390811061119957fe5b01556001600160a01b03918216600090815260086020526040902060020154909116906111c6565b6111ce565b600101611113565b50505b60028101546001600160a01b0316156113335760028101546001600160a01b031660005b6003811015611330576001600160a01b0382161561132357600061123f6103e8610a486000858154811061122557fe5b906000526020600020015434611b4190919063ffffffff16565b6001600160a01b03841660009081526008602052604090206006015490915061126e908263ffffffff611ba116565b6001600160a01b03841660009081526008602052604090206006810191909155600701546112a2908263ffffffff611ba116565b6001600160a01b038416600081815260086020908152604091829020600701939093558051848152905185933393927fd41f7e766eebcc7ff42b11ac8691bdf864db4afc0c55e71d629d54edce460d98929081900390910190a4506001600160a01b0391821660009081526008602052604090206002015490911690611328565b611330565b6001016111f5565b50505b8054611373574260018201556040805133815290517f9fd565cd14c3c391679eb0cad12a14dcf7534e9d3462bcb9b67a098a9bbbc24a9181900360200190a15b6040805160608101825260ff85811682523460208084018281524295850195865286546001808201895560008981529390932095516003909102909501805460ff191695909416949094178355925192820192909255915160029283015590546113dc91611ba1565b6002556040805160ff851681523460208201524281830152905133917f5998f12fe9332603ffeda0abbc2ea68418dfad46909149aa0f4fcbd1d8f7c620919081900360600190a260065460ff161561164f57805460021180159061144257508054600510155b1561164f5760008160000160008154811061145957fe5b9060005260206000209060030201600101549050600554811061164d5781546000908390600119810190811061148b57fe5b600091825260209091206001600390920201015483549091506002141561153257348114156114ef5760016000815481106114c257fe5b6000918252602080832090910154338352600982526040808420875460001901855290925291205561152d565b8034111561152d576001808154811061150457fe5b600091825260208083209091015433835260098252604080842087546000190185529092529120555b6115fd565b82546003141561156857348114156115525760016000815481106114c257fe5b8034111561152d57600160028154811061150457fe5b82546004141561159e57348114156115885760016000815481106114c257fe5b8034111561152d57600160038154811061150457fe5b8254600514156115fd57348114156115be57600160008154811061150457fe5b803411156115fd5760016004815481106115d457fe5b600091825260208083209091015433835260098252604080842087546000190185529092529120555b336000908152600960209081526040808320865460001901845290915290205461164890611639906103e890610a48903463ffffffff611b4116565b6003549063ffffffff611ba116565b600355505b505b50505050565b6000818154811061166257fe5b600091825260209091200154905081565b6000806000611681846116d2565b61168a85611af4565b61169386611b13565b9250925092509193909250565b6001600160a01b03811660009081526008602052604081206006810154600790910154610c059163ffffffff611c6516565b6000805b6001600160a01b038316600090815260086020526040902054811015610eba576001600160a01b0383166000908152600860205260409020805461174091908390811061171f57fe5b90600052602060002090600302016001015483611ba190919063ffffffff16565b91506001016116d6565b600b546001600160a01b03163314611796576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b6006805460ff1916911515919091179055565b600b546001600160a01b031633146117f5576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b604080516370a0823160e01b8152306004820152905183916001600160a01b0383169163a9059cbb91859184916370a08231916024808301926020929190829003018186803b15801561184757600080fd5b505afa15801561185b573d6000803e3d6000fd5b505050506040513d602081101561187157600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b1580156118c257600080fd5b505af11580156118d6573d6000803e3d6000fd5b505050506040513d602081101561164d57600080fd5b600b546001600160a01b03163314611938576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9037bbb732b960b11b604482015290519081900360640190fd5b600491909155600555565b6001600160a01b031660009081526008602052604090205490565b60035481565b60008060078360ff168154811061197757fe5b906000526020600020906002020160000154915060078360ff168154811061199b57fe5b9060005260206000209060020201600101549050915091565b600a81565b6001600160a01b0382166000908152600860205260408120805482918291829182918190889081106119e757fe5b60009182526020909120600390910201546007805460ff90921697509087908110611a0e57fe5b9060005260206000209060020201600101549450806000018781548110611a3157fe5b9060005260206000209060030201600101549350806000018781548110611a5457fe5b9060005260206000209060030201600201549250611a92611a83620151806007846000018b8154811061094f57fe5b82600001898154811061099c57fe5b9150509295509295909350565b6001818154811061166257fe5b60055481565b6001600160a01b031660009081526008602052604090206001015490565b60045481565b6001600160a01b031660009081526008602052604090206006015490565b6001600160a01b03166000908152600860208190526040909120015490565b6001600160a01b03166000908152600860205260409020600581015460048201546003909201549091010190565b600082611b5057506000610c05565b82820282848281611b5d57fe5b0414611b9a5760405162461bcd60e51b8152600401808060200182810382526021815260200180611ce16021913960400191505060405180910390fd5b9392505050565b600082820183811015611b9a576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000808211611c51576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481611c5c57fe5b04949350505050565b600082821115611cbc576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6040518060600160405280600390602082028038833950919291505056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a265627a7a723058206b49852ec4e92615b45314a9baf29462be38563e21958cfc7c838d0b31f5fde164736f6c634300050a0032
[ 4, 12, 16, 26, 18 ]
0xf1f1b6c9a3c16fc69cd59d33197329928e0a9bcb
/** *Submitted for verification at Etherscan.io on 2020-03-29 */ pragma solidity ^0.5.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) { // 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"); } } /** * @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); } /** * @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"); } } } /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ 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; } /* * @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 is Initializable { // 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 aplied to your functions to restrict their use to * the owner. */ contract Ownable is Initializable, Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function initialize(address sender) public initializer { _owner = sender; emit OwnershipTransferred(address(0), _owner); } /** * @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; } uint256[50] private ______gap; } /** * @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; } } /** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. */ contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; using SafeERC20 for IERC20; event TokensReleased(address token, uint256 amount); event TokenVestingRevoked(address token); // beneficiary of tokens after they are released address private _beneficiary; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _cliff; uint256 private _start; uint256 private _duration; bool private _revocable; mapping (address => uint256) private _released; mapping (address => bool) private _revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param start the time (as Unix time) at which point vesting starts * @param duration duration in seconds of the period in which the tokens will vest * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); // solhint-disable-next-line max-line-length require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); _beneficiary = beneficiary; _revocable = revocable; _duration = duration; _cliff = start.add(cliffDuration); _start = start; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view returns (address) { return _beneficiary; } /** * @return the cliff time of the token vesting. */ function cliff() public view returns (uint256) { return _cliff; } /** * @return the start time of the token vesting. */ function start() public view returns (uint256) { return _start; } /** * @return the duration of the token vesting. */ function duration() public view returns (uint256) { return _duration; } /** * @return true if the vesting is revocable. */ function revocable() public view returns (bool) { return _revocable; } /** * @return the amount of the token released. */ function released(address token) public view returns (uint256) { return _released[token]; } /** * @return true if the token is revoked. */ function revoked(address token) public view returns (bool) { return _revoked[token]; } /** * @notice Transfers vested tokens to beneficiary. * @param token ERC20 token which is being vested */ function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); require(unreleased > 0, "TokenVesting: no tokens are due"); _released[address(token)] = _released[address(token)].add(unreleased); token.safeTransfer(_beneficiary, unreleased); emit TokensReleased(address(token), unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { require(_revocable, "TokenVesting: cannot revoke"); require(!_revoked[address(token)], "TokenVesting: token already revoked"); uint256 balance = token.balanceOf(address(this)); uint256 unreleased = _releasableAmount(token); uint256 refund = balance.sub(unreleased); _revoked[address(token)] = true; token.safeTransfer(owner(), refund); emit TokenVestingRevoked(address(token)); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. * @param token ERC20 token which is being vested */ function _releasableAmount(IERC20 token) private view returns (uint256) { return _vestedAmount(token).sub(_released[address(token)]); } /** * @dev Calculates the amount that has already vested. * @param token ERC20 token which is being vested */ function _vestedAmount(IERC20 token) private view returns (uint256) { uint256 currentBalance = token.balanceOf(address(this)); uint256 totalBalance = currentBalance.add(_released[address(token)]); if (block.timestamp < _cliff) { return 0; } else if (block.timestamp >= _start.add(_duration) || _revoked[address(token)]) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); } } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80638da5cb5b1161008c578063be9a655511610066578063be9a6555146101dd578063c4d66de8146101e5578063f2fde38b1461020b578063fa01dc0614610231576100ea565b80638da5cb5b146101a75780638f32d59b146101af5780639852595c146101b7576100ea565b806338af3eed116100c857806338af3eed14610139578063715018a61461015d57806374a8f10314610165578063872a78101461018b576100ea565b80630fb5a6b4146100ef57806313d033c0146101095780631916558714610111575b600080fd5b6100f7610257565b60408051918252519081900360200190f35b6100f761025d565b6101376004803603602081101561012757600080fd5b50356001600160a01b0316610263565b005b610141610368565b604080516001600160a01b039092168252519081900360200190f35b610137610377565b6101376004803603602081101561017b57600080fd5b50356001600160a01b031661041a565b610193610642565b604080519115158252519081900360200190f35b61014161064b565b61019361065a565b6100f7600480360360208110156101cd57600080fd5b50356001600160a01b0316610680565b6100f761069f565b610137600480360360208110156101fb57600080fd5b50356001600160a01b03166106a5565b6101376004803603602081101561022157600080fd5b50356001600160a01b0316610797565b6101936004803603602081101561024757600080fd5b50356001600160a01b03166107fc565b60695490565b60675490565b600061026e8261081a565b9050600081116102c5576040805162461bcd60e51b815260206004820152601f60248201527f546f6b656e56657374696e673a206e6f20746f6b656e73206172652064756500604482015290519081900360640190fd5b6001600160a01b0382166000908152606b60205260409020546102ee908263ffffffff61085216565b6001600160a01b038084166000818152606b60205260409020929092556066546103209291168363ffffffff6108b316565b604080516001600160a01b03841681526020810183905281517fc7798891864187665ac6dd119286e44ec13f014527aeeb2b8eb3fd413df93179929181900390910190a15050565b6066546001600160a01b031690565b61037f61065a565b6103d0576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b61042261065a565b610473576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b606a5460ff166104ca576040805162461bcd60e51b815260206004820152601b60248201527f546f6b656e56657374696e673a2063616e6e6f74207265766f6b650000000000604482015290519081900360640190fd5b6001600160a01b0381166000908152606c602052604090205460ff16156105225760405162461bcd60e51b8152600401808060200182810382526023815260200180610f6d6023913960400191505060405180910390fd5b604080516370a0823160e01b815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561056c57600080fd5b505afa158015610580573d6000803e3d6000fd5b505050506040513d602081101561059657600080fd5b5051905060006105a58361081a565b905060006105b9838363ffffffff61090a16565b6001600160a01b0385166000908152606c60205260409020805460ff1916600117905590506106006105e961064b565b6001600160a01b038616908363ffffffff6108b316565b604080516001600160a01b038616815290517f39983c6d4d174a7aee564f449d4a5c3c7ac9649d72b7793c56901183996f8af69181900360200190a150505050565b606a5460ff1690565b6033546001600160a01b031690565b6033546000906001600160a01b031661067161094c565b6001600160a01b031614905090565b6001600160a01b0381166000908152606b60205260409020545b919050565b60685490565b600054610100900460ff16806106be57506106be610950565b806106cc575060005460ff16155b6107075760405162461bcd60e51b815260040180806020018281038252602e815260200180610f15602e913960400191505060405180910390fd5b600054610100900460ff16158015610732576000805460ff1961ff0019909116610100171660011790555b603380546001600160a01b0319166001600160a01b0384811691909117918290556040519116906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a38015610793576000805461ff00191690555b5050565b61079f61065a565b6107f0576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6107f981610956565b50565b6001600160a01b03166000908152606c602052604090205460ff1690565b6001600160a01b0381166000908152606b602052604081205461084c90610840846109f7565b9063ffffffff61090a16565b92915050565b6000828201838110156108ac576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610905908490610b3c565b505050565b60006108ac83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610cfa565b3390565b303b1590565b6001600160a01b03811661099b5760405162461bcd60e51b8152600401808060200182810382526026815260200180610ece6026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b604080516370a0823160e01b8152306004820152905160009182916001600160a01b038516916370a08231916024808301926020929190829003018186803b158015610a4257600080fd5b505afa158015610a56573d6000803e3d6000fd5b505050506040513d6020811015610a6c57600080fd5b50516001600160a01b0384166000908152606b602052604081205491925090610a9c90839063ffffffff61085216565b9050606754421015610ab35760009250505061069a565b606954606854610ac89163ffffffff61085216565b42101580610aee57506001600160a01b0384166000908152606c602052604090205460ff165b15610afc57915061069a9050565b610b33606954610b27610b1a6068544261090a90919063ffffffff16565b849063ffffffff610d9116565b9063ffffffff610dea16565b9250505061069a565b610b4e826001600160a01b0316610e2c565b610b9f576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310610bdd5780518252601f199092019160209182019101610bbe565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610c3f576040519150601f19603f3d011682016040523d82523d6000602084013e610c44565b606091505b509150915081610c9b576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610cf457808060200190516020811015610cb757600080fd5b5051610cf45760405162461bcd60e51b815260040180806020018281038252602a815260200180610f43602a913960400191505060405180910390fd5b50505050565b60008184841115610d895760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d4e578181015183820152602001610d36565b50505050905090810190601f168015610d7b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082610da05750600061084c565b82820282848281610dad57fe5b04146108ac5760405162461bcd60e51b8152600401808060200182810382526021815260200180610ef46021913960400191505060405180910390fd5b60006108ac83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610e68565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610e6057508115155b949350505050565b60008183610eb75760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610d4e578181015183820152602001610d36565b506000838581610ec357fe5b049594505050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564546f6b656e56657374696e673a20746f6b656e20616c7265616479207265766f6b6564a265627a7a72315820b2ac9fb626e80490beb5c41158bc10d1bb5e110ed2e87ba116df0671166bbe5364736f6c634300050c0032
[ 20 ]
0xf1f1dcc3138aa932f361189591b652b9751595c7
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 = 0x30dd027bcfE232cB1C5D3B6de46E728737253bAe; } 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; } }
0x6080604052600436106100b95763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631624335681146100be57806338af3eed146100e55780636e15266a14610116578063834ee4171461012b57806386d1a69f146101405780638da5cb5b146101575780639b7faaf01461016c5780639e1a4d1914610195578063a4e2d634146101aa578063f2fde38b146101bf578063f83d08ba146101e0578063fa2a8997146101f5575b600080fd5b3480156100ca57600080fd5b506100d361020a565b60408051918252519081900360200190f35b3480156100f157600080fd5b506100fa610210565b60408051600160a060020a039092168252519081900360200190f35b34801561012257600080fd5b506100d361021f565b34801561013757600080fd5b506100d3610225565b34801561014c57600080fd5b5061015561022b565b005b34801561016357600080fd5b506100fa6103d1565b34801561017857600080fd5b506101816103e0565b604080519115158252519081900360200190f35b3480156101a157600080fd5b506100d36103e8565b3480156101b657600080fd5b5061018161047e565b3480156101cb57600080fd5b50610155600160a060020a036004351661049f565b3480156101ec57600080fd5b50610181610533565b34801561020157600080fd5b506101816105db565b60045481565b600254600160a060020a031681565b60055481565b60035481565b60008054600160a060020a0316331461024357600080fd5b60025474010000000000000000000000000000000000000000900460ff16151561026c57600080fd5b6002547501000000000000000000000000000000000000000000900460ff161561029557600080fd5b61029d6103e0565b15156102a857600080fd5b6102b06103e8565b600154600254604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03928316600482015260248101859052905193945091169163a9059cbb916044808201926020929091908290030181600087803b15801561032457600080fd5b505af1158015610338573d6000803e3d6000fd5b505050506040513d602081101561034e57600080fd5b505060025460408051600160a060020a0390921682526020820183905280517f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a919281900390910190a1506002805475ff00000000000000000000000000000000000000000019167501000000000000000000000000000000000000000000179055565b600054600160a060020a031681565b600454421190565b600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b15801561044d57600080fd5b505af1158015610461573d6000803e3d6000fd5b505050506040513d602081101561047757600080fd5b5051905090565b60025474010000000000000000000000000000000000000000900460ff1681565b600054600160a060020a031633146104b657600080fd5b600160a060020a03811615156104cb57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461054b57600080fd5b60025474010000000000000000000000000000000000000000900460ff161561057357600080fd5b600061057d6103e8565b1161058757600080fd5b4260038190556005546105a0919063ffffffff6105fd16565b6004556002805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905590565b6002547501000000000000000000000000000000000000000000900460ff1681565b60008282018381101561060c57fe5b93925050505600a165627a7a7230582022135be2110c94ed5e0073a45cdf2303b410e8c42587557849e6d22ce6ab96940029
[ 16, 7 ]
0xf1f1fb3da05c6897447e9858fb84e0d3988a0e82
// 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.s * * 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 PapaAkita 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 = 'Papa Akita'; string private _symbol = 'PKITA'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 10000000 * 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 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); } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e9961461063b578063d543dbeb14610695578063dd62ed3e146106c3578063f2cc0c181461073b578063f2fde38b1461077f578063f84354f1146107c35761014d565b8063715018a6146104945780637d1db4a51461049e5780638da5cb5b146104bc57806395d89b41146104f0578063a457c2d714610573578063a9059cbb146105d75761014d565b806323b872dd1161011557806323b872dd146102a35780632d83811914610327578063313ce56714610369578063395093511461038a5780634549b039146103ee57806370a082311461043c5761014d565b8063053ab1821461015257806306fdde0314610180578063095ea7b31461020357806313114a9d1461026757806318160ddd14610285575b600080fd5b61017e6004803603602081101561016857600080fd5b8101908080359060200190929190505050610807565b005b610188610997565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101c85780820151818401526020810190506101ad565b50505050905090810190601f1680156101f55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024f6004803603604081101561021957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a39565b60405180821515815260200191505060405180910390f35b61026f610a57565b6040518082815260200191505060405180910390f35b61028d610a61565b6040518082815260200191505060405180910390f35b61030f600480360360608110156102b957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a72565b60405180821515815260200191505060405180910390f35b6103536004803603602081101561033d57600080fd5b8101908080359060200190929190505050610b4b565b6040518082815260200191505060405180910390f35b610371610bcf565b604051808260ff16815260200191505060405180910390f35b6103d6600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610be6565b60405180821515815260200191505060405180910390f35b6104266004803603604081101561040457600080fd5b8101908080359060200190929190803515159060200190929190505050610c99565b6040518082815260200191505060405180910390f35b61047e6004803603602081101561045257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d55565b6040518082815260200191505060405180910390f35b61049c610e40565b005b6104a6610fc6565b6040518082815260200191505060405180910390f35b6104c4610fcc565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104f8610ff5565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561053857808201518184015260208101905061051d565b50505050905090810190601f1680156105655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105bf6004803603604081101561058957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611097565b60405180821515815260200191505060405180910390f35b610623600480360360408110156105ed57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611164565b60405180821515815260200191505060405180910390f35b61067d6004803603602081101561065157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611182565b60405180821515815260200191505060405180910390f35b6106c1600480360360208110156106ab57600080fd5b81019080803590602001909291905050506111d8565b005b610725600480360360408110156106d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112d8565b6040518082815260200191505060405180910390f35b61077d6004803603602081101561075157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061135f565b005b6107c16004803603602081101561079557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611679565b005b610805600480360360208110156107d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611884565b005b6000610811611c0e565b9050600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156108b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613544602c913960400191505060405180910390fd5b60006108c183611c16565b50505050905061091981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061097181600654611c6e90919063ffffffff16565b60068190555061098c83600754611cb890919063ffffffff16565b600781905550505050565b606060088054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a2f5780601f10610a0457610100808354040283529160200191610a2f565b820191906000526020600020905b815481529060010190602001808311610a1257829003601f168201915b5050505050905090565b6000610a4d610a46611c0e565b8484611d40565b6001905092915050565b6000600754905090565b6000683635c9adc5dea00000905090565b6000610a7f848484611f37565b610b4084610a8b611c0e565b610b3b856040518060600160405280602881526020016134aa60289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610af1611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124679092919063ffffffff16565b611d40565b600190509392505050565b6000600654821115610ba8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806133ef602a913960400191505060405180910390fd5b6000610bb2612527565b9050610bc7818461255290919063ffffffff16565b915050919050565b6000600a60009054906101000a900460ff16905090565b6000610c8f610bf3611c0e565b84610c8a8560036000610c04611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b611d40565b6001905092915050565b6000683635c9adc5dea00000831115610d1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b81610d39576000610d2a84611c16565b50505050905080915050610d4f565b6000610d4484611c16565b505050915050809150505b92915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610df057600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050610e3b565b610e38600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4b565b90505b919050565b610e48611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600b5481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060098054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561108d5780601f106110625761010080835404028352916020019161108d565b820191906000526020600020905b81548152906001019060200180831161107057829003601f168201915b5050505050905090565b600061115a6110a4611c0e565b846111558560405180606001604052806025815260200161357060259139600360006110ce611c0e565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546124679092919063ffffffff16565b611d40565b6001905092915050565b6000611178611171611c0e565b8484611f37565b6001905092915050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6111e0611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6112cf60646112c183683635c9adc5dea0000061259c90919063ffffffff16565b61255290919063ffffffff16565b600b8190555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611367611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611427576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156114e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411156115bb57611577600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610b4b565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b611681611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611741576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156117c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806134196026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61188c611c0e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461194c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611a0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600580549050811015611c0a578173ffffffffffffffffffffffffffffffffffffffff1660058281548110611a3f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611bfd57600560016005805490500381548110611a9b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660058281548110611ad357fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005805480611bc357fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055611c0a565b8080600101915050611a0e565b5050565b600033905090565b6000806000806000806000611c2a88612622565b915091506000611c38612527565b90506000806000611c4a8c8686612674565b92509250925082828288889a509a509a509a509a5050505050505091939590929450565b6000611cb083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612467565b905092915050565b600080828401905083811015611d36576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dc6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806135206024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e4c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061343f6022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611fbd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806134fb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612043576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806133cc6023913960400191505060405180910390fd5b6000811161209c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806134d26029913960400191505060405180910390fd5b6120a4610fcc565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561211257506120e2610fcc565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561217357600b54811115612172576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806134616028913960400191505060405180910390fd5b5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156122165750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561222b576122268383836126d2565b612462565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156122ce5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156122e3576122de838383612925565b612461565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156123875750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561239c57612397838383612b78565b612460565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561243e5750600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156124535761244e838383612d36565b61245f565b61245e838383612b78565b5b5b5b5b505050565b6000838311158290612514576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156124d95780820151818401526020810190506124be565b50505050905090810190601f1680156125065780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080600061253461301e565b9150915061254b818361255290919063ffffffff16565b9250505090565b600061259483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506132cb565b905092915050565b6000808314156125af576000905061261c565b60008284029050828482816125c057fe5b0414612617576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806134896021913960400191505060405180910390fd5b809150505b92915050565b600080600061264e600261264060648761255290919063ffffffff16565b61259c90919063ffffffff16565b905060006126658286611c6e90919063ffffffff16565b90508082935093505050915091565b60008060008061268d858861259c90919063ffffffff16565b905060006126a4868861259c90919063ffffffff16565b905060006126bb8284611c6e90919063ffffffff16565b905082818395509550955050505093509350939050565b60008060008060006126e386611c16565b9450945094509450945061273f86600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127d485600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061286984600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128b68382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600080600061293686611c16565b9450945094509450945061299285600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a2782600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612abc84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612b098382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612b8986611c16565b94509450945094509450612be585600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c7a84600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cc78382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b6000806000806000612d4786611c16565b94509450945094509450612da386600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e3885600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c6e90919063ffffffff16565b600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612ecd82600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612f6284600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cb890919063ffffffff16565b600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612faf8382613391565b8673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b600080600060065490506000683635c9adc5dea00000905060005b6005805490508110156132805782600160006005848154811061305857fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054118061313f57508160026000600584815481106130d757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b1561315d57600654683635c9adc5dea00000945094505050506132c7565b6131e6600160006005848154811061317157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484611c6e90919063ffffffff16565b925061327160026000600584815481106131fc57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611c6e90919063ffffffff16565b91508080600101915050613039565b5061329f683635c9adc5dea0000060065461255290919063ffffffff16565b8210156132be57600654683635c9adc5dea000009350935050506132c7565b81819350935050505b9091565b60008083118290613377576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561333c578082015181840152602081019050613321565b50505050905090810190601f1680156133695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161338357fe5b049050809150509392505050565b6133a682600654611c6e90919063ffffffff16565b6006819055506133c181600754611cb890919063ffffffff16565b600781905550505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212208aaaa04831a3d735ae9c281477606f40d6e70fe8ee896e8325313fca8cf80e2d64736f6c634300060c0033
[ 4 ]
0xf1f28973081f365225cf7bcbe4bf817791793cae
/* Extraterrestrial Elon (ETE) Website : https://etelon.space ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Social Platforms : Twitter: https://Twitter.com/ET_Elon TG: https://t.me/ExtraterrestrialElon */ // SPDX-License-Identifier: MIT 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 ETEToken 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) public bots; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = 'Extraterrestrial Elon'; string private constant _symbol = 'ETE'; uint8 private constant _decimals = 18; uint256 private _taxFee = 4; uint256 private _teamFee = 5; uint256 private _previousTaxFee = _taxFee; uint256 private _previousTeamFee = _teamFee; address payable private _devWalletAddress; address payable private _marketingWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwap = false; bool private swapEnabled = true; bool private tradingEnabled = false; uint256 private _maxTxAmount = 3000000 * 10**18; uint256 private constant _numOfTokensToExchangeForTeam = 5000 * 10**18; uint256 private _maxWalletSize = _tTotal; // addresses that can make transfers before presale is over mapping (address => bool) public canTransferBeforeTradingIsEnabled; modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () public { _devWalletAddress = 0xac19bd8C38260cD61F9126524AE8c833189AFD82; _marketingWalletAddress = 0x9Ee29476A76d265F35792A2b5BEEAf1731E4Ff3b; _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; // enable owner and fixed-sale wallet to send tokens before presales are over canTransferBeforeTradingIsEnabled[owner()] = 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 allowPreTrading(address account, bool allowed) external onlyOwner { // used for owner and pre sale addresses require(canTransferBeforeTradingIsEnabled[account] != allowed, "TOKEN: Pre trading is already the value of 'excluded'"); canTransferBeforeTradingIsEnabled[account] = allowed; } 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 blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } 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"); if (!tradingEnabled) { require(canTransferBeforeTradingIsEnabled[sender], "TOKEN: This account cannot send tokens until trading is enabled"); } if(sender != owner() && recipient != owner()) { require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); require(!bots[sender] && !bots[recipient]); } if(sender != owner() && recipient != owner() && recipient != uniswapV2Pair && recipient != address(0xdead) && recipient != address(this)) { uint256 tokenBalanceRecipient = balanceOf(recipient); require(tokenBalanceRecipient + amount <= _maxWalletSize, "Recipient exceeds max wallet size."); } 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]) || (sender != uniswapV2Pair && recipient != uniswapV2Pair)){ 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(2)); _marketingWalletAddress.transfer(amount.div(2)); } 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 _getMaxTxAmount() public view returns(uint256) { return _maxTxAmount; } function _getETHBalance() public view returns(uint256 balance) { return address(this).balance; } function _setTaxFee(uint256 taxFee) external onlyOwner() { _taxFee = taxFee; } function _setTeamFee(uint256 teamFee) external onlyOwner() { _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; } function setTrading(bool _tradingEnabled) external onlyOwner { tradingEnabled = _tradingEnabled; } }
0x60806040526004361061025f5760003560e01c8063602bc62b11610144578063af9549e0116100b6578063f2cc0c181161007a578063f2cc0c18146109c7578063f2fde38b146109fa578063f429389014610a2d578063f7a9159114610a42578063f815a84214610a57578063f84354f114610a6c57610266565b8063af9549e0146108bf578063bfd79284146108fa578063cba0e9961461092d578063dd62ed3e14610960578063e01af92c1461099b57610266565b80638da5cb5b116101085780638da5cb5b146107cd5780638f70ccf7146107e257806395d89b411461080e5780639e6c752914610823578063a457c2d71461084d578063a9059cbb1461088657610266565b8063602bc62b1461070a5780636b9990531461071f57806370a0823114610752578063715018a6146107855780637e0e155c1461079a57610266565b806328667162116101dd5780633bd5d173116101a15780633bd5d173146106275780634549b0391461065157806349bd5a5e1461068357806351bc3c85146106985780635342acb4146106ad5780635880b873146106e057610266565b806328667162146105345780632d8381191461055e5780632f9c456914610588578063313ce567146105c357806339509351146105ee57610266565b80631694505e116102245780631694505e1461044e57806318160ddd1461047f5780631bbae6e0146104945780631ff53b60146104be57806323b872dd146104f157610266565b8062b8cf2a1461026b57806306fdde031461031d578063095ea7b3146103a75780630a1f8ea8146103f457806313114a9d1461042757610266565b3661026657005b600080fd5b34801561027757600080fd5b5061031b6004803603602081101561028e57600080fd5b8101906020810181356401000000008111156102a957600080fd5b8201836020820111156102bb57600080fd5b803590602001918460208302840111640100000000831117156102dd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610a9f945050505050565b005b34801561032957600080fd5b50610332610b53565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561036c578181015183820152602001610354565b50505050905090810190601f1680156103995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103b357600080fd5b506103e0600480360360408110156103ca57600080fd5b506001600160a01b038135169060200135610b82565b604080519115158252519081900360200190f35b34801561040057600080fd5b5061031b6004803603602081101561041757600080fd5b50356001600160a01b0316610ba0565b34801561043357600080fd5b5061043c610c1a565b60408051918252519081900360200190f35b34801561045a57600080fd5b50610463610c20565b604080516001600160a01b039092168252519081900360200190f35b34801561048b57600080fd5b5061043c610c44565b3480156104a057600080fd5b5061031b600480360360208110156104b757600080fd5b5035610c54565b3480156104ca57600080fd5b5061031b600480360360208110156104e157600080fd5b50356001600160a01b0316610cb1565b3480156104fd57600080fd5b506103e06004803603606081101561051457600080fd5b506001600160a01b03813581169160208101359091169060400135610d2b565b34801561054057600080fd5b5061031b6004803603602081101561055757600080fd5b5035610db2565b34801561056a57600080fd5b5061043c6004803603602081101561058157600080fd5b5035610e0f565b34801561059457600080fd5b5061031b600480360360408110156105ab57600080fd5b506001600160a01b0381351690602001351515610e71565b3480156105cf57600080fd5b506105d8610f52565b6040805160ff9092168252519081900360200190f35b3480156105fa57600080fd5b506103e06004803603604081101561061157600080fd5b506001600160a01b038135169060200135610f57565b34801561063357600080fd5b5061031b6004803603602081101561064a57600080fd5b5035610fa5565b34801561065d57600080fd5b5061043c6004803603604081101561067457600080fd5b5080359060200135151561107f565b34801561068f57600080fd5b5061046361111b565b3480156106a457600080fd5b5061031b61113f565b3480156106b957600080fd5b506103e0600480360360208110156106d057600080fd5b50356001600160a01b03166111b0565b3480156106ec57600080fd5b5061031b6004803603602081101561070357600080fd5b50356111ce565b34801561071657600080fd5b5061043c61122b565b34801561072b57600080fd5b5061031b6004803603602081101561074257600080fd5b50356001600160a01b0316611231565b34801561075e57600080fd5b5061043c6004803603602081101561077557600080fd5b50356001600160a01b03166112aa565b34801561079157600080fd5b5061031b61130c565b3480156107a657600080fd5b506103e0600480360360208110156107bd57600080fd5b50356001600160a01b03166113ae565b3480156107d957600080fd5b506104636113c3565b3480156107ee57600080fd5b5061031b6004803603602081101561080557600080fd5b503515156113d2565b34801561081a57600080fd5b50610332611448565b34801561082f57600080fd5b5061031b6004803603602081101561084657600080fd5b5035611465565b34801561085957600080fd5b506103e06004803603604081101561087057600080fd5b506001600160a01b0381351690602001356114c2565b34801561089257600080fd5b506103e0600480360360408110156108a957600080fd5b506001600160a01b03813516906020013561152a565b3480156108cb57600080fd5b5061031b600480360360408110156108e257600080fd5b506001600160a01b038135169060200135151561153e565b34801561090657600080fd5b506103e06004803603602081101561091d57600080fd5b50356001600160a01b03166115c1565b34801561093957600080fd5b506103e06004803603602081101561095057600080fd5b50356001600160a01b03166115d6565b34801561096c57600080fd5b5061043c6004803603604081101561098357600080fd5b506001600160a01b03813581169160200135166115f4565b3480156109a757600080fd5b5061031b600480360360208110156109be57600080fd5b5035151561161f565b3480156109d357600080fd5b5061031b600480360360208110156109ea57600080fd5b50356001600160a01b0316611695565b348015610a0657600080fd5b5061031b60048036036020811015610a1d57600080fd5b50356001600160a01b0316611877565b348015610a3957600080fd5b5061031b61196f565b348015610a4e57600080fd5b5061043c6119d1565b348015610a6357600080fd5b5061043c6119d7565b348015610a7857600080fd5b5061031b60048036036020811015610a8f57600080fd5b50356001600160a01b03166119db565b610aa7611b98565b6000546001600160a01b03908116911614610af7576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b60005b8151811015610b4f57600160096000848481518110610b1557fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610afa565b5050565b60408051808201909152601581527422bc3a3930ba32b93932b9ba3934b0b61022b637b760591b602082015290565b6000610b96610b8f611b98565b8484611b9c565b5060015b92915050565b610ba8611b98565b6000546001600160a01b03908116911614610bf8576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b601080546001600160a01b0319166001600160a01b0392909216919091179055565b600b5490565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6b033b2e3c9fd0803ce800000090565b610c5c611b98565b6000546001600160a01b03908116911614610cac576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b601255565b610cb9611b98565b6000546001600160a01b03908116911614610d09576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b601180546001600160a01b0319166001600160a01b0392909216919091179055565b6000610d38848484611c88565b610da884610d44611b98565b610da385604051806060016040528060288152602001612f1c602891396001600160a01b038a16600090815260056020526040812090610d82611b98565b6001600160a01b03168152602081019190915260400160002054919061211c565b611b9c565b5060019392505050565b610dba611b98565b6000546001600160a01b03908116911614610e0a576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b600d55565b6000600a54821115610e525760405162461bcd60e51b815260040180806020018281038252602a815260200180612e0a602a913960400191505060405180910390fd5b6000610e5c6121b3565b9050610e6883826121d6565b9150505b919050565b610e79611b98565b6000546001600160a01b03908116911614610ec9576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b6001600160a01b03821660009081526014602052604090205460ff1615158115151415610f275760405162461bcd60e51b8152600401808060200182810382526035815260200180612e7c6035913960400191505060405180910390fd5b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b601290565b6000610b96610f64611b98565b84610da38560056000610f75611b98565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061221f565b6000610faf611b98565b6001600160a01b03811660009081526007602052604090205490915060ff161561100a5760405162461bcd60e51b815260040180806020018281038252602c815260200180612ff8602c913960400191505060405180910390fd5b600061101583612279565b505050506001600160a01b038416600090815260036020526040902054919250611041919050826122d6565b6001600160a01b038316600090815260036020526040902055600a5461106790826122d6565b600a55600b54611077908461221f565b600b55505050565b60006b033b2e3c9fd0803ce80000008311156110e2576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b816111015760006110f284612279565b50939550610b9a945050505050565b600061110c84612279565b50929550610b9a945050505050565b7f0000000000000000000000004d25821486903b9d91f63589ea27bb5b9a180e1e81565b611147611b98565b6000546001600160a01b03908116911614611197576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b60006111a2306112aa565b90506111ad81612318565b50565b6001600160a01b031660009081526006602052604090205460ff1690565b6111d6611b98565b6000546001600160a01b03908116911614611226576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b600c55565b60025490565b611239611b98565b6000546001600160a01b03908116911614611289576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6001600160a01b03811660009081526007602052604081205460ff16156112ea57506001600160a01b038116600090815260046020526040902054610e6c565b6001600160a01b038216600090815260036020526040902054610b9a90610e0f565b611314611b98565b6000546001600160a01b03908116911614611364576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60146020526000908152604090205460ff1681565b6000546001600160a01b031690565b6113da611b98565b6000546001600160a01b0390811691161461142a576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b60118054911515600160b01b0260ff60b01b19909216919091179055565b60408051808201909152600381526245544560e81b602082015290565b61146d611b98565b6000546001600160a01b039081169116146114bd576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b601355565b6000610b966114cf611b98565b84610da38560405180606001604052806025815260200161302460259139600560006114f9611b98565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919061211c565b6000610b96611537611b98565b8484611c88565b611546611b98565b6000546001600160a01b03908116911614611596576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600660205260409020805460ff1916911515919091179055565b60096020526000908152604090205460ff1681565b6001600160a01b031660009081526007602052604090205460ff1690565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b611627611b98565b6000546001600160a01b03908116911614611677576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b60118054911515600160a81b0260ff60a81b19909216919091179055565b61169d611b98565b6000546001600160a01b039081169116146116ed576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03821614156117495760405162461bcd60e51b8152600401808060200182810382526022815260200180612fd66022913960400191505060405180910390fd5b6001600160a01b03811660009081526007602052604090205460ff16156117b7576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526003602052604090205415611811576001600160a01b0381166000908152600360205260409020546117f790610e0f565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b61187f611b98565b6000546001600160a01b039081169116146118cf576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b6001600160a01b0381166119145760405162461bcd60e51b8152600401808060200182810382526026815260200180612e346026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611977611b98565b6000546001600160a01b039081169116146119c7576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b476111ad8161254f565b60125490565b4790565b6119e3611b98565b6000546001600160a01b03908116911614611a33576040805162461bcd60e51b81526020600482018190526024820152600080516020612f44833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526007602052604090205460ff16611aa0576040805162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f74206578636c75646564000000000000000000604482015290519081900360640190fd5b60005b600854811015610b4f57816001600160a01b031660088281548110611ac457fe5b6000918252602090912001546001600160a01b03161415611b9057600880546000198101908110611af157fe5b600091825260209091200154600880546001600160a01b039092169183908110611b1757fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480611b6957fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610b4f565b600101611aa3565b3390565b6001600160a01b038316611be15760405162461bcd60e51b8152600401808060200182810382526024815260200180612fb26024913960400191505060405180910390fd5b6001600160a01b038216611c265760405162461bcd60e51b8152600401808060200182810382526022815260200180612e5a6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260056020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316611ccd5760405162461bcd60e51b8152600401808060200182810382526025815260200180612f8d6025913960400191505060405180910390fd5b6001600160a01b038216611d125760405162461bcd60e51b8152600401808060200182810382526023815260200180612da86023913960400191505060405180910390fd5b60008111611d515760405162461bcd60e51b8152600401808060200182810382526029815260200180612f646029913960400191505060405180910390fd5b601154600160b01b900460ff16611db9576001600160a01b03831660009081526014602052604090205460ff16611db95760405162461bcd60e51b815260040180806020018281038252603f815260200180612dcb603f913960400191505060405180910390fd5b611dc16113c3565b6001600160a01b0316836001600160a01b031614158015611dfb5750611de56113c3565b6001600160a01b0316826001600160a01b031614155b15611e8c57601254811115611e415760405162461bcd60e51b8152600401808060200182810382526028815260200180612ed36028913960400191505060405180910390fd5b6001600160a01b03831660009081526009602052604090205460ff16158015611e8357506001600160a01b03821660009081526009602052604090205460ff16155b611e8c57600080fd5b611e946113c3565b6001600160a01b0316836001600160a01b031614158015611ece5750611eb86113c3565b6001600160a01b0316826001600160a01b031614155b8015611f0c57507f0000000000000000000000004d25821486903b9d91f63589ea27bb5b9a180e1e6001600160a01b0316826001600160a01b031614155b8015611f2357506001600160a01b03821661dead14155b8015611f3857506001600160a01b0382163014155b15611f8f576000611f48836112aa565b90506013548282011115611f8d5760405162461bcd60e51b8152600401808060200182810382526022815260200180612eb16022913960400191505060405180910390fd5b505b6000611f9a306112aa565b90506012548110611faa57506012545b60115469010f0cf064dd5920000082101590600160a01b900460ff16158015611fdc5750601154600160a81b900460ff165b8015611fe55750805b801561202357507f0000000000000000000000004d25821486903b9d91f63589ea27bb5b9a180e1e6001600160a01b0316856001600160a01b031614155b156120435761203182612318565b478015612041576120414761254f565b505b6001600160a01b03851660009081526006602052604090205460019060ff168061208557506001600160a01b03851660009081526006602052604090205460ff165b806120ff57507f0000000000000000000000004d25821486903b9d91f63589ea27bb5b9a180e1e6001600160a01b0316866001600160a01b0316141580156120ff57507f0000000000000000000000004d25821486903b9d91f63589ea27bb5b9a180e1e6001600160a01b0316856001600160a01b031614155b15612108575060005b612114868686846125d4565b505050505050565b600081848411156121ab5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612170578181015183820152602001612158565b50505050905090810190601f16801561219d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008060006121c0612748565b90925090506121cf82826121d6565b9250505090565b600061221883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506128d3565b9392505050565b600082820183811015612218576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008060008060008060008060006122968a600c54600d54612938565b92509250925060006122a66121b3565b905060008060006122b98e87878761298d565b919e509c509a509598509396509194505050505091939550919395565b600061221883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061211c565b6011805460ff60a01b1916600160a01b1790556040805160028082526060808301845292602083019080368337019050509050308160008151811061235957fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156123d257600080fd5b505afa1580156123e6573d6000803e3d6000fd5b505050506040513d60208110156123fc57600080fd5b505181518290600190811061240d57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050612458307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611b9c565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663791ac9478360008430426040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156124fd5781810151838201526020016124e5565b505050509050019650505050505050600060405180830381600087803b15801561252657600080fd5b505af115801561253a573d6000803e3d6000fd5b50506011805460ff60a01b1916905550505050565b6010546001600160a01b03166108fc6125698360026121d6565b6040518115909202916000818181858888f19350505050158015612591573d6000803e3d6000fd5b506011546001600160a01b03166108fc6125ac8360026121d6565b6040518115909202916000818181858888f19350505050158015610b4f573d6000803e3d6000fd5b806125e1576125e16129dd565b6001600160a01b03841660009081526007602052604090205460ff16801561262257506001600160a01b03831660009081526007602052604090205460ff16155b1561263757612632848484612a0f565b612735565b6001600160a01b03841660009081526007602052604090205460ff1615801561267857506001600160a01b03831660009081526007602052604090205460ff165b1561268857612632848484612b33565b6001600160a01b03841660009081526007602052604090205460ff161580156126ca57506001600160a01b03831660009081526007602052604090205460ff16155b156126da57612632848484612bdc565b6001600160a01b03841660009081526007602052604090205460ff16801561271a57506001600160a01b03831660009081526007602052604090205460ff165b1561272a57612632848484612c20565b612735848484612bdc565b8061274257612742612c93565b50505050565b600a5460009081906b033b2e3c9fd0803ce8000000825b60085481101561288d5782600360006008848154811061277b57fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806127e057508160046000600884815481106127b957fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561280157600a546b033b2e3c9fd0803ce8000000945094505050506128cf565b612841600360006008848154811061281557fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205484906122d6565b9250612883600460006008848154811061285757fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205483906122d6565b915060010161275f565b50600a546128a7906b033b2e3c9fd0803ce80000006121d6565b8210156128c957600a546b033b2e3c9fd0803ce80000009350935050506128cf565b90925090505b9091565b600081836129225760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612170578181015183820152602001612158565b50600083858161292e57fe5b0495945050505050565b6000808080612952606461294c8989612ca1565b906121d6565b90506000612965606461294c8a89612ca1565b9050600061297d826129778b866122d6565b906122d6565b9992985090965090945050505050565b600080808061299c8886612ca1565b905060006129aa8887612ca1565b905060006129b88888612ca1565b905060006129ca8261297786866122d6565b939b939a50919850919650505050505050565b600c541580156129ed5750600d54155b156129f757612a0d565b600c8054600e55600d8054600f55600091829055555b565b600080600080600080612a2187612279565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612a5390886122d6565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612a8290876122d6565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612ab1908661221f565b6001600160a01b038916600090815260036020526040902055612ad381612cfa565b612add8483612d83565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080612b4587612279565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612b7790876122d6565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612bad908461221f565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612ab1908661221f565b600080600080600080612bee87612279565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612a8290876122d6565b600080600080600080612c3287612279565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612c6490886122d6565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612b7790876122d6565b600e54600c55600f54600d55565b600082612cb057506000610b9a565b82820282848281612cbd57fe5b04146122185760405162461bcd60e51b8152600401808060200182810382526021815260200180612efb6021913960400191505060405180910390fd5b6000612d046121b3565b90506000612d128383612ca1565b30600090815260036020526040902054909150612d2f908261221f565b3060009081526003602090815260408083209390935560079052205460ff1615612d7e5730600090815260046020526040902054612d6d908461221f565b306000908152600460205260409020555b505050565b600a54612d9090836122d6565b600a55600b54612da0908261221f565b600b55505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e6420746f6b656e7320756e74696c2074726164696e6720697320656e61626c6564416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373544f4b454e3a205072652074726164696e6720697320616c7265616479207468652076616c7565206f6620276578636c7564656427526563697069656e742065786365656473206d61782077616c6c65742073697a652e5472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737357652063616e206e6f74206578636c75646520556e697377617020726f757465722e4578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122022560597fe15a077e07f39d690755835104aec1c2484f27b0240eeb667fd237e64736f6c634300060c0033
[ 13, 0, 11 ]
0xf1f327B7B5Fc964b3db2292958aE9D4f222F2747
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "./ERC721A.sol"; contract Bibiz is ERC721A, Ownable { uint256 public constant PRICE = 0.069 ether; uint256 public constant MAX_PER_TXN = 4; bool public publicSale = false; uint256 public maxSupply = 6900; uint256 public freeMaxSupply = 0; string private baseURI = ""; constructor() ERC721A("Bibiz", "BBZ") {} // public sale modifier publicSaleOpen() { require(publicSale, "Public Sale Not Started"); _; } function togglePublicSale() external onlyOwner { publicSale = !publicSale; } // public mint modifier insideLimits(uint256 _quantity) { require(totalSupply() + _quantity <= maxSupply, "Hit Limit"); _; } modifier insideMaxPerTxn(uint256 _quantity) { require(_quantity > 0 && _quantity <= MAX_PER_TXN, "Over Max Per Txn"); _; } function mint(uint256 _quantity) public payable publicSaleOpen insideLimits(_quantity) insideMaxPerTxn(_quantity) { if (totalSupply() + _quantity > freeMaxSupply) { require(msg.value >= PRICE * _quantity, "Not Enough Funds"); } _safeMint(msg.sender, _quantity); } // admin mint function adminMint(address _recipient, uint256 _quantity) public onlyOwner insideLimits(_quantity) { _safeMint(_recipient, _quantity); } // lock total mintable supply forever function decreaseTotalSupply(uint256 _total) public onlyOwner { require(_total <= maxSupply, "Over Current Max"); require(_total >= totalSupply(), "Must Be Over Total"); maxSupply = _total; } function setFreeSupply(uint256 _total) public onlyOwner { require(_total <= maxSupply, "Over Current Max"); require(_total >= totalSupply(), "Under Total"); freeMaxSupply = _total; } // base uri function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function withdraw() external onlyOwner { Address.sendValue(payable(owner()), address(this).balance); } } // 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: UNLICENSED pragma solidity ^0.8.0; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@openzeppelin/contracts/utils/Context.sol'; import '@openzeppelin/contracts/utils/Strings.sol'; import '@openzeppelin/contracts/utils/introspection/ERC165.sol'; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using Address for address; using Strings for uint256; struct TokenOwnership { address addr; uint64 startTimestamp; } struct AddressData { uint128 balance; uint128 numberMinted; } uint256 internal currentIndex; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // 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_; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { return currentIndex; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { require(index < totalSupply(), 'ERC721A: global index out of bounds'); return index; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first. * It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { require(index < balanceOf(owner), 'ERC721A: owner index out of bounds'); uint256 numMintedSoFar = totalSupply(); uint256 tokenIdsIdx; address currOwnershipAddr; // Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar. unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { if (tokenIdsIdx == index) { return i; } tokenIdsIdx++; } } } revert('ERC721A: unable to get token of owner by index'); } /** * @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 || interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), 'ERC721A: balance query for the zero address'); return uint256(_addressData[owner].balance); } function _numberMinted(address owner) internal view returns (uint256) { require(owner != address(0), 'ERC721A: number minted query for the zero address'); return uint256(_addressData[owner].numberMinted); } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { require(_exists(tokenId), 'ERC721A: owner query for nonexistent token'); unchecked { for (uint256 curr = tokenId; curr >= 0; curr--) { TokenOwnership memory ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } revert('ERC721A: unable to determine the owner of token'); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @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 override { address owner = ERC721A.ownerOf(tokenId); require(to != owner, 'ERC721A: approval to current owner'); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), 'ERC721A: approve caller is not owner nor approved for all' ); _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), 'ERC721A: approved query for nonexistent token'); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public override { require(operator != _msgSender(), 'ERC721A: 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 override { _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public override { _transfer(from, to, tokenId); require( _checkOnERC721Received(from, to, tokenId, _data), 'ERC721A: 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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return tokenId < currentIndex; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = currentIndex; require(to != address(0), 'ERC721A: mint to the zero address'); require(quantity != 0, 'ERC721A: quantity must be greater than 0'); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1 // updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1 unchecked { _addressData[to].balance += uint128(quantity); _addressData[to].numberMinted += uint128(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; for (uint256 i; i < quantity; i++) { emit Transfer(address(0), to, updatedIndex); if (safe) { require( _checkOnERC721Received(address(0), to, updatedIndex, _data), 'ERC721A: transfer to non ERC721Receiver implementer' ); } updatedIndex++; } currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = ownershipOf(tokenId); bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr || getApproved(tokenId) == _msgSender() || isApprovedForAll(prevOwnership.addr, _msgSender())); require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved'); require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner'); require(to != address(0), 'ERC721A: transfer to the zero address'); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, prevOwnership.addr); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; _ownerships[tokenId].addr = to; _ownerships[tokenId].startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; if (_ownerships[nextTokenId].addr == address(0)) { if (_exists(nextTokenId)) { _ownerships[nextTokenId].addr = prevOwnership.addr; _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, 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('ERC721A: transfer to non ERC721Receiver implementer'); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * 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`. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // 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 (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 (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) 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); /** * @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 // 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/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); }
0x6080604052600436106101d85760003560e01c80636e11451111610102578063b88d4fde11610095578063e58306f911610064578063e58306f91461050f578063e985e9c51461052f578063f2fde38b14610578578063f676308a1461059857600080fd5b8063b88d4fde146104a4578063c87b56dd146104c4578063d5abeb01146104e4578063e222c7f9146104fa57600080fd5b80638da5cb5b116100d15780638da5cb5b1461043e57806395d89b411461045c578063a0712d6814610471578063a22cb4651461048457600080fd5b80636e114511146103ce57806370a08231146103ee578063715018a61461040e5780638d859f3e1461042357600080fd5b806333bc1c5c1161017a5780635097bdef116101495780635097bdef1461036357806351b96d921461037957806355f804b31461038e5780636352211e146103ae57600080fd5b806333bc1c5c146102ed5780633ccfd60b1461030e57806342842e0e146103235780634f6ccce71461034357600080fd5b8063095ea7b3116101b6578063095ea7b31461026c57806318160ddd1461028e57806323b872dd146102ad5780632f745c59146102cd57600080fd5b806301ffc9a7146101dd57806306fdde0314610212578063081812fc14610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611df3565b6105b8565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b50610227610625565b6040516102099190611f21565b34801561024057600080fd5b5061025461024f366004611e71565b6106b7565b6040516001600160a01b039091168152602001610209565b34801561027857600080fd5b5061028c610287366004611dca565b610747565b005b34801561029a57600080fd5b506000545b604051908152602001610209565b3480156102b957600080fd5b5061028c6102c8366004611cdc565b61085f565b3480156102d957600080fd5b5061029f6102e8366004611dca565b61086a565b3480156102f957600080fd5b506007546101fd90600160a01b900460ff1681565b34801561031a57600080fd5b5061028c6109c7565b34801561032f57600080fd5b5061028c61033e366004611cdc565b610a0e565b34801561034f57600080fd5b5061029f61035e366004611e71565b610a29565b34801561036f57600080fd5b5061029f60095481565b34801561038557600080fd5b5061029f600481565b34801561039a57600080fd5b5061028c6103a9366004611e2b565b610a8b565b3480156103ba57600080fd5b506102546103c9366004611e71565b610acc565b3480156103da57600080fd5b5061028c6103e9366004611e71565b610ade565b3480156103fa57600080fd5b5061029f610409366004611c90565b610b99565b34801561041a57600080fd5b5061028c610c2a565b34801561042f57600080fd5b5061029f66f523226980800081565b34801561044a57600080fd5b506007546001600160a01b0316610254565b34801561046857600080fd5b50610227610c5e565b61028c61047f366004611e71565b610c6d565b34801561049057600080fd5b5061028c61049f366004611d90565b610de3565b3480156104b057600080fd5b5061028c6104bf366004611d17565b610ea8565b3480156104d057600080fd5b506102276104df366004611e71565b610ee1565b3480156104f057600080fd5b5061029f60085481565b34801561050657600080fd5b5061028c610faf565b34801561051b57600080fd5b5061028c61052a366004611dca565b610ffa565b34801561053b57600080fd5b506101fd61054a366004611caa565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b34801561058457600080fd5b5061028c610593366004611c90565b611080565b3480156105a457600080fd5b5061028c6105b3366004611e71565b61111b565b60006001600160e01b031982166380ac58cd60e01b14806105e957506001600160e01b03198216635b5e139f60e01b145b8061060457506001600160e01b0319821663780e9d6360e01b145b8061061f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600180546106349061204a565b80601f01602080910402602001604051908101604052809291908181526020018280546106609061204a565b80156106ad5780601f10610682576101008083540402835291602001916106ad565b820191906000526020600020905b81548152906001019060200180831161069057829003601f168201915b5050505050905090565b60006106c4826000541190565b61072b5760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b600061075282610acc565b9050806001600160a01b0316836001600160a01b031614156107c15760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610722565b336001600160a01b03821614806107dd57506107dd813361054a565b61084f5760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610722565b61085a8383836111cf565b505050565b61085a83838361122b565b600061087583610b99565b82106108ce5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610722565b600080549080805b83811015610967576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff16918301919091521561092957805192505b876001600160a01b0316836001600160a01b0316141561095e57868414156109575750935061061f92505050565b6001909301925b506001016108d6565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610722565b6007546001600160a01b031633146109f15760405162461bcd60e51b815260040161072290611f34565b610a0c610a066007546001600160a01b031690565b47611510565b565b61085a83838360405180602001604052806000815250610ea8565b600080548210610a875760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610722565b5090565b6007546001600160a01b03163314610ab55760405162461bcd60e51b815260040161072290611f34565b8051610ac890600a906020840190611b6e565b5050565b6000610ad782611629565b5192915050565b6007546001600160a01b03163314610b085760405162461bcd60e51b815260040161072290611f34565b600854811115610b4d5760405162461bcd60e51b815260206004820152601060248201526f09eeccae44086eae4e4cadce8409ac2f60831b6044820152606401610722565b600054811015610b945760405162461bcd60e51b8152602060048201526012602482015271135d5cdd0810994813dd995c88151bdd185b60721b6044820152606401610722565b600855565b60006001600160a01b038216610c055760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610722565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6007546001600160a01b03163314610c545760405162461bcd60e51b815260040161072290611f34565b610a0c6000611700565b6060600280546106349061204a565b600754600160a01b900460ff16610cc65760405162461bcd60e51b815260206004820152601760248201527f5075626c69632053616c65204e6f7420537461727465640000000000000000006044820152606401610722565b8060085481610cd460005490565b610cde9190611fbc565b1115610d185760405162461bcd60e51b8152602060048201526009602482015268121a5d08131a5b5a5d60ba1b6044820152606401610722565b81600081118015610d2a575060048111155b610d695760405162461bcd60e51b815260206004820152601060248201526f27bb32b91026b0bc102832b9102a3c3760811b6044820152606401610722565b60095483610d7660005490565b610d809190611fbc565b1115610dd957610d978366f5232269808000611fe8565b341015610dd95760405162461bcd60e51b815260206004820152601060248201526f4e6f7420456e6f7567682046756e647360801b6044820152606401610722565b61085a3384611752565b6001600160a01b038216331415610e3c5760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610722565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610eb384848461122b565b610ebf8484848461176c565b610edb5760405162461bcd60e51b815260040161072290611f69565b50505050565b6060610eee826000541190565b610f525760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610722565b6000610f5c61187a565b9050805160001415610f7d5760405180602001604052806000815250610fa8565b80610f8784611889565b604051602001610f98929190611eb5565b6040516020818303038152906040525b9392505050565b6007546001600160a01b03163314610fd95760405162461bcd60e51b815260040161072290611f34565b6007805460ff60a01b198116600160a01b9182900460ff1615909102179055565b6007546001600160a01b031633146110245760405162461bcd60e51b815260040161072290611f34565b806008548161103260005490565b61103c9190611fbc565b11156110765760405162461bcd60e51b8152602060048201526009602482015268121a5d08131a5b5a5d60ba1b6044820152606401610722565b61085a8383611752565b6007546001600160a01b031633146110aa5760405162461bcd60e51b815260040161072290611f34565b6001600160a01b03811661110f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610722565b61111881611700565b50565b6007546001600160a01b031633146111455760405162461bcd60e51b815260040161072290611f34565b60085481111561118a5760405162461bcd60e51b815260206004820152601060248201526f09eeccae44086eae4e4cadce8409ac2f60831b6044820152606401610722565b6000548110156111ca5760405162461bcd60e51b815260206004820152600b60248201526a155b99195c88151bdd185b60aa1b6044820152606401610722565b600955565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061123682611629565b80519091506000906001600160a01b0316336001600160a01b0316148061126d575033611262846106b7565b6001600160a01b0316145b8061127f5750815161127f903361054a565b9050806112e95760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610722565b846001600160a01b031682600001516001600160a01b03161461135d5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610722565b6001600160a01b0384166113c15760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610722565b6113d160008484600001516111cf565b6001600160a01b03858116600090815260046020908152604080832080546001600160801b03198082166001600160801b03928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255888552600390935281842080546001600160e01b031916909117600160a01b4267ffffffffffffffff16021790559086018083529120549091166114c657611479816000541190565b156114c6578251600082815260036020908152604090912080549186015167ffffffffffffffff16600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b804710156115605760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610722565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146115ad576040519150601f19603f3d011682016040523d82523d6000602084013e6115b2565b606091505b505090508061085a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610722565b6040805180820190915260008082526020820152611648826000541190565b6116a75760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b6064820152608401610722565b815b6000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156116f6579392505050565b50600019016116a9565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610ac88282604051806020016040528060008152506119a3565b60006001600160a01b0384163b1561186e57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906117b0903390899088908890600401611ee4565b602060405180830381600087803b1580156117ca57600080fd5b505af19250505080156117fa575060408051601f3d908101601f191682019092526117f791810190611e0f565b60015b611854573d808015611828576040519150601f19603f3d011682016040523d82523d6000602084013e61182d565b606091505b50805161184c5760405162461bcd60e51b815260040161072290611f69565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611872565b5060015b949350505050565b6060600a80546106349061204a565b6060816118ad5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156118d757806118c181612085565b91506118d09050600a83611fd4565b91506118b1565b60008167ffffffffffffffff81111561190057634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561192a576020820181803683370190505b5090505b84156118725761193f600183612007565b915061194c600a866120a0565b611957906030611fbc565b60f81b81838151811061197a57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535061199c600a86611fd4565b945061192e565b61085a83838360016000546001600160a01b038516611a0e5760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610722565b83611a6c5760405162461bcd60e51b815260206004820152602860248201527f455243373231413a207175616e74697479206d75737420626520677265617465604482015267072207468616e20360c41b6064820152608401610722565b6001600160a01b03851660008181526004602090815260408083208054600160801b6001600160801b031982166001600160801b039283168c01831690811782900483168c01909216021790558483526003909152812080546001600160e01b031916909217600160a01b4267ffffffffffffffff16021790915581905b85811015611b655760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48315611b5957611b3d600088848861176c565b611b595760405162461bcd60e51b815260040161072290611f69565b60019182019101611aea565b50600055611509565b828054611b7a9061204a565b90600052602060002090601f016020900481019282611b9c5760008555611be2565b82601f10611bb557805160ff1916838001178555611be2565b82800160010185558215611be2579182015b82811115611be2578251825591602001919060010190611bc7565b50610a879291505b80821115610a875760008155600101611bea565b600067ffffffffffffffff80841115611c1957611c196120e0565b604051601f8501601f19908116603f01168101908282118183101715611c4157611c416120e0565b81604052809350858152868686011115611c5a57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611c8b57600080fd5b919050565b600060208284031215611ca1578081fd5b610fa882611c74565b60008060408385031215611cbc578081fd5b611cc583611c74565b9150611cd360208401611c74565b90509250929050565b600080600060608486031215611cf0578081fd5b611cf984611c74565b9250611d0760208501611c74565b9150604084013590509250925092565b60008060008060808587031215611d2c578081fd5b611d3585611c74565b9350611d4360208601611c74565b925060408501359150606085013567ffffffffffffffff811115611d65578182fd5b8501601f81018713611d75578182fd5b611d8487823560208401611bfe565b91505092959194509250565b60008060408385031215611da2578182fd5b611dab83611c74565b915060208301358015158114611dbf578182fd5b809150509250929050565b60008060408385031215611ddc578182fd5b611de583611c74565b946020939093013593505050565b600060208284031215611e04578081fd5b8135610fa8816120f6565b600060208284031215611e20578081fd5b8151610fa8816120f6565b600060208284031215611e3c578081fd5b813567ffffffffffffffff811115611e52578182fd5b8201601f81018413611e62578182fd5b61187284823560208401611bfe565b600060208284031215611e82578081fd5b5035919050565b60008151808452611ea181602086016020860161201e565b601f01601f19169290920160200192915050565b60008351611ec781846020880161201e565b835190830190611edb81836020880161201e565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611f1790830184611e89565b9695505050505050565b602081526000610fa86020830184611e89565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b60008219821115611fcf57611fcf6120b4565b500190565b600082611fe357611fe36120ca565b500490565b6000816000190483118215151615612002576120026120b4565b500290565b600082821015612019576120196120b4565b500390565b60005b83811015612039578181015183820152602001612021565b83811115610edb5750506000910152565b600181811c9082168061205e57607f821691505b6020821081141561207f57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612099576120996120b4565b5060010190565b6000826120af576120af6120ca565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461111857600080fdfea26469706673582212209ada7a0b99133320016d927dc108837f0b09baa71330626bc0c8cb1b3477348664736f6c63430008040033
[ 12, 5, 19 ]
0xf1F32C8EEb06046d3cc3157B8F9f72B09D84ee5b
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; // Part: ICurveRegistry interface ICurveRegistry { function get_n_coins(address lp) external view returns (uint, uint); function pool_list(uint id) external view returns (address); function get_coins(address pool) external view returns (address[8] memory); function get_gauges(address pool) external view returns (address[10] memory, uint128[10] memory); function get_lp_token(address pool) external view returns (address); function get_pool_from_lp_token(address lp) external view returns (address); } // Part: IERC20Wrapper interface IERC20Wrapper { /// @dev Return the underlying ERC-20 for the given ERC-1155 token id. function getUnderlyingToken(uint id) external view returns (address); /// @dev Return the conversion rate from ERC-1155 to ERC-20, multiplied by 2**112. function getUnderlyingRate(uint id) external view returns (uint); } // Part: ILiquidityGauge interface ILiquidityGauge { function minter() external view returns (address); function crv_token() external view returns (address); function lp_token() external view returns (address); function balanceOf(address addr) external view returns (uint); function deposit(uint value) external; function withdraw(uint value) external; } // Part: ILiquidityGaugeMinter interface ILiquidityGaugeMinter { function mint(address gauge) external; } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/Address /** * @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); } } } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/Context /* * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/IERC165 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/IERC20 /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/ReentrancyGuard /** * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/SafeMath /** * @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; } } // Part: HomoraMath library HomoraMath { using SafeMath for uint; function divCeil(uint lhs, uint rhs) internal pure returns (uint) { return lhs.add(rhs).sub(1) / rhs; } function fmul(uint lhs, uint rhs) internal pure returns (uint) { return lhs.mul(rhs) / (2**112); } function fdiv(uint lhs, uint rhs) internal pure returns (uint) { return lhs.mul(2**112) / rhs; } // implementation from https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0 // original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint x) internal pure returns (uint) { if (x == 0) return 0; uint xx = x; uint 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 uint r1 = x / r; return (r < r1 ? r : r1); } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/ERC165 /** * @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; } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/IERC1155 /** * @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; } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/IERC1155Receiver /** * _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); } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/Initializable /** * @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) { return !Address.isContract(address(this)); } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/SafeERC20 /** * @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"); } } } // Part: Governable contract Governable is Initializable { event SetGovernor(address governor); event SetPendingGovernor(address pendingGovernor); event AcceptGovernor(address governor); address public governor; // The current governor. address public pendingGovernor; // The address pending to become the governor once accepted. bytes32[64] _gap; // reserve space for upgrade modifier onlyGov() { require(msg.sender == governor, 'not the governor'); _; } /// @dev Initialize using msg.sender as the first governor. function __Governable__init() internal initializer { governor = msg.sender; pendingGovernor = address(0); emit SetGovernor(msg.sender); } /// @dev Set the pending governor, which will be the governor once accepted. /// @param _pendingGovernor The address to become the pending governor. function setPendingGovernor(address _pendingGovernor) external onlyGov { pendingGovernor = _pendingGovernor; emit SetPendingGovernor(_pendingGovernor); } /// @dev Accept to become the new governor. Must be called by the pending governor. function acceptGovernor() external { require(msg.sender == pendingGovernor, 'not the pending governor'); pendingGovernor = address(0); governor = msg.sender; emit AcceptGovernor(msg.sender); } } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/IERC1155MetadataURI /** * @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); } // Part: OpenZeppelin/openzeppelin-contracts@3.4.0/ERC1155 /** * * @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 SafeMath for uint256; 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; /* * bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58e * bytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4 * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432a * bytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 * * => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ * 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 */ bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26; /* * bytes4(keccak256('uri(uint256)')) == 0x0e89341c */ bytes4 private constant _INTERFACE_ID_ERC1155_METADATA_URI = 0x0e89341c; /** * @dev See {_setURI}. */ constructor (string memory uri_) public { _setURI(uri_); // register the supported interfaces to conform to ERC1155 via ERC165 _registerInterface(_INTERFACE_ID_ERC1155); // register the supported interfaces to conform to ERC1155MetadataURI via ERC165 _registerInterface(_INTERFACE_ID_ERC1155_METADATA_URI); } /** * @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) external 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 { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][from] = _balances[id][from].sub(amount, "ERC1155: insufficient balance for transfer"); _balances[id][to] = _balances[id][to].add(amount); emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, 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(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); 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]; _balances[id][from] = _balances[id][from].sub( amount, "ERC1155: insufficient balance for transfer" ); _balances[id][to] = _balances[id][to].add(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 `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address account, uint256 id, uint256 amount, bytes memory data) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] = _balances[id][account].add(amount); emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, 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 (uint i = 0; i < ids.length; i++) { _balances[ids[i]][to] = amounts[i].add(_balances[ids[i]][to]); } 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 `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn(address account, uint256 id, uint256 amount) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); _balances[id][account] = _balances[id][account].sub( amount, "ERC1155: burn amount exceeds balance" ); emit TransferSingle(operator, account, 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 account, uint256[] memory ids, uint256[] memory amounts) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint i = 0; i < ids.length; i++) { _balances[ids[i]][account] = _balances[ids[i]][account].sub( amounts[i], "ERC1155: burn amount exceeds balance" ); } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @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(to).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(to).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; } } // File: WLiquidityGauge.sol contract WLiquidityGauge is ERC1155('WLiquidityGauge'), ReentrancyGuard, IERC20Wrapper, Governable { using SafeMath for uint; using HomoraMath for uint; using SafeERC20 for IERC20; struct GaugeInfo { ILiquidityGauge impl; // Gauge implementation uint accCrvPerShare; // Accumulated CRV per share } ICurveRegistry public immutable registry; // Curve registry IERC20 public immutable crv; // CRV token mapping(uint => mapping(uint => GaugeInfo)) public gauges; // Mapping from pool id to (mapping from gauge id to GaugeInfo) constructor(ICurveRegistry _registry, IERC20 _crv) public { __Governable__init(); registry = _registry; crv = _crv; } /// @dev Encode pid, gid, crvPerShare to a ERC1155 token id /// @param pid Curve pool id (10-bit) /// @param gid Curve gauge id (6-bit) /// @param crvPerShare CRV amount per share, multiplied by 1e18 (240-bit) function encodeId( uint pid, uint gid, uint crvPerShare ) public pure returns (uint) { require(pid < (1 << 10), 'bad pid'); require(gid < (1 << 6), 'bad gid'); require(crvPerShare < (1 << 240), 'bad crv per share'); return (pid << 246) | (gid << 240) | crvPerShare; } /// @dev Decode ERC1155 token id to pid, gid, crvPerShare /// @param id Token id to decode function decodeId(uint id) public pure returns ( uint pid, uint gid, uint crvPerShare ) { pid = id >> 246; // First 10 bits gid = (id >> 240) & (63); // Next 6 bits crvPerShare = id & ((1 << 240) - 1); // Last 240 bits } /// @dev Get underlying ERC20 token of ERC1155 given pid, gid /// @param pid pool id /// @param gid gauge id function getUnderlyingTokenFromIds(uint pid, uint gid) public view returns (address) { ILiquidityGauge impl = gauges[pid][gid].impl; require(address(impl) != address(0), 'no gauge'); return impl.lp_token(); } /// @dev Get underlying ERC20 token of ERC1155 given token id /// @param id Token id function getUnderlyingToken(uint id) external view override returns (address) { (uint pid, uint gid, ) = decodeId(id); return getUnderlyingTokenFromIds(pid, gid); } /// @dev Return the conversion rate from ERC-1155 to ERC-20, multiplied by 2**112. function getUnderlyingRate(uint) external view override returns (uint) { return 2**112; } /// @dev Register curve gauge to storage given pool id and gauge id /// @param pid Pool id /// @param gid Gauge id function registerGauge(uint pid, uint gid) external onlyGov { require(address(gauges[pid][gid].impl) == address(0), 'gauge already exists'); address pool = registry.pool_list(pid); require(pool != address(0), 'no pool'); (address[10] memory _gauges, ) = registry.get_gauges(pool); address gauge = _gauges[gid]; require(gauge != address(0), 'no gauge'); IERC20 lpToken = IERC20(ILiquidityGauge(gauge).lp_token()); lpToken.approve(gauge, 0); lpToken.approve(gauge, uint(-1)); gauges[pid][gid] = GaugeInfo({impl: ILiquidityGauge(gauge), accCrvPerShare: 0}); } /// @dev Mint ERC1155 token for the given ERC20 token /// @param pid Pool id /// @param gid Gauge id /// @param amount Token amount to wrap function mint( uint pid, uint gid, uint amount ) external nonReentrant returns (uint) { GaugeInfo storage gauge = gauges[pid][gid]; ILiquidityGauge impl = gauge.impl; require(address(impl) != address(0), 'gauge not registered'); mintCrv(gauge); IERC20 lpToken = IERC20(impl.lp_token()); lpToken.safeTransferFrom(msg.sender, address(this), amount); impl.deposit(amount); uint id = encodeId(pid, gid, gauge.accCrvPerShare); _mint(msg.sender, id, amount, ''); return id; } /// @dev Burn ERC1155 token to redeem ERC20 token back /// @param id Token id to burn /// @param amount Token amount to burn function burn(uint id, uint amount) external nonReentrant returns (uint) { if (amount == uint(-1)) { amount = balanceOf(msg.sender, id); } (uint pid, uint gid, uint stCrvPerShare) = decodeId(id); _burn(msg.sender, id, amount); GaugeInfo storage gauge = gauges[pid][gid]; ILiquidityGauge impl = gauge.impl; require(address(impl) != address(0), 'gauge not registered'); mintCrv(gauge); impl.withdraw(amount); IERC20(impl.lp_token()).safeTransfer(msg.sender, amount); uint stCrv = stCrvPerShare.mul(amount).divCeil(1e18); uint enCrv = gauge.accCrvPerShare.mul(amount).div(1e18); if (enCrv > stCrv) { crv.safeTransfer(msg.sender, enCrv.sub(stCrv)); } return pid; } /// @dev Mint CRV reward for curve gauge /// @param gauge Curve gauge to mint reward function mintCrv(GaugeInfo storage gauge) internal { ILiquidityGauge impl = gauge.impl; uint balanceBefore = crv.balanceOf(address(this)); ILiquidityGaugeMinter(impl.minter()).mint(address(impl)); uint balanceAfter = crv.balanceOf(address(this)); uint gain = balanceAfter.sub(balanceBefore); uint supply = impl.balanceOf(address(this)); if (gain > 0 && supply > 0) { gauge.accCrvPerShare = gauge.accCrvPerShare.add(gain.mul(1e18).div(supply)); } } }
0x608060405234801561001057600080fd5b506004361061014c5760003560e01c80637b103999116100c3578063dc20c6fa1161007c578063dc20c6fa1461072f578063e3056a341461076a578063e58bb63914610772578063e985e9c51461077a578063f235757f146107a8578063f242432a146107ce5761014c565b80637b10399914610679578063a22cb46514610681578063a4775772146106af578063a9b4e6fe146106cc578063af8002df146106ef578063b390c0ab1461070c5761014c565b80631175e077116101155780631175e077146102a95780632eb2c2d6146102ce5780634548ff841461048f5780634e1273f4146104b85780635a1994c41461062b5780636a4874a1146106715761014c565b8062fdd58e1461015157806301ffc9a71461018f57806302acc94b146101ca5780630c340a24146101f35780630e89341c14610217575b600080fd5b61017d6004803603604081101561016757600080fd5b506001600160a01b038135169060200135610897565b60408051918252519081900360200190f35b6101b6600480360360208110156101a557600080fd5b50356001600160e01b031916610909565b604080519115158252519081900360200190f35b61017d600480360360608110156101e057600080fd5b5080359060208101359060400135610928565b6101fb610b17565b604080516001600160a01b039092168252519081900360200190f35b6102346004803603602081101561022d57600080fd5b5035610b2c565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561026e578181015183820152602001610256565b50505050905090810190601f16801561029b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102cc600480360360408110156102bf57600080fd5b5080359060200135610bc4565b005b6102cc600480360360a08110156102e457600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b81111561031757600080fd5b82018360208201111561032957600080fd5b803590602001918460208302840111600160201b8311171561034a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561039957600080fd5b8201836020820111156103ab57600080fd5b803590602001918460208302840111600160201b831117156103cc57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561041b57600080fd5b82018360208201111561042d57600080fd5b803590602001918460018302840111600160201b8311171561044e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611030945050505050565b61017d600480360360608110156104a557600080fd5b508035906020810135906040013561132e565b6105db600480360360408110156104ce57600080fd5b810190602081018135600160201b8111156104e857600080fd5b8201836020820111156104fa57600080fd5b803590602001918460208302840111600160201b8311171561051b57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561056a57600080fd5b82018360208201111561057c57600080fd5b803590602001918460208302840111600160201b8311171561059d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611411945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156106175781810151838201526020016105ff565b505050509050019250505060405180910390f35b61064e6004803603604081101561064157600080fd5b50803590602001356114fd565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6101fb61152d565b6101fb611551565b6102cc6004803603604081101561069757600080fd5b506001600160a01b0381351690602001351515611575565b6101fb600480360360208110156106c557600080fd5b5035611664565b6101fb600480360360408110156106e257600080fd5b5080359060200135611689565b61017d6004803603602081101561070557600080fd5b5035611756565b61017d6004803603604081101561072257600080fd5b508035906020013561175f565b61074c6004803603602081101561074557600080fd5b50356119e9565b60408051938452602084019290925282820152519081900360600190f35b6101fb611a04565b6102cc611a13565b6101b66004803603604081101561079057600080fd5b506001600160a01b0381358116916020013516611ad5565b6102cc600480360360208110156107be57600080fd5b50356001600160a01b0316611b03565b6102cc600480360360a08110156107e457600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b81111561082357600080fd5b82018360208201111561083557600080fd5b803590602001918460018302840111600160201b8311171561085657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611baf945050505050565b60006001600160a01b0383166108de5760405162461bcd60e51b815260040180806020018281038252602b815260200180612d1a602b913960400191505060405180910390fd5b5060008181526001602090815260408083206001600160a01b03861684529091529020545b92915050565b6001600160e01b03191660009081526020819052604090205460ff1690565b600060026004541415610982576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026004556000848152604760209081526040808320868452909152902080546001600160a01b0316806109f4576040805162461bcd60e51b815260206004820152601460248201527319d85d59d9481b9bdd081c9959da5cdd195c995960621b604482015290519081900360640190fd5b6109fd82611d80565b6000816001600160a01b03166382c630666040518163ffffffff1660e01b815260040160206040518083038186803b158015610a3857600080fd5b505afa158015610a4c573d6000803e3d6000fd5b505050506040513d6020811015610a6257600080fd5b50519050610a7b6001600160a01b03821633308861205e565b816001600160a01b031663b6b55f25866040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610ac157600080fd5b505af1158015610ad5573d6000803e3d6000fd5b505050506000610aea8888866001015461132e565b9050610b07338288604051806020016040528060008152506120be565b6001600455979650505050505050565b6005546201000090046001600160a01b031681565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610bb85780601f10610b8d57610100808354040283529160200191610bb8565b820191906000526020600020905b815481529060010190602001808311610b9b57829003601f168201915b50505050509050919050565b6005546201000090046001600160a01b03163314610c1c576040805162461bcd60e51b815260206004820152601060248201526f3737ba103a34329033b7bb32b93737b960811b604482015290519081900360640190fd5b60008281526047602090815260408083208484529091529020546001600160a01b031615610c88576040805162461bcd60e51b8152602060048201526014602482015273676175676520616c72656164792065786973747360601b604482015290519081900360640190fd5b60007f0000000000000000000000007d86446ddb609ed0f5f8684acf30380a356b2b4c6001600160a01b0316633a1d5d8e846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610cee57600080fd5b505afa158015610d02573d6000803e3d6000fd5b505050506040513d6020811015610d1857600080fd5b505190506001600160a01b038116610d61576040805162461bcd60e51b81526020600482015260076024820152661b9bc81c1bdbdb60ca1b604482015290519081900360640190fd5b610d69612bf3565b7f0000000000000000000000007d86446ddb609ed0f5f8684acf30380a356b2b4c6001600160a01b03166356059ffb836040518263ffffffff1660e01b815260040180826001600160a01b031681526020019150506102806040518083038186803b158015610dd757600080fd5b505afa158015610deb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610280811015610e1157600080fd5b50905060008184600a8110610e2257fe5b602002015190506001600160a01b038116610e6f576040805162461bcd60e51b81526020600482015260086024820152676e6f20676175676560c01b604482015290519081900360640190fd5b6000816001600160a01b03166382c630666040518163ffffffff1660e01b815260040160206040518083038186803b158015610eaa57600080fd5b505afa158015610ebe573d6000803e3d6000fd5b505050506040513d6020811015610ed457600080fd5b50516040805163095ea7b360e01b81526001600160a01b038581166004830152600060248301819052925193945084169263095ea7b392604480840193602093929083900390910190829087803b158015610f2e57600080fd5b505af1158015610f42573d6000803e3d6000fd5b505050506040513d6020811015610f5857600080fd5b50506040805163095ea7b360e01b81526001600160a01b038481166004830152600019602483015291519183169163095ea7b3916044808201926020929091908290030181600087803b158015610fae57600080fd5b505af1158015610fc2573d6000803e3d6000fd5b505050506040513d6020811015610fd857600080fd5b50506040805180820182526001600160a01b0393841681526000602080830182815299825260478152838220988252979097529520945185546001600160a01b03191692169190911784555050915160019091015550565b81518351146110705760405162461bcd60e51b8152600401808060200182810382526028815260200180612ed36028913960400191505060405180910390fd5b6001600160a01b0384166110b55760405162461bcd60e51b8152600401808060200182810382526025815260200180612d926025913960400191505060405180910390fd5b6110bd6121c6565b6001600160a01b0316856001600160a01b031614806110e857506110e8856110e36121c6565b611ad5565b6111235760405162461bcd60e51b8152600401808060200182810382526032815260200180612db76032913960400191505060405180910390fd5b600061112d6121c6565b905061113d818787878787611326565b60005b845181101561123e57600085828151811061115757fe5b60200260200101519050600085838151811061116f57fe5b602002602001015190506111dc816040518060600160405280602a8152602001612e0c602a91396001600086815260200190815260200160002060008d6001600160a01b03166001600160a01b03168152602001908152602001600020546121cb9092919063ffffffff16565b60008381526001602090815260408083206001600160a01b038e811685529252808320939093558a16815220546112139082612262565b60009283526001602081815260408086206001600160a01b038d168752909152909320555001611140565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156112c45781810151838201526020016112ac565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156113035781810151838201526020016112eb565b5050505090500194505050505060405180910390a46113268187878787876122bc565b505050505050565b60006104008410611370576040805162461bcd60e51b8152602060048201526007602482015266189859081c1a5960ca1b604482015290519081900360640190fd5b604083106113af576040805162461bcd60e51b81526020600482015260076024820152661898590819da5960ca1b604482015290519081900360640190fd5b600160f01b82106113fb576040805162461bcd60e51b8152602060048201526011602482015270626164206372762070657220736861726560781b604482015290519081900360640190fd5b5060f683901b60f083901b1781175b9392505050565b606081518351146114535760405162461bcd60e51b8152600401808060200182810382526029815260200180612eaa6029913960400191505060405180910390fd5b6060835167ffffffffffffffff8111801561146d57600080fd5b50604051908082528060200260200182016040528015611497578160200160208202803683370190505b50905060005b84518110156114f5576114d68582815181106114b557fe5b60200260200101518583815181106114c957fe5b6020026020010151610897565b8282815181106114e257fe5b602090810291909101015260010161149d565b509392505050565b6047602090815260009283526040808420909152908252902080546001909101546001600160a01b039091169082565b7f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5281565b7f0000000000000000000000007d86446ddb609ed0f5f8684acf30380a356b2b4c81565b816001600160a01b03166115876121c6565b6001600160a01b031614156115cd5760405162461bcd60e51b8152600401808060200182810382526029815260200180612e576029913960400191505060405180910390fd5b80600260006115da6121c6565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561161e6121c6565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6000806000611672846119e9565b50915091506116818282611689565b949350505050565b60008281526047602090815260408083208484529091528120546001600160a01b0316806116e9576040805162461bcd60e51b81526020600482015260086024820152676e6f20676175676560c01b604482015290519081900360640190fd5b806001600160a01b03166382c630666040518163ffffffff1660e01b815260040160206040518083038186803b15801561172257600080fd5b505afa158015611736573d6000803e3d6000fd5b505050506040513d602081101561174c57600080fd5b5051949350505050565b50600160701b90565b6000600260045414156117b9576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026004556000198214156117d5576117d23384610897565b91505b60008060006117e3866119e9565b9250925092506117f433878761253b565b6000838152604760209081526040808320858452909152902080546001600160a01b031680611861576040805162461bcd60e51b815260206004820152601460248201527319d85d59d9481b9bdd081c9959da5cdd195c995960621b604482015290519081900360640190fd5b61186a82611d80565b806001600160a01b0316632e1a7d4d886040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156118b057600080fd5b505af11580156118c4573d6000803e3d6000fd5b505050506119423388836001600160a01b03166382c630666040518163ffffffff1660e01b815260040160206040518083038186803b15801561190657600080fd5b505afa15801561191a573d6000803e3d6000fd5b505050506040513d602081101561193057600080fd5b50516001600160a01b0316919061266e565b6000611960670de0b6b3a764000061195a868b6126c5565b9061271e565b9050600061198d670de0b6b3a76400006119878b87600101546126c590919063ffffffff16565b90612745565b9050818111156119d6576119d6336119a583856127a4565b6001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5216919061266e565b5050600160045550929695505050505050565b60f681901c91603f60f083901c16916001600160f01b031690565b6006546001600160a01b031681565b6006546001600160a01b03163314611a72576040805162461bcd60e51b815260206004820152601860248201527f6e6f74207468652070656e64696e6720676f7665726e6f720000000000000000604482015290519081900360640190fd5b600680546001600160a01b03191690556005805462010000600160b01b031916336201000081029190911790915560408051918252517fd345d81ce68c70b119a17eee79dc1421700bd9cb21ca148a62dc90983964e82f916020908290030190a1565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205460ff1690565b6005546201000090046001600160a01b03163314611b5b576040805162461bcd60e51b815260206004820152601060248201526f3737ba103a34329033b7bb32b93737b960811b604482015290519081900360640190fd5b600680546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f964dea888b00b2ab53f13dfe7ca334b46e99338c222ae232d98547a1da019f609181900360200190a150565b6001600160a01b038416611bf45760405162461bcd60e51b8152600401808060200182810382526025815260200180612d926025913960400191505060405180910390fd5b611bfc6121c6565b6001600160a01b0316856001600160a01b03161480611c225750611c22856110e36121c6565b611c5d5760405162461bcd60e51b8152600401808060200182810382526029815260200180612d696029913960400191505060405180910390fd5b6000611c676121c6565b9050611c87818787611c7888612801565b611c8188612801565b87611326565b611cce836040518060600160405280602a8152602001612e0c602a913960008781526001602090815260408083206001600160a01b038d16845290915290205491906121cb565b60008581526001602090815260408083206001600160a01b038b81168552925280832093909355871681522054611d059084612262565b60008581526001602090815260408083206001600160a01b03808b168086529184529382902094909455805188815291820187905280518a8416938616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a4611326818787878787612845565b3b151590565b8054604080516370a0823160e01b815230600482015290516001600160a01b03928316926000927f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52909116916370a0823191602480820192602092909190829003018186803b158015611df257600080fd5b505afa158015611e06573d6000803e3d6000fd5b505050506040513d6020811015611e1c57600080fd5b5051604080516303aa30b960e11b815290519192506001600160a01b03841691630754617291600480820192602092909190829003018186803b158015611e6257600080fd5b505afa158015611e76573d6000803e3d6000fd5b505050506040513d6020811015611e8c57600080fd5b5051604080516335313c2160e11b81526001600160a01b03858116600483015291519190921691636a62784291602480830192600092919082900301818387803b158015611ed957600080fd5b505af1158015611eed573d6000803e3d6000fd5b5050505060007f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd526001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015611f6057600080fd5b505afa158015611f74573d6000803e3d6000fd5b505050506040513d6020811015611f8a57600080fd5b505190506000611f9a82846127a4565b90506000846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015611feb57600080fd5b505afa158015611fff573d6000803e3d6000fd5b505050506040513d602081101561201557600080fd5b5051905081158015906120285750600081115b15611326576120516120468261198785670de0b6b3a76400006126c5565b600188015490612262565b6001870155505050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526120b89085906129b6565b50505050565b6001600160a01b0384166121035760405162461bcd60e51b8152600401808060200182810382526021815260200180612efb6021913960400191505060405180910390fd5b600061210d6121c6565b905061211f81600087611c7888612801565b60008481526001602090815260408083206001600160a01b038916845290915290205461214c9084612262565b60008581526001602090815260408083206001600160a01b03808b16808652918452828520959095558151898152928301889052815190948616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a46121bf81600087878787612845565b5050505050565b335b90565b6000818484111561225a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561221f578181015183820152602001612207565b50505050905090810190601f16801561224c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008282018381101561140a576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6122ce846001600160a01b0316611d7a565b1561132657836001600160a01b031663bc197c8187878686866040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b03168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561235c578181015183820152602001612344565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561239b578181015183820152602001612383565b50505050905001848103825285818151815260200191508051906020019080838360005b838110156123d75781810151838201526020016123bf565b50505050905090810190601f1680156124045780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b15801561242957600080fd5b505af192505050801561244e57506040513d602081101561244957600080fd5b505160015b6124e35761245a612c18565b8061246557506124ac565b60405162461bcd60e51b815260206004820181815283516024840152835184939192839260440191908501908083836000831561221f578181015183820152602001612207565b60405162461bcd60e51b8152600401808060200182810382526034815260200180612cbe6034913960400191505060405180910390fd5b6001600160e01b0319811663bc197c8160e01b146125325760405162461bcd60e51b8152600401808060200182810382526028815260200180612cf26028913960400191505060405180910390fd5b50505050505050565b6001600160a01b0383166125805760405162461bcd60e51b8152600401808060200182810382526023815260200180612de96023913960400191505060405180910390fd5b600061258a6121c6565b90506125ba8185600061259c87612801565b6125a587612801565b60405180602001604052806000815250611326565b61260182604051806060016040528060248152602001612d456024913960008681526001602090815260408083206001600160a01b038b16845290915290205491906121cb565b60008481526001602090815260408083206001600160a01b03808a16808652918452828520959095558151888152928301879052815193949093908616927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292908290030190a450505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526126c09084906129b6565b505050565b6000826126d457506000610903565b828202828482816126e157fe5b041461140a5760405162461bcd60e51b8152600401808060200182810382526021815260200180612e366021913960400191505060405180910390fd5b60008161273660016127308684612262565b906127a4565b8161273d57fe5b049392505050565b600080821161279b576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161273d57fe5b6000828211156127fb576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60408051600180825281830190925260609182919060208083019080368337019050509050828160008151811061283457fe5b602090810291909101015292915050565b612857846001600160a01b0316611d7a565b1561132657836001600160a01b031663f23a6e6187878686866040518663ffffffff1660e01b815260040180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156128e65781810151838201526020016128ce565b50505050905090810190601f1680156129135780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b15801561293657600080fd5b505af192505050801561295b57506040513d602081101561295657600080fd5b505160015b6129675761245a612c18565b6001600160e01b0319811663f23a6e6160e01b146125325760405162461bcd60e51b8152600401808060200182810382526028815260200180612cf26028913960400191505060405180910390fd5b6060612a0b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a679092919063ffffffff16565b8051909150156126c057808060200190516020811015612a2a57600080fd5b50516126c05760405162461bcd60e51b815260040180806020018281038252602a815260200180612e80602a913960400191505060405180910390fd5b6060611681848460008585612a7b85611d7a565b612acc576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310612b0b5780518252601f199092019160209182019101612aec565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612b6d576040519150601f19603f3d011682016040523d82523d6000602084013e612b72565b606091505b5091509150612b82828286612b8d565b979650505050505050565b60608315612b9c57508161140a565b825115612bac5782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561221f578181015183820152602001612207565b604051806101400160405280600a906020820280368337509192915050565b60e01c90565b600060443d1015612c28576121c8565b600481823e6308c379a0612c3c8251612c12565b14612c46576121c8565b6040513d600319016004823e80513d67ffffffffffffffff8160248401118184111715612c7657505050506121c8565b82840192508251915080821115612c9057505050506121c8565b503d83016020828401011115612ca8575050506121c8565b601f01601f191681016020016040529150509056fe455243313135353a207472616e7366657220746f206e6f6e2045524331313535526563656976657220696d706c656d656e746572455243313135353a204552433131353552656365697665722072656a656374656420746f6b656e73455243313135353a2062616c616e636520717565727920666f7220746865207a65726f2061646472657373455243313135353a206275726e20616d6f756e7420657863656564732062616c616e6365455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243313135353a207472616e7366657220746f20746865207a65726f2061646472657373455243313135353a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564455243313135353a206275726e2066726f6d20746865207a65726f2061646472657373455243313135353a20696e73756666696369656e742062616c616e636520666f72207472616e73666572536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77455243313135353a2073657474696e6720617070726f76616c2073746174757320666f722073656c665361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564455243313135353a206163636f756e747320616e6420696473206c656e677468206d69736d61746368455243313135353a2069647320616e6420616d6f756e7473206c656e677468206d69736d61746368455243313135353a206d696e7420746f20746865207a65726f2061646472657373a26469706673582212205e45458cec935e420cd0ebba55793bda9b7ae42e58b70635f12c3d819a788d1e64736f6c634300060c0033
[ 5, 7, 12 ]
0xf1f34f0019700e9662749cf79f4d144fe6525a94
pragma solidity ^0.4.18; 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; } 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(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } } contract ERC20Basic { uint256 public totalSupply; bool public transfersEnabled; 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); } contract ERC20 { uint256 public totalSupply; bool public transfersEnabled; function balanceOf(address _owner) public constant returns (uint256 balance); 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 constant returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev protection against short address attack */ modifier onlyPayloadSize(uint numwords) { assert(msg.data.length == numwords * 32 + 4); _; } /** * @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 onlyPayloadSize(2) returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); require(transfersEnabled); // 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]; } } contract StandardToken is ERC20, BasicToken { mapping(address => mapping(address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(3) returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); require(transfersEnabled); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); 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 onlyPayloadSize(2) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval(address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } contract HashProject is StandardToken { string public constant name = "Hash Project"; string public constant symbol = "HSH"; uint8 public constant decimals = 18; uint256 public constant INITIAL_SUPPLY = 800 * 10**6 * (10**uint256(decimals)); uint256 public weiRaised; uint256 public tokenAllocated; address public owner; bool public saleToken = true; event OwnerChanged(address indexed previousOwner, address indexed newOwner); event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount); event TokenLimitReached(uint256 tokenRaised, uint256 purchasedToken); event Transfer(address indexed _from, address indexed _to, uint256 _value); function HashProject(address _owner) public { totalSupply = INITIAL_SUPPLY; owner = _owner; //owner = msg.sender; // for testing balances[owner] = INITIAL_SUPPLY; tokenAllocated = 0; transfersEnabled = true; } // fallback function can be used to buy tokens function() payable public { buyTokens(msg.sender); } function buyTokens(address _investor) public payable returns (uint256){ require(_investor != address(0)); require(saleToken == true); address wallet = owner; uint256 weiAmount = msg.value; uint256 tokens = validPurchaseTokens(weiAmount); if (tokens == 0) {revert();} weiRaised = weiRaised.add(weiAmount); tokenAllocated = tokenAllocated.add(tokens); mint(_investor, tokens, owner); TokenPurchase(_investor, weiAmount, tokens); wallet.transfer(weiAmount); return tokens; } function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) { uint256 addTokens = getTotalAmountOfTokens(_weiAmount); if (addTokens > balances[owner]) { TokenLimitReached(tokenAllocated, addTokens); return 0; } return addTokens; } /** Token Distribution */ function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) { uint256 amountOfTokens = 0; if( _weiAmount == 0.005 ether){ amountOfTokens = 20 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.01 ether){ amountOfTokens = 40 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.05 ether){ amountOfTokens = 200 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.1 ether){ amountOfTokens = 600 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 0.5 ether){ amountOfTokens = 2000 * 10**3 * (10**uint256(decimals)); } if( _weiAmount == 1 ether){ amountOfTokens = 8000 * 10**3 * (10**uint256(decimals)); } return amountOfTokens; } function mint(address _to, uint256 _amount, address _owner) internal returns (bool) { require(_to != address(0)); require(_amount <= balances[_owner]); balances[_to] = balances[_to].add(_amount); balances[_owner] = balances[_owner].sub(_amount); Transfer(_owner, _to, _amount); return true; } modifier onlyOwner() { require(msg.sender == owner); _; } function changeOwner(address _newOwner) onlyOwner public returns (bool){ require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; return true; } function startSale() public onlyOwner { saleToken = true; } function stopSale() public onlyOwner { saleToken = false; } function enableTransfers(bool _transfersEnabled) onlyOwner public { transfersEnabled = _transfersEnabled; } /** * Peterson's Law Protection * Claim tokens */ function claimTokens() public onlyOwner { owner.transfer(this.balance); uint256 balance = balanceOf(this); transfer(owner, balance); Transfer(this, owner, balance); } }
0x60806040526004361061013d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610149578063095ea7b3146101d357806318160ddd1461020b57806323b872dd146102325780632ff2e9dc1461025c578063313ce567146102715780634042b66f1461029c57806348c54b9d146102b157806366188463146102c857806370a08231146102ec57806378f7aeee1461030d5780638da5cb5b1461032257806395d89b4114610353578063a6f9dae114610368578063a9059cbb14610389578063b66a0e5d146103ad578063bef97c87146103c2578063d73dd623146103d7578063dd62ed3e146103fb578063e36b0b3714610422578063e985e36714610437578063ec8ac4d81461044c578063f41e60c514610460578063fc38ce191461047a575b61014633610492565b50005b34801561015557600080fd5b5061015e6105c8565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610198578181015183820152602001610180565b50505050905090810190601f1680156101c55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101df57600080fd5b506101f7600160a060020a03600435166024356105ff565b604080519115158252519081900360200190f35b34801561021757600080fd5b50610220610665565b60408051918252519081900360200190f35b34801561023e57600080fd5b506101f7600160a060020a036004358116906024351660443561066b565b34801561026857600080fd5b506102206107f0565b34801561027d57600080fd5b50610286610800565b6040805160ff9092168252519081900360200190f35b3480156102a857600080fd5b50610220610805565b3480156102bd57600080fd5b506102c661080b565b005b3480156102d457600080fd5b506101f7600160a060020a03600435166024356108b9565b3480156102f857600080fd5b50610220600160a060020a03600435166109a9565b34801561031957600080fd5b506102206109c4565b34801561032e57600080fd5b506103376109ca565b60408051600160a060020a039092168252519081900360200190f35b34801561035f57600080fd5b5061015e6109d9565b34801561037457600080fd5b506101f7600160a060020a0360043516610a10565b34801561039557600080fd5b506101f7600160a060020a0360043516602435610aab565b3480156103b957600080fd5b506102c6610b9a565b3480156103ce57600080fd5b506101f7610be8565b3480156103e357600080fd5b506101f7600160a060020a0360043516602435610bf1565b34801561040757600080fd5b50610220600160a060020a0360043581169060243516610c8a565b34801561042e57600080fd5b506102c6610cc5565b34801561044357600080fd5b506101f7610cfc565b610220600160a060020a0360043516610492565b34801561046c57600080fd5b506102c66004351515610d1d565b34801561048657600080fd5b50610220600435610d47565b6000808080600160a060020a03851615156104ac57600080fd5b60085474010000000000000000000000000000000000000000900460ff1615156001146104d857600080fd5b600854600160a060020a031692503491506104f282610d47565b905080151561050057600080fd5b600654610513908363ffffffff610dc816565b600655600754610529908263ffffffff610dc816565b6007556008546105459086908390600160a060020a0316610dde565b5060408051838152602081018390528151600160a060020a038816927fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f928290030190a2604051600160a060020a0384169083156108fc029084906000818181858888f193505050501580156105bf573d6000803e3d6000fd5b50949350505050565b60408051808201909152600c81527f486173682050726f6a6563740000000000000000000000000000000000000000602082015281565b336000818152600560209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60025481565b600060033660641461067957fe5b600160a060020a038416151561068e57600080fd5b600160a060020a0385166000908152600460205260409020548311156106b357600080fd5b600160a060020a03851660009081526005602090815260408083203384529091529020548311156106e357600080fd5b60035460ff1615156106f457600080fd5b600160a060020a03851660009081526004602052604090205461071d908463ffffffff610ec916565b600160a060020a038087166000908152600460205260408082209390935590861681522054610752908463ffffffff610dc816565b600160a060020a038086166000908152600460209081526040808320949094559188168152600582528281203382529091522054610796908463ffffffff610ec916565b600160a060020a0380871660008181526005602090815260408083203384528252918290209490945580518781529051928816939192600080516020610f91833981519152929181900390910190a3506001949350505050565b6b0295be96e64066972000000081565b601281565b60065481565b600854600090600160a060020a0316331461082557600080fd5b600854604051600160a060020a0390911690303180156108fc02916000818181858888f1935050505015801561085f573d6000803e3d6000fd5b50610869306109a9565b60085490915061088290600160a060020a031682610aab565b50600854604080518381529051600160a060020a03909216913091600080516020610f91833981519152919081900360200190a350565b336000908152600560209081526040808320600160a060020a03861684529091528120548083111561090e57336000908152600560209081526040808320600160a060020a0388168452909152812055610943565b61091e818463ffffffff610ec916565b336000908152600560209081526040808320600160a060020a03891684529091529020555b336000818152600560209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526004602052604090205490565b60075481565b600854600160a060020a031681565b60408051808201909152600381527f4853480000000000000000000000000000000000000000000000000000000000602082015281565b600854600090600160a060020a03163314610a2a57600080fd5b600160a060020a0382161515610a3f57600080fd5b600854604051600160a060020a038085169216907fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c90600090a35060088054600160a060020a03831673ffffffffffffffffffffffffffffffffffffffff199091161790556001919050565b6000600236604414610ab957fe5b600160a060020a0384161515610ace57600080fd5b33600090815260046020526040902054831115610aea57600080fd5b60035460ff161515610afb57600080fd5b33600090815260046020526040902054610b1b908463ffffffff610ec916565b3360009081526004602052604080822092909255600160a060020a03861681522054610b4d908463ffffffff610dc816565b600160a060020a038516600081815260046020908152604091829020939093558051868152905191923392600080516020610f918339815191529281900390910190a35060019392505050565b600854600160a060020a03163314610bb157600080fd5b6008805474ff0000000000000000000000000000000000000000191674010000000000000000000000000000000000000000179055565b60035460ff1681565b336000908152600560209081526040808320600160a060020a0386168452909152812054610c25908363ffffffff610dc816565b336000818152600560209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6000600236604414610c9857fe5b5050600160a060020a03918216600090815260056020908152604080832093909416825291909152205490565b600854600160a060020a03163314610cdc57600080fd5b6008805474ff000000000000000000000000000000000000000019169055565b60085474010000000000000000000000000000000000000000900460ff1681565b600854600160a060020a03163314610d3457600080fd5b6003805460ff1916911515919091179055565b600080610d5383610edb565b600854600160a060020a0316600090815260046020526040902054909150811115610dbe57600754604080519182526020820183905280517f77fcbebee5e7fc6abb70669438e18dae65fc2057b32b694851724c2726a35b629281900390910190a160009150610dc2565b8091505b50919050565b600082820183811015610dd757fe5b9392505050565b6000600160a060020a0384161515610df557600080fd5b600160a060020a038216600090815260046020526040902054831115610e1a57600080fd5b600160a060020a038416600090815260046020526040902054610e43908463ffffffff610dc816565b600160a060020a038086166000908152600460205260408082209390935590841681522054610e78908463ffffffff610ec916565b600160a060020a038084166000818152600460209081526040918290209490945580518781529051928816939192600080516020610f91833981519152929181900390910190a35060019392505050565b600082821115610ed557fe5b50900390565b6000806611c37937e08000831415610efa575069043c33c19375648000005b82662386f26fc100001415610f165750690878678326eac90000005b8266b1a2bc2ec500001415610f325750692a5a058fc295ed0000005b8267016345785d8a00001415610f4f5750697f0e10af47c1c70000005b826706f05b59d3b200001415610f6d57506a01a784379d99db420000005b82670de0b6b3a76400001415610dbe57506a069e10de76676d08000000929150505600ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa165627a7a723058206a39509de57a3693974b8aca28d72081a86cee1124bad104782f160d025d4cb70029
[ 38 ]
0xF1F3ca6268f330fDa08418db12171c3173eE39C9
// SPDX-License-Identifier: MIT 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 { require( _msgSender() != operator, "ERC1155: setting approval status for self" ); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not owner nor approved" ); 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" ); _balances[id][from] = fromBalance - amount; _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, 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( ids.length == amounts.length, "ERC1155: ids and amounts length mismatch" ); require(to != address(0), "ERC1155: transfer to the zero address"); require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: transfer caller is not owner nor approved" ); 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" ); _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 `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer( operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data ); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck( operator, address(0), account, 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 `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer( operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), "" ); uint256 accountBalance = _balances[id][account]; require( accountBalance >= amount, "ERC1155: burn amount exceeds balance" ); _balances[id][account] = accountBalance - amount; emit TransferSingle(operator, account, 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 account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require( ids.length == amounts.length, "ERC1155: ids and amounts length mismatch" ); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require( accountBalance >= amount, "ERC1155: burn amount exceeds balance" ); _balances[id][account] = accountBalance - amount; } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @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(to).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(to).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 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 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 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); } // ███████╗░█████╗░██████╗░██████╗░███████╗██████╗░░░░███████╗██╗ // ╚════██║██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔══██╗░░░██╔════╝██║ // ░░███╔═╝███████║██████╔╝██████╔╝█████╗░░██████╔╝░░░█████╗░░██║ // ██╔══╝░░██╔══██║██╔═══╝░██╔═══╝░██╔══╝░░██╔══██╗░░░██╔══╝░░██║ // ███████╗██║░░██║██║░░░░░██║░░░░░███████╗██║░░██║██╗██║░░░░░██║ // ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░░░░╚══════╝╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝ // Copyright (C) 2021 zapper // Copyright (c) 2018 Tasuku Nakamura // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 2 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 Affero General Public License for more details. // ///@author Zapper ///@notice This contract checks if a message has been signed by a verified signer via personal_sign. // SPDX-License-Identifier: GPL-2.0 pragma solidity ^0.8.0; contract SignatureVerifier_V2 { address public signer; constructor(address _signer) { signer = _signer; } function verify(bytes32 messageHash, bytes memory signature) internal view returns (bool) { bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); return recoverSigner(ethSignedMessageHash, signature) == signer; } function getEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32) { return keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", messageHash ) ); } function recoverSigner( bytes32 _ethSignedMessageHash, bytes memory _signature ) internal pure returns (address) { (bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature); return ecrecover(_ethSignedMessageHash, v, r, s); } function splitSignature(bytes memory signature) internal pure returns ( bytes32 r, bytes32 s, uint8 v ) { require(signature.length == 65, "invalid signature length"); assembly { r := mload(add(signature, 32)) s := mload(add(signature, 64)) v := byte(0, mload(add(signature, 96))) } } } // ███████╗░█████╗░██████╗░██████╗░███████╗██████╗░░░░███████╗██╗ // ╚════██║██╔══██╗██╔══██╗██╔══██╗██╔════╝██╔══██╗░░░██╔════╝██║ // ░░███╔═╝███████║██████╔╝██████╔╝█████╗░░██████╔╝░░░█████╗░░██║ // ██╔══╝░░██╔══██║██╔═══╝░██╔═══╝░██╔══╝░░██╔══██╗░░░██╔══╝░░██║ // ███████╗██║░░██║██║░░░░░██║░░░░░███████╗██║░░██║██╗██║░░░░░██║ // ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░░░░╚══════╝╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝ // Copyright (C) 2021 zapper // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 2 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 Affero General Public License for more details. // ///@author Zapper ///@notice This contract manages Zapper V2 NFTs and Volts. /// Volts can be claimed through quests in order to mint various NFTs. /// Crafting combines NFTs of the same type into higher tier NFTs. NFTs /// can also be redemeed for Volts. // SPDX-License-Identifier: GPL-2.0 pragma solidity ^0.8.0; import "./ERC1155/ERC1155.sol"; import "./access/Ownable.sol"; import "./SignatureVerifier/SignatureVerifier_V2.sol"; import "./ERC1155/IERC1155.sol"; import "./utils/Strings.sol"; contract Zapper_NFT_V2_0_1 is ERC1155, Ownable, SignatureVerifier_V2 { // Used in pausable modifier bool public paused; // NFT name string public name; // NFT symbol string public symbol; // Season deadline uint256 public deadline; // Modifier to apply to cost of NFT when redeeming in bps uint256 public redeemModifier = 7500; // Quantity of NFTs consumed per crafting event uint256 public craftingRequirement = 3; // Mapping from token ID to token supply mapping(uint256 => uint256) private tokenSupply; // Mapping of accessory contracts that have permission to mint mapping(address => bool) public accessoryContract; // Total Volt supply uint256 public voltSupply; // Mapping from account to Volt balance mapping(address => uint256) public voltBalance; // Mapping from token ID to token existence mapping(uint256 => bool) private exists; // Mapping for the rarity classes for use in crafting mapping(uint256 => uint256) public nextRarity; // Mapping from token ID to token cost in volts mapping(uint256 => uint256) public cost; // Mapping from account to nonce mapping(address => uint256) public nonces; // Emitted when `account` claims Volts event ClaimVolts( address indexed account, uint256 voltsRecieved, uint256 nonce ); // Emitted when `account` burns Volts event BurnVolts(address indexed account, uint256 voltsBurned); // Emitted when `account` mints one or more NFTs by spending Volts event Mint(address indexed account, uint256 voltsSpent); // Emitted when `account` redeems Volts by burning one or more NFTs event Redeem(address indexed account, uint256 voltsRecieved); // Emitted when `account` crafts one or more of the same NFT event Craft(address indexed account, uint256 craftID); // Emitted when `account` crafts multiple different NFTs event CraftBatch(address indexed account, uint256[] craftIDs); // Emitted when a new NFT type is added event Add(uint256 id, uint256 cost, uint256 nextRarity); // Emitted when the baseURI is updated event updateBaseURI(string uri); modifier pausable { require(!paused, "Paused"); _; } modifier beforeDeadline { require(block.timestamp <= deadline, "Deadline elapsed"); _; } constructor( string memory _name, string memory _symbol, string memory _uri, address signer, address manager, uint256 _deadline ) ERC1155(_uri) SignatureVerifier_V2(signer) { name = _name; symbol = _symbol; deadline = _deadline; transferOwnership(manager); } /** * @dev Adds a new NFT and initializes crafting params * @param costs An array of the cost of each ID. 0 if it cannot * be crafted * @param nextRarities An array of higher rarity IDs which can be * crafted from the ID. 0 if max rarity. */ function add( uint256[] calldata ids, uint256[] calldata costs, uint256[] calldata nextRarities ) external onlyOwner { require( ids.length == costs.length && ids.length == nextRarities.length, "Mismatched array lengths" ); for (uint256 i = 0; i < ids.length; i++) { uint256 newId = ids[i]; require(!exists[newId], "ID already exists"); require(newId != 0, "Invalid ID"); exists[newId] = true; cost[newId] = costs[i]; nextRarity[newId] = nextRarities[i]; emit Add(newId, costs[i], nextRarities[i]); } } /** * @notice Claims Volts earned through quests * @param voltsEarned The quantity of Volts being awarded * @param signature The signature granting msg.sender the volts */ function claimVolts(uint256 voltsEarned, bytes calldata signature) external pausable beforeDeadline { bytes32 messageHash = getMessageHash(msg.sender, voltsEarned, nonces[msg.sender]++); require(verify(messageHash, signature), "Invalid Signature"); _createVolts(voltsEarned); emit ClaimVolts(msg.sender, voltsEarned, nonces[msg.sender]); } /** * @notice Burns Volts * @param voltsBurned The quantity of Volts being burned */ function burnVolts(uint256 voltsBurned) external pausable { _burnVolts(voltsBurned); emit BurnVolts(msg.sender, voltsBurned); } /** * @notice Mints a desired quantity of a single NFT ID * in exchange for Volts * @param id The ID of the NFT to mint * @param quantity The quantity of the NFT to mint */ function mint(uint256 id, uint256 quantity) external pausable { require(exists[id], "Invalid ID"); uint256 voltsSpent; if (!accessoryContract[msg.sender]) { require(cost[id] > 0, "Price not set"); voltsSpent = cost[id] * quantity; _burnVolts(voltsSpent); } _mint(msg.sender, id, quantity, new bytes(0)); emit Mint(msg.sender, voltsSpent); } /** * @notice Batch Mints desired quantities of different NFT IDs * in exchange for Volts * @param ids An array consisting of the IDs of the NFTs to mint * @param quantities An array consisting of the quantities of the NFTs to mint */ function mintBatch(uint256[] calldata ids, uint256[] calldata quantities) external pausable { require(ids.length == quantities.length, "Mismatched array lengths"); uint256 voltsSpent; if (!accessoryContract[msg.sender]) { for (uint256 i = 0; i < ids.length; i++) { require(exists[ids[i]], "Invalid ID"); require(cost[ids[i]] > 0, "Price not set"); voltsSpent += cost[ids[i]] * quantities[i]; } _burnVolts(voltsSpent); } else { for (uint256 i = 0; i < ids.length; i++) { require(exists[ids[i]], "Invalid ID"); } } _mintBatch(msg.sender, ids, quantities, new bytes(0)); emit Mint(msg.sender, voltsSpent); } /** * @notice Burns an NFT * @dev Does not award Volts! * @param id The ID of the NFT to burn * @param quantity The quantity of the NFT to burn */ function burn(uint256 id, uint256 quantity) external pausable { _burn(msg.sender, id, quantity); } /** * @notice Batch burns NFTs * @dev Does not award Volts! * @param ids An array consisting of the IDs of the NFTs to burn * @param quantities An array consisting of the quantities * of each NFT to burn */ function burnBatch(uint256[] calldata ids, uint256[] calldata quantities) external pausable { _burnBatch(msg.sender, ids, quantities); } /** * @notice Redeems an NFT for Volts. Redeeming NFTs is * subject to a modifier which returns some percentage of * the full cost of the NFT * @param id ID of the NFT to redeem * @param quantity The quantity of the NFT being redeemed */ function redeem(uint256 id, uint256 quantity) external pausable { require(cost[id] > 0, "Cannot redeem this type"); _burn(msg.sender, id, quantity); uint256 voltsRecieved = (cost[id] * quantity * redeemModifier) / 10000; _createVolts(voltsRecieved); emit Redeem(msg.sender, voltsRecieved); } /** * @notice Redeems multiple NFTs for Volts. Redeeming NFTs is * subject to a modifier which returns some percentage of * the full cost of the NFT * @param ids An array consisting of the IDs of the NFTs to redeem * @param quantities An array consisting of the quantities of * each NFT to redeem */ function redeemBatch(uint256[] calldata ids, uint256[] calldata quantities) external pausable { _burnBatch(msg.sender, ids, quantities); uint256 voltsRecieved; for (uint256 i = 0; i < ids.length; i++) { require(cost[ids[i]] > 0, "Cannot redeem this type"); voltsRecieved += (cost[ids[i]] * quantities[i] * redeemModifier) / 10000; } _createVolts(voltsRecieved); emit Redeem(msg.sender, voltsRecieved); } /** * @notice Crafts higher tier NFTs with lower tier NFTs * @param id ID of the NFT used for crafting * @param quantity The quantity of id to consume in crafting */ function craft(uint256 id, uint256 quantity) external pausable { uint256 craftID = nextRarity[id]; require(craftID != 0, "Already maximum rarity"); require( quantity % craftingRequirement == 0, "Incorrect quantity for crafting" ); _burn(msg.sender, id, quantity); uint256 craftQuantity = quantity / craftingRequirement; _mint(msg.sender, craftID, craftQuantity, new bytes(0)); emit Craft(msg.sender, craftID); } /** * @notice Crafts multiple different higher tier NFTs with * lower tier NFTs * @param ids An array consisting of the IDs of the NFT used for crafting * @param quantities An array consisting of the quantities of the NFT * to consume in crafting */ function craftBatch(uint256[] calldata ids, uint256[] calldata quantities) external pausable { _burnBatch(msg.sender, ids, quantities); uint256[] memory craftQuantities = new uint256[](quantities.length); uint256[] memory craftIds = new uint256[](ids.length); for (uint256 i = 0; i < ids.length; i++) { uint256 craftID = nextRarity[ids[i]]; require(craftID != 0, "Already maximum rarity"); require( quantities[i] % craftingRequirement == 0, "Incorrect quantity for crafting" ); craftIds[i] = craftID; craftQuantities[i] = quantities[i] / craftingRequirement; } _mintBatch(msg.sender, craftIds, craftQuantities, new bytes(0)); emit CraftBatch(msg.sender, craftIds); } /** * @dev Function to set the URI for all NFT IDs */ function setBaseURI(string calldata _uri) external onlyOwner { _setURI(_uri); emit updateBaseURI(_uri); } /** * @dev Returns the URI of a token given its ID * @param id ID of the token to query * @return uri of the token or an empty string if it does not exist */ function uri(uint256 id) public view override returns (string memory) { require(exists[id], "URI query for nonexistent token"); string memory baseUri = super.uri(0); return string(abi.encodePacked(baseUri, Strings.toString(id))); } /** * @notice Maps the rarity classes and Volt costs * for use in crafting * @param ids An array of the IDs being updated * @param costs An array of the cost of each ID * @param nextRarities An array of higher rarity IDs which * can be crafted from the ID */ function updateCraftingParameters( uint256[] calldata ids, uint256[] calldata costs, uint256[] calldata nextRarities ) external onlyOwner { require( ids.length == costs.length && ids.length == nextRarities.length, "Mismatched array lengths" ); for (uint256 i = 0; i < ids.length; i++) { require(exists[ids[i]], "ID does not exist"); cost[ids[i]] = costs[i]; nextRarity[ids[i]] = nextRarities[i]; } } /** * @dev Updates the modifier which is used when redeeming * NFTs for Volts */ function updateRedeemModifier(uint256 _redeemModifier) external onlyOwner { redeemModifier = _redeemModifier; } /** * @dev Updates the crafting requirement modifier which determines * the quantity of NFTs that are burned in order to craft * higher rarity NFTs */ function updateCraftingRequirement(uint256 _craftingRequirement) external onlyOwner { craftingRequirement = _craftingRequirement; } /** * @dev Updates the mapping of accessory contracts which have * special permssions to mint NFTs (lootbox, bridge, etc.) */ function updateAccessoryContracts(address _accessoryContract, bool allowed) external onlyOwner { accessoryContract[_accessoryContract] = allowed; } /** * @dev Updates the deadline after which Volts can no longer be claimed */ function updateDeadline(uint256 _deadline) external onlyOwner { deadline = _deadline; } /** * @dev Returns the total quantity for a token ID * @param id ID of the token to query * @return amount of token in existence */ function totalSupply(uint256 id) external view returns (uint256) { return tokenSupply[id]; } /** * @dev Pause or unpause the contract */ function pause() external onlyOwner { paused = !paused; } /** * @dev Function to return the message hash that will be * signed by the signer */ function getMessageHash( address account, uint256 volts, uint256 nonce ) public pure returns (bytes32) { return keccak256(abi.encodePacked(account, volts, nonce)); } /** * @dev Internal override function for minting an NFT */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal override { super._mint(account, id, amount, data); tokenSupply[id] += amount; } /** * @dev Internal override function for batch minting NFTs */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal override { super._mintBatch(to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { tokenSupply[ids[i]] += amounts[i]; } } /** * @dev Internal override function for burning an NFT */ function _burn( address account, uint256 id, uint256 amount ) internal override { super._burn(account, id, amount); tokenSupply[id] -= amount; } /** * @dev Internal override function for batch burning NFTs */ function _burnBatch( address account, uint256[] memory ids, uint256[] memory amounts ) internal override { super._burnBatch(account, ids, amounts); for (uint256 i; i < ids.length; i++) { tokenSupply[ids[i]] -= amounts[i]; } } /** * @dev Internal function to create volts */ function _createVolts(uint256 quantity) internal { voltBalance[msg.sender] += quantity; voltSupply += quantity; } /** * @dev Internal function to burn volts */ function _burnVolts(uint256 quantity) internal { require( voltBalance[msg.sender] >= quantity, "Insufficient Volt balance" ); voltBalance[msg.sender] -= quantity; voltSupply -= quantity; } } // 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() { 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; } } // 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; /* * @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; /** * @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); }
0x608060405234801561001057600080fd5b50600436106102735760003560e01c806382f8711711610151578063afad42f6116100c3578063d351cfdc11610087578063d351cfdc14610580578063dab3798e14610593578063e985e9c5146105b6578063f0522590146105f2578063f242432a14610612578063f2fde38b1461062557600080fd5b8063afad42f614610514578063b008a4d014610527578063b390c0ab1461053a578063bd85b0391461054d578063d2b0737b1461056d57600080fd5b80638da5cb5b116101155780638da5cb5b146104a25780639097548d146104b357806395d89b41146104d35780639e57af97146104db5780639fe99370146104ee578063a22cb4651461050157600080fd5b806382f871171461045857806383ca4b6f1461046b5780638456cb591461047e5780638baf7b4d146104865780638c4c407c1461049957600080fd5b80632eb2c2d6116101ea5780635c975abb116101ae5780635c975abb146103ed5780635f56e5c714610401578063649117d31461040a578063715018a61461041d5780637cbc2373146104255780637ecebe001461043857600080fd5b80632eb2c2d61461038b57806342af18841461039e5780634e1273f4146103b1578063503d5f6c146103d157806355f804b3146103da57600080fd5b80631b908dd91161023c5780631b908dd9146102fe578063238ac9331461031157806324d22e871461033c578063263203c51461034f578063289137a11461036f57806329dcb0cf1461038257600080fd5b8062fdd58e1461027857806301ffc9a71461029e57806306fdde03146102c15780630e89341c146102d65780631b2ef1ca146102e9575b600080fd5b61028b6102863660046135e1565b610638565b6040519081526020015b60405180910390f35b6102b16102ac366004613803565b6106cf565b6040519015158152602001610295565b6102c9610721565b6040516102959190613aa4565b6102c96102e436600461387a565b6107af565b6102fc6102f73660046138db565b610850565b005b6102fc61030c36600461376e565b6109a3565b600454610324906001600160a01b031681565b6040516001600160a01b039091168152602001610295565b6102fc61034a36600461387a565b610b67565b61028b61035d36600461344d565b600d6020526000908152604090205481565b6102fc61037d3660046138db565b610b96565b61028b60075481565b6102fc6103993660046134a0565b610cd5565b6102fc6103ac36600461387a565b610f5b565b6103c46103bf36600461363c565b610f8a565b6040516102959190613a34565b61028b60095481565b6102fc6103e836600461383b565b6110eb565b6004546102b190600160a01b900460ff1681565b61028b60085481565b6102fc610418366004613706565b611191565b6102fc6113a2565b6102fc6104333660046138db565b611416565b61028b61044636600461344d565b60116020526000908152604090205481565b6102fc610466366004613892565b611514565b6102fc610479366004613706565b611682565b6102fc611720565b6102fc61049436600461387a565b61176b565b61028b600c5481565b6003546001600160a01b0316610324565b61028b6104c136600461387a565b60106020526000908152604090205481565b6102c96117d6565b6102fc6104e936600461387a565b6117e3565b6102fc6104fc3660046135a7565b611812565b6102fc61050f3660046135a7565b611867565b6102fc610522366004613706565b61193e565b6102fc61053536600461376e565b611cb4565b6102fc6105483660046138db565b611ef4565b61028b61055b36600461387a565b6000908152600a602052604090205490565b61028b61057b36600461360a565b611f2d565b6102fc61058e366004613706565b611f7c565b6102b16105a136600461344d565b600b6020526000908152604090205460ff1681565b6102b16105c436600461346e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b61028b61060036600461387a565b600f6020526000908152604090205481565b6102fc610620366004613545565b612271565b6102fc61063336600461344d565b612418565b60006001600160a01b0383166106a95760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b148061070057506001600160e01b031982166303a24d0760e21b145b8061071b57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6005805461072e90613dff565b80601f016020809104026020016040519081016040528092919081815260200182805461075a90613dff565b80156107a75780601f1061077c576101008083540402835291602001916107a7565b820191906000526020600020905b81548152906001019060200180831161078a57829003601f168201915b505050505081565b6000818152600e602052604090205460609060ff166108105760405162461bcd60e51b815260206004820152601f60248201527f55524920717565727920666f72206e6f6e6578697374656e7420746f6b656e0060448201526064016106a0565b600061081c6000612503565b90508061082884612597565b604051602001610839929190613962565b604051602081830303815290604052915050919050565b600454600160a01b900460ff161561087a5760405162461bcd60e51b81526004016106a090613aff565b6000828152600e602052604090205460ff166108a85760405162461bcd60e51b81526004016106a090613ba8565b336000908152600b602052604081205460ff1661092f5760008381526010602052604090205461090a5760405162461bcd60e51b815260206004820152600d60248201526c141c9a58d9481b9bdd081cd95d609a1b60448201526064016106a0565b600083815260106020526040902054610924908390613d9d565b905061092f816126b8565b61096833848460005b6040519080825280601f01601f191660200182016040528015610962576020820181803683370190505b50612757565b60405181815233907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885906020015b60405180910390a2505050565b6003546001600160a01b031633146109cd5760405162461bcd60e51b81526004016106a090613c59565b84831480156109db57508481145b6109f75760405162461bcd60e51b81526004016106a090613c8e565b60005b85811015610b5e57600e6000888884818110610a2657634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000205460ff16610a835760405162461bcd60e51b8152602060048201526011602482015270125108191bd95cc81b9bdd08195e1a5cdd607a1b60448201526064016106a0565b848482818110610aa357634e487b7160e01b600052603260045260246000fd5b9050602002013560106000898985818110610ace57634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002081905550828282818110610b0757634e487b7160e01b600052603260045260246000fd5b90506020020135600f6000898985818110610b3257634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020819055508080610b5690613e66565b9150506109fa565b50505050505050565b6003546001600160a01b03163314610b915760405162461bcd60e51b81526004016106a090613c59565b600955565b600454600160a01b900460ff1615610bc05760405162461bcd60e51b81526004016106a090613aff565b6000828152600f602052604090205480610c155760405162461bcd60e51b8152602060048201526016602482015275416c7265616479206d6178696d756d2072617269747960501b60448201526064016106a0565b600954610c229083613e81565b15610c6f5760405162461bcd60e51b815260206004820152601f60248201527f496e636f7272656374207175616e7469747920666f72206372616674696e670060448201526064016106a0565b610c7a33848461278c565b600060095483610c8a9190613d89565b9050610c993383836000610938565b60405182815233907f82bf558222c4c37aae80230f0a656373f327bcc6f1ac1ef73c385d4dec21b223906020015b60405180910390a250505050565b8151835114610cf65760405162461bcd60e51b81526004016106a090613cc5565b6001600160a01b038416610d1c5760405162461bcd60e51b81526004016106a090613b63565b6001600160a01b038516331480610d385750610d3885336105c4565b610d9f5760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b60648201526084016106a0565b3360005b8451811015610eed576000858281518110610dce57634e487b7160e01b600052603260045260246000fd5b602002602001015190506000858381518110610dfa57634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015610e4a5760405162461bcd60e51b81526004016106a090613c0f565b610e548282613dbc565b60008085815260200190815260200160002060008c6001600160a01b03166001600160a01b03168152602001908152602001600020819055508160008085815260200190815260200160002060008b6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610ed29190613d71565b9250508190555050505080610ee690613e66565b9050610da3565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610f3d929190613a47565b60405180910390a4610f538187878787876127bf565b505050505050565b6003546001600160a01b03163314610f855760405162461bcd60e51b81526004016106a090613c59565b600755565b60608151835114610fef5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016106a0565b600083516001600160401b0381111561101857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611041578160200160208202803683370190505b50905060005b84518110156110e3576110a885828151811061107357634e487b7160e01b600052603260045260246000fd5b602002602001015185838151811061109b57634e487b7160e01b600052603260045260246000fd5b6020026020010151610638565b8282815181106110c857634e487b7160e01b600052603260045260246000fd5b60209081029190910101526110dc81613e66565b9050611047565b509392505050565b6003546001600160a01b031633146111155760405162461bcd60e51b81526004016106a090613c59565b61115482828080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061292a92505050565b7f931688cb31e59bc860b2a6ca0126cc5ab5fc51b1ec8749cfd79a057c24b33c588282604051611185929190613a75565b60405180910390a15050565b600454600160a01b900460ff16156111bb5760405162461bcd60e51b81526004016106a090613aff565b611229338585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080890282810182019093528882529093508892508791829185019084908082843760009201919091525061293d92505050565b6000805b8481101561135b5760006010600088888581811061125b57634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002054116112b85760405162461bcd60e51b815260206004820152601760248201527643616e6e6f742072656465656d2074686973207479706560481b60448201526064016106a0565b6127106008548585848181106112de57634e487b7160e01b600052603260045260246000fd5b90506020020135601060008a8a8781811061130957634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020546113299190613d9d565b6113339190613d9d565b61133d9190613d89565b6113479083613d71565b91508061135381613e66565b91505061122d565b50611365816129dd565b60405181815233907f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a6906020015b60405180910390a25050505050565b6003546001600160a01b031633146113cc5760405162461bcd60e51b81526004016106a090613c59565b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b600454600160a01b900460ff16156114405760405162461bcd60e51b81526004016106a090613aff565b6000828152601060205260409020546114955760405162461bcd60e51b815260206004820152601760248201527643616e6e6f742072656465656d2074686973207479706560481b60448201526064016106a0565b6114a033838361278c565b6008546000838152601060205260408120549091612710916114c3908590613d9d565b6114cd9190613d9d565b6114d79190613d89565b90506114e2816129dd565b60405181815233907f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a690602001610996565b600454600160a01b900460ff161561153e5760405162461bcd60e51b81526004016106a090613aff565b6007544211156115835760405162461bcd60e51b815260206004820152601060248201526f111958591b1a5b9948195b185c1cd95960821b60448201526064016106a0565b336000818152601160205260408120805491926115b2929091879190856115a983613e66565b91905055611f2d565b90506115f48184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612a1592505050565b6116345760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964205369676e617475726560781b60448201526064016106a0565b61163d846129dd565b33600081815260116020908152604091829020548251888152918201527f84dfc8ca06308fffaa4f1db726d14912516138f571803591e31f6e861115fabe9101610cc7565b600454600160a01b900460ff16156116ac5760405162461bcd60e51b81526004016106a090613aff565b61171a338585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080890282810182019093528882529093508892508791829185019084908082843760009201919091525061293d92505050565b50505050565b6003546001600160a01b0316331461174a5760405162461bcd60e51b81526004016106a090613c59565b6004805460ff60a01b198116600160a01b9182900460ff1615909102179055565b600454600160a01b900460ff16156117955760405162461bcd60e51b81526004016106a090613aff565b61179e816126b8565b60405181815233907f5e0d769d3ed505e55795061ac4b2c163d0d5e0e0b735f967ac3b17208788641d9060200160405180910390a250565b6006805461072e90613dff565b6003546001600160a01b0316331461180d5760405162461bcd60e51b81526004016106a090613c59565b600855565b6003546001600160a01b0316331461183c5760405162461bcd60e51b81526004016106a090613c59565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336001600160a01b03831614156118d25760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016106a0565b3360008181526001602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600454600160a01b900460ff16156119685760405162461bcd60e51b81526004016106a090613aff565b6119d6338585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602080890282810182019093528882529093508892508791829185019084908082843760009201919091525061293d92505050565b6000816001600160401b038111156119fe57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611a27578160200160208202803683370190505b5090506000846001600160401b03811115611a5257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611a7b578160200160208202803683370190505b50905060005b85811015611c31576000600f6000898985818110611aaf57634e487b7160e01b600052603260045260246000fd5b9050602002013581526020019081526020016000205490508060001415611b115760405162461bcd60e51b8152602060048201526016602482015275416c7265616479206d6178696d756d2072617269747960501b60448201526064016106a0565b600954868684818110611b3457634e487b7160e01b600052603260045260246000fd5b90506020020135611b459190613e81565b15611b925760405162461bcd60e51b815260206004820152601f60248201527f496e636f7272656374207175616e7469747920666f72206372616674696e670060448201526064016106a0565b80838381518110611bb357634e487b7160e01b600052603260045260246000fd5b602002602001018181525050600954868684818110611be257634e487b7160e01b600052603260045260246000fd5b90506020020135611bf39190613d89565b848381518110611c1357634e487b7160e01b600052603260045260246000fd5b60209081029190910101525080611c2981613e66565b915050611a81565b50611c6b33828460005b6040519080825280601f01601f191660200182016040528015611c65576020820181803683370190505b50612a9a565b336001600160a01b03167f05028d6a08b9899850722b5e39c783597a065af9a175d3f1b3c8d1c48365c63082604051611ca49190613a34565b60405180910390a2505050505050565b6003546001600160a01b03163314611cde5760405162461bcd60e51b81526004016106a090613c59565b8483148015611cec57508481145b611d085760405162461bcd60e51b81526004016106a090613c8e565b60005b85811015610b5e576000878783818110611d3557634e487b7160e01b600052603260045260246000fd5b602090810292909201356000818152600e9093526040909220549192505060ff1615611d975760405162461bcd60e51b8152602060048201526011602482015270494420616c72656164792065786973747360781b60448201526064016106a0565b80611db45760405162461bcd60e51b81526004016106a090613ba8565b6000818152600e60205260409020805460ff19166001179055858583818110611ded57634e487b7160e01b600052603260045260246000fd5b905060200201356010600083815260200190815260200160002081905550838383818110611e2b57634e487b7160e01b600052603260045260246000fd5b90506020020135600f6000838152602001908152602001600020819055507f2a31efc7e9b3f67e8cd108d5980ce3d6ac332ef092f12c5f1d748a7dfdf48f0681878785818110611e8b57634e487b7160e01b600052603260045260246000fd5b90506020020135868686818110611eb257634e487b7160e01b600052603260045260246000fd5b90506020020135604051611ed9939291909283526020830191909152604082015260600190565b60405180910390a15080611eec81613e66565b915050611d0b565b600454600160a01b900460ff1615611f1e5760405162461bcd60e51b81526004016106a090613aff565b611f2933838361278c565b5050565b6040516bffffffffffffffffffffffff19606085901b16602082015260348101839052605481018290526000906074016040516020818303038152906040528051906020012090509392505050565b600454600160a01b900460ff1615611fa65760405162461bcd60e51b81526004016106a090613aff565b828114611fc55760405162461bcd60e51b81526004016106a090613c8e565b336000908152600b602052604081205460ff166121555760005b8481101561214657600e600087878481811061200b57634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000205460ff166120445760405162461bcd60e51b81526004016106a090613ba8565b60006010600088888581811061206a57634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002054116120bd5760405162461bcd60e51b815260206004820152600d60248201526c141c9a58d9481b9bdd081cd95d609a1b60448201526064016106a0565b8383828181106120dd57634e487b7160e01b600052603260045260246000fd5b905060200201356010600088888581811061210857634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020546121289190613d9d565b6121329083613d71565b91508061213e81613e66565b915050611fdf565b50612150816126b8565b6121d1565b60005b848110156121cf57600e600087878481811061218457634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000205460ff166121bd5760405162461bcd60e51b81526004016106a090613ba8565b806121c781613e66565b915050612158565b505b61223f3386868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808a0282810182019093528982529093508992508891829185019084908082843760009201829052509250611c3b915050565b60405181815233907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688590602001611393565b6001600160a01b0384166122975760405162461bcd60e51b81526004016106a090613b63565b6001600160a01b0385163314806122b357506122b385336105c4565b6123115760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b60648201526084016106a0565b3361233181878761232188612b3b565b61232a88612b3b565b5050505050565b6000848152602081815260408083206001600160a01b038a168452909152902054838110156123725760405162461bcd60e51b81526004016106a090613c0f565b61237c8482613dbc565b6000868152602081815260408083206001600160a01b038c811685529252808320939093558816815290812080548692906123b8908490613d71565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610b5e828888888888612b94565b6003546001600160a01b031633146124425760405162461bcd60e51b81526004016106a090613c59565b6001600160a01b0381166124a75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106a0565b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b60606002805461251290613dff565b80601f016020809104026020016040519081016040528092919081815260200182805461253e90613dff565b801561258b5780601f106125605761010080835404028352916020019161258b565b820191906000526020600020905b81548152906001019060200180831161256e57829003601f168201915b50505050509050919050565b6060816125bb5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156125e557806125cf81613e66565b91506125de9050600a83613d89565b91506125bf565b6000816001600160401b0381111561260d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612637576020820181803683370190505b5090505b84156126b05761264c600183613dbc565b9150612659600a86613e81565b612664906030613d71565b60f81b81838151811061268757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506126a9600a86613d89565b945061263b565b949350505050565b336000908152600d60205260409020548111156127175760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e7420566f6c742062616c616e63650000000000000060448201526064016106a0565b336000908152600d602052604081208054839290612736908490613dbc565b9250508190555080600c600082825461274f9190613dbc565b909155505050565b61276384848484612c5e565b6000838152600a602052604081208054849290612781908490613d71565b909155505050505050565b612797838383612d25565b6000828152600a6020526040812080548392906127b5908490613dbc565b9091555050505050565b6001600160a01b0384163b15610f535760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906128039089908990889088908890600401613991565b602060405180830381600087803b15801561281d57600080fd5b505af192505050801561284d575060408051601f3d908101601f1916820190925261284a9181019061381f565b60015b6128fa57612859613ed7565b806308c379a01415612893575061286e613eef565b806128795750612895565b8060405162461bcd60e51b81526004016106a09190613aa4565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016106a0565b6001600160e01b0319811663bc197c8160e01b14610b5e5760405162461bcd60e51b81526004016106a090613ab7565b8051611f2990600290602084019061322e565b612948838383612e2f565b60005b825181101561171a5781818151811061297457634e487b7160e01b600052603260045260246000fd5b6020026020010151600a60008584815181106129a057634e487b7160e01b600052603260045260246000fd5b6020026020010151815260200190815260200160002060008282546129c59190613dbc565b909155508190506129d581613e66565b91505061294b565b336000908152600d6020526040812080548392906129fc908490613d71565b9250508190555080600c600082825461274f9190613d71565b600080612a6f846040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b6004549091506001600160a01b0316612a888285612fd4565b6001600160a01b031614949350505050565b612aa684848484613053565b60005b835181101561232a57828181518110612ad257634e487b7160e01b600052603260045260246000fd5b6020026020010151600a6000868481518110612afe57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000828254612b239190613d71565b90915550819050612b3381613e66565b915050612aa9565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110612b8357634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b6001600160a01b0384163b15610f535760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612bd890899089908890889088906004016139ef565b602060405180830381600087803b158015612bf257600080fd5b505af1925050508015612c22575060408051601f3d908101601f19168201909252612c1f9181019061381f565b60015b612c2e57612859613ed7565b6001600160e01b0319811663f23a6e6160e01b14610b5e5760405162461bcd60e51b81526004016106a090613ab7565b6001600160a01b038416612c845760405162461bcd60e51b81526004016106a090613d0d565b33612c958160008761232188612b3b565b6000848152602081815260408083206001600160a01b038916845290915281208054859290612cc5908490613d71565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461232a81600087878787612b94565b6001600160a01b038316612d4b5760405162461bcd60e51b81526004016106a090613bcc565b33612d7b81856000612d5c87612b3b565b612d6587612b3b565b5050604080516020810190915260009052505050565b6000838152602081815260408083206001600160a01b038816845290915290205482811015612dbc5760405162461bcd60e51b81526004016106a090613b1f565b612dc68382613dbc565b6000858152602081815260408083206001600160a01b038a811680865291845282852095909555815189815292830188905292938616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a45050505050565b6001600160a01b038316612e555760405162461bcd60e51b81526004016106a090613bcc565b8051825114612e765760405162461bcd60e51b81526004016106a090613cc5565b604080516020810190915260009081905233905b8351811015612f75576000848281518110612eb557634e487b7160e01b600052603260045260246000fd5b602002602001015190506000848381518110612ee157634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600084815280835260408082206001600160a01b038c168352909352919091205490915081811015612f315760405162461bcd60e51b81526004016106a090613b1f565b612f3b8282613dbc565b6000938452602084815260408086206001600160a01b038c1687529091529093209290925550819050612f6d81613e66565b915050612e8a565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612fc6929190613a47565b60405180910390a450505050565b600080600080612fe3856131ba565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa15801561303e573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b6001600160a01b0384166130795760405162461bcd60e51b81526004016106a090613d0d565b815183511461309a5760405162461bcd60e51b81526004016106a090613cc5565b3360005b8451811015613152578381815181106130c757634e487b7160e01b600052603260045260246000fd5b60200260200101516000808784815181106130f257634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b03168152602001908152602001600020600082825461313a9190613d71565b9091555081905061314a81613e66565b91505061309e565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516131a3929190613a47565b60405180910390a461232a816000878787876127bf565b600080600083516041146132105760405162461bcd60e51b815260206004820152601860248201527f696e76616c6964207369676e6174757265206c656e677468000000000000000060448201526064016106a0565b50505060208101516040820151606090920151909260009190911a90565b82805461323a90613dff565b90600052602060002090601f01602090048101928261325c57600085556132a2565b82601f1061327557805160ff19168380011785556132a2565b828001600101855582156132a2579182015b828111156132a2578251825591602001919060010190613287565b506132ae9291506132b2565b5090565b5b808211156132ae57600081556001016132b3565b80356001600160a01b03811681146132de57600080fd5b919050565b60008083601f8401126132f4578182fd5b5081356001600160401b0381111561330a578182fd5b6020830191508360208260051b850101111561332557600080fd5b9250929050565b600082601f83011261333c578081fd5b8135602061334982613d4e565b6040516133568282613e3a565b8381528281019150858301600585901b87018401881015613375578586fd5b855b8581101561339357813584529284019290840190600101613377565b5090979650505050505050565b60008083601f8401126133b1578182fd5b5081356001600160401b038111156133c7578182fd5b60208301915083602082850101111561332557600080fd5b600082601f8301126133ef578081fd5b81356001600160401b0381111561340857613408613ec1565b60405161341f601f8301601f191660200182613e3a565b818152846020838601011115613433578283fd5b816020850160208301379081016020019190915292915050565b60006020828403121561345e578081fd5b613467826132c7565b9392505050565b60008060408385031215613480578081fd5b613489836132c7565b9150613497602084016132c7565b90509250929050565b600080600080600060a086880312156134b7578081fd5b6134c0866132c7565b94506134ce602087016132c7565b935060408601356001600160401b03808211156134e9578283fd5b6134f589838a0161332c565b9450606088013591508082111561350a578283fd5b61351689838a0161332c565b9350608088013591508082111561352b578283fd5b50613538888289016133df565b9150509295509295909350565b600080600080600060a0868803121561355c578081fd5b613565866132c7565b9450613573602087016132c7565b9350604086013592506060860135915060808601356001600160401b0381111561359b578182fd5b613538888289016133df565b600080604083850312156135b9578182fd5b6135c2836132c7565b9150602083013580151581146135d6578182fd5b809150509250929050565b600080604083850312156135f3578182fd5b6135fc836132c7565b946020939093013593505050565b60008060006060848603121561361e578283fd5b613627846132c7565b95602085013595506040909401359392505050565b6000806040838503121561364e578182fd5b82356001600160401b0380821115613664578384fd5b818501915085601f830112613677578384fd5b8135602061368482613d4e565b6040516136918282613e3a565b8381528281019150858301600585901b870184018b10156136b0578889fd5b8896505b848710156136d9576136c5816132c7565b8352600196909601959183019183016136b4565b50965050860135925050808211156136ef578283fd5b506136fc8582860161332c565b9150509250929050565b6000806000806040858703121561371b578182fd5b84356001600160401b0380821115613731578384fd5b61373d888389016132e3565b90965094506020870135915080821115613755578384fd5b50613762878288016132e3565b95989497509550505050565b60008060008060008060608789031215613786578384fd5b86356001600160401b038082111561379c578586fd5b6137a88a838b016132e3565b909850965060208901359150808211156137c0578586fd5b6137cc8a838b016132e3565b909650945060408901359150808211156137e4578283fd5b506137f189828a016132e3565b979a9699509497509295939492505050565b600060208284031215613814578081fd5b813561346781613f78565b600060208284031215613830578081fd5b815161346781613f78565b6000806020838503121561384d578182fd5b82356001600160401b03811115613862578283fd5b61386e858286016133a0565b90969095509350505050565b60006020828403121561388b578081fd5b5035919050565b6000806000604084860312156138a6578081fd5b8335925060208401356001600160401b038111156138c2578182fd5b6138ce868287016133a0565b9497909650939450505050565b600080604083850312156138ed578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b8381101561392b5781518752958201959082019060010161390f565b509495945050505050565b6000815180845261394e816020860160208601613dd3565b601f01601f19169290920160200192915050565b60008351613974818460208801613dd3565b835190830190613988818360208801613dd3565b01949350505050565b6001600160a01b0386811682528516602082015260a0604082018190526000906139bd908301866138fc565b82810360608401526139cf81866138fc565b905082810360808401526139e38185613936565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090613a2990830184613936565b979650505050505050565b60208152600061346760208301846138fc565b604081526000613a5a60408301856138fc565b8281036020840152613a6c81856138fc565b95945050505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020815260006134676020830184613936565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526006908201526514185d5cd95960d21b604082015260600190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252600a9082015269125b9d985b1a5908125160b21b604082015260600190565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526018908201527f4d69736d617463686564206172726179206c656e677468730000000000000000604082015260600190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60006001600160401b03821115613d6757613d67613ec1565b5060051b60200190565b60008219821115613d8457613d84613e95565b500190565b600082613d9857613d98613eab565b500490565b6000816000190483118215151615613db757613db7613e95565b500290565b600082821015613dce57613dce613e95565b500390565b60005b83811015613dee578181015183820152602001613dd6565b8381111561171a5750506000910152565b600181811c90821680613e1357607f821691505b60208210811415613e3457634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f191681016001600160401b0381118282101715613e5f57613e5f613ec1565b6040525050565b6000600019821415613e7a57613e7a613e95565b5060010190565b600082613e9057613e90613eab565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d1115613eec57600481823e5160e01c5b90565b600060443d1015613efd5790565b6040516003193d81016004833e81513d6001600160401b038160248401118184111715613f2c57505050505090565b8285019150815181811115613f445750505050505090565b843d8701016020828501011115613f5e5750505050505090565b613f6d60208286010187613e3a565b509095945050505050565b6001600160e01b031981168114613f8e57600080fd5b5056fea2646970667358221220d93844d9ccc114f4db3574d14826241294f713e8c67c587a69b92011a20f9c2164736f6c63430008040033
[ 5, 12 ]
0xf1f3ee49470606ab2c209ccc0daccc47ee9b6355
// SPDX-License-Identifier: MIT // 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/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; /** * @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 // OpenZeppelin Contracts v4.4.1 (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() { _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); } } // File: @openzeppelin/contracts/utils/Address.sol // 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); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // 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); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (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 // OpenZeppelin Contracts v4.4.1 (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 // OpenZeppelin Contracts v4.4.1 (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: erc721a/contracts/ERC721A.sol // Creator: Chiru Labs pragma solidity ^0.8.4; error ApprovalCallerNotOwnerNorApproved(); error ApprovalQueryForNonexistentToken(); error ApproveToCaller(); error ApprovalToCurrentOwner(); error BalanceQueryForZeroAddress(); error MintToZeroAddress(); error MintZeroQuantity(); error OwnerQueryForNonexistentToken(); error TransferCallerNotOwnerNorApproved(); error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); error TransferToZeroAddress(); error URIQueryForNonexistentToken(); /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // 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_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @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 override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _ownershipOf(tokenId).addr; } /** * @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) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); 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 override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _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 { _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 { _transfer(from, to, tokenId); if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ''); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { _mint(to, quantity, _data, true); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint( address to, uint256 quantity, bytes memory _data, bool safe ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; if (safe && to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex != end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex != end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = to; currSlot.startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev This is equivalent to _burn(tokenId, false) */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); address from = prevOwnership.addr; if (approvalCheck) { bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { AddressData storage addressData = _addressData[from]; addressData.balance -= 1; addressData.numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = from; currSlot.startTimestamp = uint64(block.timestamp); currSlot.burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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 _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { 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 TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * 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, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} } // File: contracts/TweetMoonbirds.sol pragma solidity >=0.8.0 <0.9.0; contract TweetMoonbirds is ERC721A, Ownable, ReentrancyGuard { using Strings for uint256; string public _baseTokenURI; string public hiddenMetadataUri; uint256 public cost = 0.005 ether; uint256 public maxSupply = 2500; uint256 public maxMintAmountPerTx = 20; bool public paused; bool public revealed; constructor( string memory _hiddenMetadataUri ) ERC721A("Tweet Moonbirds", "TWMOONBIRD") { setHiddenMetadataUri(_hiddenMetadataUri); } function mint(uint256 _mintAmount) public payable nonReentrant { require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!"); require(totalSupply() + _mintAmount <= maxSupply, "Max supply exceeded!"); require(!paused, "The contract is paused!"); require(msg.value >= cost * _mintAmount, "Insufficient funds!"); _safeMint(_msgSender(), _mintAmount); } function mintForAddress(uint256 _mintAmount, address _receiver) public onlyOwner { _safeMint(_receiver, _mintAmount); } function _startTokenId() internal view virtual override returns (uint256) { return 1; } 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 setPaused(bool _state) public onlyOwner { paused = _state; } function withdraw() public onlyOwner nonReentrant { (bool os, ) = payable(owner()).call{value: address(this).balance}(''); require(os); } // METADATA HANDLING function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner { hiddenMetadataUri = _hiddenMetadataUri; } function setBaseURI(string calldata baseURI) public onlyOwner { _baseTokenURI = baseURI; } function _baseURI() internal view virtual override returns (string memory) { return _baseTokenURI; } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), "URI does not exist!"); if (revealed) { return string(abi.encodePacked(_baseURI(), _tokenId.toString())); } else { return hiddenMetadataUri; } } }
0x6080604052600436106101ee5760003560e01c806370a082311161010d578063b071401b116100a0578063d5abeb011161006f578063d5abeb011461054e578063e0a8085314610564578063e985e9c514610584578063efbd73f4146105cd578063f2fde38b146105ed57600080fd5b8063b071401b146104d9578063b88d4fde146104f9578063c87b56dd14610519578063cfc86f7b1461053957600080fd5b806395d89b41116100dc57806395d89b411461047c578063a0712d6814610491578063a22cb465146104a4578063a45ba8e7146104c457600080fd5b806370a0823114610413578063715018a6146104335780638da5cb5b1461044857806394354fd01461046657600080fd5b80633ccfd60b116101855780635183022711610154578063518302271461039a57806355f804b3146103b95780635c975abb146103d95780636352211e146103f357600080fd5b80633ccfd60b1461032557806342842e0e1461033a57806344a0d68a1461035a5780634fdd43cb1461037a57600080fd5b806313faede6116101c157806313faede6146102a457806316c38b3c146102c857806318160ddd146102e857806323b872dd1461030557600080fd5b806301ffc9a7146101f357806306fdde0314610228578063081812fc1461024a578063095ea7b314610282575b600080fd5b3480156101ff57600080fd5b5061021361020e366004611b40565b61060d565b60405190151581526020015b60405180910390f35b34801561023457600080fd5b5061023d61065f565b60405161021f9190611d09565b34801561025657600080fd5b5061026a610265366004611c35565b6106f1565b6040516001600160a01b03909116815260200161021f565b34801561028e57600080fd5b506102a261029d366004611afb565b610735565b005b3480156102b057600080fd5b506102ba600c5481565b60405190815260200161021f565b3480156102d457600080fd5b506102a26102e3366004611b25565b6107c3565b3480156102f457600080fd5b5060015460005403600019016102ba565b34801561031157600080fd5b506102a2610320366004611a19565b610809565b34801561033157600080fd5b506102a2610814565b34801561034657600080fd5b506102a2610355366004611a19565b61090f565b34801561036657600080fd5b506102a2610375366004611c35565b61092a565b34801561038657600080fd5b506102a2610395366004611bec565b610959565b3480156103a657600080fd5b50600f5461021390610100900460ff1681565b3480156103c557600080fd5b506102a26103d4366004611b7a565b61099a565b3480156103e557600080fd5b50600f546102139060ff1681565b3480156103ff57600080fd5b5061026a61040e366004611c35565b6109d0565b34801561041f57600080fd5b506102ba61042e3660046119c4565b6109e2565b34801561043f57600080fd5b506102a2610a31565b34801561045457600080fd5b506008546001600160a01b031661026a565b34801561047257600080fd5b506102ba600e5481565b34801561048857600080fd5b5061023d610a67565b6102a261049f366004611c35565b610a76565b3480156104b057600080fd5b506102a26104bf366004611ad1565b610c32565b3480156104d057600080fd5b5061023d610cc8565b3480156104e557600080fd5b506102a26104f4366004611c35565b610d56565b34801561050557600080fd5b506102a2610514366004611a55565b610d85565b34801561052557600080fd5b5061023d610534366004611c35565b610dd6565b34801561054557600080fd5b5061023d610f02565b34801561055a57600080fd5b506102ba600d5481565b34801561057057600080fd5b506102a261057f366004611b25565b610f0f565b34801561059057600080fd5b5061021361059f3660046119e6565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b3480156105d957600080fd5b506102a26105e8366004611c4e565b610f53565b3480156105f957600080fd5b506102a26106083660046119c4565b610f87565b60006001600160e01b031982166380ac58cd60e01b148061063e57506001600160e01b03198216635b5e139f60e01b145b8061065957506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606002805461066e90611ddf565b80601f016020809104026020016040519081016040528092919081815260200182805461069a90611ddf565b80156106e75780601f106106bc576101008083540402835291602001916106e7565b820191906000526020600020905b8154815290600101906020018083116106ca57829003601f168201915b5050505050905090565b60006106fc82611022565b610719576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6000610740826109d0565b9050806001600160a01b0316836001600160a01b031614156107755760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b038216148015906107955750610793813361059f565b155b156107b3576040516367d9dca160e11b815260040160405180910390fd5b6107be83838361105b565b505050565b6008546001600160a01b031633146107f65760405162461bcd60e51b81526004016107ed90611d1c565b60405180910390fd5b600f805460ff1916911515919091179055565b6107be8383836110b7565b6008546001600160a01b0316331461083e5760405162461bcd60e51b81526004016107ed90611d1c565b600260095414156108915760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107ed565b600260095560006108aa6008546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d80600081146108f4576040519150601f19603f3d011682016040523d82523d6000602084013e6108f9565b606091505b505090508061090757600080fd5b506001600955565b6107be83838360405180602001604052806000815250610d85565b6008546001600160a01b031633146109545760405162461bcd60e51b81526004016107ed90611d1c565b600c55565b6008546001600160a01b031633146109835760405162461bcd60e51b81526004016107ed90611d1c565b805161099690600b90602084019061181a565b5050565b6008546001600160a01b031633146109c45760405162461bcd60e51b81526004016107ed90611d1c565b6107be600a838361189e565b60006109db826112a7565b5192915050565b60006001600160a01b038216610a0b576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b031660009081526005602052604090205467ffffffffffffffff1690565b6008546001600160a01b03163314610a5b5760405162461bcd60e51b81526004016107ed90611d1c565b610a6560006113d0565b565b60606003805461066e90611ddf565b60026009541415610ac95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107ed565b60026009558015801590610adf5750600e548111155b610b225760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b60448201526064016107ed565b600d546001546000548391900360001901610b3d9190611d51565b1115610b825760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b60448201526064016107ed565b600f5460ff1615610bd55760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016107ed565b80600c54610be39190611d7d565b341015610c285760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016107ed565b6109073382611422565b6001600160a01b038216331415610c5c5760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600b8054610cd590611ddf565b80601f0160208091040260200160405190810160405280929190818152602001828054610d0190611ddf565b8015610d4e5780601f10610d2357610100808354040283529160200191610d4e565b820191906000526020600020905b815481529060010190602001808311610d3157829003601f168201915b505050505081565b6008546001600160a01b03163314610d805760405162461bcd60e51b81526004016107ed90611d1c565b600e55565b610d908484846110b7565b6001600160a01b0383163b15158015610db25750610db08484848461143c565b155b15610dd0576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6060610de182611022565b610e235760405162461bcd60e51b815260206004820152601360248201527255524920646f6573206e6f742065786973742160681b60448201526064016107ed565b600f54610100900460ff1615610e6b57610e3b611534565b610e4483611543565b604051602001610e55929190611c9d565b6040516020818303038152906040529050919050565b600b8054610e7890611ddf565b80601f0160208091040260200160405190810160405280929190818152602001828054610ea490611ddf565b8015610ef15780601f10610ec657610100808354040283529160200191610ef1565b820191906000526020600020905b815481529060010190602001808311610ed457829003601f168201915b50505050509050919050565b919050565b600a8054610cd590611ddf565b6008546001600160a01b03163314610f395760405162461bcd60e51b81526004016107ed90611d1c565b600f80549115156101000261ff0019909216919091179055565b6008546001600160a01b03163314610f7d5760405162461bcd60e51b81526004016107ed90611d1c565b6109968183611422565b6008546001600160a01b03163314610fb15760405162461bcd60e51b81526004016107ed90611d1c565b6001600160a01b0381166110165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107ed565b61101f816113d0565b50565b600081600111158015611036575060005482105b8015610659575050600090815260046020526040902054600160e01b900460ff161590565b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006110c2826112a7565b9050836001600160a01b031681600001516001600160a01b0316146110f95760405162a1148160e81b815260040160405180910390fd5b6000336001600160a01b03861614806111175750611117853361059f565b80611132575033611127846106f1565b6001600160a01b0316145b90508061115257604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03841661117957604051633a954ecd60e21b815260040160405180910390fd5b6111856000848761105b565b6001600160a01b038581166000908152600560209081526040808320805467ffffffffffffffff1980821667ffffffffffffffff92831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600490945282852080546001600160e01b031916909417600160a01b4290921691909102178355870180845292208054919390911661125b57600054821461125b578054602086015167ffffffffffffffff16600160a01b026001600160e01b03199091166001600160a01b038a16171781555b50505082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b604080516060810182526000808252602082018190529181019190915281806001111580156112d7575060005481105b156113b757600081815260046020908152604091829020825160608101845290546001600160a01b0381168252600160a01b810467ffffffffffffffff1692820192909252600160e01b90910460ff161515918101829052906113b55780516001600160a01b03161561134b579392505050565b5060001901600081815260046020908152604091829020825160608101845290546001600160a01b038116808352600160a01b820467ffffffffffffffff1693830193909352600160e01b900460ff16151592810192909252156113b0579392505050565b61134b565b505b604051636f96cda160e11b815260040160405180910390fd5b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610996828260405180602001604052806000815250611641565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290611471903390899088908890600401611ccc565b602060405180830381600087803b15801561148b57600080fd5b505af19250505080156114bb575060408051601f3d908101601f191682019092526114b891810190611b5d565b60015b611516573d8080156114e9576040519150601f19603f3d011682016040523d82523d6000602084013e6114ee565b606091505b50805161150e576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6060600a805461066e90611ddf565b6060816115675750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611591578061157b81611e1a565b915061158a9050600a83611d69565b915061156b565b60008167ffffffffffffffff8111156115ac576115ac611e8b565b6040519080825280601f01601f1916602001820160405280156115d6576020820181803683370190505b5090505b841561152c576115eb600183611d9c565b91506115f8600a86611e35565b611603906030611d51565b60f81b81838151811061161857611618611e75565b60200101906001600160f81b031916908160001a90535061163a600a86611d69565b94506115da565b6107be83838360016000546001600160a01b03851661167257604051622e076360e81b815260040160405180910390fd5b836116905760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260056020908152604080832080546fffffffffffffffffffffffffffffffff19811667ffffffffffffffff8083168c0181169182176801000000000000000067ffffffffffffffff1990941690921783900481168c01811690920217909155858452600490925290912080546001600160e01b031916909217600160a01b42909216919091021790558080850183801561174257506001600160a01b0387163b15155b156117cb575b60405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4611793600088848060010195508861143c565b6117b0576040516368d2bf6b60e11b815260040160405180910390fd5b808214156117485782600054146117c657600080fd5b611811565b5b6040516001830192906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4808214156117cc575b506000556112a0565b82805461182690611ddf565b90600052602060002090601f016020900481019282611848576000855561188e565b82601f1061186157805160ff191683800117855561188e565b8280016001018555821561188e579182015b8281111561188e578251825591602001919060010190611873565b5061189a929150611912565b5090565b8280546118aa90611ddf565b90600052602060002090601f0160209004810192826118cc576000855561188e565b82601f106118e55782800160ff1982351617855561188e565b8280016001018555821561188e579182015b8281111561188e5782358255916020019190600101906118f7565b5b8082111561189a5760008155600101611913565b600067ffffffffffffffff8084111561194257611942611e8b565b604051601f8501601f19908116603f0116810190828211818310171561196a5761196a611e8b565b8160405280935085815286868601111561198357600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114610efd57600080fd5b80358015158114610efd57600080fd5b6000602082840312156119d657600080fd5b6119df8261199d565b9392505050565b600080604083850312156119f957600080fd5b611a028361199d565b9150611a106020840161199d565b90509250929050565b600080600060608486031215611a2e57600080fd5b611a378461199d565b9250611a456020850161199d565b9150604084013590509250925092565b60008060008060808587031215611a6b57600080fd5b611a748561199d565b9350611a826020860161199d565b925060408501359150606085013567ffffffffffffffff811115611aa557600080fd5b8501601f81018713611ab657600080fd5b611ac587823560208401611927565b91505092959194509250565b60008060408385031215611ae457600080fd5b611aed8361199d565b9150611a10602084016119b4565b60008060408385031215611b0e57600080fd5b611b178361199d565b946020939093013593505050565b600060208284031215611b3757600080fd5b6119df826119b4565b600060208284031215611b5257600080fd5b81356119df81611ea1565b600060208284031215611b6f57600080fd5b81516119df81611ea1565b60008060208385031215611b8d57600080fd5b823567ffffffffffffffff80821115611ba557600080fd5b818501915085601f830112611bb957600080fd5b813581811115611bc857600080fd5b866020828501011115611bda57600080fd5b60209290920196919550909350505050565b600060208284031215611bfe57600080fd5b813567ffffffffffffffff811115611c1557600080fd5b8201601f81018413611c2657600080fd5b61152c84823560208401611927565b600060208284031215611c4757600080fd5b5035919050565b60008060408385031215611c6157600080fd5b82359150611a106020840161199d565b60008151808452611c89816020860160208601611db3565b601f01601f19169290920160200192915050565b60008351611caf818460208801611db3565b835190830190611cc3818360208801611db3565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611cff90830184611c71565b9695505050505050565b6020815260006119df6020830184611c71565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115611d6457611d64611e49565b500190565b600082611d7857611d78611e5f565b500490565b6000816000190483118215151615611d9757611d97611e49565b500290565b600082821015611dae57611dae611e49565b500390565b60005b83811015611dce578181015183820152602001611db6565b83811115610dd05750506000910152565b600181811c90821680611df357607f821691505b60208210811415611e1457634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415611e2e57611e2e611e49565b5060010190565b600082611e4457611e44611e5f565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461101f57600080fdfea2646970667358221220a5af9e54942929ae320c342d413906ebff987c053f1161dc6525e8bb897d7e6664736f6c63430008070033
[ 7, 5 ]
0xf1f5E5DF82a6962731e3Bd9f67Ec6b1d4A23E2CF
/* SPDX-License-Identifier: MIT */ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import {IBean} from "../../interfaces/IBean.sol"; /** * @author Publius * @title InitBip5 runs the code for BIP-5. **/ interface IBS { function createFundraiser(address fundraiser, address token, uint256 amount) external; } contract InitBip5 { address private constant payee = address(0x925753106FCdB6D2f30C3db295328a0A1c5fD1D1); address private constant token = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); address private constant bean = address(0xDC59ac4FeFa32293A95889Dc396682858d52e5Db); function init() external { IBS(address(this)).createFundraiser(payee, token, 140000000000); IBean(address(bean)).mint(payee, 15000000000); } } /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @author Publius * @title Bean Interface **/ abstract contract IBean is IERC20 { function burn(uint256 amount) public virtual; function burnFrom(address account, uint256 amount) public virtual; function mint(address account, uint256 amount) public virtual returns (bool); } // 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); }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e1c7392a14610030575b600080fd5b61003861003a565b005b6040517f4b4e8d9a0000000000000000000000000000000000000000000000000000000081523090634b4e8d9a906100a79073925753106fcdb6d2f30c3db295328a0a1c5fd1d19073a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4890642098a67800906004016101c0565b600060405180830381600087803b1580156100c157600080fd5b505af11580156100d5573d6000803e3d6000fd5b50506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273dc59ac4fefa32293a95889dc396682858d52e5db92506340c10f1991506101449073925753106fcdb6d2f30c3db295328a0a1c5fd1d19064037e11d600906004016101f1565b602060405180830381600087803b15801561015e57600080fd5b505af1158015610172573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101969190610199565b50565b6000602082840312156101aa578081fd5b815180151581146101b9578182fd5b9392505050565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff92909216825260208201526040019056fea26469706673582212203694574264ae79c024972ae230f67bf1501645a7aae37beb5c8fc2fe7ec8a57964736f6c63430007060033
[ 5 ]
0xf1f5e9c1e78b57d460cba544129bdadd1c6cad27
pragma solidity ^0.4.4; contract Token { /// @return total amount of tokens function totalSupply() constant returns (uint256 supply) {} /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) constant returns (uint256 balance) {} /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) returns (bool success) {} /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {} /// @notice `msg.sender` approves `_addr` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) returns (bool success) {} /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) constant returns (uint256 remaining) {} event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { function transfer(address _to, uint256 _value) returns (bool success) { //Default assumes totalSupply can't be over max (2^256 - 1). //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. //Replace the if with this one instead. //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { return false; } } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { //same as above. Replace this line with the following if you want to protect against wrapping uints. //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } else { return false; } } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; uint256 public totalSupply; } //name this contract whatever you'd like contract MapleCoin is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of ERC20Token function MapleCoin( ) { balances[msg.sender] = 10000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 10000000000; // Update total supply (100000 for example) name = "MAPLE COIN"; // Set the name for display purposes decimals = 6; // Amount of decimals for display purposes symbol = "MPL"; // Set the symbol for display purposes } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100c1578063095ea7b31461015157806318160ddd146101b657806323b872dd146101e1578063313ce5671461026657806354fd4d501461029757806370a082311461032757806395d89b411461037e578063a9059cbb1461040e578063cae9ca5114610473578063dd62ed3e1461051e575b3480156100bb57600080fd5b50600080fd5b3480156100cd57600080fd5b506100d6610595565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101165780820151818401526020810190506100fb565b50505050905090810190601f1680156101435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015d57600080fd5b5061019c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610633565b604051808215151515815260200191505060405180910390f35b3480156101c257600080fd5b506101cb610725565b6040518082815260200191505060405180910390f35b3480156101ed57600080fd5b5061024c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061072b565b604051808215151515815260200191505060405180910390f35b34801561027257600080fd5b5061027b6109a4565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102a357600080fd5b506102ac6109b7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102ec5780820151818401526020810190506102d1565b50505050905090810190601f1680156103195780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561033357600080fd5b50610368600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a55565b6040518082815260200191505060405180910390f35b34801561038a57600080fd5b50610393610a9d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103d35780820151818401526020810190506103b8565b50505050905090810190601f1680156104005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041a57600080fd5b50610459600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b3b565b604051808215151515815260200191505060405180910390f35b34801561047f57600080fd5b50610504600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610ca1565b604051808215151515815260200191505060405180910390f35b34801561052a57600080fd5b5061057f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f3e565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107f7575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156108035750600082115b1561099857816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061099d565b600090505b9392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4d5780601f10610a2257610100808354040283529160200191610a4d565b820191906000526020600020905b815481529060010190602001808311610a3057829003601f168201915b505050505081565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b335780601f10610b0857610100808354040283529160200191610b33565b820191906000526020600020905b815481529060010190602001808311610b1657829003601f168201915b505050505081565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610b8b5750600082115b15610c9657816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610c9b565b600090505b92915050565b600082600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ee2578082015181840152602081019050610ec7565b50505050905090810190601f168015610f0f5780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f3357600080fd5b600190509392505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a723058208e8b3d81602d277386c2bbc6f30000e695974cb367a2069ec1bea0b63dc595bc0029
[ 38 ]
0xf1f6be5468638ce9503b4bd892948e10fa5c3cbd
pragma solidity ^0.8.3; // SPDX-License-Identifier: Unlicensed /** * @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); } // 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; } } } /* * @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 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); } } } } /** * @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 () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @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; } } 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 implementation contract PUFA is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "Platform for Underpaid Female Athletes"; string private _symbol = "PUFA"; uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals); // uint256 public defaultTaxFee = 0; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // uint256 public defaultMarketingFee = 10; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 12; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(100); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x1779376cFE6F8f7EBD5a8E1dd56D4F98C0b625A3); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); // set the rest of the contract variables uniswapV2Router = _uniswapV2Router; //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeMarketing(uint256 tMarketing) private { uint256 currentRate = _getRate(); uint256 rMarketing = tMarketing.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tMarketing); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) private lockTheSwap { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeMarketing(tMarketing); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
0x6080604052600436106102555760003560e01c806370a0823111610139578063a3864430116100b6578063cba851b31161007a578063cba851b31461071b578063d54994db14610731578063dab522a814610751578063dd62ed3e14610771578063ea2f0b37146107b7578063f2fde38b146107d75761025c565b8063a386443014610695578063a457c2d7146106ab578063a9059cbb146106cb578063bc951f98146106eb578063c537bd8f146107015761025c565b80638da5cb5b116100fd5780638da5cb5b1461060d57806395d89b411461062b5780639f64621414610640578063a062e3ba14610656578063a08f6760146106755761025c565b806370a0823114610569578063715018a61461058957806375f0a8741461059e5780637d1db4a5146105be57806388f82020146105d45761025c565b80632d838119116101d2578063437823ec11610196578063437823ec1461047c5780634549b0391461049c57806349bd5a5e146104bc57806352390c02146104f05780635342acb41461051057806357e0a1d0146105495761025c565b80632d838119146103d4578063313ce567146103f45780633685d4191461042657806339509351146104465780633b124fe7146104665761025c565b80631bbae6e0116102195780631bbae6e01461033c5780631ff53b601461035e57806322976e0d1461037e57806323b872dd146103945780632663236f146103b45761025c565b806306fdde0314610261578063095ea7b31461028c57806313114a9d146102bc5780631694505e146102db57806318160ddd146103275761025c565b3661025c57005b600080fd5b34801561026d57600080fd5b506102766107f7565b6040516102839190612226565b60405180910390f35b34801561029857600080fd5b506102ac6102a736600461219e565b610889565b6040519015158152602001610283565b3480156102c857600080fd5b506015545b604051908152602001610283565b3480156102e757600080fd5b5061030f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610283565b34801561033357600080fd5b506003546102cd565b34801561034857600080fd5b5061035c6103573660046121e3565b6108a0565b005b34801561036a57600080fd5b5061035c6103793660046120ee565b6108d8565b34801561038a57600080fd5b506102cd60085481565b3480156103a057600080fd5b506102ac6103af36600461215e565b610924565b3480156103c057600080fd5b5061035c6103cf3660046121c9565b61098d565b3480156103e057600080fd5b506102cd6103ef3660046121e3565b610a0b565b34801561040057600080fd5b50610414600054600160a01b900460ff1690565b60405160ff9091168152602001610283565b34801561043257600080fd5b5061035c6104413660046120ee565b610a91565b34801561045257600080fd5b506102ac61046136600461219e565b610c81565b34801561047257600080fd5b506102cd60055481565b34801561048857600080fd5b5061035c6104973660046120ee565b610cb7565b3480156104a857600080fd5b506102cd6104b73660046121fb565b610d05565b3480156104c857600080fd5b5061030f7f00000000000000000000000005c35cfe94f9a2741606294d0184a7ab6bab55e481565b3480156104fc57600080fd5b5061035c61050b3660046120ee565b610d92565b34801561051c57600080fd5b506102ac61052b3660046120ee565b6001600160a01b031660009081526012602052604090205460ff1690565b34801561055557600080fd5b5061035c6105643660046121c9565b610ee5565b34801561057557600080fd5b506102cd6105843660046120ee565b610f22565b34801561059557600080fd5b5061035c610f84565b3480156105aa57600080fd5b50600e5461030f906001600160a01b031681565b3480156105ca57600080fd5b506102cd600c5481565b3480156105e057600080fd5b506102ac6105ef3660046120ee565b6001600160a01b031660009081526013602052604090205460ff1690565b34801561061957600080fd5b506000546001600160a01b031661030f565b34801561063757600080fd5b50610276610ff8565b34801561064c57600080fd5b506102cd60075481565b34801561066257600080fd5b506017546102ac90610100900460ff1681565b34801561068157600080fd5b5061035c6106903660046121e3565b611007565b3480156106a157600080fd5b506102cd600d5481565b3480156106b757600080fd5b506102ac6106c636600461219e565b611036565b3480156106d757600080fd5b506102ac6106e636600461219e565b611085565b3480156106f757600080fd5b506102cd600a5481565b34801561070d57600080fd5b50600b546102ac9060ff1681565b34801561072757600080fd5b506102cd60045481565b34801561073d57600080fd5b5061035c61074c3660046121e3565b611092565b34801561075d57600080fd5b5061035c61076c3660046121e3565b6110c1565b34801561077d57600080fd5b506102cd61078c366004612126565b6001600160a01b03918216600090815260116020908152604080832093909416825291909152205490565b3480156107c357600080fd5b5061035c6107d23660046120ee565b6110f0565b3480156107e357600080fd5b5061035c6107f23660046120ee565b61113b565b6060600180546108069061238c565b80601f01602080910402602001604051908101604052809291908181526020018280546108329061238c565b801561087f5780601f106108545761010080835404028352916020019161087f565b820191906000526020600020905b81548152906001019060200180831161086257829003601f168201915b5050505050905090565b6000610896338484611238565b5060015b92915050565b6000546001600160a01b031633146108d35760405162461bcd60e51b81526004016108ca90612279565b60405180910390fd5b600c55565b6000546001600160a01b031633146109025760405162461bcd60e51b81526004016108ca90612279565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b600061093184848461135c565b610983843361097e8560405180606001604052806028815260200161240e602891396001600160a01b038a166000908152601160209081526040808320338452909152902054919061161e565b611238565b5060019392505050565b6000546001600160a01b031633146109b75760405162461bcd60e51b81526004016108ca90612279565b601780548215156101000261ff00199091161790556040517f3efb3f9ce66ef48ce5be6bff57df61c60b91f67f10f414ed7cd767b1c9cdad7d90610a0090831515815260200190565b60405180910390a150565b6000601654821115610a725760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016108ca565b6000610a7c61164a565b9050610a888382611225565b9150505b919050565b6000546001600160a01b03163314610abb5760405162461bcd60e51b81526004016108ca90612279565b6001600160a01b03811660009081526013602052604090205460ff16610b235760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c75646564000000000060448201526064016108ca565b60005b601454811015610c7d57816001600160a01b031660148281548110610b5b57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610c6b5760148054610b8690600190612375565b81548110610ba457634e487b7160e01b600052603260045260246000fd5b600091825260209091200154601480546001600160a01b039092169183908110610bde57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152601082526040808220829055601390925220805460ff191690556014805480610c4457634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b0319169055019055610c7d565b80610c75816123c7565b915050610b26565b5050565b3360008181526011602090815260408083206001600160a01b0387168452909152812054909161089691859061097e908661166d565b6000546001600160a01b03163314610ce15760405162461bcd60e51b81526004016108ca90612279565b6001600160a01b03166000908152601260205260409020805460ff19166001179055565b6000600354831115610d595760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c790060448201526064016108ca565b81610d78576000610d6984611679565b5093955061089a945050505050565b6000610d8384611679565b5092955061089a945050505050565b6000546001600160a01b03163314610dbc5760405162461bcd60e51b81526004016108ca90612279565b6001600160a01b03811660009081526013602052604090205460ff1615610e255760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c75646564000000000060448201526064016108ca565b6001600160a01b0381166000908152600f602052604090205415610e7f576001600160a01b0381166000908152600f6020526040902054610e6590610a0b565b6001600160a01b0382166000908152601060205260409020555b6001600160a01b03166000818152601360205260408120805460ff191660019081179091556014805491820181559091527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec0180546001600160a01b0319169091179055565b6000546001600160a01b03163314610f0f5760405162461bcd60e51b81526004016108ca90612279565b600b805460ff1916911515919091179055565b6001600160a01b03811660009081526013602052604081205460ff1615610f6257506001600160a01b038116600090815260106020526040902054610a8c565b6001600160a01b0382166000908152600f602052604090205461089a90610a0b565b6000546001600160a01b03163314610fae5760405162461bcd60e51b81526004016108ca90612279565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6060600280546108069061238c565b6000546001600160a01b031633146110315760405162461bcd60e51b81526004016108ca90612279565b600a55565b6000610896338461097e85604051806060016040528060258152602001612436602591393360009081526011602090815260408083206001600160a01b038d168452909152902054919061161e565b600061089633848461135c565b6000546001600160a01b031633146110bc5760405162461bcd60e51b81526004016108ca90612279565b600755565b6000546001600160a01b031633146110eb5760405162461bcd60e51b81526004016108ca90612279565b600d55565b6000546001600160a01b0316331461111a5760405162461bcd60e51b81526004016108ca90612279565b6001600160a01b03166000908152601260205260409020805460ff19169055565b6000546001600160a01b031633146111655760405162461bcd60e51b81526004016108ca90612279565b6001600160a01b0381166111ca5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108ca565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b60006112318284612336565b9392505050565b6001600160a01b03831661129a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016108ca565b6001600160a01b0382166112fb5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016108ca565b6001600160a01b0383811660008181526011602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166113c05760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016108ca565b6001600160a01b0382166114225760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016108ca565b600081116114845760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016108ca565b6000546001600160a01b038481169116148015906114b057506000546001600160a01b03838116911614155b1561151857600c548111156115185760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b60648201526084016108ca565b600061152330610f22565b600d54600c5491925082101590821061153c57600c5491505b80801561154c575060175460ff16155b801561158a57507f00000000000000000000000005c35cfe94f9a2741606294d0184a7ab6bab55e46001600160a01b0316856001600160a01b031614155b801561159d5750601754610100900460ff165b156115ab576115ab826116c8565b600b5460ff16156115bf576115bf84611910565b6001600160a01b03851660009081526012602052604090205460019060ff168061160157506001600160a01b03851660009081526012602052604090205460ff165b1561160a575060005b6116168686868461195b565b505050505050565b600081848411156116425760405162461bcd60e51b81526004016108ca9190612226565b505050900390565b6000806000611657611ad8565b90925090506116668282611225565b9250505090565b6000611231828461231e565b60008060008060008060008060006116908a611c95565b92509250925060008060006116ae8d86866116a961164a565b611cd7565b919f909e50909c50959a5093985091965092945050505050565b6017805460ff19166001179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061171857634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561179157600080fd5b505afa1580156117a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c9919061210a565b816001815181106117ea57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050611835307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611238565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac9479061188a9085906000908690309042906004016122ae565b600060405180830381600087803b1580156118a457600080fd5b505af11580156118b8573d6000803e3d6000fd5b50479250508115905061190157600e546040516001600160a01b039091169082156108fc029083906000818181858888f193505050501580156118ff573d6000803e3d6000fd5b505b50506017805460ff1916905550565b6004546005556007546008557f00000000000000000000000005c35cfe94f9a2741606294d0184a7ab6bab55e46001600160a01b03908116908216141561195857600a546008555b50565b8061196857611968611d27565b6001600160a01b03841660009081526013602052604090205460ff1680156119a957506001600160a01b03831660009081526013602052604090205460ff16155b156119be576119b9848484611d59565b611abc565b6001600160a01b03841660009081526013602052604090205460ff161580156119ff57506001600160a01b03831660009081526013602052604090205460ff165b15611a0f576119b9848484611e7f565b6001600160a01b03841660009081526013602052604090205460ff16158015611a5157506001600160a01b03831660009081526013602052604090205460ff16155b15611a61576119b9848484611f28565b6001600160a01b03841660009081526013602052604090205460ff168015611aa157506001600160a01b03831660009081526013602052604090205460ff165b15611ab1576119b9848484611f6c565b611abc848484611f28565b80611ad257611ad2600654600555600954600855565b50505050565b6016546003546000918291825b601454811015611c635782600f600060148481548110611b1557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611b8e5750816010600060148481548110611b6757634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611ba55760165460035494509450505050611c91565b611bf9600f600060148481548110611bcd57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611fdb565b9250611c4f6010600060148481548110611c2357634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611fdb565b915080611c5b816123c7565b915050611ae5565b50600354601654611c7391611225565b821015611c8b57601654600354935093505050611c91565b90925090505b9091565b600080600080611ca485611fe7565b90506000611cb186612009565b90506000611cc982611cc38986611fdb565b90611fdb565b979296509094509092505050565b6000808080611ce68886612025565b90506000611cf48887612025565b90506000611d028888612025565b90506000611d1482611cc38686611fdb565b939b939a50919850919650505050505050565b600554158015611d375750600854155b15611d4157611d57565b6005805460065560088054600955600091829055555b565b600080600080600080611d6b87611679565b6001600160a01b038f16600090815260106020526040902054959b50939950919750955093509150611d9d9088611fdb565b6001600160a01b038a16600090815260106020908152604080832093909355600f90522054611dcc9087611fdb565b6001600160a01b03808b166000908152600f602052604080822093909355908a1681522054611dfb908661166d565b6001600160a01b0389166000908152600f6020526040902055611e1d81612031565b611e2784836120ba565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611e6c91815260200190565b60405180910390a3505050505050505050565b600080600080600080611e9187611679565b6001600160a01b038f166000908152600f6020526040902054959b50939950919750955093509150611ec39087611fdb565b6001600160a01b03808b166000908152600f6020908152604080832094909455918b16815260109091522054611ef9908461166d565b6001600160a01b038916600090815260106020908152604080832093909355600f90522054611dfb908661166d565b600080600080600080611f3a87611679565b6001600160a01b038f166000908152600f6020526040902054959b50939950919750955093509150611dcc9087611fdb565b600080600080600080611f7e87611679565b6001600160a01b038f16600090815260106020526040902054959b50939950919750955093509150611fb09088611fdb565b6001600160a01b038a16600090815260106020908152604080832093909355600f90522054611ec390875b60006112318284612375565b600061089a60646120036005548561202590919063ffffffff16565b90611225565b600061089a60646120036008548561202590919063ffffffff16565b60006112318284612356565b600061203b61164a565b905060006120498383612025565b306000908152600f6020526040902054909150612066908261166d565b306000908152600f602090815260408083209390935560139052205460ff16156120b557306000908152601060205260409020546120a4908461166d565b306000908152601060205260409020555b505050565b6016546120c79083611fdb565b6016556015546120d7908261166d565b6015555050565b80358015158114610a8c57600080fd5b6000602082840312156120ff578081fd5b8135611231816123f8565b60006020828403121561211b578081fd5b8151611231816123f8565b60008060408385031215612138578081fd5b8235612143816123f8565b91506020830135612153816123f8565b809150509250929050565b600080600060608486031215612172578081fd5b833561217d816123f8565b9250602084013561218d816123f8565b929592945050506040919091013590565b600080604083850312156121b0578182fd5b82356121bb816123f8565b946020939093013593505050565b6000602082840312156121da578081fd5b611231826120de565b6000602082840312156121f4578081fd5b5035919050565b6000806040838503121561220d578182fd5b8235915061221d602084016120de565b90509250929050565b6000602080835283518082850152825b8181101561225257858101830151858201604001528201612236565b818111156122635783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156122fd5784516001600160a01b0316835293830193918301916001016122d8565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115612331576123316123e2565b500190565b60008261235157634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612370576123706123e2565b500290565b600082821015612387576123876123e2565b500390565b600181811c908216806123a057607f821691505b602082108114156123c157634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156123db576123db6123e2565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461195857600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212201c04daeeb8d57ae7598031108ed90dce81f74e5ec7d332bb2fff13f905b8953a64736f6c63430008030033
[ 13, 11 ]
0xf1f74c9842fae5c06b174e5412cdcea2a62f267f
pragma solidity ^0.4.24; // ---------------------------------------------------------------------------- // 'FDC🐉' token contract // // Deployed to : 0x5088F5b699D7e987fce386E677cA92828e475dc3 // Symbol : FDC🐉 // Name : fdc.blogfa.com // Total supply: 1000000000000000 // Decimals : 18 // // // // // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- 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; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- 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); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract FDC is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor () public { symbol = "FDC🐉"; name = "fdc.blogfa.com"; decimals = 18; _totalSupply = 1000000000000000000000000000000000; balances[0x5088F5b699D7e987fce386E677cA92828e475dc3] = _totalSupply; emit Transfer(address(0), 0x5088F5b699D7e987fce386E677cA92828e475dc3, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a723058206d047765e86a17a1339749ab48c3eb7c2d8dc34f47f5570862e0852432c744fd0029
[ 2 ]
0xF1f792bf1AfF602c7a74ab9a8a4cC0310E719c63
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract KeepWatchCrew is ERC721Enumerable, Ownable { using SafeMath for uint256; using Strings for uint256; enum SaleModes { NONE, VIP_PRESALE, PUBLIC_SALE } string public notRevealedUri; string private baseTokenURI; SaleModes public saleMode = SaleModes.NONE; mapping(address => bool) public presaleAddresses; mapping(address => bool) public vipAddresses; mapping(address => uint256) mintedAmounts; bool public revealed = false; bool public paused = false; uint256 public constant MAX_ELEMENTS = 6969; uint256 public PRICE = 69 * (10**15); // 0.069 ETH uint256 public DISCOUNT_PRICE = 59 * (10**15); // 0.059 ETH uint256 public maxVIPMint = 1; uint256 public maxPresaleMint = 4; uint256 public maxPublicMint = 8; uint256 public publicSaleDate = 1639695600; address payable public constant payoutAddress = payable(0x032b023b216Dc3b9A30975ABf1f51De92a764a46); event CreateKWC(uint256 indexed id); constructor(string memory baseURI, string memory _notRevealedUri) ERC721("KeepWatchCrew", "KWC") { setBaseURI(baseURI); // Dummy IPFS metadata JSON URI for before reveal setNotRevealedURI(_notRevealedUri); // Pause minting by default pause(true); } function isVIP(address _user) public view returns (bool) { return vipAddresses[_user]; } function isInPresale(address _user) public view returns (bool) { return presaleAddresses[_user]; } function totalMint(address _user) public view returns (uint256) { return mintedAmounts[_user]; } function _mintAnElement(address _to) internal { uint256 id = totalSupply() + 1; _safeMint(_to, id); emit CreateKWC(id); } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if (revealed == false) { return notRevealedUri; } string memory currentBaseURI = baseTokenURI; return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked( currentBaseURI, tokenId.toString(), ".json" ) ) : ""; } function mint(uint256 _count) public payable { require(!paused, "Pausable: paused"); uint256 total = totalSupply(); address sender = _msgSender(); require(_count > 0); require(total <= MAX_ELEMENTS, "Sale end"); require(total + _count <= MAX_ELEMENTS, "Max limit"); // Nobody can mint except the contract owner if it's in default mode if (saleMode == SaleModes.NONE) { require(sender == owner()); } uint256 mintedAmount = mintedAmounts[sender]; bool isInPresaleList = isInPresale(sender); bool isInVIP = isVIP(sender); if (saleMode == SaleModes.VIP_PRESALE) { if (sender != owner()) { require(isInVIP || isInPresaleList); if (isInVIP) { if (mintedAmount == 0) { require(_count == maxVIPMint, "You can't mint more than allowed number of tokens"); } else { require(isInPresaleList, "You are not allowed to mint"); uint256 maxMint = maxVIPMint + maxPresaleMint; require(_count + mintedAmount <= maxMint, "You can't mint more than allowed number of tokens"); require(msg.value >= DISCOUNT_PRICE.mul(_count), "Value below price"); } } else { require(_count + mintedAmount <= maxPresaleMint, "You can't mint more than allowed number of tokens"); require(msg.value >= DISCOUNT_PRICE.mul(_count), "Value below price"); } } } if (saleMode == SaleModes.PUBLIC_SALE) { if (sender != owner()) { require(_count <= maxPublicMint, "Number of mintable tokens limited per wallet"); require(msg.value >= PRICE.mul(_count), "Value below price"); } } for (uint256 i = 0; i < _count; i++) { _mintAnElement(sender); mintedAmounts[sender] += 1; } } // Only owner // Change Mode function activateNextSaleMode() external onlyOwner { if (saleMode == SaleModes.NONE) { saleMode = SaleModes.VIP_PRESALE; } else if (saleMode == SaleModes.VIP_PRESALE) { saleMode = SaleModes.PUBLIC_SALE; } } // Add users to Presale list function addUsersToPresaleList(address[] calldata _users) external onlyOwner { for(uint256 i = 0; i < _users.length; i++) { address user = _users[i]; require(user != address(0), "Null Address"); presaleAddresses[user] = true; } } function removeUsersFromPresaleList(address[] calldata _users) external onlyOwner { for(uint256 i = 0; i < _users.length; i++) { address user = _users[i]; require(user != address(0), "Null Address"); presaleAddresses[user] = false; } } // Add users to VIP list function addUsersToVIPList(address[] calldata _users) external onlyOwner { for(uint256 i = 0; i < _users.length; i++) { address user = _users[i]; require(user != address(0), "Null Address"); vipAddresses[user] = true; } } function removeUsersFromVIPList(address[] calldata _users) external onlyOwner { for(uint256 i = 0; i < _users.length; i++) { address user = _users[i]; require(user != address(0), "Null Address"); vipAddresses[user] = false; } } // Reveals real metadata for NFTs function reveal() public onlyOwner { revealed = true; } // Pause/unpause contract function pause(bool val) public onlyOwner { paused = val; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function setNotRevealedURI(string memory _notRevealedUri) public onlyOwner { notRevealedUri = _notRevealedUri; } function updateMaxPresaleAmount(uint256 _amount) external onlyOwner { maxPresaleMint = _amount; } function updateMaxPublicAmount(uint256 _amount) external onlyOwner { maxPublicMint = _amount; } function withdraw() external onlyOwner { uint256 balance = address(this).balance; require(balance > 0); payoutAddress.transfer(balance); } } // 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. 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 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; /** * @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); } }
0x6080604052600436106102ae5760003560e01c806361fe4c4a11610175578063a787c33a116100dc578063cabadaa011610095578063eced38731161006f578063eced3873146107c1578063f2c4ce1e146107d6578063f2fde38b146107f6578063f4201c3c14610816576102ae565b8063cabadaa01461076c578063e0fa184214610781578063e985e9c5146107a1576102ae565b8063a787c33a146106b7578063b4576278146106d7578063b88d4fde146106ec578063bb9968441461070c578063c54f9f121461072c578063c87b56dd1461074c576102ae565b80638d859f3e1161012e5780638d859f3e146106305780638da5cb5b1461064557806395d89b411461065a578063a0712d681461066f578063a22cb46514610682578063a475b5dd146106a2576102ae565b806361fe4c4a1461057b5780636352211e1461059b57806366fca980146105bb57806370a08231146105db578063715018a6146105fb57806382f1209c14610610576102ae565b80632f745c59116102195780634f6ccce7116101d25780634f6ccce7146104e7578063518302271461050757806354e614a21461051c57806355f804b3146105315780635b8d02d7146105515780635c975abb14610566576102ae565b80632f745c59146104485780633502a716146104685780633b04a4e11461047d5780633ccfd60b1461049d57806342842e0e146104b25780634ca518c8146104d2576102ae565b8063081c8c441161026b578063081c8c441461039c578063095ea7b3146103b15780630deed6a6146103d157806318160ddd146103f357806323b872dd146104085780632c56171e14610428576102ae565b806301ffc9a7146102b357806302329a29146102e9578063057707a01461030b57806306735bb01461032d57806306fdde031461034d578063081812fc1461036f575b600080fd5b3480156102bf57600080fd5b506102d36102ce366004612709565b610836565b6040516102e0919061285b565b60405180910390f35b3480156102f557600080fd5b506103096103043660046126ef565b610863565b005b34801561031757600080fd5b506103206108c5565b6040516102e09190612f32565b34801561033957600080fd5b506102d361034836600461252e565b6108cb565b34801561035957600080fd5b506103626108e0565b6040516102e0919061288e565b34801561037b57600080fd5b5061038f61038a366004612787565b610972565b6040516102e0919061280a565b3480156103a857600080fd5b506103626109b5565b3480156103bd57600080fd5b506103096103cc366004612657565b610a43565b3480156103dd57600080fd5b506103e6610adb565b6040516102e09190612866565b3480156103ff57600080fd5b50610320610ae4565b34801561041457600080fd5b5061030961042336600461257a565b610aea565b34801561043457600080fd5b50610309610443366004612680565b610b22565b34801561045457600080fd5b50610320610463366004612657565b610bff565b34801561047457600080fd5b50610320610c51565b34801561048957600080fd5b50610309610498366004612680565b610c57565b3480156104a957600080fd5b50610309610d31565b3480156104be57600080fd5b506103096104cd36600461257a565b610dc0565b3480156104de57600080fd5b50610320610ddb565b3480156104f357600080fd5b50610320610502366004612787565b610de1565b34801561051357600080fd5b506102d3610e3c565b34801561052857600080fd5b50610309610e45565b34801561053d57600080fd5b5061030961054c366004612741565b610f00565b34801561055d57600080fd5b5061038f610f52565b34801561057257600080fd5b506102d3610f6a565b34801561058757600080fd5b50610309610596366004612787565b610f78565b3480156105a757600080fd5b5061038f6105b6366004612787565b610fbc565b3480156105c757600080fd5b506102d36105d636600461252e565b610ff1565b3480156105e757600080fd5b506103206105f636600461252e565b611006565b34801561060757600080fd5b5061030961104a565b34801561061c57600080fd5b5061030961062b366004612680565b611093565b34801561063c57600080fd5b5061032061116d565b34801561065157600080fd5b5061038f611173565b34801561066657600080fd5b50610362611182565b61030961067d366004612787565b611191565b34801561068e57600080fd5b5061030961069d36600461262e565b61151c565b3480156106ae57600080fd5b506103096115ea565b3480156106c357600080fd5b506103096106d2366004612680565b611638565b3480156106e357600080fd5b50610320611715565b3480156106f857600080fd5b506103096107073660046125b5565b61171b565b34801561071857600080fd5b506102d361072736600461252e565b61175a565b34801561073857600080fd5b50610309610747366004612787565b611778565b34801561075857600080fd5b50610362610767366004612787565b6117bc565b34801561077857600080fd5b5061032061195e565b34801561078d57600080fd5b5061032061079c36600461252e565b611964565b3480156107ad57600080fd5b506102d36107bc366004612548565b61197f565b3480156107cd57600080fd5b506103206119ad565b3480156107e257600080fd5b506103096107f1366004612741565b6119b3565b34801561080257600080fd5b5061030961081136600461252e565b611a05565b34801561082257600080fd5b506102d361083136600461252e565b611a76565b60006001600160e01b0319821663780e9d6360e01b148061085b575061085b82611a94565b90505b919050565b61086b611ad4565b6001600160a01b031661087c611173565b6001600160a01b0316146108ab5760405162461bcd60e51b81526004016108a290612ce5565b60405180910390fd5b601180549115156101000261ff0019909216919091179055565b60135481565b600f6020526000908152604090205460ff1681565b6060600080546108ef90612fc9565b80601f016020809104026020016040519081016040528092919081815260200182805461091b90612fc9565b80156109685780601f1061093d57610100808354040283529160200191610968565b820191906000526020600020905b81548152906001019060200180831161094b57829003601f168201915b5050505050905090565b600061097d82611ad8565b6109995760405162461bcd60e51b81526004016108a290612c99565b506000908152600460205260409020546001600160a01b031690565b600b80546109c290612fc9565b80601f01602080910402602001604051908101604052809291908181526020018280546109ee90612fc9565b8015610a3b5780601f10610a1057610100808354040283529160200191610a3b565b820191906000526020600020905b815481529060010190602001808311610a1e57829003601f168201915b505050505081565b6000610a4e82610fbc565b9050806001600160a01b0316836001600160a01b03161415610a825760405162461bcd60e51b81526004016108a290612ddd565b806001600160a01b0316610a94611ad4565b6001600160a01b03161480610ab05750610ab0816107bc611ad4565b610acc5760405162461bcd60e51b81526004016108a290612b06565b610ad68383611af5565b505050565b600d5460ff1681565b60085490565b610afb610af5611ad4565b82611b63565b610b175760405162461bcd60e51b81526004016108a290612e1e565b610ad6838383611be8565b610b2a611ad4565b6001600160a01b0316610b3b611173565b6001600160a01b031614610b615760405162461bcd60e51b81526004016108a290612ce5565b60005b81811015610ad6576000838383818110610b8e57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610ba3919061252e565b90506001600160a01b038116610bcb5760405162461bcd60e51b81526004016108a290612f0c565b6001600160a01b03166000908152600e60205260409020805460ff1916600117905580610bf781613004565b915050610b64565b6000610c0a83611006565b8210610c285760405162461bcd60e51b81526004016108a2906128d8565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b611b3981565b610c5f611ad4565b6001600160a01b0316610c70611173565b6001600160a01b031614610c965760405162461bcd60e51b81526004016108a290612ce5565b60005b81811015610ad6576000838383818110610cc357634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610cd8919061252e565b90506001600160a01b038116610d005760405162461bcd60e51b81526004016108a290612f0c565b6001600160a01b03166000908152600e60205260409020805460ff1916905580610d2981613004565b915050610c99565b610d39611ad4565b6001600160a01b0316610d4a611173565b6001600160a01b031614610d705760405162461bcd60e51b81526004016108a290612ce5565b4780610d7b57600080fd5b60405173032b023b216dc3b9a30975abf1f51de92a764a469082156108fc029083906000818181858888f19350505050158015610dbc573d6000803e3d6000fd5b5050565b610ad68383836040518060200160405280600081525061171b565b60145481565b6000610deb610ae4565b8210610e095760405162461bcd60e51b81526004016108a290612ec0565b60088281548110610e2a57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b60115460ff1681565b610e4d611ad4565b6001600160a01b0316610e5e611173565b6001600160a01b031614610e845760405162461bcd60e51b81526004016108a290612ce5565b6000600d5460ff166002811115610eab57634e487b7160e01b600052602160045260246000fd5b1415610ec357600d805460ff19166001179055610efe565b6001600d5460ff166002811115610eea57634e487b7160e01b600052602160045260246000fd5b1415610efe57600d805460ff191660021790555b565b610f08611ad4565b6001600160a01b0316610f19611173565b6001600160a01b031614610f3f5760405162461bcd60e51b81526004016108a290612ce5565b8051610dbc90600c9060208401906123fe565b73032b023b216dc3b9a30975abf1f51de92a764a4681565b601154610100900460ff1681565b610f80611ad4565b6001600160a01b0316610f91611173565b6001600160a01b031614610fb75760405162461bcd60e51b81526004016108a290612ce5565b601655565b6000818152600260205260408120546001600160a01b03168061085b5760405162461bcd60e51b81526004016108a290612bad565b600e6020526000908152604090205460ff1681565b60006001600160a01b03821661102e5760405162461bcd60e51b81526004016108a290612b63565b506001600160a01b031660009081526003602052604090205490565b611052611ad4565b6001600160a01b0316611063611173565b6001600160a01b0316146110895760405162461bcd60e51b81526004016108a290612ce5565b610efe6000611d15565b61109b611ad4565b6001600160a01b03166110ac611173565b6001600160a01b0316146110d25760405162461bcd60e51b81526004016108a290612ce5565b60005b81811015610ad65760008383838181106110ff57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611114919061252e565b90506001600160a01b03811661113c5760405162461bcd60e51b81526004016108a290612f0c565b6001600160a01b03166000908152600f60205260409020805460ff191690558061116581613004565b9150506110d5565b60125481565b600a546001600160a01b031690565b6060600180546108ef90612fc9565b601154610100900460ff16156111b95760405162461bcd60e51b81526004016108a290612adc565b60006111c3610ae4565b905060006111cf611ad4565b9050600083116111de57600080fd5b611b398211156112005760405162461bcd60e51b81526004016108a290612c77565b611b3961120d8484612f3b565b111561122b5760405162461bcd60e51b81526004016108a290612a6d565b6000600d5460ff16600281111561125257634e487b7160e01b600052602160045260246000fd5b141561127d57611260611173565b6001600160a01b0316816001600160a01b03161461127d57600080fd5b6001600160a01b038116600090815260106020526040812054906112a08361175a565b905060006112ad84611a76565b90506001600d5460ff1660028111156112d657634e487b7160e01b600052602160045260246000fd5b1415611423576112e4611173565b6001600160a01b0316846001600160a01b0316146114235780806113055750815b61130e57600080fd5b80156113cc578261133f57601454861461133a5760405162461bcd60e51b81526004016108a290612e6f565b6113c7565b8161135c5760405162461bcd60e51b81526004016108a2906128a1565b600060155460145461136e9190612f3b565b90508061137b8589612f3b565b11156113995760405162461bcd60e51b81526004016108a290612e6f565b6013546113a69088611d67565b3410156113c55760405162461bcd60e51b81526004016108a290612db2565b505b611423565b6015546113d98488612f3b565b11156113f75760405162461bcd60e51b81526004016108a290612e6f565b6013546114049087611d67565b3410156114235760405162461bcd60e51b81526004016108a290612db2565b6002600d5460ff16600281111561144a57634e487b7160e01b600052602160045260246000fd5b14156114be57611458611173565b6001600160a01b0316846001600160a01b0316146114be576016548611156114925760405162461bcd60e51b81526004016108a290612bf6565b60125461149f9087611d67565b3410156114be5760405162461bcd60e51b81526004016108a290612db2565b60005b86811015611513576114d285611d73565b6001600160a01b03851660009081526010602052604081208054600192906114fb908490612f3b565b9091555081905061150b81613004565b9150506114c1565b50505050505050565b611524611ad4565b6001600160a01b0316826001600160a01b031614156115555760405162461bcd60e51b81526004016108a290612a36565b8060056000611562611ad4565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff1916921515929092179091556115a6611ad4565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516115de919061285b565b60405180910390a35050565b6115f2611ad4565b6001600160a01b0316611603611173565b6001600160a01b0316146116295760405162461bcd60e51b81526004016108a290612ce5565b6011805460ff19166001179055565b611640611ad4565b6001600160a01b0316611651611173565b6001600160a01b0316146116775760405162461bcd60e51b81526004016108a290612ce5565b60005b81811015610ad65760008383838181106116a457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906116b9919061252e565b90506001600160a01b0381166116e15760405162461bcd60e51b81526004016108a290612f0c565b6001600160a01b03166000908152600f60205260409020805460ff191660011790558061170d81613004565b91505061167a565b60155481565b61172c611726611ad4565b83611b63565b6117485760405162461bcd60e51b81526004016108a290612e1e565b61175484848484611dc3565b50505050565b6001600160a01b03166000908152600e602052604090205460ff1690565b611780611ad4565b6001600160a01b0316611791611173565b6001600160a01b0316146117b75760405162461bcd60e51b81526004016108a290612ce5565b601555565b60606117c782611ad8565b6117e35760405162461bcd60e51b81526004016108a290612d63565b60115460ff1661187f57600b80546117fa90612fc9565b80601f016020809104026020016040519081016040528092919081815260200182805461182690612fc9565b80156118735780601f1061184857610100808354040283529160200191611873565b820191906000526020600020905b81548152906001019060200180831161185657829003601f168201915b5050505050905061085e565b6000600c805461188e90612fc9565b80601f01602080910402602001604051908101604052809291908181526020018280546118ba90612fc9565b80156119075780601f106118dc57610100808354040283529160200191611907565b820191906000526020600020905b8154815290600101906020018083116118ea57829003601f168201915b50505050509050600081511161192c5760405180602001604052806000815250611957565b8061193684611df6565b6040516020016119479291906127cb565b6040516020818303038152906040525b9392505050565b60165481565b6001600160a01b031660009081526010602052604090205490565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60175481565b6119bb611ad4565b6001600160a01b03166119cc611173565b6001600160a01b0316146119f25760405162461bcd60e51b81526004016108a290612ce5565b8051610dbc90600b9060208401906123fe565b611a0d611ad4565b6001600160a01b0316611a1e611173565b6001600160a01b031614611a445760405162461bcd60e51b81526004016108a290612ce5565b6001600160a01b038116611a6a5760405162461bcd60e51b81526004016108a290612975565b611a7381611d15565b50565b6001600160a01b03166000908152600f602052604090205460ff1690565b60006001600160e01b031982166380ac58cd60e01b1480611ac557506001600160e01b03198216635b5e139f60e01b145b8061085b575061085b82611f11565b3390565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611b2a82610fbc565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611b6e82611ad8565b611b8a5760405162461bcd60e51b81526004016108a290612a90565b6000611b9583610fbc565b9050806001600160a01b0316846001600160a01b03161480611bd05750836001600160a01b0316611bc584610972565b6001600160a01b0316145b80611be05750611be0818561197f565b949350505050565b826001600160a01b0316611bfb82610fbc565b6001600160a01b031614611c215760405162461bcd60e51b81526004016108a290612d1a565b6001600160a01b038216611c475760405162461bcd60e51b81526004016108a2906129f2565b611c52838383611f2a565b611c5d600082611af5565b6001600160a01b0383166000908152600360205260408120805460019290611c86908490612f86565b90915550506001600160a01b0382166000908152600360205260408120805460019290611cb4908490612f3b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006119578284612f67565b6000611d7d610ae4565b611d88906001612f3b565b9050611d948282611fb3565b60405181907f7cb574218d14b9dd790daadb2b993eb8771d849bc51194d1c43c07db36ea9d7290600090a25050565b611dce848484611be8565b611dda84848484611fcd565b6117545760405162461bcd60e51b81526004016108a290612923565b606081611e1b57506040805180820190915260018152600360fc1b602082015261085e565b8160005b8115611e455780611e2f81613004565b9150611e3e9050600a83612f53565b9150611e1f565b60008167ffffffffffffffff811115611e6e57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015611e98576020820181803683370190505b5090505b8415611be057611ead600183612f86565b9150611eba600a8661301f565b611ec5906030612f3b565b60f81b818381518110611ee857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611f0a600a86612f53565b9450611e9c565b6001600160e01b031981166301ffc9a760e01b14919050565b611f35838383610ad6565b6001600160a01b038316611f5157611f4c816120e8565b611f74565b816001600160a01b0316836001600160a01b031614611f7457611f74838261212c565b6001600160a01b038216611f9057611f8b816121c9565b610ad6565b826001600160a01b0316826001600160a01b031614610ad657610ad682826122a2565b610dbc8282604051806020016040528060008152506122e6565b6000611fe1846001600160a01b0316612319565b156120dd57836001600160a01b031663150b7a02611ffd611ad4565b8786866040518563ffffffff1660e01b815260040161201f949392919061281e565b602060405180830381600087803b15801561203957600080fd5b505af1925050508015612069575060408051601f3d908101601f1916820190925261206691810190612725565b60015b6120c3573d808015612097576040519150601f19603f3d011682016040523d82523d6000602084013e61209c565b606091505b5080516120bb5760405162461bcd60e51b81526004016108a290612923565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611be0565b506001949350505050565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6000600161213984611006565b6121439190612f86565b600083815260076020526040902054909150808214612196576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906121db90600190612f86565b6000838152600960205260408120546008805493945090928490811061221157634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806008838154811061224057634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061228657634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006122ad83611006565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6122f0838361231f565b6122fd6000848484611fcd565b610ad65760405162461bcd60e51b81526004016108a290612923565b3b151590565b6001600160a01b0382166123455760405162461bcd60e51b81526004016108a290612c42565b61234e81611ad8565b1561236b5760405162461bcd60e51b81526004016108a2906129bb565b61237760008383611f2a565b6001600160a01b03821660009081526003602052604081208054600192906123a0908490612f3b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461240a90612fc9565b90600052602060002090601f01602090048101928261242c5760008555612472565b82601f1061244557805160ff1916838001178555612472565b82800160010185558215612472579182015b82811115612472578251825591602001919060010190612457565b5061247e929150612482565b5090565b5b8082111561247e5760008155600101612483565b600067ffffffffffffffff808411156124b2576124b261305f565b604051601f8501601f1916810160200182811182821017156124d6576124d661305f565b6040528481529150818385018610156124ee57600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b038116811461085e57600080fd5b8035801515811461085e57600080fd5b60006020828403121561253f578081fd5b61195782612507565b6000806040838503121561255a578081fd5b61256383612507565b915061257160208401612507565b90509250929050565b60008060006060848603121561258e578081fd5b61259784612507565b92506125a560208501612507565b9150604084013590509250925092565b600080600080608085870312156125ca578081fd5b6125d385612507565b93506125e160208601612507565b925060408501359150606085013567ffffffffffffffff811115612603578182fd5b8501601f81018713612613578182fd5b61262287823560208401612497565b91505092959194509250565b60008060408385031215612640578182fd5b61264983612507565b91506125716020840161251e565b60008060408385031215612669578182fd5b61267283612507565b946020939093013593505050565b60008060208385031215612692578182fd5b823567ffffffffffffffff808211156126a9578384fd5b818501915085601f8301126126bc578384fd5b8135818111156126ca578485fd5b86602080830285010111156126dd578485fd5b60209290920196919550909350505050565b600060208284031215612700578081fd5b6119578261251e565b60006020828403121561271a578081fd5b813561195781613075565b600060208284031215612736578081fd5b815161195781613075565b600060208284031215612752578081fd5b813567ffffffffffffffff811115612768578182fd5b8201601f81018413612778578182fd5b611be084823560208401612497565b600060208284031215612798578081fd5b5035919050565b600081518084526127b7816020860160208601612f9d565b601f01601f19169290920160200192915050565b600083516127dd818460208801612f9d565b8351908301906127f1818360208801612f9d565b64173539b7b760d91b9101908152600501949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906128519083018461279f565b9695505050505050565b901515815260200190565b602081016003831061288857634e487b7160e01b600052602160045260246000fd5b91905290565b600060208252611957602083018461279f565b6020808252601b908201527f596f7520617265206e6f7420616c6c6f77656420746f206d696e740000000000604082015260600190565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b60208082526009908201526813585e081b1a5b5a5d60ba1b604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252602c908201527f4e756d626572206f66206d696e7461626c6520746f6b656e73206c696d69746560408201526b19081c195c881dd85b1b195d60a21b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b60208082526008908201526714d85b1948195b9960c21b604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b60208082526011908201527056616c75652062656c6f7720707269636560781b604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526031908201527f596f752063616e2774206d696e74206d6f7265207468616e20616c6c6f776564604082015270206e756d626572206f6620746f6b656e7360781b606082015260800190565b6020808252602c908201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60408201526b7574206f6620626f756e647360a01b606082015260800190565b6020808252600c908201526b4e756c6c204164647265737360a01b604082015260600190565b90815260200190565b60008219821115612f4e57612f4e613033565b500190565b600082612f6257612f62613049565b500490565b6000816000190483118215151615612f8157612f81613033565b500290565b600082821015612f9857612f98613033565b500390565b60005b83811015612fb8578181015183820152602001612fa0565b838111156117545750506000910152565b600281046001821680612fdd57607f821691505b60208210811415612ffe57634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561301857613018613033565b5060010190565b60008261302e5761302e613049565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114611a7357600080fdfea26469706673582212208ece526b9c1251d5a1402ee39f3780d38d0867338bfff152d5afc2411b239eb464736f6c63430008000033
[ 7, 5 ]
0xf1f7ebcbf295c659ec25077f2886703147f55e3f
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; 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; } } /* * @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; } } /** * @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 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; } /** * @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); } } } } /** * @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() public{ 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; } } /** * @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 Mint amount of token to specified account by an operator address */ function mint(address account, uint256 amount) external returns (bool); /** * @dev Burn amount of token from specified account by an operator address */ function burn(address account, uint256 amount) external returns (bool); /** * @dev Add an address to operator list of token */ function addOperator(address minter) external returns (bool); /** * @dev Remove an address from operator list of token */ function removeOperator(address minter) 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 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"); } } } contract StakeUSDLrLGD is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public token; IERC20 public lgd; uint256 public tokenDecimal; uint256 public timeStart; uint256 public duration = 7 * 24 * 60 * 60; uint256 public _PoolInterestRate = 10; mapping(address => uint256) public _PoolClaimedRewards; event TokenTransfer( address indexed wallet, uint256 amount, string reason, uint256 atBlock, uint256 datetime ); struct StakeInfo { uint256 startAt; uint256 endedAt; uint256 amount; uint256 snapshotAmount; } mapping(address => StakeInfo[]) public _StakeSlots; mapping(address => uint256) public depositAt; // in case of flashloan attacks constructor( address _token, uint256 _tokenDecimal, address _lgd, uint256 _timeStart ) public { token = IERC20(_token); tokenDecimal = _tokenDecimal; lgd = IERC20(_lgd); timeStart = _timeStart; } function Deposit(uint256 _amount) external { require(_amount > 0, "need gt 0"); uint256 startAt = timeStart > block.timestamp ? timeStart : block.timestamp; uint256 endAt = startAt.add(duration); StakeInfo memory info = StakeInfo({ startAt: startAt, endedAt: endAt, amount: _amount, snapshotAmount: _amount }); _StakeSlots[msg.sender].push(info); token.safeTransferFrom(msg.sender, address(this), _amount); } function rewardsOf(address stakeholder) public view returns (uint256 userRewardsLGD, uint256 totalRewardLGD) { uint256 totalRewardsLGD = 0; for (uint256 i = 0; i < _StakeSlots[stakeholder].length; i++) { StakeInfo storage infodsc = _StakeSlots[stakeholder][i]; uint256 currentTime = infodsc.endedAt > block.timestamp ? block.timestamp : infodsc.endedAt; uint256 spentTime = timeStart > block.timestamp ? 0 : currentTime.sub(infodsc.startAt); uint256 newRewards = (infodsc.snapshotAmount * spentTime * _PoolInterestRate) / (duration * 100 * 500); totalRewardsLGD = totalRewardsLGD.add(newRewards); } uint256 availableRewards = totalRewardsLGD - _PoolClaimedRewards[stakeholder]; return (availableRewards, totalRewardsLGD); } function Claimd() public { (uint256 userRewards, ) = rewardsOf(msg.sender); require(userRewards > 0, "Invalid rewards amount."); uint256 amountTransfer = userRewards.mul(uint256(1e18)).div(10**tokenDecimal); lgd.mint(msg.sender, amountTransfer); _PoolClaimedRewards[msg.sender] = _PoolClaimedRewards[ msg.sender ] .add(userRewards); emit TokenTransfer( msg.sender, userRewards, "LGDReward", block.number, block.timestamp ); } function withdraw(uint256 id) public { require( _StakeSlots[msg.sender][id].amount > 0, "Invalid amount to withdraw" ); // Then process to withdraw stake token uint256 withdrawAmount = _StakeSlots[msg.sender][id].amount; _StakeSlots[msg.sender][id].amount = 0; _StakeSlots[msg.sender][id].endedAt = timeStart > block.timestamp ? timeStart : block.timestamp; token.safeTransfer(msg.sender, withdrawAmount); emit TokenTransfer( msg.sender, withdrawAmount, "USDL WITHDRAWAL", block.number, block.timestamp ); } function withdrawAndExit() public { (uint256 userRewards, ) = rewardsOf(msg.sender); //transfer reward uint256 amountTransfer = userRewards.mul(uint256(1e18)).div(10**tokenDecimal); lgd.mint(msg.sender, amountTransfer); _PoolClaimedRewards[msg.sender] = _PoolClaimedRewards[ msg.sender ] .add(userRewards); emit TokenTransfer( msg.sender, userRewards, "LGDReward", block.number, block.timestamp ); //transfer total stake uint256 totalStake = 0; for (uint256 i = 0; i < _StakeSlots[msg.sender].length; i++) { StakeInfo storage infodsc = _StakeSlots[msg.sender][i]; totalStake = totalStake.add(infodsc.amount); if(infodsc.amount != 0){ infodsc.endedAt = timeStart > block.timestamp ? timeStart : block.timestamp; infodsc.amount = 0; } } require(totalStake > 0, "Invalid withdrawal amount."); token.safeTransfer(msg.sender, totalStake); emit TokenTransfer( msg.sender, totalStake, "USDL WITHDRAWAL", block.number, block.timestamp ); } function getStakeSlots(address _address) public view returns (StakeInfo[] memory) { return _StakeSlots[_address]; } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80637f1abbda116100a2578063e6b0595011610071578063e6b05950146102ad578063f2fde38b146102dd578063fc0c546a146102f9578063fc894dc714610317578063fd74d2941461033557610116565b80637f1abbda14610211578063880ec0741461022f57806388bc71de1461025f5780638da5cb5b1461028f57610116565b806352ad2e62116100e957806352ad2e62146101a25780635caed029146101ac5780636f20a3c5146101ca578063715018a6146101d457806371a8a6e6146101de57610116565b80630fb5a6b41461011b5780632e1a7d4d14610139578063479ba7ae146101555780634d6ce1e514610186575b600080fd5b610123610353565b6040516101309190612163565b60405180910390f35b610153600480360361014e91908101906119ee565b610359565b005b61016f600480360361016a9190810190611960565b6105cd565b60405161017d929190612212565b60405180910390f35b6101a0600480360361019b91908101906119ee565b610763565b005b6101aa6108e9565b005b6101b4610cb6565b6040516101c19190612163565b60405180910390f35b6101d2610cbc565b005b6101dc610ede565b005b6101f860048036036101f39190810190611989565b611033565b604051610208949392919061223b565b60405180910390f35b61021961107d565b6040516102269190611fe6565b60405180910390f35b61024960048036036102449190810190611960565b6110a3565b6040516102569190612163565b60405180910390f35b61027960048036036102749190810190611960565b6110bb565b6040516102869190611fc4565b60405180910390f35b610297611181565b6040516102a49190611f20565b60405180910390f35b6102c760048036036102c29190810190611960565b6111aa565b6040516102d49190612163565b60405180910390f35b6102f760048036036102f29190810190611960565b6111c2565b005b610301611386565b60405161030e9190611fe6565b60405180910390f35b61031f6113ac565b60405161032c9190612163565b60405180910390f35b61033d6113b2565b60405161034a9190612163565b60405180910390f35b60055481565b6000600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481106103a557fe5b906000526020600020906004020160020154116103f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ee906120a3565b60405180910390fd5b6000600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811061044357fe5b90600052602060002090600402016002015490506000600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083815481106104a357fe5b90600052602060002090600402016002018190555042600454116104c757426104cb565b6004545b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020838154811061051557fe5b9060005260206000209060040201600101819055506105773382600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113b89092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f6fe2a1b5927c8a3644677f120580bbc93f1423a193e852883b2c61e0d6019dc58243426040516105c1939291906121c8565b60405180910390a25050565b600080600080905060008090505b600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905081101561070f576000600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811061067157fe5b9060005260206000209060040201905060004282600101541161069857816001015461069a565b425b9050600042600454116106c3576106be83600001548361143e90919063ffffffff16565b6106c6565b60005b905060006101f4606460055402026006548386600301540202816106e657fe5b0490506106fc818761148890919063ffffffff16565b95505050505080806001019150506105db565b506000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054820390508082935093505050915091565b600081116107a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079d90612023565b60405180910390fd5b600042600454116107b757426107bb565b6004545b905060006107d46005548361148890919063ffffffff16565b90506107de6118f9565b6040518060800160405280848152602001838152602001858152602001858152509050600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190806001815401808255809150506001900390600052602060002090600402016000909190919091506000820151816000015560208201518160010155604082015181600201556060820151816003015550506108e3333086600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166114dd909392919063ffffffff16565b50505050565b60006108f4336105cd565b509050600061092b600354600a0a61091d670de0b6b3a76400008561156690919063ffffffff16565b6115d690919063ffffffff16565b9050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933836040518363ffffffff1660e01b815260040161098a929190611f3b565b602060405180830381600087803b1580156109a457600080fd5b505af11580156109b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506109dc91908101906119c5565b50610a2f82600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461148890919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f6fe2a1b5927c8a3644677f120580bbc93f1423a193e852883b2c61e0d6019dc5834342604051610abc9392919061217e565b60405180910390a2600080905060008090505b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050811015610bce576000600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110610b6557fe5b90600052602060002090600402019050610b8c81600201548461148890919063ffffffff16565b92506000816002015414610bc0574260045411610ba95742610bad565b6004545b8160010181905550600081600201819055505b508080600101915050610acf565b5060008111610c12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c09906120c3565b60405180910390fd5b610c5f3382600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113b89092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167f6fe2a1b5927c8a3644677f120580bbc93f1423a193e852883b2c61e0d6019dc5824342604051610ca9939291906121c8565b60405180910390a2505050565b60035481565b6000610cc7336105cd565b50905060008111610d0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0490612083565b60405180910390fd5b6000610d41600354600a0a610d33670de0b6b3a76400008561156690919063ffffffff16565b6115d690919063ffffffff16565b9050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933836040518363ffffffff1660e01b8152600401610da0929190611f3b565b602060405180830381600087803b158015610dba57600080fd5b505af1158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610df291908101906119c5565b50610e4582600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461148890919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f6fe2a1b5927c8a3644677f120580bbc93f1423a193e852883b2c61e0d6019dc5834342604051610ed29392919061217e565b60405180910390a25050565b610ee6611620565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6b90612103565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6008602052816000526040600020818154811061104c57fe5b9060005260206000209060040201600091509150508060000154908060010154908060020154908060030154905084565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60076020528060005260406000206000915090505481565b6060600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561117657838290600052602060002090600402016040518060800160405290816000820154815260200160018201548152602001600282015481526020016003820154815250508152602001906001019061111c565b505050509050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60096020528060005260406000206000915090505481565b6111ca611620565b73ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611258576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124f90612103565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156112c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112bf90612043565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b60045481565b6114398363a9059cbb60e01b84846040516024016113d7929190611f9b565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611628565b505050565b600061148083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506116ef565b905092915050565b6000808284019050838110156114d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114ca90612063565b60405180910390fd5b8091505092915050565b611560846323b872dd60e01b8585856040516024016114fe93929190611f64565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611628565b50505050565b60008083141561157957600090506115d0565b600082840290508284828161158a57fe5b04146115cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c2906120e3565b60405180910390fd5b809150505b92915050565b600061161883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061174a565b905092915050565b600033905090565b606061168a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166117ab9092919063ffffffff16565b90506000815111156116ea57808060200190516116aa91908101906119c5565b6116e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116e090612143565b60405180910390fd5b5b505050565b6000838311158290611737576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161172e9190612001565b60405180910390fd5b5060008385039050809150509392505050565b60008083118290611791576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117889190612001565b60405180910390fd5b50600083858161179d57fe5b049050809150509392505050565b60606117ba84846000856117c3565b90509392505050565b60606117ce856118e6565b61180d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180490612123565b60405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040516118379190611f09565b60006040518083038185875af1925050503d8060008114611874576040519150601f19603f3d011682016040523d82523d6000602084013e611879565b606091505b5091509150811561188e5780925050506118de565b6000815111156118a15780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d59190612001565b60405180910390fd5b949350505050565b600080823b905060008111915050919050565b6040518060800160405280600081526020016000815260200160008152602001600081525090565b600081359050611930816123d1565b92915050565b600081519050611945816123e8565b92915050565b60008135905061195a816123ff565b92915050565b60006020828403121561197257600080fd5b600061198084828501611921565b91505092915050565b6000806040838503121561199c57600080fd5b60006119aa85828601611921565b92505060206119bb8582860161194b565b9150509250929050565b6000602082840312156119d757600080fd5b60006119e584828501611936565b91505092915050565b600060208284031215611a0057600080fd5b6000611a0e8482850161194b565b91505092915050565b6000611a238383611e96565b60808301905092915050565b611a3881612333565b82525050565b611a47816122eb565b82525050565b6000611a5882612290565b611a6281856122be565b9350611a6d83612280565b8060005b83811015611a9e578151611a858882611a17565b9750611a90836122b1565b925050600181019050611a71565b5085935050505092915050565b6000611ab68261229b565b611ac081856122cf565b9350611ad081856020860161238d565b80840191505092915050565b611ae581612345565b82525050565b6000611af6826122a6565b611b0081856122da565b9350611b1081856020860161238d565b611b19816123c0565b840191505092915050565b6000611b316009836122da565b91507f6e656564206774203000000000000000000000000000000000000000000000006000830152602082019050919050565b6000611b716026836122da565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611bd7601b836122da565b91507f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006000830152602082019050919050565b6000611c176017836122da565b91507f496e76616c6964207265776172647320616d6f756e742e0000000000000000006000830152602082019050919050565b6000611c57601a836122da565b91507f496e76616c696420616d6f756e7420746f2077697468647261770000000000006000830152602082019050919050565b6000611c97601a836122da565b91507f496e76616c6964207769746864726177616c20616d6f756e742e0000000000006000830152602082019050919050565b6000611cd76021836122da565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611d3d6020836122da565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000611d7d6009836122da565b91507f4c474452657761726400000000000000000000000000000000000000000000006000830152602082019050919050565b6000611dbd600f836122da565b91507f5553444c205749544844524157414c00000000000000000000000000000000006000830152602082019050919050565b6000611dfd601d836122da565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b6000611e3d602a836122da565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b608082016000820151611eac6000850182611eeb565b506020820151611ebf6020850182611eeb565b506040820151611ed26040850182611eeb565b506060820151611ee56060850182611eeb565b50505050565b611ef481612329565b82525050565b611f0381612329565b82525050565b6000611f158284611aab565b915081905092915050565b6000602082019050611f356000830184611a3e565b92915050565b6000604082019050611f506000830185611a2f565b611f5d6020830184611efa565b9392505050565b6000606082019050611f796000830186611a3e565b611f866020830185611a3e565b611f936040830184611efa565b949350505050565b6000604082019050611fb06000830185611a3e565b611fbd6020830184611efa565b9392505050565b60006020820190508181036000830152611fde8184611a4d565b905092915050565b6000602082019050611ffb6000830184611adc565b92915050565b6000602082019050818103600083015261201b8184611aeb565b905092915050565b6000602082019050818103600083015261203c81611b24565b9050919050565b6000602082019050818103600083015261205c81611b64565b9050919050565b6000602082019050818103600083015261207c81611bca565b9050919050565b6000602082019050818103600083015261209c81611c0a565b9050919050565b600060208201905081810360008301526120bc81611c4a565b9050919050565b600060208201905081810360008301526120dc81611c8a565b9050919050565b600060208201905081810360008301526120fc81611cca565b9050919050565b6000602082019050818103600083015261211c81611d30565b9050919050565b6000602082019050818103600083015261213c81611df0565b9050919050565b6000602082019050818103600083015261215c81611e30565b9050919050565b60006020820190506121786000830184611efa565b92915050565b60006080820190506121936000830186611efa565b81810360208301526121a481611d70565b90506121b36040830185611efa565b6121c06060830184611efa565b949350505050565b60006080820190506121dd6000830186611efa565b81810360208301526121ee81611db0565b90506121fd6040830185611efa565b61220a6060830184611efa565b949350505050565b60006040820190506122276000830185611efa565b6122346020830184611efa565b9392505050565b60006080820190506122506000830187611efa565b61225d6020830186611efa565b61226a6040830185611efa565b6122776060830184611efa565b95945050505050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b60006122f682612309565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600061233e82612369565b9050919050565b600061235082612357565b9050919050565b600061236282612309565b9050919050565b60006123748261237b565b9050919050565b600061238682612309565b9050919050565b60005b838110156123ab578082015181840152602081019050612390565b838111156123ba576000848401525b50505050565b6000601f19601f8301169050919050565b6123da816122eb565b81146123e557600080fd5b50565b6123f1816122fd565b81146123fc57600080fd5b50565b61240881612329565b811461241357600080fd5b5056fea26469706673582212207551237b5d4708a77e9e099b27d5910877b96ecd1736ba544d064f2b0755218164736f6c63430006020033
[ 7, 5 ]
0xf1f955016EcbCd7321c7266BccFB96c68ea5E49b
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; // /* * @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; } } // /** * @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 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; } } // /** * @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 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; } /** * @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); } } } } // /** * @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 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 { } } // contract RallyToken is ERC20 { //15 billion fixed token supply with default 18 decimals uint256 public constant TOKEN_SUPPLY = 15 * 10**9 * 10**18; constructor ( address _escrow ) public ERC20( "Rally", "RLY" ) { _mint(_escrow, TOKEN_SUPPLY); } }
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a082311461021057806395d89b4114610236578063a457c2d71461023e578063a9059cbb1461026a578063b152f6cf14610296578063dd62ed3e1461029e576100b4565b806306fdde03146100b9578063095ea7b31461013657806318160ddd1461017657806323b872dd14610190578063313ce567146101c657806339509351146101e4575b600080fd5b6100c16102cc565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100fb5781810151838201526020016100e3565b50505050905090810190601f1680156101285780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101626004803603604081101561014c57600080fd5b506001600160a01b038135169060200135610362565b604080519115158252519081900360200190f35b61017e61037f565b60408051918252519081900360200190f35b610162600480360360608110156101a657600080fd5b506001600160a01b03813581169160208101359091169060400135610385565b6101ce61040c565b6040805160ff9092168252519081900360200190f35b610162600480360360408110156101fa57600080fd5b506001600160a01b038135169060200135610415565b61017e6004803603602081101561022657600080fd5b50356001600160a01b0316610463565b6100c161047e565b6101626004803603604081101561025457600080fd5b506001600160a01b0381351690602001356104df565b6101626004803603604081101561028057600080fd5b506001600160a01b038135169060200135610547565b61017e61055b565b61017e600480360360408110156102b457600080fd5b506001600160a01b038135811691602001351661056b565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103585780601f1061032d57610100808354040283529160200191610358565b820191906000526020600020905b81548152906001019060200180831161033b57829003601f168201915b5050505050905090565b600061037661036f6105f7565b84846105fb565b50600192915050565b60025490565b60006103928484846106e7565b6104028461039e6105f7565b6103fd8560405180606001604052806028815260200161094a602891396001600160a01b038a166000908152600160205260408120906103dc6105f7565b6001600160a01b031681526020810191909152604001600020549190610842565b6105fb565b5060019392505050565b60055460ff1690565b60006103766104226105f7565b846103fd85600160006104336105f7565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610596565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103585780601f1061032d57610100808354040283529160200191610358565b60006103766104ec6105f7565b846103fd856040518060600160405280602581526020016109bb60259139600160006105166105f7565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610842565b60006103766105546105f7565b84846106e7565b6b3077b58d5d3783919800000081565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6000828201838110156105f0576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b0383166106405760405162461bcd60e51b81526004018080602001828103825260248152602001806109976024913960400191505060405180910390fd5b6001600160a01b0382166106855760405162461bcd60e51b81526004018080602001828103825260228152602001806109026022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b03831661072c5760405162461bcd60e51b81526004018080602001828103825260258152602001806109726025913960400191505060405180910390fd5b6001600160a01b0382166107715760405162461bcd60e51b81526004018080602001828103825260238152602001806108df6023913960400191505060405180910390fd5b61077c8383836108d9565b6107b981604051806060016040528060268152602001610924602691396001600160a01b0386166000908152602081905260409020549190610842565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546107e89082610596565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600081848411156108d15760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561089657818101518382015260200161087e565b50505050905090810190601f1680156108c35780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122069a6bd1ae1dba3de9c678bf81c873ee12bd768242a79ea2bfb89e50529f7246764736f6c634300060c0033
[ 38 ]
0xf1f9c1ec9c2dac0a4c1ee99df476e383f0abbf98
// SPDX-License-Identifier: No License pragma solidity 0.6.12; // ---------------------------------------------------------------------------- // 'BEAM ME UP' token contract // // Symbol : SCOTTY // Name : BEAM ME UP // Total supply: 100 000 // Decimals : 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) { 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; } } /** * @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. */ constructor () internal { 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; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ interface ERC20Basic { function balanceOf(address who) external view returns (uint256 balance); function transfer(address to, uint256 value) external returns (bool trans1); function allowance(address owner, address spender) external view returns (uint256 remaining); function transferFrom(address from, address to, uint256 value) external returns (bool trans); function approve(address spender, uint256 value) external returns (bool hello); event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ /** * @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 ERC20Basic, Ownable { uint256 public totalSupply; using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public override returns (bool trans1) { require(_to != address(0)); //require(canTransfer(msg.sender)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. */ function balanceOf(address _owner) public view override returns (uint256 balance) { return balances[_owner]; } mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public override returns (bool trans) { require(_to != address(0)); // require(canTransfer(msg.sender)); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public override returns (bool hello) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. */ function allowance(address _owner, address _spender) public view override returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } } /** * @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); emit Burn(burner, _value); emit Transfer(burner, address(0), _value); } } contract SCOTTY is BurnableToken { string public constant name = "BEAM ME UP"; string public constant symbol = "SCOTTY"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 100000 * (10 ** uint256(decimals)); // Constructors constructor () public{ totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner //allowedAddresses[owner] = true; } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80636618846311610097578063a9059cbb11610066578063a9059cbb14610460578063d73dd623146104c4578063dd62ed3e14610528578063f2fde38b146105a0576100f5565b806366188463146102ed57806370a08231146103515780638da5cb5b146103a957806395d89b41146103dd576100f5565b806323b872dd116100d357806323b872dd146101ff578063313ce56714610283578063378dc3dc146102a157806342966c68146102bf576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e1575b600080fd5b6101026105e4565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061061d565b60405180821515815260200191505060405180910390f35b6101e961070f565b6040518082815260200191505060405180910390f35b61026b6004803603606081101561021557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610715565b60405180821515815260200191505060405180910390f35b61028b6109ff565b6040518082815260200191505060405180910390f35b6102a9610a04565b6040518082815260200191505060405180910390f35b6102eb600480360360208110156102d557600080fd5b8101908080359060200190929190505050610a11565b005b6103396004803603604081101561030357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bd7565b60405180821515815260200191505060405180910390f35b6103936004803603602081101561036757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e68565b6040518082815260200191505060405180910390f35b6103b1610eb1565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6103e5610ed5565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561042557808201518184015260208101905061040a565b50505050905090810190601f1680156104525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104ac6004803603604081101561047657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f0e565b60405180821515815260200191505060405180910390f35b610510600480360360408110156104da57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110e2565b60405180821515815260200191505060405180910390f35b61058a6004803603604081101561053e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506112de565b6040518082815260200191505060405180910390f35b6105e2600480360360208110156105b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611365565b005b6040518060400160405280600a81526020017f4245414d204d452055500000000000000000000000000000000000000000000081525081565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60015481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561075057600080fd5b6000600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905061082383600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b490919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108b883600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114cb90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061090e83826114b490919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b601281565b6012600a0a620186a00281565b60008111610a1e57600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054811115610a6a57600080fd5b6000339050610ac182600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b490919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b19826001546114b490919063ffffffff16565b6001819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a2600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050565b600080600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610ce8576000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d7c565b610cfb83826114b490919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040518060400160405280600681526020017f53434f545459000000000000000000000000000000000000000000000000000081525081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f4957600080fd5b610f9b82600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b490919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061103082600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114cb90919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600061117382600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114cb90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113bd57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113f757600080fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000828211156114c057fe5b818303905092915050565b6000808284019050838110156114dd57fe5b809150509291505056fea264697066735822122077fd7ca400923b27f29d39484a0f8b7fc53b912d8bff5a3f23abc1810a2db7ef64736f6c634300060c0033
[ 38 ]
0xf1fa285ef1e28315d3ddb534c85dee02dfb90f9e
pragma solidity ^0.4.24; library SafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c>=a && c>=b); return c; } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) view public returns (uint256 balance); 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) view public returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract StandardToken is Token { mapping (address => uint256) public _balances; mapping (address => mapping (address => uint256)) public _allowed; function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(_value <= _balances[msg.sender]); require(_balances[_to] + _value > _balances[_to]); _balances[msg.sender] = SafeMath.safeSub(_balances[msg.sender], _value); _balances[_to] = SafeMath.safeAdd(_balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(_value <= _balances[_from]); require(_value <= _allowed[_from][msg.sender]); require(_balances[_to] + _value > _balances[_to]); _balances[_to] = SafeMath.safeAdd(_balances[_to], _value); _balances[_from] = SafeMath.safeSub(_balances[_from], _value); _allowed[_from][msg.sender] = SafeMath.safeSub(_allowed[_from][msg.sender], _value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) view public returns (uint256 balance) { return _balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { require((_value == 0) || (_allowed[msg.sender][_spender] == 0)); _allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) view public returns (uint256 remaining) { return _allowed[_owner][_spender]; } } contract SNKToken is StandardToken { function () public payable { revert(); } string public name = "SNK Super Game"; uint8 public decimals = 4; string public symbol = "SNK"; uint256 public totalSupply = 1000000000*10**uint256(decimals); constructor() public { _balances[msg.sender] = totalSupply; emit Transfer(address(0), msg.sender, totalSupply); } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014457806318160ddd146101a957806323b872dd146101d4578063313ce567146102595780636ebcf6071461028a57806370a08231146102e157806395d89b4114610338578063a9059cbb146103c8578063ba0fb8611461042d578063dd62ed3e146104a4575b600080fd5b3480156100c057600080fd5b506100c961051b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101095780820151818401526020810190506100ee565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061018f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105b9565b604051808215151515815260200191505060405180910390f35b3480156101b557600080fd5b506101be610740565b6040518082815260200191505060405180910390f35b3480156101e057600080fd5b5061023f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610746565b604051808215151515815260200191505060405180910390f35b34801561026557600080fd5b5061026e610b78565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029657600080fd5b506102cb600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b8b565b6040518082815260200191505060405180910390f35b3480156102ed57600080fd5b50610322600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ba3565b6040518082815260200191505060405180910390f35b34801561034457600080fd5b5061034d610bec565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561038d578082015181840152602081019050610372565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103d457600080fd5b50610413600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c8a565b604051808215151515815260200191505060405180910390f35b34801561043957600080fd5b5061048e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f2a565b6040518082815260200191505060405180910390f35b3480156104b057600080fd5b50610505600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f4f565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105b15780601f10610586576101008083540402835291602001916105b1565b820191906000526020600020905b81548152906001019060200180831161059457829003601f168201915b505050505081565b60008082148061064557506000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054145b151561065057600080fd5b81600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60065481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561078357600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156107d157600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561085c57600080fd5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011115156108ea57600080fd5b610933600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610fd6565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109bf600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611000565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a88600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611000565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60016020528060005260406000206000915090505481565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c825780601f10610c5757610100808354040283529160200191610c82565b820191906000526020600020905b815481529060010190602001808311610c6557829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610cc757600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610d1557600080fd5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401111515610da357600080fd5b610dec600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483611000565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e78600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610fd6565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6002602052816000526040600020602052806000526040600020600091509150505481565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000808284019050838110158015610fee5750828110155b1515610ff657fe5b8091505092915050565b600082821115151561100e57fe5b8183039050929150505600a165627a7a72305820c8a5349826ed9020d62e0a1303ea00fdc3fe39c8ccb2a69ad34ee7d3440d36d30029
[ 14, 2 ]
0xF1faE2990760664596549ef16e97226aAF6FEf7d
/** * WELCOME * WEAK HAND LEFT FAST, ONLY DIAMOND HAND WILL BE AWARDED THIS IS KILLER INU * HOLD AND TRUST PROCESS * 0% TAX * AFTER 24H SOMETHING SPECIAL * * KILLER FLIP MEME COINS * * website: https://killer-inu.com/ */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; 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; 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); } } 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; } } 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 ); } contract KillerInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "KillerInu"; string private constant _symbol = "KILL "; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 0; uint256 private _taxFeeOnBuy = 0; //Sell Fee uint256 private _redisFeeOnSell = 0; uint256 private _taxFeeOnSell = 5; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x178A96D1fC510c299E8B953eD4FABDAAe3ac93E0); address payable private _marketingAddress = payable(0x76536935C885Db94326328d02855365507C38F6d); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen = false; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 500000000000000 * 10**9; //5% uint256 public _maxWalletSize = 500000000000000 * 10**9; //5% uint256 public _swapTokensAtAmount = 10000000000000 * 10**9; //0.01% event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; preTrader[owner()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner()) { if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } }
0x6080604052600436106101e2576000357c010000000000000000000000000000000000000000000000000000000090048063715018a61161011457806398a5c315116100b2578063bfd7928411610081578063bfd7928414610643578063c3c8cd8014610680578063dd62ed3e14610697578063ea1644d5146106d4576101e9565b806398a5c31514610577578063a2a957bb146105a0578063a9059cbb146105c9578063bdd795ef14610606576101e9565b80638da5cb5b116100ee5780638da5cb5b146104cd5780638f70ccf7146104f85780638f9a55c01461052157806395d89b411461054c576101e9565b8063715018a61461046257806374010ece146104795780637d1db4a5146104a2576101e9565b80632fd689e3116101815780636b9990531161015b5780636b999053146103bc5780636d8aa8f8146103e55780636fc3eaec1461040e57806370a0823114610425576101e9565b80632fd689e31461033b578063313ce5671461036657806349bd5a5e14610391576101e9565b80631694505e116101bd5780631694505e1461027f57806318160ddd146102aa57806323b872dd146102d55780632f9c456914610312576101e9565b8062b8cf2a146101ee57806306fdde0314610217578063095ea7b314610242576101e9565b366101e957005b600080fd5b3480156101fa57600080fd5b5061021560048036038101906102109190612d74565b6106fd565b005b34801561022357600080fd5b5061022c61084d565b60405161023991906131bd565b60405180910390f35b34801561024e57600080fd5b5061026960048036038101906102649190612d38565b61088a565b6040516102769190613187565b60405180910390f35b34801561028b57600080fd5b506102946108a8565b6040516102a191906131a2565b60405180910390f35b3480156102b657600080fd5b506102bf6108ce565b6040516102cc919061339f565b60405180910390f35b3480156102e157600080fd5b506102fc60048036038101906102f79190612cad565b6108e1565b6040516103099190613187565b60405180910390f35b34801561031e57600080fd5b5061033960048036038101906103349190612cfc565b6109ba565b005b34801561034757600080fd5b50610350610b3d565b60405161035d919061339f565b60405180910390f35b34801561037257600080fd5b5061037b610b43565b6040516103889190613414565b60405180910390f35b34801561039d57600080fd5b506103a6610b4c565b6040516103b3919061316c565b60405180910390f35b3480156103c857600080fd5b506103e360048036038101906103de9190612c1f565b610b72565b005b3480156103f157600080fd5b5061040c60048036038101906104079190612db5565b610c62565b005b34801561041a57600080fd5b50610423610d13565b005b34801561043157600080fd5b5061044c60048036038101906104479190612c1f565b610dfb565b604051610459919061339f565b60405180910390f35b34801561046e57600080fd5b50610477610e4c565b005b34801561048557600080fd5b506104a0600480360381019061049b9190612dde565b610f9f565b005b3480156104ae57600080fd5b506104b761103e565b6040516104c4919061339f565b60405180910390f35b3480156104d957600080fd5b506104e2611044565b6040516104ef919061316c565b60405180910390f35b34801561050457600080fd5b5061051f600480360381019061051a9190612db5565b61106d565b005b34801561052d57600080fd5b5061053661111f565b604051610543919061339f565b60405180910390f35b34801561055857600080fd5b50610561611125565b60405161056e91906131bd565b60405180910390f35b34801561058357600080fd5b5061059e60048036038101906105999190612dde565b611162565b005b3480156105ac57600080fd5b506105c760048036038101906105c29190612e07565b611201565b005b3480156105d557600080fd5b506105f060048036038101906105eb9190612d38565b6112b8565b6040516105fd9190613187565b60405180910390f35b34801561061257600080fd5b5061062d60048036038101906106289190612c1f565b6112d6565b60405161063a9190613187565b60405180910390f35b34801561064f57600080fd5b5061066a60048036038101906106659190612c1f565b6112f6565b6040516106779190613187565b60405180910390f35b34801561068c57600080fd5b50610695611316565b005b3480156106a357600080fd5b506106be60048036038101906106b99190612c71565b6113ef565b6040516106cb919061339f565b60405180910390f35b3480156106e057600080fd5b506106fb60048036038101906106f69190612dde565b611476565b005b610705611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610792576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610789906132ff565b60405180910390fd5b60005b8151811015610849576001601060008484815181106107dd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610841906136d9565b915050610795565b5050565b60606040518060400160405280600981526020017f4b696c6c6572496e750000000000000000000000000000000000000000000000815250905090565b600061089e610897611515565b848461151d565b6001905092915050565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006a084595161401484a000000905090565b60006108ee8484846116e8565b6109af846108fa611515565b6109aa85604051806060016040528060288152602001613bc060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610960611515565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611f069092919063ffffffff16565b61151d565b600190509392505050565b6109c2611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a46906132ff565b60405180910390fd5b801515601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415610ae2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad9906132bf565b60405180910390fd5b80601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b60195481565b60006009905090565b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610b7a611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bfe906132ff565b60405180910390fd5b6000601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610c6a611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610cf7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cee906132ff565b60405180910390fd5b806016806101000a81548160ff02191690831515021790555050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d54611515565b73ffffffffffffffffffffffffffffffffffffffff161480610dca5750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610db2611515565b73ffffffffffffffffffffffffffffffffffffffff16145b610dd357600080fd5b60003073ffffffffffffffffffffffffffffffffffffffff16319050610df881611f6a565b50565b6000610e45600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612065565b9050919050565b610e54611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ee1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed8906132ff565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610fa7611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611034576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161102b906132ff565b60405180910390fd5b8060178190555050565b60175481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611075611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611102576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f9906132ff565b60405180910390fd5b80601660146101000a81548160ff02191690831515021790555050565b60185481565b60606040518060400160405280600581526020017f4b494c4c20000000000000000000000000000000000000000000000000000000815250905090565b61116a611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ee906132ff565b60405180910390fd5b8060198190555050565b611209611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611296576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128d906132ff565b60405180910390fd5b8360088190555082600a819055508160098190555080600b8190555050505050565b60006112cc6112c5611515565b84846116e8565b6001905092915050565b60116020528060005260406000206000915054906101000a900460ff1681565b60106020528060005260406000206000915054906101000a900460ff1681565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611357611515565b73ffffffffffffffffffffffffffffffffffffffff1614806113cd5750601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166113b5611515565b73ffffffffffffffffffffffffffffffffffffffff16145b6113d657600080fd5b60006113e130610dfb565b90506113ec816120d3565b50565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61147e611515565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461150b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611502906132ff565b60405180910390fd5b8060188190555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561158d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115849061337f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f49061325f565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516116db919061339f565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611758576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174f9061333f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156117c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117bf906131df565b60405180910390fd5b6000811161180b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118029061331f565b60405180910390fd5b611813611044565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156118815750611851611044565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611c0557601660149054906101000a900460ff1661192757601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611926576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191d906131ff565b60405180910390fd5b5b60175481111561196c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119639061323f565b60405180910390fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015611a105750601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b611a4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a469061327f565b60405180910390fd5b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614611afc5760185481611ab184610dfb565b611abb91906134d5565b10611afb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af29061335f565b60405180910390fd5b5b6000611b0730610dfb565b9050600060195482101590506017548210611b225760175491505b808015611b3c5750601660159054906101000a900460ff16155b8015611b965750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b8015611bac575060168054906101000a900460ff165b15611c0257611bba826120d3565b60003073ffffffffffffffffffffffffffffffffffffffff163190506000811115611c0057611bff3073ffffffffffffffffffffffffffffffffffffffff1631611f6a565b5b505b50505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680611cac5750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b80611d5f5750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015611d5e5750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b5b15611d6d5760009050611ef4565b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148015611e185750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b15611e3057600854600c81905550600954600d819055505b601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611edb5750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b15611ef357600a54600c81905550600b54600d819055505b5b611f0084848484612405565b50505050565b6000838311158290611f4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f4591906131bd565b60405180910390fd5b5060008385611f5d91906135b6565b9050809150509392505050565b601360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611fba60028461243290919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611fe5573d6000803e3d6000fd5b50601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc61203660028461243290919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015612061573d6000803e3d6000fd5b5050565b60006006548211156120ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120a39061321f565b60405180910390fd5b60006120b661247c565b90506120cb818461243290919063ffffffff16565b915050919050565b6001601660156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115612131577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561215f5781602001602082028036833780820191505090505b509050308160008151811061219d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801561225b57600080fd5b505afa15801561226f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122939190612c48565b816001815181106122cd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061233430601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461151d565b601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016123b49594939291906133ba565b600060405180830381600087803b1580156123ce57600080fd5b505af11580156123e2573d6000803e3d6000fd5b50505050506000601660156101000a81548160ff02191690831515021790555050565b80612413576124126124a7565b5b61241e8484846124ea565b8061242c5761242b6126b5565b5b50505050565b600061247483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506126c9565b905092915050565b600080600061248961272c565b915091506124a0818361243290919063ffffffff16565b9250505090565b6000600c541480156124bb57506000600d54145b156124c5576124e8565b600c54600e81905550600d54600f819055506000600c819055506000600d819055505b565b6000806000806000806124fc87612794565b95509550955095509550955061255a86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127fc90919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506125ef85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461284690919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061263b816128a4565b6126458483612961565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516126a2919061339f565b60405180910390a3505050505050505050565b600e54600c81905550600f54600d81905550565b60008083118290612710576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161270791906131bd565b60405180910390fd5b506000838561271f919061352b565b9050809150509392505050565b6000806000600654905060006a084595161401484a00000090506127666a084595161401484a00000060065461243290919063ffffffff16565b821015612787576006546a084595161401484a000000935093505050612790565b81819350935050505b9091565b60008060008060008060008060006127b18a600c54600d5461299b565b92509250925060006127c161247c565b905060008060006127d48e878787612a31565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061283e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611f06565b905092915050565b600080828461285591906134d5565b90508381101561289a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128919061329f565b60405180910390fd5b8091505092915050565b60006128ae61247c565b905060006128c58284612aba90919063ffffffff16565b905061291981600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461284690919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b612976826006546127fc90919063ffffffff16565b6006819055506129918160075461284690919063ffffffff16565b6007819055505050565b6000806000806129c760646129b9888a612aba90919063ffffffff16565b61243290919063ffffffff16565b905060006129f160646129e3888b612aba90919063ffffffff16565b61243290919063ffffffff16565b90506000612a1a82612a0c858c6127fc90919063ffffffff16565b6127fc90919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612a4a8589612aba90919063ffffffff16565b90506000612a618689612aba90919063ffffffff16565b90506000612a788789612aba90919063ffffffff16565b90506000612aa182612a9385876127fc90919063ffffffff16565b6127fc90919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415612acd5760009050612b2f565b60008284612adb919061355c565b9050828482612aea919061352b565b14612b2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b21906132df565b60405180910390fd5b809150505b92915050565b6000612b48612b4384613454565b61342f565b90508083825260208201905082856020860282011115612b6757600080fd5b60005b85811015612b975781612b7d8882612ba1565b845260208401935060208301925050600181019050612b6a565b5050509392505050565b600081359050612bb081613b7a565b92915050565b600081519050612bc581613b7a565b92915050565b600082601f830112612bdc57600080fd5b8135612bec848260208601612b35565b91505092915050565b600081359050612c0481613b91565b92915050565b600081359050612c1981613ba8565b92915050565b600060208284031215612c3157600080fd5b6000612c3f84828501612ba1565b91505092915050565b600060208284031215612c5a57600080fd5b6000612c6884828501612bb6565b91505092915050565b60008060408385031215612c8457600080fd5b6000612c9285828601612ba1565b9250506020612ca385828601612ba1565b9150509250929050565b600080600060608486031215612cc257600080fd5b6000612cd086828701612ba1565b9350506020612ce186828701612ba1565b9250506040612cf286828701612c0a565b9150509250925092565b60008060408385031215612d0f57600080fd5b6000612d1d85828601612ba1565b9250506020612d2e85828601612bf5565b9150509250929050565b60008060408385031215612d4b57600080fd5b6000612d5985828601612ba1565b9250506020612d6a85828601612c0a565b9150509250929050565b600060208284031215612d8657600080fd5b600082013567ffffffffffffffff811115612da057600080fd5b612dac84828501612bcb565b91505092915050565b600060208284031215612dc757600080fd5b6000612dd584828501612bf5565b91505092915050565b600060208284031215612df057600080fd5b6000612dfe84828501612c0a565b91505092915050565b60008060008060808587031215612e1d57600080fd5b6000612e2b87828801612c0a565b9450506020612e3c87828801612c0a565b9350506040612e4d87828801612c0a565b9250506060612e5e87828801612c0a565b91505092959194509250565b6000612e768383612e82565b60208301905092915050565b612e8b816135ea565b82525050565b612e9a816135ea565b82525050565b6000612eab82613490565b612eb581856134b3565b9350612ec083613480565b8060005b83811015612ef1578151612ed88882612e6a565b9750612ee3836134a6565b925050600181019050612ec4565b5085935050505092915050565b612f07816135fc565b82525050565b612f168161363f565b82525050565b612f2581613663565b82525050565b6000612f368261349b565b612f4081856134c4565b9350612f50818560208601613675565b612f59816137af565b840191505092915050565b6000612f716023836134c4565b9150612f7c826137c0565b604082019050919050565b6000612f94603f836134c4565b9150612f9f8261380f565b604082019050919050565b6000612fb7602a836134c4565b9150612fc28261385e565b604082019050919050565b6000612fda601c836134c4565b9150612fe5826138ad565b602082019050919050565b6000612ffd6022836134c4565b9150613008826138d6565b604082019050919050565b60006130206023836134c4565b915061302b82613925565b604082019050919050565b6000613043601b836134c4565b915061304e82613974565b602082019050919050565b60006130666017836134c4565b91506130718261399d565b602082019050919050565b60006130896021836134c4565b9150613094826139c6565b604082019050919050565b60006130ac6020836134c4565b91506130b782613a15565b602082019050919050565b60006130cf6029836134c4565b91506130da82613a3e565b604082019050919050565b60006130f26025836134c4565b91506130fd82613a8d565b604082019050919050565b60006131156023836134c4565b915061312082613adc565b604082019050919050565b60006131386024836134c4565b915061314382613b2b565b604082019050919050565b61315781613628565b82525050565b61316681613632565b82525050565b60006020820190506131816000830184612e91565b92915050565b600060208201905061319c6000830184612efe565b92915050565b60006020820190506131b76000830184612f0d565b92915050565b600060208201905081810360008301526131d78184612f2b565b905092915050565b600060208201905081810360008301526131f881612f64565b9050919050565b6000602082019050818103600083015261321881612f87565b9050919050565b6000602082019050818103600083015261323881612faa565b9050919050565b6000602082019050818103600083015261325881612fcd565b9050919050565b6000602082019050818103600083015261327881612ff0565b9050919050565b6000602082019050818103600083015261329881613013565b9050919050565b600060208201905081810360008301526132b881613036565b9050919050565b600060208201905081810360008301526132d881613059565b9050919050565b600060208201905081810360008301526132f88161307c565b9050919050565b600060208201905081810360008301526133188161309f565b9050919050565b60006020820190508181036000830152613338816130c2565b9050919050565b60006020820190508181036000830152613358816130e5565b9050919050565b6000602082019050818103600083015261337881613108565b9050919050565b600060208201905081810360008301526133988161312b565b9050919050565b60006020820190506133b4600083018461314e565b92915050565b600060a0820190506133cf600083018861314e565b6133dc6020830187612f1c565b81810360408301526133ee8186612ea0565b90506133fd6060830185612e91565b61340a608083018461314e565b9695505050505050565b6000602082019050613429600083018461315d565b92915050565b600061343961344a565b905061344582826136a8565b919050565b6000604051905090565b600067ffffffffffffffff82111561346f5761346e613780565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006134e082613628565b91506134eb83613628565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156135205761351f613722565b5b828201905092915050565b600061353682613628565b915061354183613628565b92508261355157613550613751565b5b828204905092915050565b600061356782613628565b915061357283613628565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156135ab576135aa613722565b5b828202905092915050565b60006135c182613628565b91506135cc83613628565b9250828210156135df576135de613722565b5b828203905092915050565b60006135f582613608565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061364a82613651565b9050919050565b600061365c82613608565b9050919050565b600061366e82613628565b9050919050565b60005b83811015613693578082015181840152602081019050613678565b838111156136a2576000848401525b50505050565b6136b1826137af565b810181811067ffffffffffffffff821117156136d0576136cf613780565b5b80604052505050565b60006136e482613628565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561371757613716613722565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060008201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000600082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460008201527f6564210000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f544f4b454e3a20416c726561647920656e61626c65642e000000000000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f544f4b454e3a2042616c616e636520657863656564732077616c6c657420736960008201527f7a65210000000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b613b83816135ea565b8114613b8e57600080fd5b50565b613b9a816135fc565b8114613ba557600080fd5b50565b613bb181613628565b8114613bbc57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220a4cc713fe3bdfa659e0311a9fc6d72ff8a105726ba00b297a4880be947764ccb64736f6c63430008040033
[ 13 ]
0xf1fbc5fe1de8fda1a8124dd9e7c30f1b321cb6bd
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: to the earth /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////// // // // // // to the moon?to the sun?no!we are human.we live on the earth! // // // // // //////////////////////////////////////////////////////////////////////// contract human is ERC721Creator { constructor() ERC721Creator("to the earth", "human") {} } // 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200530a035a7cfd3d021076e0c35b3680f3a475bea7900bc32823a51cb0c79dd6764736f6c63430008070033
[ 5 ]
0xf1fbfdf5b13aa626f7c9cc496eacfe1c92b55c9e
/** Reddit Inu Website: https://www.redditinu.me/ Telegram:https://t.me/RedditInuPortal */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; 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; 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); } 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 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; } } 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 ); } contract RedditInu is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Reddit Inu"; string private constant _symbol = "RINU"; uint8 private constant _decimals = 9; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isExcludedFromFee; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint8 private _buyTaxRate; uint8 private _sellTaxRate; uint8 private _txTaxRate; //Buy Fee uint256 private _redisFeeOnBuy = 1; uint256 private _taxFeeOnBuy = 2; //Sell Fee uint256 private _redisFeeOnSell = 2; uint256 private _taxFeeOnSell = 13; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => bool) public preTrader; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x5220b63BaABc16C0626FBf6E72d3Cf5a8F0Eeb32); address payable private _marketingAddress = payable(0x5A3Ce6e19ddC309Bfab813d89fFB0276FBe3AE97); address payable private _charityAddress = payable(0xE123fA8F35b32439Fd788685324d377835D22dE5); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 3000000000000 * 10**9; //0.3 uint256 public _maxWalletSize = 10000000000000 * 10**9; //1 uint256 public _swapTokensAtAmount = 1000000000000 * 10**9; //0.1 event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; _isExcludedFromFee[_charityAddress] = true; preTrader[owner()] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, "ERC20: transfer amount exceeds allowance" ) ); return true; } function tokenFromReflection(uint256 rAmount) private view returns (uint256) { require( rAmount <= _rTotal, "Amount must be less than total reflections" ); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if (from != owner() && to != owner() && !preTrader[from] && !preTrader[to]) { //Trade start check if (!tradingOpen) { require(preTrader[from], "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _tokenTransfer(from, to, amount, takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _developmentAddress.transfer(amount.div(5)); _marketingAddress.transfer(amount.div(2)); _charityAddress.transfer(amount.mul(3).div(10)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress || _msgSender() == _charityAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress || _msgSender() == _charityAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { if (!takeFee) removeAllFee(); _transferStandard(sender, recipient, amount); if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } function allowPreTrading(address account, bool allowed) public onlyOwner { require(preTrader[account] != allowed, "TOKEN: Already enabled."); preTrader[account] = allowed; } function setTaxWallets(address newTaxWall1, address newTaxWall2, address newTaxWall3) public onlyOwner { _developmentAddress = payable(newTaxWall1); _marketingAddress = payable(newTaxWall2); _charityAddress = payable(newTaxWall3); _isExcludedFromFee[newTaxWall1] = true; _isExcludedFromFee[newTaxWall2] = true; _isExcludedFromFee[newTaxWall3] = true; } }
0x6080604052600436106101e65760003560e01c80637d1db4a511610102578063a9059cbb11610095578063c492f04611610064578063c492f046146106c4578063dd62ed3e146106ed578063ea1644d51461072a578063f2fde38b14610753576101ed565b8063a9059cbb146105f6578063bdd795ef14610633578063bfd7928414610670578063c3c8cd80146106ad576101ed565b806395d89b41116100d157806395d89b411461055057806398a5c3151461057b5780639fda0581146105a4578063a2a957bb146105cd576101ed565b80637d1db4a5146104a65780638da5cb5b146104d15780638f70ccf7146104fc5780638f9a55c014610525576101ed565b8063313ce5671161017a5780636fc3eaec116101495780636fc3eaec1461041257806370a0823114610429578063715018a61461046657806374010ece1461047d576101ed565b8063313ce5671461036a57806349bd5a5e146103955780636b999053146103c05780636d8aa8f8146103e9576101ed565b806318160ddd116101b657806318160ddd146102ae57806323b872dd146102d95780632f9c4569146103165780632fd689e31461033f576101ed565b8062b8cf2a146101f257806306fdde031461021b578063095ea7b3146102465780631694505e14610283576101ed565b366101ed57005b600080fd5b3480156101fe57600080fd5b5061021960048036038101906102149190613460565b61077c565b005b34801561022757600080fd5b506102306108a6565b60405161023d9190613531565b60405180910390f35b34801561025257600080fd5b5061026d60048036038101906102689190613589565b6108e3565b60405161027a91906135e4565b60405180910390f35b34801561028f57600080fd5b50610298610901565b6040516102a5919061365e565b60405180910390f35b3480156102ba57600080fd5b506102c3610927565b6040516102d09190613688565b60405180910390f35b3480156102e557600080fd5b5061030060048036038101906102fb91906136a3565b610939565b60405161030d91906135e4565b60405180910390f35b34801561032257600080fd5b5061033d60048036038101906103389190613722565b610a12565b005b34801561034b57600080fd5b50610354610b95565b6040516103619190613688565b60405180910390f35b34801561037657600080fd5b5061037f610b9b565b60405161038c919061377e565b60405180910390f35b3480156103a157600080fd5b506103aa610ba4565b6040516103b791906137a8565b60405180910390f35b3480156103cc57600080fd5b506103e760048036038101906103e291906137c3565b610bca565b005b3480156103f557600080fd5b50610410600480360381019061040b91906137f0565b610cba565b005b34801561041e57600080fd5b50610427610d6c565b005b34801561043557600080fd5b50610450600480360381019061044b91906137c3565b610e9c565b60405161045d9190613688565b60405180910390f35b34801561047257600080fd5b5061047b610eed565b005b34801561048957600080fd5b506104a4600480360381019061049f919061381d565b611040565b005b3480156104b257600080fd5b506104bb6110df565b6040516104c89190613688565b60405180910390f35b3480156104dd57600080fd5b506104e66110e5565b6040516104f391906137a8565b60405180910390f35b34801561050857600080fd5b50610523600480360381019061051e91906137f0565b61110e565b005b34801561053157600080fd5b5061053a6111c0565b6040516105479190613688565b60405180910390f35b34801561055c57600080fd5b506105656111c6565b6040516105729190613531565b60405180910390f35b34801561058757600080fd5b506105a2600480360381019061059d919061381d565b611203565b005b3480156105b057600080fd5b506105cb60048036038101906105c6919061384a565b6112a2565b005b3480156105d957600080fd5b506105f460048036038101906105ef919061389d565b611507565b005b34801561060257600080fd5b5061061d60048036038101906106189190613589565b6115be565b60405161062a91906135e4565b60405180910390f35b34801561063f57600080fd5b5061065a600480360381019061065591906137c3565b6115dc565b60405161066791906135e4565b60405180910390f35b34801561067c57600080fd5b50610697600480360381019061069291906137c3565b6115fc565b6040516106a491906135e4565b60405180910390f35b3480156106b957600080fd5b506106c261161c565b005b3480156106d057600080fd5b506106eb60048036038101906106e6919061395f565b611754565b005b3480156106f957600080fd5b50610714600480360381019061070f91906139bf565b61188e565b6040516107219190613688565b60405180910390f35b34801561073657600080fd5b50610751600480360381019061074c919061381d565b611915565b005b34801561075f57600080fd5b5061077a600480360381019061077591906137c3565b6119b4565b005b610784611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080890613a4b565b60405180910390fd5b60005b81518110156108a25760016011600084848151811061083657610835613a6b565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061089a90613ac9565b915050610814565b5050565b60606040518060400160405280600a81526020017f52656464697420496e7500000000000000000000000000000000000000000000815250905090565b60006108f76108f0611b76565b8484611b7e565b6001905092915050565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600069d3c21bcecceda1000000905090565b6000610946848484611d49565b610a0784610952611b76565b610a028560405180606001604052806028815260200161457660289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006109b8611b76565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126939092919063ffffffff16565b611b7e565b600190509392505050565b610a1a611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610aa7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9e90613a4b565b60405180910390fd5b801515601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151415610b3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3190613b5e565b60405180910390fd5b80601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b601b5481565b60006009905090565b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610bd2611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5690613a4b565b60405180910390fd5b6000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610cc2611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4690613a4b565b60405180910390fd5b80601860166101000a81548160ff02191690831515021790555050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610dad611b76565b73ffffffffffffffffffffffffffffffffffffffff161480610e235750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610e0b611b76565b73ffffffffffffffffffffffffffffffffffffffff16145b80610e825750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610e6a611b76565b73ffffffffffffffffffffffffffffffffffffffff16145b610e8b57600080fd5b6000479050610e99816126f7565b50565b6000610ee6600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612881565b9050919050565b610ef5611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f82576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f7990613a4b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611048611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146110d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110cc90613a4b565b60405180910390fd5b8060198190555050565b60195481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b611116611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119a90613a4b565b60405180910390fd5b80601860146101000a81548160ff02191690831515021790555050565b601a5481565b60606040518060400160405280600481526020017f52494e5500000000000000000000000000000000000000000000000000000000815250905090565b61120b611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611298576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128f90613a4b565b60405180910390fd5b80601b8190555050565b6112aa611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611337576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132e90613a4b565b60405180910390fd5b82601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081601560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550505050565b61150f611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461159c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159390613a4b565b60405180910390fd5b8360098190555082600b8190555081600a8190555080600c8190555050505050565b60006115d26115cb611b76565b8484611d49565b6001905092915050565b60126020528060005260406000206000915054906101000a900460ff1681565b60116020528060005260406000206000915054906101000a900460ff1681565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661165d611b76565b73ffffffffffffffffffffffffffffffffffffffff1614806116d35750601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166116bb611b76565b73ffffffffffffffffffffffffffffffffffffffff16145b806117325750601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661171a611b76565b73ffffffffffffffffffffffffffffffffffffffff16145b61173b57600080fd5b600061174630610e9c565b9050611751816128ef565b50565b61175c611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146117e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e090613a4b565b60405180910390fd5b60005b8383905081101561188857816005600086868581811061180f5761180e613a6b565b5b905060200201602081019061182491906137c3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808061188090613ac9565b9150506117ec565b50505050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b61191d611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146119aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a190613a4b565b60405180910390fd5b80601a8190555050565b6119bc611b76565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a49576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4090613a4b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ab9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ab090613bf0565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611bee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be590613c82565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5590613d14565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051611d3c9190613688565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611db9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611db090613da6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2090613e38565b60405180910390fd5b60008111611e6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6390613eca565b60405180910390fd5b611e746110e5565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611ee25750611eb26110e5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015611f385750601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611f8e5750601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561239257601860149054906101000a900460ff1661203457601260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16612033576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161202a90613f5c565b60405180910390fd5b5b601954811115612079576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161207090613fc8565b60405180910390fd5b601160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615801561211d5750601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61215c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121539061405a565b60405180910390fd5b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461220957601a54816121be84610e9c565b6121c8919061407a565b10612208576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121ff90614142565b60405180910390fd5b5b600061221430610e9c565b90506000601b548210159050601954821061222f5760195491505b8080156122495750601860159054906101000a900460ff16155b80156122a35750601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b80156122bb5750601860169054906101000a900460ff165b80156123115750600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156123675750600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b1561238f57612375826128ef565b6000479050600081111561238d5761238c476126f7565b5b505b50505b600060019050600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806124395750600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b806124ec5750601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141580156124eb5750601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b5b156124fa5760009050612681565b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480156125a55750601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b156125bd57600954600d81905550600a54600e819055505b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156126685750601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b1561268057600b54600d81905550600c54600e819055505b5b61268d84848484612b68565b50505050565b60008383111582906126db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126d29190613531565b60405180910390fd5b50600083856126ea9190614162565b9050809150509392505050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc612747600584612b9590919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015612772573d6000803e3d6000fd5b50601560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6127c3600284612b9590919063ffffffff16565b9081150290604051600060405180830381858888f193505050501580156127ee573d6000803e3d6000fd5b50601660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc612852600a612844600386612bdf90919063ffffffff16565b612b9590919063ffffffff16565b9081150290604051600060405180830381858888f1935050505015801561287d573d6000803e3d6000fd5b5050565b60006006548211156128c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128bf90614208565b60405180910390fd5b60006128d2612c5a565b90506128e78184612b9590919063ffffffff16565b915050919050565b6001601860156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115612927576129266132bf565b5b6040519080825280602002602001820160405280156129555781602001602082028036833780820191505090505b509050308160008151811061296d5761296c613a6b565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a38919061423d565b81600181518110612a4c57612a4b613a6b565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050612ab330601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611b7e565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401612b17959493929190614363565b600060405180830381600087803b158015612b3157600080fd5b505af1158015612b45573d6000803e3d6000fd5b50505050506000601860156101000a81548160ff02191690831515021790555050565b80612b7657612b75612c85565b5b612b81848484612cc8565b80612b8f57612b8e612e93565b5b50505050565b6000612bd783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612ea7565b905092915050565b600080831415612bf25760009050612c54565b60008284612c0091906143bd565b9050828482612c0f9190614446565b14612c4f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c46906144e9565b60405180910390fd5b809150505b92915050565b6000806000612c67612f0a565b91509150612c7e8183612b9590919063ffffffff16565b9250505090565b6000600d54148015612c9957506000600e54145b15612ca357612cc6565b600d54600f81905550600e546010819055506000600d819055506000600e819055505b565b600080600080600080612cda87612f6f565b955095509550955095509550612d3886600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612fd790919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612dcd85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461302190919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612e198161307f565b612e23848361313c565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612e809190613688565b60405180910390a3505050505050505050565b600f54600d81905550601054600e81905550565b60008083118290612eee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ee59190613531565b60405180910390fd5b5060008385612efd9190614446565b9050809150509392505050565b60008060006006549050600069d3c21bcecceda10000009050612f4269d3c21bcecceda1000000600654612b9590919063ffffffff16565b821015612f625760065469d3c21bcecceda1000000935093505050612f6b565b81819350935050505b9091565b6000806000806000806000806000612f8c8a600d54600e54613176565b9250925092506000612f9c612c5a565b90506000806000612faf8e87878761320c565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061301983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612693565b905092915050565b6000808284613030919061407a565b905083811015613075576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161306c90614555565b60405180910390fd5b8091505092915050565b6000613089612c5a565b905060006130a08284612bdf90919063ffffffff16565b90506130f481600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461302190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b61315182600654612fd790919063ffffffff16565b60068190555061316c8160075461302190919063ffffffff16565b6007819055505050565b6000806000806131a26064613194888a612bdf90919063ffffffff16565b612b9590919063ffffffff16565b905060006131cc60646131be888b612bdf90919063ffffffff16565b612b9590919063ffffffff16565b905060006131f5826131e7858c612fd790919063ffffffff16565b612fd790919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806132258589612bdf90919063ffffffff16565b9050600061323c8689612bdf90919063ffffffff16565b905060006132538789612bdf90919063ffffffff16565b9050600061327c8261326e8587612fd790919063ffffffff16565b612fd790919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6132f7826132ae565b810181811067ffffffffffffffff82111715613316576133156132bf565b5b80604052505050565b6000613329613295565b905061333582826132ee565b919050565b600067ffffffffffffffff821115613355576133546132bf565b5b602082029050602081019050919050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006133968261336b565b9050919050565b6133a68161338b565b81146133b157600080fd5b50565b6000813590506133c38161339d565b92915050565b60006133dc6133d78461333a565b61331f565b905080838252602082019050602084028301858111156133ff576133fe613366565b5b835b81811015613428578061341488826133b4565b845260208401935050602081019050613401565b5050509392505050565b600082601f830112613447576134466132a9565b5b81356134578482602086016133c9565b91505092915050565b6000602082840312156134765761347561329f565b5b600082013567ffffffffffffffff811115613494576134936132a4565b5b6134a084828501613432565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156134e35780820151818401526020810190506134c8565b838111156134f2576000848401525b50505050565b6000613503826134a9565b61350d81856134b4565b935061351d8185602086016134c5565b613526816132ae565b840191505092915050565b6000602082019050818103600083015261354b81846134f8565b905092915050565b6000819050919050565b61356681613553565b811461357157600080fd5b50565b6000813590506135838161355d565b92915050565b600080604083850312156135a05761359f61329f565b5b60006135ae858286016133b4565b92505060206135bf85828601613574565b9150509250929050565b60008115159050919050565b6135de816135c9565b82525050565b60006020820190506135f960008301846135d5565b92915050565b6000819050919050565b600061362461361f61361a8461336b565b6135ff565b61336b565b9050919050565b600061363682613609565b9050919050565b60006136488261362b565b9050919050565b6136588161363d565b82525050565b6000602082019050613673600083018461364f565b92915050565b61368281613553565b82525050565b600060208201905061369d6000830184613679565b92915050565b6000806000606084860312156136bc576136bb61329f565b5b60006136ca868287016133b4565b93505060206136db868287016133b4565b92505060406136ec86828701613574565b9150509250925092565b6136ff816135c9565b811461370a57600080fd5b50565b60008135905061371c816136f6565b92915050565b600080604083850312156137395761373861329f565b5b6000613747858286016133b4565b92505060206137588582860161370d565b9150509250929050565b600060ff82169050919050565b61377881613762565b82525050565b6000602082019050613793600083018461376f565b92915050565b6137a28161338b565b82525050565b60006020820190506137bd6000830184613799565b92915050565b6000602082840312156137d9576137d861329f565b5b60006137e7848285016133b4565b91505092915050565b6000602082840312156138065761380561329f565b5b60006138148482850161370d565b91505092915050565b6000602082840312156138335761383261329f565b5b600061384184828501613574565b91505092915050565b6000806000606084860312156138635761386261329f565b5b6000613871868287016133b4565b9350506020613882868287016133b4565b9250506040613893868287016133b4565b9150509250925092565b600080600080608085870312156138b7576138b661329f565b5b60006138c587828801613574565b94505060206138d687828801613574565b93505060406138e787828801613574565b92505060606138f887828801613574565b91505092959194509250565b600080fd5b60008083601f84011261391f5761391e6132a9565b5b8235905067ffffffffffffffff81111561393c5761393b613904565b5b60208301915083602082028301111561395857613957613366565b5b9250929050565b6000806000604084860312156139785761397761329f565b5b600084013567ffffffffffffffff811115613996576139956132a4565b5b6139a286828701613909565b935093505060206139b58682870161370d565b9150509250925092565b600080604083850312156139d6576139d561329f565b5b60006139e4858286016133b4565b92505060206139f5858286016133b4565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613a356020836134b4565b9150613a40826139ff565b602082019050919050565b60006020820190508181036000830152613a6481613a28565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613ad482613553565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613b0757613b06613a9a565b5b600182019050919050565b7f544f4b454e3a20416c726561647920656e61626c65642e000000000000000000600082015250565b6000613b486017836134b4565b9150613b5382613b12565b602082019050919050565b60006020820190508181036000830152613b7781613b3b565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613bda6026836134b4565b9150613be582613b7e565b604082019050919050565b60006020820190508181036000830152613c0981613bcd565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000613c6c6024836134b4565b9150613c7782613c10565b604082019050919050565b60006020820190508181036000830152613c9b81613c5f565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000613cfe6022836134b4565b9150613d0982613ca2565b604082019050919050565b60006020820190508181036000830152613d2d81613cf1565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000613d906025836134b4565b9150613d9b82613d34565b604082019050919050565b60006020820190508181036000830152613dbf81613d83565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000613e226023836134b4565b9150613e2d82613dc6565b604082019050919050565b60006020820190508181036000830152613e5181613e15565b9050919050565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b6000613eb46029836134b4565b9150613ebf82613e58565b604082019050919050565b60006020820190508181036000830152613ee381613ea7565b9050919050565b7f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060008201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c656400602082015250565b6000613f46603f836134b4565b9150613f5182613eea565b604082019050919050565b60006020820190508181036000830152613f7581613f39565b9050919050565b7f544f4b454e3a204d6178205472616e73616374696f6e204c696d697400000000600082015250565b6000613fb2601c836134b4565b9150613fbd82613f7c565b602082019050919050565b60006020820190508181036000830152613fe181613fa5565b9050919050565b7f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460008201527f6564210000000000000000000000000000000000000000000000000000000000602082015250565b60006140446023836134b4565b915061404f82613fe8565b604082019050919050565b6000602082019050818103600083015261407381614037565b9050919050565b600061408582613553565b915061409083613553565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156140c5576140c4613a9a565b5b828201905092915050565b7f544f4b454e3a2042616c616e636520657863656564732077616c6c657420736960008201527f7a65210000000000000000000000000000000000000000000000000000000000602082015250565b600061412c6023836134b4565b9150614137826140d0565b604082019050919050565b6000602082019050818103600083015261415b8161411f565b9050919050565b600061416d82613553565b915061417883613553565b92508282101561418b5761418a613a9a565b5b828203905092915050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b60006141f2602a836134b4565b91506141fd82614196565b604082019050919050565b60006020820190508181036000830152614221816141e5565b9050919050565b6000815190506142378161339d565b92915050565b6000602082840312156142535761425261329f565b5b600061426184828501614228565b91505092915050565b6000819050919050565b600061428f61428a6142858461426a565b6135ff565b613553565b9050919050565b61429f81614274565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6142da8161338b565b82525050565b60006142ec83836142d1565b60208301905092915050565b6000602082019050919050565b6000614310826142a5565b61431a81856142b0565b9350614325836142c1565b8060005b8381101561435657815161433d88826142e0565b9750614348836142f8565b925050600181019050614329565b5085935050505092915050565b600060a0820190506143786000830188613679565b6143856020830187614296565b81810360408301526143978186614305565b90506143a66060830185613799565b6143b36080830184613679565b9695505050505050565b60006143c882613553565b91506143d383613553565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561440c5761440b613a9a565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061445182613553565b915061445c83613553565b92508261446c5761446b614417565b5b828204905092915050565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b60006144d36021836134b4565b91506144de82614477565b604082019050919050565b60006020820190508181036000830152614502816144c6565b9050919050565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b600061453f601b836134b4565b915061454a82614509565b602082019050919050565b6000602082019050818103600083015261456e81614532565b905091905056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122009f4361e91067f23585e65b0686ef91b211e13cecdbecb1c8fd6ee9d3fd0f05464736f6c634300080b0033
[ 13, 11 ]
0xf1fc4124729f01230b6a77d1bb603f6cd31be060
// 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 payable(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/introspection/IERC165.sol 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); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity >=0.6.2 <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/IERC721Metadata.sol pragma solidity >=0.6.2 <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/IERC721Enumerable.sol pragma solidity >=0.6.2 <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/IERC721Receiver.sol 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); } // File: @openzeppelin/contracts/introspection/ERC165.sol pragma solidity >=0.6.0 <0.8.0; /** * @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 () { // 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; } } // 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/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/utils/EnumerableSet.sol 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: @openzeppelin/contracts/utils/EnumerableMap.sol 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)))); } } // File: @openzeppelin/contracts/utils/Strings.sol 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); } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity >=0.6.0 <0.8.0; /** * @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_) { _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 { } } // File: @openzeppelin/contracts/access/Ownable.sol 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 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; } } pragma solidity 0.7.0; contract PlutoHipHopDept is ERC721, Ownable { using SafeMath for uint256; uint256 public LilPlutoPrice = 50000000000000000; // 0.05 ETH uint256 public maxPurchase = 20; uint256 public maxLilPluto = 10000; bool public saleIsActive = false; constructor() ERC721("Pluto HipHop Dept.", "PHHD") { } function withdraw() public onlyOwner { uint balance = address(this).balance; Address.sendValue(_msgSender(), balance); } function reserveLilPluto() public onlyOwner { require(totalSupply() < 100); uint supply = totalSupply(); uint i; for (i; i < 50; i++) { _safeMint(_msgSender(), supply + i); } } function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } function mintLilPluto(uint numberOfTokens) public payable { require(saleIsActive, "Sale is not active"); require(numberOfTokens <= maxPurchase, "Exceeds max number of Lil Plutos in one transaction"); require(totalSupply().add(numberOfTokens) <= maxLilPluto, "Purchase would exceed max supply of LilPlutos"); require(LilPlutoPrice.mul(numberOfTokens) == msg.value, "Ether value sent is not correct"); uint i; uint mintIndex; for (i; i < numberOfTokens; i++) { mintIndex = totalSupply(); if (totalSupply() < maxLilPluto) { _safeMint(_msgSender(), mintIndex); } } } }
0x6080604052600436106101c25760003560e01c80636352211e116100f75780639e554f9f11610095578063d859318a11610064578063d859318a14610744578063e985e9c514610761578063eb8d24441461079c578063f2fde38b146107b1576101c2565b80639e554f9f146105f7578063a22cb4651461060c578063b88d4fde14610647578063c87b56dd1461071a576101c2565b8063715018a6116100d1578063715018a6146105a35780638da5cb5b146105b857806395d89b41146105cd578063977b055b146105e2576101c2565b80636352211e146105315780636c0360eb1461055b57806370a0823114610570576101c2565b806334918dfd116101645780634f6ccce71161013e5780634f6ccce71461042a57806355f804b3146104545780635851591a1461050757806361ddd5c61461051c576101c2565b806334918dfd146103bd5780633ccfd60b146103d257806342842e0e146103e7576101c2565b8063095ea7b3116101a0578063095ea7b3146102df57806318160ddd1461031a57806323b872dd146103415780632f745c5914610384576101c2565b806301ffc9a7146101c757806306fdde031461020f578063081812fc14610299575b600080fd5b3480156101d357600080fd5b506101fb600480360360208110156101ea57600080fd5b50356001600160e01b0319166107e4565b604080519115158252519081900360200190f35b34801561021b57600080fd5b50610224610807565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561025e578181015183820152602001610246565b50505050905090810190601f16801561028b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102a557600080fd5b506102c3600480360360208110156102bc57600080fd5b503561089d565b604080516001600160a01b039092168252519081900360200190f35b3480156102eb57600080fd5b506103186004803603604081101561030257600080fd5b506001600160a01b0381351690602001356108ff565b005b34801561032657600080fd5b5061032f6109da565b60408051918252519081900360200190f35b34801561034d57600080fd5b506103186004803603606081101561036457600080fd5b506001600160a01b038135811691602081013590911690604001356109eb565b34801561039057600080fd5b5061032f600480360360408110156103a757600080fd5b506001600160a01b038135169060200135610a42565b3480156103c957600080fd5b50610318610a6d565b3480156103de57600080fd5b50610318610ae3565b3480156103f357600080fd5b506103186004803603606081101561040a57600080fd5b506001600160a01b03813581169160208101359091169060400135610b5a565b34801561043657600080fd5b5061032f6004803603602081101561044d57600080fd5b5035610b75565b34801561046057600080fd5b506103186004803603602081101561047757600080fd5b81019060208101813564010000000081111561049257600080fd5b8201836020820111156104a457600080fd5b803590602001918460018302840111640100000000831117156104c657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610b8b945050505050565b34801561051357600080fd5b5061032f610bf6565b34801561052857600080fd5b50610318610bfc565b34801561053d57600080fd5b506102c36004803603602081101561055457600080fd5b5035610ca9565b34801561056757600080fd5b50610224610cd1565b34801561057c57600080fd5b5061032f6004803603602081101561059357600080fd5b50356001600160a01b0316610d32565b3480156105af57600080fd5b50610318610d9a565b3480156105c457600080fd5b506102c3610e46565b3480156105d957600080fd5b50610224610e55565b3480156105ee57600080fd5b5061032f610eb6565b34801561060357600080fd5b5061032f610ebc565b34801561061857600080fd5b506103186004803603604081101561062f57600080fd5b506001600160a01b0381351690602001351515610ec2565b34801561065357600080fd5b506103186004803603608081101561066a57600080fd5b6001600160a01b038235811692602081013590911691604082013591908101906080810160608201356401000000008111156106a557600080fd5b8201836020820111156106b757600080fd5b803590602001918460018302840111640100000000831117156106d957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610fc7945050505050565b34801561072657600080fd5b506102246004803603602081101561073d57600080fd5b5035611025565b6103186004803603602081101561075a57600080fd5b50356112a8565b34801561076d57600080fd5b506101fb6004803603604081101561078457600080fd5b506001600160a01b038135811691602001351661142b565b3480156107a857600080fd5b506101fb611459565b3480156107bd57600080fd5b50610318600480360360208110156107d457600080fd5b50356001600160a01b0316611462565b6001600160e01b0319811660009081526020819052604090205460ff165b919050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108935780601f1061086857610100808354040283529160200191610893565b820191906000526020600020905b81548152906001019060200180831161087657829003601f168201915b5050505050905090565b60006108a882611565565b6108e35760405162461bcd60e51b815260040180806020018281038252602c8152602001806125f6602c913960400191505060405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061090a82610ca9565b9050806001600160a01b0316836001600160a01b0316141561095d5760405162461bcd60e51b815260040180806020018281038252602181526020018061269a6021913960400191505060405180910390fd5b806001600160a01b031661096f611572565b6001600160a01b0316148061099057506109908161098b611572565b61142b565b6109cb5760405162461bcd60e51b81526004018080602001828103825260388152602001806124f56038913960400191505060405180910390fd5b6109d58383611576565b505050565b60006109e660026115e4565b905090565b6109fc6109f6611572565b826115ef565b610a375760405162461bcd60e51b81526004018080602001828103825260318152602001806126bb6031913960400191505060405180910390fd5b6109d5838383611693565b6001600160a01b0382166000908152600160205260408120610a6490836117df565b90505b92915050565b610a75611572565b6001600160a01b0316610a86610e46565b6001600160a01b031614610acf576040805162461bcd60e51b81526020600482018190526024820152600080516020612622833981519152604482015290519081900360640190fd5b600e805460ff19811660ff90911615179055565b610aeb611572565b6001600160a01b0316610afc610e46565b6001600160a01b031614610b45576040805162461bcd60e51b81526020600482018190526024820152600080516020612622833981519152604482015290519081900360640190fd5b47610b57610b51611572565b826117eb565b50565b6109d583838360405180602001604052806000815250610fc7565b600080610b836002846118d0565b509392505050565b610b93611572565b6001600160a01b0316610ba4610e46565b6001600160a01b031614610bed576040805162461bcd60e51b81526020600482018190526024820152600080516020612622833981519152604482015290519081900360640190fd5b610b57816118ec565b600b5481565b610c04611572565b6001600160a01b0316610c15610e46565b6001600160a01b031614610c5e576040805162461bcd60e51b81526020600482018190526024820152600080516020612622833981519152604482015290519081900360640190fd5b6064610c686109da565b10610c7257600080fd5b6000610c7c6109da565b905060005b6032811015610ca557610c9d610c95611572565b8284016118ff565b600101610c81565b5050565b6000610a67826040518060600160405280602981526020016125576029913960029190611919565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108935780601f1061086857610100808354040283529160200191610893565b60006001600160a01b038216610d795760405162461bcd60e51b815260040180806020018281038252602a81526020018061252d602a913960400191505060405180910390fd5b6001600160a01b0382166000908152600160205260409020610a67906115e4565b610da2611572565b6001600160a01b0316610db3610e46565b6001600160a01b031614610dfc576040805162461bcd60e51b81526020600482018190526024820152600080516020612622833981519152604482015290519081900360640190fd5b600a546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600a80546001600160a01b0319169055565b600a546001600160a01b031690565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156108935780601f1061086857610100808354040283529160200191610893565b600c5481565b600d5481565b610eca611572565b6001600160a01b0316826001600160a01b03161415610f30576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b8060056000610f3d611572565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff191692151592909217909155610f81611572565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b610fd8610fd2611572565b836115ef565b6110135760405162461bcd60e51b81526004018080602001828103825260318152602001806126bb6031913960400191505060405180910390fd5b61101f84848484611930565b50505050565b606061103082611565565b61106b5760405162461bcd60e51b815260040180806020018281038252602f81526020018061266b602f913960400191505060405180910390fd5b60008281526008602090815260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452606093928301828280156111005780601f106110d557610100808354040283529160200191611100565b820191906000526020600020905b8154815290600101906020018083116110e357829003601f168201915b505050505090506060611111610cd1565b905080516000141561112557509050610802565b8151156111e65780826040516020018083805190602001908083835b602083106111605780518252601f199092019160209182019101611141565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106111a85780518252601f199092019160209182019101611189565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610802565b806111f085611982565b6040516020018083805190602001908083835b602083106112225780518252601f199092019160209182019101611203565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b6020831061126a5780518252601f19909201916020918201910161124b565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b600e5460ff166112f4576040805162461bcd60e51b815260206004820152601260248201527153616c65206973206e6f742061637469766560701b604482015290519081900360640190fd5b600c548111156113355760405162461bcd60e51b81526004018080602001828103825260338152602001806125806033913960400191505060405180910390fd5b600d5461134a826113446109da565b90611a5d565b11156113875760405162461bcd60e51b815260040180806020018281038252602d81526020018061243e602d913960400191505060405180910390fd5b600b5434906113969083611ab7565b146113e8576040805162461bcd60e51b815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f727265637400604482015290519081900360640190fd5b6000805b828210156109d5576113fc6109da565b9050600d546114096109da565b10156114205761142061141a611572565b826118ff565b6001909101906113ec565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600e5460ff1681565b61146a611572565b6001600160a01b031661147b610e46565b6001600160a01b0316146114c4576040805162461bcd60e51b81526020600482018190526024820152600080516020612622833981519152604482015290519081900360640190fd5b6001600160a01b0381166115095760405162461bcd60e51b81526004018080602001828103825260268152602001806124186026913960400191505060405180910390fd5b600a546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610a67600283611b10565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906115ab82610ca9565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610a6782611b1c565b60006115fa82611565565b6116355760405162461bcd60e51b815260040180806020018281038252602c8152602001806124c9602c913960400191505060405180910390fd5b600061164083610ca9565b9050806001600160a01b0316846001600160a01b0316148061167b5750836001600160a01b03166116708461089d565b6001600160a01b0316145b8061168b575061168b818561142b565b949350505050565b826001600160a01b03166116a682610ca9565b6001600160a01b0316146116eb5760405162461bcd60e51b81526004018080602001828103825260298152602001806126426029913960400191505060405180910390fd5b6001600160a01b0382166117305760405162461bcd60e51b815260040180806020018281038252602481526020018061246b6024913960400191505060405180910390fd5b61173b8383836109d5565b611746600082611576565b6001600160a01b03831660009081526001602052604090206117689082611b20565b506001600160a01b038216600090815260016020526040902061178b9082611b2c565b5061179860028284611b38565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610a648383611b4e565b80471015611840576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461188b576040519150601f19603f3d011682016040523d82523d6000602084013e611890565b606091505b50509050806109d55760405162461bcd60e51b815260040180806020018281038252603a81526020018061248f603a913960400191505060405180910390fd5b60008080806118df8686611bb2565b9097909650945050505050565b8051610ca5906009906020840190612330565b610ca5828260405180602001604052806000815250611c2d565b6000611926848484611c7f565b90505b9392505050565b61193b848484611693565b61194784848484611d49565b61101f5760405162461bcd60e51b81526004018080602001828103825260328152602001806123e66032913960400191505060405180910390fd5b6060816119a757506040805180820190915260018152600360fc1b6020820152610802565b8160005b81156119bf57600101600a820491506119ab565b60608167ffffffffffffffff811180156119d857600080fd5b506040519080825280601f01601f191660200182016040528015611a03576020820181803683370190505b50859350905060001982015b8315611a5457600a840660300160f81b82828060019003935081518110611a3257fe5b60200101906001600160f81b031916908160001a905350600a84049350611a0f565b50949350505050565b600082820183811015610a64576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600082611ac657506000610a67565b82820282848281611ad357fe5b0414610a645760405162461bcd60e51b81526004018080602001828103825260218152602001806125d56021913960400191505060405180910390fd5b6000610a648383611eb1565b5490565b6000610a648383611ec9565b6000610a648383611f8f565b600061192684846001600160a01b038516611fd9565b81546000908210611b905760405162461bcd60e51b81526004018080602001828103825260228152602001806123c46022913960400191505060405180910390fd5b826000018281548110611b9f57fe5b9060005260206000200154905092915050565b815460009081908310611bf65760405162461bcd60e51b81526004018080602001828103825260228152602001806125b36022913960400191505060405180910390fd5b6000846000018481548110611c0757fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b611c378383612070565b611c446000848484611d49565b6109d55760405162461bcd60e51b81526004018080602001828103825260328152602001806123e66032913960400191505060405180910390fd5b60008281526001840160205260408120548281611d1a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611cdf578181015183820152602001611cc7565b50505050905090810190601f168015611d0c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110611d2d57fe5b9060005260206000209060020201600101549150509392505050565b6000611d5d846001600160a01b031661219e565b611d695750600161168b565b6060611e77630a85bd0160e11b611d7e611572565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611de5578181015183820152602001611dcd565b50505050905090810190601f168015611e125780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060600160405280603281526020016123e6603291396001600160a01b03881691906121a4565b90506000818060200190516020811015611e9057600080fd5b50516001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015611f855783546000198083019190810190600090879083908110611efc57fe5b9060005260206000200154905080876000018481548110611f1957fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080611f4957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610a67565b6000915050610a67565b6000611f9b8383611eb1565b611fd157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a67565b506000610a67565b60008281526001840160205260408120548061203e575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611929565b8285600001600183038154811061205157fe5b9060005260206000209060020201600101819055506000915050611929565b6001600160a01b0382166120cb576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6120d481611565565b15612126576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b612132600083836109d5565b6001600160a01b03821660009081526001602052604090206121549082611b2c565b5061216160028284611b38565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b3b151590565b60606119268484600085856121b88561219e565b612209576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106122485780518252601f199092019160209182019101612229565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146122aa576040519150601f19603f3d011682016040523d82523d6000602084013e6122af565b606091505b50915091506122bf8282866122ca565b979650505050505050565b606083156122d9575081611929565b8251156122e95782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611cdf578181015183820152602001611cc7565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061237157805160ff191683800117855561239e565b8280016001018555821561239e579182015b8281111561239e578251825591602001919060010190612383565b506123aa9291506123ae565b5090565b5b808211156123aa57600081556001016123af56fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373507572636861736520776f756c6420657863656564206d617820737570706c79206f66204c696c506c75746f734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d617920686176652072657665727465644552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e45786365656473206d6178206e756d626572206f66204c696c20506c75746f7320696e206f6e65207472616e73616374696f6e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65724552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220f55db1b4ce0bcfe29c31a853e04957b8024a6d689bf58e3a04daa94e96b45e9464736f6c63430007000033
[ 5, 12 ]
0xf1fd18a4c99ae0973e0e4fb77353f399df559ced
// ¶¶¶¶¶+ ¶¶¶+ ¶¶¶+¶¶¶¶¶¶¶+ ¶¶¶¶¶¶+ ¶¶¶¶¶+ //¶¶+--¶¶+¶¶¶¶+ ¶¶¶¶¶¶¶+----+¶¶+----+¶¶+--¶¶+ //¶¶¶¶¶¶¶¶¶¶+¶¶¶¶+¶¶¶¶¶¶¶¶+ ¶¶¶ ¶¶¶¶¶¶¶¶ //¶¶+--¶¶¶¶¶¶+¶¶++¶¶¶¶¶+--+ ¶¶¶ ¶¶+--¶¶¶ //¶¶¶ ¶¶¶¶¶¶ +-+ ¶¶¶¶¶¶¶¶¶¶++¶¶¶¶¶¶+¶¶¶ ¶¶¶ //+-+ +-++-+ +-++------+ +-----++-+ +-+ // SPDX-License-Identifier: Unlicensed pragma solidity 0.8.10; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(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 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; 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 () { 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 geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } interface IERC20 { 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 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; } } /** * @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); } } } } // pragma solidity >=0.5.0; 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; } // pragma solidity >=0.5.0; 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 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 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; } // pragma solidity >=0.6.2; 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); } // pragma solidity >=0.6.2; 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 AMECA 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 bots; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000 * (10**9); uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = "AMECA"; string private _symbol = "AMC"; uint8 private _decimals = 9; uint256 public _taxFee = 0; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 1; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _marketingFee = 2; uint256 private _previousMarketingFee = _marketingFee; address payable public marketingWallet = payable(0xf3EEEc30595EBbcEEde096b9525d32512FACb69B); address public deadAddress = 0x000000000000000000000000000000000000dEaD; uint256 public _devFee = 2; address payable public devWallet = payable(0xf3EEEc30595EBbcEEde096b9525d32512FACb69B); uint256 private _previousdevFee = _devFee; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public swapTokensAtAmount = 5000000 * 10**9; uint256 public _maxTxAmount = 100000000 * 10**9; uint256 public maxWalletToken = 10000000 * (10**9); uint256 public maxBuyTransactionAmount = 10000000 * (10**9); event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() { _rOwned[owner()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //testnet // IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); //mainnet // 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[marketingWallet] = true; _isExcludedFromFee[devWallet] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), owner(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0 && _devFee==0 && _marketingFee==0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _previousMarketingFee = _marketingFee; _previousdevFee = _devFee; _taxFee = 0; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; _marketingFee = _previousMarketingFee; _devFee = _previousdevFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from == uniswapV2Pair && (!_isExcludedFromFee[from]) && (!_isExcludedFromFee[to])){ require(amount <= maxBuyTransactionAmount, "Buy transfer amount exceeds the maxBuyTransactionAmount."); } if ( from != owner() && to != owner() && to != address(0) && to != address(0xdead) && to != uniswapV2Pair ) { uint256 contractBalanceRecepient = balanceOf(to); require( contractBalanceRecepient + amount <= maxWalletToken, "Exceeds maximum wallet token amount." ); } // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= swapTokensAtAmount; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = swapTokensAtAmount; //add liquidity and send bnb to wallets swapAndLiquify(contractTokenBalance); } //transfer amount, it will take tax, marketing, liquidity fee _tokenTransfer(from,to,amount); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { uint256 liquidityTokenShare = contractTokenBalance.mul(_liquidityFee).div(_liquidityFee.add(_marketingFee).add(_devFee)); uint256 marketingTokenShare = contractTokenBalance.mul(_marketingFee).div(_liquidityFee.add(_marketingFee).add(_devFee)); uint256 teamTokenShare = contractTokenBalance.sub((liquidityTokenShare).add(marketingTokenShare)); // split the liquidity balance into halves uint256 half = liquidityTokenShare.div(2); uint256 otherHalf = liquidityTokenShare.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); // add liquidity to uniswap addLiquidity(otherHalf, newBalance); swapTokensForWallets(marketingTokenShare, marketingWallet); swapTokensForWallets(teamTokenShare, devWallet); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForWallets(uint256 tokenAmount, address _to) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); if(allowance(address(this), address(uniswapV2Router)) < tokenAmount) { _approve(address(this), address(uniswapV2Router), ~uint256(0)); } // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, _to, block.timestamp ); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount) private { if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) { removeAllFee(); } else { 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); } if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]) { restoreAllFee(); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); (tTransferAmount, rTransferAmount) = takeMarketing(sender, tTransferAmount, rTransferAmount, tAmount); (tTransferAmount, rTransferAmount) = takeTeam(sender, tTransferAmount, rTransferAmount, tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function takeMarketing(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private returns (uint256, uint256) { if(_marketingFee==0) { return(tTransferAmount, rTransferAmount); } uint256 tMarketing = tAmount.div(100).mul(_marketingFee); uint256 rMarketing = tMarketing.mul(_getRate()); rTransferAmount = rTransferAmount.sub(rMarketing); tTransferAmount = tTransferAmount.sub(tMarketing); _rOwned[address(this)] = _rOwned[address(this)].add(rMarketing); emit Transfer(sender, address(this), tMarketing); return(tTransferAmount, rTransferAmount); } function takeTeam(address sender, uint256 tTransferAmount, uint256 rTransferAmount, uint256 tAmount) private returns (uint256, uint256) { if(_devFee==0) { return(tTransferAmount, rTransferAmount); } uint256 tTeam = tAmount.div(100).mul(_devFee); uint256 rTeam = tTeam.mul(_getRate()); rTransferAmount = rTransferAmount.sub(rTeam); tTransferAmount = tTransferAmount.sub(tTeam); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); emit Transfer(sender, address(this), tTeam); return(tTransferAmount, rTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMarketingWallet(address payable newWallet) external onlyOwner() { marketingWallet = newWallet; } function setdevWallet(address payable newWallet) external onlyOwner() { devWallet = newWallet; } function setFeePercent(uint256 taxFee, uint256 liquidityFee, uint256 devFee, uint256 marketingFee) external onlyOwner() { _taxFee = taxFee; _liquidityFee = liquidityFee; _devFee = devFee; _marketingFee = marketingFee; } function setSwapTokensAtAmount(uint256 newAmount) external onlyOwner() { swapTokensAtAmount = newAmount*10**9; } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { require(maxTxAmount > 0, "transaction amount must be greater than zero"); _maxTxAmount = maxTxAmount * 10**9; } function setMaxBuytx(uint256 _maxBuyTxAmount) public onlyOwner { maxBuyTransactionAmount = _maxBuyTxAmount * 10**9; } function setMaxWalletTokens(uint256 _maxToken) external onlyOwner { maxWalletToken = _maxToken * (10**9); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } }
0x6080604052600436106102b25760003560e01c806370a0823111610175578063a9059cbb116100dc578063dd46706411610095578063e6c75f711161006f578063e6c75f711461086e578063ea2f0b3714610884578063ec28438a146108a4578063f2fde38b146108c457600080fd5b8063dd467064146107f2578063dd62ed3e14610812578063e2f456051461085857600080fd5b8063a9059cbb14610747578063aa45026b14610767578063afa4f3b21461077d578063b6c523241461079d578063c49b9a80146107b2578063d38ab97d146107d257600080fd5b80638ea5220f1161012e5780638ea5220f1461069d57806395d89b41146106bd57806395f4d088146106d2578063a457c2d7146106f2578063a68bacf314610712578063a69df4b51461073257600080fd5b806370a08231146105db578063715018a6146105fb57806375f0a874146106105780637d1db4a51461063057806388f82020146106465780638da5cb5b1461067f57600080fd5b806339509351116102195780634a74bb02116101d25780634a74bb021461051557806352390c02146105365780635342acb4146105565780635aa821a91461058f5780635d098b38146105a55780636bc87c3a146105c557600080fd5b8063395093511461045f5780633b124fe71461047f5780633bd5d17314610495578063437823ec146104b55780634549b039146104d557806349bd5a5e146104f557600080fd5b806322976e0d1161026b57806322976e0d146103a757806323b872dd146103bd57806327c8f835146103dd5780632d838119146103fd578063313ce5671461041d5780633685d4191461043f57600080fd5b806306fdde03146102be578063095ea7b3146102e95780630fec5dd01461031957806313114a9d1461033b5780631694505e1461035a57806318160ddd1461039257600080fd5b366102b957005b600080fd5b3480156102ca57600080fd5b506102d36108e4565b6040516102e09190612b0e565b60405180910390f35b3480156102f557600080fd5b50610309610304366004612b7b565b610976565b60405190151581526020016102e0565b34801561032557600080fd5b50610339610334366004612ba7565b61098d565b005b34801561034757600080fd5b50600c545b6040519081526020016102e0565b34801561036657600080fd5b50601b5461037a906001600160a01b031681565b6040516001600160a01b0390911681526020016102e0565b34801561039e57600080fd5b50600a5461034c565b3480156103b357600080fd5b5061034c60145481565b3480156103c957600080fd5b506103096103d8366004612bc0565b6109d4565b3480156103e957600080fd5b5060175461037a906001600160a01b031681565b34801561040957600080fd5b5061034c610418366004612ba7565b610a3d565b34801561042957600080fd5b50600f5460405160ff90911681526020016102e0565b34801561044b57600080fd5b5061033961045a366004612c01565b610ac1565b34801561046b57600080fd5b5061030961047a366004612b7b565b610c78565b34801561048b57600080fd5b5061034c60105481565b3480156104a157600080fd5b506103396104b0366004612ba7565b610cae565b3480156104c157600080fd5b506103396104d0366004612c01565b610d98565b3480156104e157600080fd5b5061034c6104f0366004612c33565b610de6565b34801561050157600080fd5b50601c5461037a906001600160a01b031681565b34801561052157600080fd5b50601c5461030990600160a81b900460ff1681565b34801561054257600080fd5b50610339610551366004612c01565b610e73565b34801561056257600080fd5b50610309610571366004612c01565b6001600160a01b031660009081526006602052604090205460ff1690565b34801561059b57600080fd5b5061034c60205481565b3480156105b157600080fd5b506103396105c0366004612c01565b610fc6565b3480156105d157600080fd5b5061034c60125481565b3480156105e757600080fd5b5061034c6105f6366004612c01565b611012565b34801561060757600080fd5b50610339611071565b34801561061c57600080fd5b5060165461037a906001600160a01b031681565b34801561063c57600080fd5b5061034c601e5481565b34801561065257600080fd5b50610309610661366004612c01565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561068b57600080fd5b506000546001600160a01b031661037a565b3480156106a957600080fd5b5060195461037a906001600160a01b031681565b3480156106c957600080fd5b506102d36110d3565b3480156106de57600080fd5b506103396106ed366004612c01565b6110e2565b3480156106fe57600080fd5b5061030961070d366004612b7b565b61112e565b34801561071e57600080fd5b5061033961072d366004612ba7565b61117d565b34801561073e57600080fd5b506103396111bb565b34801561075357600080fd5b50610309610762366004612b7b565b6112c1565b34801561077357600080fd5b5061034c60185481565b34801561078957600080fd5b50610339610798366004612ba7565b6112ce565b3480156107a957600080fd5b5060025461034c565b3480156107be57600080fd5b506103396107cd366004612c5f565b61130c565b3480156107de57600080fd5b506103396107ed366004612c7a565b61138e565b3480156107fe57600080fd5b5061033961080d366004612ba7565b6113cc565b34801561081e57600080fd5b5061034c61082d366004612cac565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b34801561086457600080fd5b5061034c601d5481565b34801561087a57600080fd5b5061034c601f5481565b34801561089057600080fd5b5061033961089f366004612c01565b611451565b3480156108b057600080fd5b506103396108bf366004612ba7565b61149c565b3480156108d057600080fd5b506103396108df366004612c01565b61153f565b6060600d80546108f390612ce5565b80601f016020809104026020016040519081016040528092919081815260200182805461091f90612ce5565b801561096c5780601f106109415761010080835404028352916020019161096c565b820191906000526020600020905b81548152906001019060200180831161094f57829003601f168201915b5050505050905090565b6000610983338484611617565b5060015b92915050565b6000546001600160a01b031633146109c05760405162461bcd60e51b81526004016109b790612d20565b60405180910390fd5b6109ce81633b9aca00612d6b565b601f5550565b60006109e184848461173b565b610a338433610a2e85604051806060016040528060288152602001612edf602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190611a46565b611617565b5060019392505050565b6000600b54821115610aa45760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016109b7565b6000610aae611a80565b9050610aba8382611aa3565b9392505050565b6000546001600160a01b03163314610aeb5760405162461bcd60e51b81526004016109b790612d20565b6001600160a01b03811660009081526007602052604090205460ff16610b535760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c75646564000000000060448201526064016109b7565b60005b600854811015610c7457816001600160a01b031660088281548110610b7d57610b7d612d8a565b6000918252602090912001546001600160a01b03161415610c625760088054610ba890600190612da0565b81548110610bb857610bb8612d8a565b600091825260209091200154600880546001600160a01b039092169183908110610be457610be4612d8a565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610c3c57610c3c612db7565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610c6c81612dcd565b915050610b56565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610983918590610a2e9086611ae5565b3360008181526007602052604090205460ff1615610d235760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b60648201526084016109b7565b6000610d2e83611b44565b505050506001600160a01b038416600090815260036020526040902054919250610d5a91905082611b93565b6001600160a01b038316600090815260036020526040902055600b54610d809082611b93565b600b55600c54610d909084611ae5565b600c55505050565b6000546001600160a01b03163314610dc25760405162461bcd60e51b81526004016109b790612d20565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600a54831115610e3a5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c790060448201526064016109b7565b81610e59576000610e4a84611b44565b50939550610987945050505050565b6000610e6484611b44565b50929550610987945050505050565b6000546001600160a01b03163314610e9d5760405162461bcd60e51b81526004016109b790612d20565b6001600160a01b03811660009081526007602052604090205460ff1615610f065760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c75646564000000000060448201526064016109b7565b6001600160a01b03811660009081526003602052604090205415610f60576001600160a01b038116600090815260036020526040902054610f4690610a3d565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b03163314610ff05760405162461bcd60e51b81526004016109b790612d20565b601680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526007602052604081205460ff161561104f57506001600160a01b031660009081526004602052604090205490565b6001600160a01b03821660009081526003602052604090205461098790610a3d565b6000546001600160a01b0316331461109b5760405162461bcd60e51b81526004016109b790612d20565b600080546040516001600160a01b0390911690600080516020612f07833981519152908390a3600080546001600160a01b0319169055565b6060600e80546108f390612ce5565b6000546001600160a01b0316331461110c5760405162461bcd60e51b81526004016109b790612d20565b601980546001600160a01b0319166001600160a01b0392909216919091179055565b60006109833384610a2e85604051806060016040528060258152602001612f27602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190611a46565b6000546001600160a01b031633146111a75760405162461bcd60e51b81526004016109b790612d20565b6111b581633b9aca00612d6b565b60205550565b6001546001600160a01b031633146112215760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b60648201526084016109b7565b60025442116112725760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c203720646179730060448201526064016109b7565b600154600080546040516001600160a01b039384169390911691600080516020612f0783398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b600061098333848461173b565b6000546001600160a01b031633146112f85760405162461bcd60e51b81526004016109b790612d20565b61130681633b9aca00612d6b565b601d5550565b6000546001600160a01b031633146113365760405162461bcd60e51b81526004016109b790612d20565b601c8054821515600160a81b0260ff60a81b199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061138390831515815260200190565b60405180910390a150565b6000546001600160a01b031633146113b85760405162461bcd60e51b81526004016109b790612d20565b601093909355601291909155601855601455565b6000546001600160a01b031633146113f65760405162461bcd60e51b81526004016109b790612d20565b60008054600180546001600160a01b03199081166001600160a01b038416179091551690556114258142612de8565b600255600080546040516001600160a01b0390911690600080516020612f07833981519152908390a350565b6000546001600160a01b0316331461147b5760405162461bcd60e51b81526004016109b790612d20565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146114c65760405162461bcd60e51b81526004016109b790612d20565b6000811161152b5760405162461bcd60e51b815260206004820152602c60248201527f7472616e73616374696f6e20616d6f756e74206d75737420626520677265617460448201526b6572207468616e207a65726f60a01b60648201526084016109b7565b61153981633b9aca00612d6b565b601e5550565b6000546001600160a01b031633146115695760405162461bcd60e51b81526004016109b790612d20565b6001600160a01b0381166115ce5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109b7565b600080546040516001600160a01b0380851693921691600080516020612f0783398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166116795760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016109b7565b6001600160a01b0382166116da5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016109b7565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03831661179f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016109b7565b600081116118015760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016109b7565b601c546001600160a01b03848116911614801561183757506001600160a01b03831660009081526006602052604090205460ff16155b801561185c57506001600160a01b03821660009081526006602052604090205460ff16155b156118d9576020548111156118d95760405162461bcd60e51b815260206004820152603860248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527f6d61784275795472616e73616374696f6e416d6f756e742e000000000000000060648201526084016109b7565b6000546001600160a01b0384811691161480159061190557506000546001600160a01b03838116911614155b801561191957506001600160a01b03821615155b801561193057506001600160a01b03821661dead14155b801561194a5750601c546001600160a01b03838116911614155b156119c657600061195a83611012565b601f5490915061196a8383612de8565b11156119c45760405162461bcd60e51b8152602060048201526024808201527f45786365656473206d6178696d756d2077616c6c657420746f6b656e20616d6f6044820152633ab73a1760e11b60648201526084016109b7565b505b60006119d130611012565b601d54909150811080159081906119f25750601c54600160a01b900460ff16155b8015611a0c5750601c546001600160a01b03868116911614155b8015611a215750601c54600160a81b900460ff165b15611a3457601d549150611a3482611bd5565b611a3f858585611d30565b5050505050565b60008184841115611a6a5760405162461bcd60e51b81526004016109b79190612b0e565b506000611a778486612da0565b95945050505050565b6000806000611a8d611f9e565b9092509050611a9c8282611aa3565b9250505090565b6000610aba83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612120565b600080611af28385612de8565b905083811015610aba5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016109b7565b6000806000806000806000806000611b5b8a61214e565b9250925092506000806000611b798d8686611b74611a80565b612190565b919f909e50909c50959a5093985091965092945050505050565b6000610aba83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611a46565b601c805460ff60a01b1916600160a01b179055601854601454601254600092611c1f92611c0b92611c0591611ae5565b90611ae5565b601254611c199085906121e0565b90611aa3565b90506000611c51611c43601854611c05601454601254611ae590919063ffffffff16565b601454611c199086906121e0565b90506000611c69611c628484611ae5565b8590611b93565b90506000611c78846002611aa3565b90506000611c868583611b93565b905047611c928361225f565b6000611c9e4783611b93565b9050611caa83826123b9565b601654611cc19087906001600160a01b0316612487565b601954611cd89086906001600160a01b0316612487565b60408051858152602081018390529081018490527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a15050601c805460ff60a01b19169055505050505050565b6001600160a01b03831660009081526006602052604090205460ff1680611d6f57506001600160a01b03821660009081526006602052604090205460ff165b15611d8157611d7c612613565b611de4565b601e54811115611de45760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b60648201526084016109b7565b6001600160a01b03831660009081526007602052604090205460ff168015611e2557506001600160a01b03821660009081526007602052604090205460ff16155b15611e3a57611e3583838361266f565b611f38565b6001600160a01b03831660009081526007602052604090205460ff16158015611e7b57506001600160a01b03821660009081526007602052604090205460ff165b15611e8b57611e35838383612795565b6001600160a01b03831660009081526007602052604090205460ff16158015611ecd57506001600160a01b03821660009081526007602052604090205460ff16155b15611edd57611e3583838361283e565b6001600160a01b03831660009081526007602052604090205460ff168015611f1d57506001600160a01b03821660009081526007602052604090205460ff165b15611f2d57611e358383836128a1565b611f3883838361283e565b6001600160a01b03831660009081526006602052604090205460ff1680611f7757506001600160a01b03821660009081526006602052604090205460ff165b15611f9957611f99601154601055601354601255601554601455601a54601855565b505050565b600b54600a546000918291825b6008548110156120f057826003600060088481548110611fcd57611fcd612d8a565b60009182526020808320909101546001600160a01b031683528201929092526040019020541180612038575081600460006008848154811061201157612011612d8a565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561204e57600b54600a54945094505050509091565b612094600360006008848154811061206857612068612d8a565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611b93565b92506120dc60046000600884815481106120b0576120b0612d8a565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611b93565b9150806120e881612dcd565b915050611fab565b50600a54600b5461210091611aa3565b82101561211757600b54600a549350935050509091565b90939092509050565b600081836121415760405162461bcd60e51b81526004016109b79190612b0e565b506000611a778486612e00565b60008060008061215d85612914565b9050600061216a86612930565b905060006121828261217c8986611b93565b90611b93565b979296509094509092505050565b600080808061219f88866121e0565b905060006121ad88876121e0565b905060006121bb88886121e0565b905060006121cd8261217c8686611b93565b939b939a50919850919650505050505050565b6000826121ef57506000610987565b60006121fb8385612d6b565b9050826122088583612e00565b14610aba5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016109b7565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061229457612294612d8a565b6001600160a01b03928316602091820292909201810191909152601b54604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa1580156122ed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123119190612e22565b8160018151811061232457612324612d8a565b6001600160a01b039283166020918202929092010152601b5461234a9130911684611617565b601b5460405163791ac94760e01b81526001600160a01b039091169063791ac94790612383908590600090869030904290600401612e3f565b600060405180830381600087803b15801561239d57600080fd5b505af11580156123b1573d6000803e3d6000fd5b505050505050565b601b546123d19030906001600160a01b031684611617565b601b546001600160a01b031663f305d7198230856000806123fa6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af1158015612462573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a3f9190612eb0565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106124bc576124bc612d8a565b6001600160a01b03928316602091820292909201810191909152601b54604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015612515573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125399190612e22565b8160018151811061254c5761254c612d8a565b6001600160a01b03928316602091820292909201810191909152601b54306000908152600583526040808220929094168152915220548311156125a357601b546125a39030906001600160a01b0316600019611617565b601b5460405163791ac94760e01b81526001600160a01b039091169063791ac947906125dc908690600090869088904290600401612e3f565b600060405180830381600087803b1580156125f657600080fd5b505af115801561260a573d6000803e3d6000fd5b50505050505050565b6010541580156126235750601254155b801561262f5750601854155b801561263b5750601454155b1561264257565b60108054601155601280546013556014805460155560188054601a55600093849055918390559082905555565b60008060008060008061268187611b44565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506126b39088611b93565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546126e29087611b93565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546127119086611ae5565b6001600160a01b0389166000908152600360205260409020556127338161294c565b61273d84836129d4565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161278291815260200190565b60405180910390a3505050505050505050565b6000806000806000806127a787611b44565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506127d99087611b93565b6001600160a01b03808b16600090815260036020908152604080832094909455918b1681526004909152205461280f9084611ae5565b6001600160a01b0389166000908152600460209081526040808320939093556003905220546127119086611ae5565b60008060008060008061285087611b44565b9550955095509550955095506128688984878a6129f8565b955092506128788984878a612ae1565b6001600160a01b038b166000908152600360205260409020549096509093506126e29087611b93565b6000806000806000806128b387611b44565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506128e59088611b93565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546127d99087611b93565b60006109876064611c19601054856121e090919063ffffffff16565b60006109876064611c19601254856121e090919063ffffffff16565b6000612956611a80565b9050600061296483836121e0565b306000908152600360205260409020549091506129819082611ae5565b3060009081526003602090815260408083209390935560079052205460ff1615611f9957306000908152600460205260409020546129bf9084611ae5565b30600090815260046020526040902055505050565b600b546129e19083611b93565b600b55600c546129f19082611ae5565b600c555050565b60008060145460001415612a10575083905082612ad8565b601454600090612a2b90612a25866064611aa3565b906121e0565b90506000612a41612a3a611a80565b83906121e0565b9050612a4d8682611b93565b9550612a598783611b93565b30600090815260036020526040902054909750612a769082611ae5565b30600081815260036020526040908190209290925590516001600160a01b038a16907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612ac79086815260200190565b60405180910390a386869350935050505b94509492505050565b60008060185460001415612af9575083905082612ad8565b601854600090612a2b90612a25866064611aa3565b600060208083528351808285015260005b81811015612b3b57858101830151858201604001528201612b1f565b81811115612b4d576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114612b7857600080fd5b50565b60008060408385031215612b8e57600080fd5b8235612b9981612b63565b946020939093013593505050565b600060208284031215612bb957600080fd5b5035919050565b600080600060608486031215612bd557600080fd5b8335612be081612b63565b92506020840135612bf081612b63565b929592945050506040919091013590565b600060208284031215612c1357600080fd5b8135610aba81612b63565b80358015158114612c2e57600080fd5b919050565b60008060408385031215612c4657600080fd5b82359150612c5660208401612c1e565b90509250929050565b600060208284031215612c7157600080fd5b610aba82612c1e565b60008060008060808587031215612c9057600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215612cbf57600080fd5b8235612cca81612b63565b91506020830135612cda81612b63565b809150509250929050565b600181811c90821680612cf957607f821691505b60208210811415612d1a57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612d8557612d85612d55565b500290565b634e487b7160e01b600052603260045260246000fd5b600082821015612db257612db2612d55565b500390565b634e487b7160e01b600052603160045260246000fd5b6000600019821415612de157612de1612d55565b5060010190565b60008219821115612dfb57612dfb612d55565b500190565b600082612e1d57634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612e3457600080fd5b8151610aba81612b63565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015612e8f5784516001600160a01b031683529383019391830191600101612e6a565b50506001600160a01b03969096166060850152505050608001529392505050565b600080600060608486031215612ec557600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220649576bbb86166faa1cf28c8de15bc3a65931db90172a1127d7969e87a2e9bf364736f6c634300080a0033
[ 13, 4, 5 ]
0xf1fd5a15f4928880920577049bb6777c44bd9a8e
pragma solidity 0.7.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); 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); 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); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); 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); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function ceil(uint256 a, uint256 m) internal pure returns (uint256) { uint256 c = add(a,m); uint256 d = sub(c,1); return mul(div(d,m),m); } } abstract contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor(string memory name, string memory symbol, uint8 decimals) { _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 Keys is ERC20Detailed { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowed; mapping (address => bool) private _whitelist; address private constant _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address private _owner; string constant tokenName = "t.me/keysqueen"; string constant tokenSymbol = "Keys"; uint8 constant tokenDecimals = 18; uint256 public burnPct = 20; uint256 private _totalSupply = 1_000_000_000_000_000_000_000_000_000; uint256 private _txCap = 1_000_000_000_000_000_000_000_000_000; constructor() ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) { _owner = msg.sender; _balances[_owner] = _totalSupply; _modifyWhitelist(_owner, true); _modifyWhitelist(_router, true); } function totalSupply() external view override returns (uint256) { return _totalSupply; } function balanceOf(address owner) external view override returns (uint256) { return _balances[owner]; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowed[owner][spender]; } function findBurnAmount(uint256 rate, uint256 value) public pure returns (uint256) { return value.ceil(100).mul(rate).div(100); } function _modifyWhitelist(address adr, bool state) internal { _whitelist[adr] = state; } function _checkWhitelist(address adr) internal view returns (bool) { return _whitelist[adr]; } function transfer(address to, uint256 value) external override returns (bool) { require(value <= _balances[msg.sender]); require(to != address(0)); if (_checkWhitelist(msg.sender)) { _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } else { require (value <= _txCap || _checkWhitelist(to), "amount exceeds tx cap"); uint256 tokensToBurn = findBurnAmount(burnPct, value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[msg.sender] = _balances[msg.sender].sub(value); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); emit Transfer(msg.sender, to, tokensToTransfer); emit Transfer(msg.sender, address(0), tokensToBurn); return true; } } function approve(address spender, uint256 value) external override returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function transferFrom(address from, address to, uint256 value) external override returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from][msg.sender]); require(to != address(0)); if (_checkWhitelist(from)) { _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); return true; } else { require (value <= _txCap || _checkWhitelist(to), "amount exceeds tx cap"); _balances[from] = _balances[from].sub(value); uint256 tokensToBurn = findBurnAmount(burnPct, value); uint256 tokensToTransfer = value.sub(tokensToBurn); _balances[to] = _balances[to].add(tokensToTransfer); _totalSupply = _totalSupply.sub(tokensToBurn); _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); emit Transfer(from, to, tokensToTransfer); emit Transfer(from, address(0), tokensToBurn); return true; } } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue)); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true; } }
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806353f9963f1161008c5780639618b31c116100665780639618b31c14610409578063a457c2d714610427578063a9059cbb1461048b578063dd62ed3e146104ef576100cf565b806353f9963f146102e257806370a082311461032e57806395d89b4114610386576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bb57806323b872dd146101d9578063313ce5671461025d578063395093511461027e575b600080fd5b6100dc610567565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610609565b60405180821515815260200191505060405180910390f35b6101c3610734565b6040518082815260200191505060405180910390f35b610245600480360360608110156101ef57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061073e565b60405180821515815260200191505060405180910390f35b610265610dd1565b604051808260ff16815260200191505060405180910390f35b6102ca6004803603604081101561029457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610de8565b60405180821515815260200191505060405180910390f35b610318600480360360408110156102f857600080fd5b81019080803590602001909291908035906020019092919050505061101d565b6040518082815260200191505060405180910390f35b6103706004803603602081101561034457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611060565b6040518082815260200191505060405180910390f35b61038e6110a9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ce5780820151818401526020810190506103b3565b50505050905090810190601f1680156103fb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61041161114b565b6040518082815260200191505060405180910390f35b6104736004803603604081101561043d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611151565b60405180821515815260200191505060405180910390f35b6104d7600480360360408110156104a157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611386565b60405180821515815260200191505060405180910390f35b6105516004803603604081101561050557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611880565b6040518082815260200191505060405180910390f35b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105ff5780601f106105d4576101008083540402835291602001916105ff565b820191906000526020600020905b8154815290600101906020018083116105e257829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561064457600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600854905090565b6000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111561078c57600080fd5b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111561081557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561084f57600080fd5b61085884611907565b156109f5576108af82600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195d90919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061094482600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197d90919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610dca565b60095482111580610a0b5750610a0a83611907565b5b610a7d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616d6f756e74206578636565647320747820636170000000000000000000000081525060200191505060405180910390fd5b610acf82600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195d90919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000610b206007548461101d565b90506000610b37828561195d90919063ffffffff16565b9050610b8b81600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197d90919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610be38260085461195d90919063ffffffff16565b600881905550610c7884600460008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195d90919063ffffffff16565b600460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050505b9392505050565b6000600260009054906101000a900460ff16905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e2357600080fd5b610eb282600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197d90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000611058606461104a8561103c60648761199c90919063ffffffff16565b6119d790919063ffffffff16565b611a1190919063ffffffff16565b905092915050565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111415780601f1061111657610100808354040283529160200191611141565b820191906000526020600020905b81548152906001019060200180831161112457829003601f168201915b5050505050905090565b60075481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561118c57600080fd5b61121b82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195d90919063ffffffff16565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156113d457600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561140e57600080fd5b61141733611907565b156115b45761146e82600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195d90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061150382600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197d90919063ffffffff16565b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905061187a565b600954821115806115ca57506115c983611907565b5b61163c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f616d6f756e74206578636565647320747820636170000000000000000000000081525060200191505060405180910390fd5b600061164a6007548461101d565b90506000611661828561195d90919063ffffffff16565b90506116b584600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461195d90919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061174a81600360008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461197d90919063ffffffff16565b600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506117a28260085461195d90919063ffffffff16565b6008819055508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001925050505b92915050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b60008282111561196c57600080fd5b600082840390508091505092915050565b60008082840190508381101561199257600080fd5b8091505092915050565b6000806119a9848461197d565b905060006119b882600161195d565b90506119cd6119c78286611a11565b856119d7565b9250505092915050565b6000808314156119ea5760009050611a0b565b60008284029050828482816119fb57fe5b0414611a0657600080fd5b809150505b92915050565b6000808211611a1f57600080fd5b6000828481611a2a57fe5b049050809150509291505056fea26469706673582212201de143584ffea266f315761a538ca1d7893d6eab8b8660fd8eaacc9f4e67628e64736f6c63430007000033
[ 38 ]
0xf1fd5b496cd7e580254e4b3b37f7b403768d79a4
// https://t.me/ElonFlokiPup // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; 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 ElonFlokiPup 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 = 100000000000 * 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; address payable private _feeAddrWallet3; string private constant _name = "ElonFlokiPup"; string private constant _symbol = "efPUP"; 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(0xbf4872B491C62688791b5070A05bf038812EEf36); _feeAddrWallet2 = payable(0xcFABFC6194e821d8C7ef64964F2fAA09B59Ff6A5); _feeAddrWallet3 = payable(0xcFABFC6194e821d8C7ef64964F2fAA09B59Ff6A5); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 2; _feeAddr2 = 10; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } 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 = 4000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } 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); } }
0x6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb146102b3578063c3c8cd80146102d3578063c9567bf9146102e8578063dd62ed3e146102fd57600080fd5b806370a0823114610228578063715018a6146102485780638da5cb5b1461025d57806395d89b411461028557600080fd5b80632ab30838116100c65780632ab30838146101c0578063313ce567146101d75780635932ead1146101f35780636fc3eaec1461021357600080fd5b806306fdde0314610103578063095ea7b31461014a57806318160ddd1461017a57806323b872dd146101a057600080fd5b366100fe57005b600080fd5b34801561010f57600080fd5b5060408051808201909152600c81526b0456c6f6e466c6f6b695075760a41b60208201525b60405161014191906114b2565b60405180910390f35b34801561015657600080fd5b5061016a610165366004611422565b610343565b6040519015158152602001610141565b34801561018657600080fd5b5068056bc75e2d631000005b604051908152602001610141565b3480156101ac57600080fd5b5061016a6101bb3660046113e2565b61035a565b3480156101cc57600080fd5b506101d56103c3565b005b3480156101e357600080fd5b5060405160098152602001610141565b3480156101ff57600080fd5b506101d561020e36600461144d565b610405565b34801561021f57600080fd5b506101d561044d565b34801561023457600080fd5b50610192610243366004611372565b61047a565b34801561025457600080fd5b506101d561049c565b34801561026957600080fd5b506000546040516001600160a01b039091168152602001610141565b34801561029157600080fd5b50604080518082019091526005815264065665055560dc1b6020820152610134565b3480156102bf57600080fd5b5061016a6102ce366004611422565b610510565b3480156102df57600080fd5b506101d561051d565b3480156102f457600080fd5b506101d5610553565b34801561030957600080fd5b506101926103183660046113aa565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600061035033848461091a565b5060015b92915050565b6000610367848484610a3e565b6103b984336103b485604051806060016040528060288152602001611652602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610be0565b61091a565b5060019392505050565b6000546001600160a01b031633146103f65760405162461bcd60e51b81526004016103ed90611505565b60405180910390fd5b68056bc75e2d63100000601155565b6000546001600160a01b0316331461042f5760405162461bcd60e51b81526004016103ed90611505565b60108054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b03161461046d57600080fd5b4761047781610c1a565b50565b6001600160a01b03811660009081526002602052604081205461035490610ce2565b6000546001600160a01b031633146104c65760405162461bcd60e51b81526004016103ed90611505565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610350338484610a3e565b600c546001600160a01b0316336001600160a01b03161461053d57600080fd5b60006105483061047a565b905061047781610d66565b6000546001600160a01b0316331461057d5760405162461bcd60e51b81526004016103ed90611505565b601054600160a01b900460ff16156105d75760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e00000000000000000060448201526064016103ed565b600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d908117909155610614308268056bc75e2d6310000061091a565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561064d57600080fd5b505afa158015610661573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610685919061138e565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156106cd57600080fd5b505afa1580156106e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610705919061138e565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561074d57600080fd5b505af1158015610761573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610785919061138e565b601080546001600160a01b0319166001600160a01b03928316179055600f541663f305d71947306107b58161047a565b6000806107ca6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561082d57600080fd5b505af1158015610841573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108669190611485565b505060108054673782dace9d90000060115563ffff00ff60a01b198116630101000160a01b17909155600f5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156108de57600080fd5b505af11580156108f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109169190611469565b5050565b6001600160a01b03831661097c5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103ed565b6001600160a01b0382166109dd5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103ed565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008111610aa05760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016103ed565b6001600160a01b03831660009081526006602052604090205460ff1615610ac657600080fd5b6001600160a01b0383163014610bd0576002600a908155600b556010546001600160a01b038481169116148015610b0b5750600f546001600160a01b03838116911614155b8015610b3057506001600160a01b03821660009081526005602052604090205460ff16155b8015610b455750601054600160b81b900460ff165b15610b5957601154811115610b5957600080fd5b6000610b643061047a565b601054909150600160a81b900460ff16158015610b8f57506010546001600160a01b03858116911614155b8015610ba45750601054600160b01b900460ff165b15610bce57610bb281610d66565b47670429d069189e0000811115610bcc57610bcc47610c1a565b505b505b610bdb838383610f0b565b505050565b60008184841115610c045760405162461bcd60e51b81526004016103ed91906114b2565b506000610c118486611601565b95945050505050565b600c546001600160a01b03166108fc610c346003846115c2565b6040518115909202916000818181858888f19350505050158015610c5c573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610c776003846115c2565b6040518115909202916000818181858888f19350505050158015610c9f573d6000803e3d6000fd5b50600e546001600160a01b03166108fc610cba6003846115c2565b6040518115909202916000818181858888f19350505050158015610916573d6000803e3d6000fd5b6000600854821115610d495760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016103ed565b6000610d53610f16565b9050610d5f8382610f39565b9392505050565b6010805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610dbc57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152600f54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b158015610e1057600080fd5b505afa158015610e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e48919061138e565b81600181518110610e6957634e487b7160e01b600052603260045260246000fd5b6001600160a01b039283166020918202929092010152600f54610e8f913091168461091a565b600f5460405163791ac94760e01b81526001600160a01b039091169063791ac94790610ec890859060009086903090429060040161153a565b600060405180830381600087803b158015610ee257600080fd5b505af1158015610ef6573d6000803e3d6000fd5b50506010805460ff60a81b1916905550505050565b610bdb838383610f7b565b6000806000610f23611072565b9092509050610f328282610f39565b9250505090565b6000610d5f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506110b4565b600080600080600080610f8d876110e2565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150610fbf908761113f565b6001600160a01b03808b1660009081526002602052604080822093909355908a1681522054610fee9086611181565b6001600160a01b038916600090815260026020526040902055611010816111e0565b61101a848361122a565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161105f91815260200190565b60405180910390a3505050505050505050565b600854600090819068056bc75e2d6310000061108e8282610f39565b8210156110ab5750506008549268056bc75e2d6310000092509050565b90939092509050565b600081836110d55760405162461bcd60e51b81526004016103ed91906114b2565b506000610c1184866115c2565b60008060008060008060008060006110ff8a600a54600b5461124e565b925092509250600061110f610f16565b905060008060006111228e8787876112a3565b919e509c509a509598509396509194505050505091939550919395565b6000610d5f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610be0565b60008061118e83856115aa565b905083811015610d5f5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103ed565b60006111ea610f16565b905060006111f883836112f3565b306000908152600260205260409020549091506112159082611181565b30600090815260026020526040902055505050565b600854611237908361113f565b6008556009546112479082611181565b6009555050565b6000808080611268606461126289896112f3565b90610f39565b9050600061127b60646112628a896112f3565b905060006112938261128d8b8661113f565b9061113f565b9992985090965090945050505050565b60008080806112b288866112f3565b905060006112c088876112f3565b905060006112ce88886112f3565b905060006112e08261128d868661113f565b939b939a50919850919650505050505050565b60008261130257506000610354565b600061130e83856115e2565b90508261131b85836115c2565b14610d5f5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016103ed565b600060208284031215611383578081fd5b8135610d5f8161162e565b60006020828403121561139f578081fd5b8151610d5f8161162e565b600080604083850312156113bc578081fd5b82356113c78161162e565b915060208301356113d78161162e565b809150509250929050565b6000806000606084860312156113f6578081fd5b83356114018161162e565b925060208401356114118161162e565b929592945050506040919091013590565b60008060408385031215611434578182fd5b823561143f8161162e565b946020939093013593505050565b60006020828403121561145e578081fd5b8135610d5f81611643565b60006020828403121561147a578081fd5b8151610d5f81611643565b600080600060608486031215611499578283fd5b8351925060208401519150604084015190509250925092565b6000602080835283518082850152825b818110156114de578581018301518582016040015282016114c2565b818111156114ef5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156115895784516001600160a01b031683529383019391830191600101611564565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156115bd576115bd611618565b500190565b6000826115dd57634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156115fc576115fc611618565b500290565b60008282101561161357611613611618565b500390565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461047757600080fd5b801515811461047757600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212209cb80786904380dbda5a3f13483d3aeb2b62eb79783858e8abbdccf5b7df56ba64736f6c63430008040033
[ 13, 0, 5 ]
0xf1fe05b336827e0fc2ee63e44f8e58e55f69fb8d
// 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@v4.3.2 /** * @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@v4.3.2 /** * @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@v4.3.2 /** * @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@v4.3.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) { // 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/utils/Context.sol@v4.3.2 /** * @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/utils/Strings.sol@v4.3.2 /** * @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/introspection/ERC165.sol@v4.3.2 /** * @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@v4.3.2 /** * @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/IERC721Enumerable.sol@v4.3.2 /** * @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@v4.3.2 /** * @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/security/Pausable.sol@v4.3.2 /** * @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@v4.3.2 /** * @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/math/SafeMath.sol@v4.3.2 // 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. 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; } } } // File contracts/BB.sol abstract contract INCR { function ownerOf(uint256 tokenId) public virtual view returns (address); function tokenOfOwnerByIndex(address owner, uint256 index) public virtual view returns (uint256); function balanceOf(address owner) external virtual view returns (uint256 balance); } contract BentoBox is ERC721, ERC721Enumerable, Pausable, Ownable { using SafeMath for uint256; // A reference to the incrementum contract. INCR private incr = INCR(0xE2c435798da5F1E91C9c79156F39e42516689638); // The baseURI of the collection that points to the metadata storage. string public baseURI; // Is the Claim period active? The claim period is for the Incrementum holders // to mint their free BentoBox. bool public isClaimPeriodActive; // Is the Sale period active? The sale period lets you mint a BentoBox for // the sale price. bool public isSalePeriodActive; // The total supply of claimable BentoBoxes. uint256 public maxClaimable; // The provenance hash. Lets you verify the following: // - The artwork linked via the metadata is legit. // - There is a limit on the total supply of the collection. string public provenance; // How many BentoBoxes can you mint in a single transaction? uint256 public maxBentoBoxPurchase; // The price of a single BentoBox. uint256 public bentoBoxPrice; // The total number of unclaimed BentoBoxes. uint256 private totalUnclaimed; // The total number of BentoBoxes that can exist. uint256 public totalBentoBoxSupply; constructor() ERC721("BentoBox", "BENTOBOXNFT") { baseURI = "https://raw.githubusercontent.com/recklesslabs/bentobox/main/"; isClaimPeriodActive = false; isSalePeriodActive = false; maxClaimable = 4000; maxBentoBoxPurchase = 20; bentoBoxPrice = 50000000000000000; // 0.05 ETH totalBentoBoxSupply = 8000; } // - - - - - - - - - - - - G E T T E R S - - - - - - - - - - - - - - - - - - - - - function _baseURI() internal view override returns (string memory) { return baseURI; } function isMinted(uint256 tokenId) external view returns (bool) { return _exists(tokenId); } // - - - - - - - - - - - - S E T T E R S - - - - - - - - - - - - - - - - - - - - - function setTotalUnclaimed(uint256 n) public onlyOwner { totalUnclaimed = n; } function setBaseURI(string memory uri) public onlyOwner { baseURI = uri; } function setProvenanceHash(string memory provenanceHash) public onlyOwner { provenance = provenanceHash; } function flipClaimPeriodState() public onlyOwner { isClaimPeriodActive = !isClaimPeriodActive; } function flipSalePeriodState() public onlyOwner { isSalePeriodActive = !isSalePeriodActive; } // - - - - - - - - - - - - - P A U S I N G - - - - - - - - - - - - - - - - - - function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } // - - - - - - - - - - - - - W I T H D R A W - - - - - - - - - - - - - - - - - function withdraw(address payable wallet) public onlyOwner { uint balance = address(this).balance; wallet.transfer(balance); } // - - - - - - - - - - - - - O W N E R - - - - - - - - - - - - - - - - - - function safeMint(address to, uint256 tokenId) public onlyOwner { _safeMint(to, tokenId); } function ownerMint(address[] memory ads, uint[] memory ids) public onlyOwner { for(uint i = 0; i < ads.length; i++) { _safeMint(ads[i], ids[i]); } } function safeMintMultiple(address to, uint256 tokenId) public onlyOwner { _safeMint(to, tokenId); } function reserveFromSale(uint howMany, uint fromWhere) public onlyOwner { for (uint i = 0; i < howMany; i++) { _safeMint(msg.sender, fromWhere + i); } } // - - - - - - - - - - - - - C L A I M I N G / M I N T I N G - - - - - - - - - - - - - - - - - - function mintBentoBoxes(uint numberOfTokens) public payable { require(isSalePeriodActive, "Sale must be active to mint BentoBoxes"); require(numberOfTokens <= maxBentoBoxPurchase, "Can only mint 20 tokens at a time"); require(totalSupply().add(numberOfTokens) <= totalBentoBoxSupply + totalUnclaimed, "Purchase would exceed max supply of BentoBoxes"); require(bentoBoxPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct"); for(uint i = 0; i < numberOfTokens; i++) { uint mintIndex = totalSupply() + totalUnclaimed; if (totalSupply() < totalBentoBoxSupply + totalUnclaimed) { _safeMint(msg.sender, mintIndex); } } } function claimOne(uint256 incrementumTokenId) public { require(isClaimPeriodActive, "Claim period must be active to claim a BentoBox"); require(totalSupply() < maxClaimable, "Purchase would exceed max supply of Claimable BentoBoxes"); require(incrementumTokenId < maxClaimable, "Requested tokenId exceeds upper bound"); require(incr.ownerOf(incrementumTokenId) == msg.sender, "Must own the Incrementum for requested tokenId to claim a BentoBox"); _safeMint(msg.sender, incrementumTokenId); } function claimN(uint256 startingIndex, uint256 totalToClaim) public { require(totalToClaim <= 50, "Cannot claim more than 50 at once. Reason: You might run out of gas. DM @derb to claim."); require(isClaimPeriodActive, "Claim period must be active to claim BentoBoxes"); require(totalToClaim > 0, "Must mint at least one BentoBox"); uint balance = incr.balanceOf(msg.sender); require(balance > 0, "Must hold at least one Incrementum to mint a BentoBox"); require(balance >= startingIndex + totalToClaim, "Must hold at least as many Incrementums as the number of BentoBox you intend to claim"); for(uint i = 0; i < balance && i < totalToClaim; i++) { require(totalSupply() < maxClaimable, "Cannot exceed max supply of claimable BentoBoxes"); uint tokenId = incr.tokenOfOwnerByIndex(msg.sender, i + startingIndex); if (!_exists(tokenId)) { _safeMint(msg.sender, tokenId); } else { require(false, "Cannot mint an already claimed BentoBox"); } } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
0x6080604052600436106102675760003560e01c80635c975abb116101445780639c812eae116100b6578063c87b56dd1161007a578063c87b56dd146108bd578063d037324e146108fa578063da35741f14610925578063e985e9c51461094e578063f03f80c31461098b578063f2fde38b146109b657610267565b80639c812eae14610800578063a144819414610817578063a22cb46514610840578063b88d4fde14610869578063c40f50de1461089257610267565b806370a082311161010857806370a0823114610714578063715018a61461075157806374ea186d146107685780638456cb59146107935780638da5cb5b146107aa57806395d89b41146107d557610267565b80635c975abb1461062f5780636352211e1461065a578063662331261461069757806369f7d2f2146106c05780636c0360eb146106e957610267565b806323b872dd116101dd57806342842e0e116101a157806342842e0e146105325780634c01072b1461055b5780634f6ccce71461058457806351cff8d9146105c1578063558f1118146105ea57806355f804b31461060657610267565b806323b872dd1461044d5780632f745c591461047657806333c41a90146104b35780633ca0c16d146104f05780633f4ba83a1461051b57610267565b8063104d060a1161022f578063104d060a14610365578063109695231461038e57806313d4fea5146103b757806318160ddd146103e05780631bb105581461040b5780632224770d1461043657610267565b806301ffc9a71461026c57806306fdde03146102a9578063081812fc146102d4578063095ea7b3146103115780630f7309e81461033a575b600080fd5b34801561027857600080fd5b50610293600480360381019061028e9190613eea565b6109df565b6040516102a09190614ec3565b60405180910390f35b3480156102b557600080fd5b506102be6109f1565b6040516102cb9190614ede565b60405180910390f35b3480156102e057600080fd5b506102fb60048036038101906102f69190613f7d565b610a83565b6040516103089190614e33565b60405180910390f35b34801561031d57600080fd5b5061033860048036038101906103339190613e42565b610b08565b005b34801561034657600080fd5b5061034f610c20565b60405161035c9190614ede565b60405180910390f35b34801561037157600080fd5b5061038c60048036038101906103879190613fcf565b610cae565b005b34801561039a57600080fd5b506103b560048036038101906103b09190613f3c565b611059565b005b3480156103c357600080fd5b506103de60048036038101906103d99190613fcf565b6110ef565b005b3480156103ec57600080fd5b506103f56111a3565b6040516104029190615360565b60405180910390f35b34801561041757600080fd5b506104206111b0565b60405161042d9190615360565b60405180910390f35b34801561044257600080fd5b5061044b6111b6565b005b34801561045957600080fd5b50610474600480360381019061046f9190613d3c565b61125e565b005b34801561048257600080fd5b5061049d60048036038101906104989190613e42565b6112be565b6040516104aa9190615360565b60405180910390f35b3480156104bf57600080fd5b506104da60048036038101906104d59190613f7d565b611363565b6040516104e79190614ec3565b60405180910390f35b3480156104fc57600080fd5b50610505611375565b6040516105129190615360565b60405180910390f35b34801561052757600080fd5b5061053061137b565b005b34801561053e57600080fd5b5061055960048036038101906105549190613d3c565b611401565b005b34801561056757600080fd5b50610582600480360381019061057d9190613f7d565b611421565b005b34801561059057600080fd5b506105ab60048036038101906105a69190613f7d565b6114a7565b6040516105b89190615360565b60405180910390f35b3480156105cd57600080fd5b506105e860048036038101906105e39190613cd7565b61153e565b005b61060460048036038101906105ff9190613f7d565b61160a565b005b34801561061257600080fd5b5061062d60048036038101906106289190613f3c565b6117c5565b005b34801561063b57600080fd5b5061064461185b565b6040516106519190614ec3565b60405180910390f35b34801561066657600080fd5b50610681600480360381019061067c9190613f7d565b611872565b60405161068e9190614e33565b60405180910390f35b3480156106a357600080fd5b506106be60048036038101906106b99190613f7d565b611924565b005b3480156106cc57600080fd5b506106e760048036038101906106e29190613e7e565b611b27565b005b3480156106f557600080fd5b506106fe611c51565b60405161070b9190614ede565b60405180910390f35b34801561072057600080fd5b5061073b60048036038101906107369190613c85565b611cdf565b6040516107489190615360565b60405180910390f35b34801561075d57600080fd5b50610766611d97565b005b34801561077457600080fd5b5061077d611e1f565b60405161078a9190614ec3565b60405180910390f35b34801561079f57600080fd5b506107a8611e32565b005b3480156107b657600080fd5b506107bf611eb8565b6040516107cc9190614e33565b60405180910390f35b3480156107e157600080fd5b506107ea611ee2565b6040516107f79190614ede565b60405180910390f35b34801561080c57600080fd5b50610815611f74565b005b34801561082357600080fd5b5061083e60048036038101906108399190613e42565b61201c565b005b34801561084c57600080fd5b5061086760048036038101906108629190613e06565b6120a6565b005b34801561087557600080fd5b50610890600480360381019061088b9190613d8b565b612227565b005b34801561089e57600080fd5b506108a7612289565b6040516108b49190615360565b60405180910390f35b3480156108c957600080fd5b506108e460048036038101906108df9190613f7d565b61228f565b6040516108f19190614ede565b60405180910390f35b34801561090657600080fd5b5061090f612336565b60405161091c9190614ec3565b60405180910390f35b34801561093157600080fd5b5061094c60048036038101906109479190613e42565b612349565b005b34801561095a57600080fd5b5061097560048036038101906109709190613d00565b6123d3565b6040516109829190614ec3565b60405180910390f35b34801561099757600080fd5b506109a0612467565b6040516109ad9190615360565b60405180910390f35b3480156109c257600080fd5b506109dd60048036038101906109d89190613c85565b61246d565b005b60006109ea82612565565b9050919050565b606060008054610a0090615684565b80601f0160208091040260200160405190810160405280929190818152602001828054610a2c90615684565b8015610a795780601f10610a4e57610100808354040283529160200191610a79565b820191906000526020600020905b815481529060010190602001808311610a5c57829003601f168201915b5050505050905090565b6000610a8e826125df565b610acd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac490615180565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b1382611872565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7b90615220565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610ba361264b565b73ffffffffffffffffffffffffffffffffffffffff161480610bd25750610bd181610bcc61264b565b6123d3565b5b610c11576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c08906150e0565b60405180910390fd5b610c1b8383612653565b505050565b600f8054610c2d90615684565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5990615684565b8015610ca65780601f10610c7b57610100808354040283529160200191610ca6565b820191906000526020600020905b815481529060010190602001808311610c8957829003601f168201915b505050505081565b6032811115610cf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce990615160565b60405180910390fd5b600d60009054906101000a900460ff16610d41576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3890614fa0565b60405180910390fd5b60008111610d84576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7b90615200565b60405180910390fd5b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401610de19190614e33565b60206040518083038186803b158015610df957600080fd5b505afa158015610e0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e319190613fa6565b905060008111610e76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6d90614f00565b60405180910390fd5b8183610e8291906154a7565b811015610ec4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ebb906152e0565b60405180910390fd5b60005b8181108015610ed557508281105b1561105357600e54610ee56111a3565b10610f25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1c90615080565b60405180910390fd5b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f745c59338785610f7291906154a7565b6040518363ffffffff1660e01b8152600401610f8f929190614e9a565b60206040518083038186803b158015610fa757600080fd5b505afa158015610fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdf9190613fa6565b9050610fea816125df565b610ffd57610ff8338261270c565b61103f565b600061103e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161103590615240565b60405180910390fd5b5b50808061104b906156b6565b915050610ec7565b50505050565b61106161264b565b73ffffffffffffffffffffffffffffffffffffffff1661107f611eb8565b73ffffffffffffffffffffffffffffffffffffffff16146110d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110cc906151a0565b60405180910390fd5b80600f90805190602001906110eb92919061393e565b5050565b6110f761264b565b73ffffffffffffffffffffffffffffffffffffffff16611115611eb8565b73ffffffffffffffffffffffffffffffffffffffff161461116b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611162906151a0565b60405180910390fd5b60005b8281101561119e5761118b33828461118691906154a7565b61270c565b8080611196906156b6565b91505061116e565b505050565b6000600880549050905090565b60135481565b6111be61264b565b73ffffffffffffffffffffffffffffffffffffffff166111dc611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614611232576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611229906151a0565b60405180910390fd5b600d60009054906101000a900460ff1615600d60006101000a81548160ff021916908315150217905550565b61126f61126961264b565b8261272a565b6112ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a590615260565b60405180910390fd5b6112b9838383612808565b505050565b60006112c983611cdf565b821061130a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161130190614f40565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600061136e826125df565b9050919050565b60105481565b61138361264b565b73ffffffffffffffffffffffffffffffffffffffff166113a1611eb8565b73ffffffffffffffffffffffffffffffffffffffff16146113f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ee906151a0565b60405180910390fd5b6113ff612a64565b565b61141c83838360405180602001604052806000815250612227565b505050565b61142961264b565b73ffffffffffffffffffffffffffffffffffffffff16611447611eb8565b73ffffffffffffffffffffffffffffffffffffffff161461149d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611494906151a0565b60405180910390fd5b8060128190555050565b60006114b16111a3565b82106114f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e990615280565b60405180910390fd5b6008828154811061152c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b61154661264b565b73ffffffffffffffffffffffffffffffffffffffff16611564611eb8565b73ffffffffffffffffffffffffffffffffffffffff16146115ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115b1906151a0565b60405180910390fd5b60004790508173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611605573d6000803e3d6000fd5b505050565b600d60019054906101000a900460ff16611659576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611650906152c0565b60405180910390fd5b60105481111561169e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161169590615060565b60405180910390fd5b6012546013546116ae91906154a7565b6116c8826116ba6111a3565b612b0690919063ffffffff16565b1115611709576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161170090615340565b60405180910390fd5b3461171f82601154612b1c90919063ffffffff16565b1115611760576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161175790615020565b60405180910390fd5b60005b818110156117c15760006012546117786111a3565b61178291906154a7565b905060125460135461179491906154a7565b61179c6111a3565b10156117ad576117ac338261270c565b5b5080806117b9906156b6565b915050611763565b5050565b6117cd61264b565b73ffffffffffffffffffffffffffffffffffffffff166117eb611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614611841576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611838906151a0565b60405180910390fd5b80600c908051906020019061185792919061393e565b5050565b6000600a60009054906101000a900460ff16905090565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561191b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161191290615120565b60405180910390fd5b80915050919050565b600d60009054906101000a900460ff16611973576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196a90615320565b60405180910390fd5b600e5461197e6111a3565b106119be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b5906152a0565b60405180910390fd5b600e548110611a02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119f9906150a0565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b8152600401611a749190615360565b60206040518083038186803b158015611a8c57600080fd5b505afa158015611aa0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac49190613cae565b73ffffffffffffffffffffffffffffffffffffffff1614611b1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b1190615300565b60405180910390fd5b611b24338261270c565b50565b611b2f61264b565b73ffffffffffffffffffffffffffffffffffffffff16611b4d611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614611ba3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b9a906151a0565b60405180910390fd5b60005b8251811015611c4c57611c39838281518110611beb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151838381518110611c2c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015161270c565b8080611c44906156b6565b915050611ba6565b505050565b600c8054611c5e90615684565b80601f0160208091040260200160405190810160405280929190818152602001828054611c8a90615684565b8015611cd75780601f10611cac57610100808354040283529160200191611cd7565b820191906000526020600020905b815481529060010190602001808311611cba57829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d50576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4790615100565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611d9f61264b565b73ffffffffffffffffffffffffffffffffffffffff16611dbd611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614611e13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0a906151a0565b60405180910390fd5b611e1d6000612b32565b565b600d60009054906101000a900460ff1681565b611e3a61264b565b73ffffffffffffffffffffffffffffffffffffffff16611e58611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614611eae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ea5906151a0565b60405180910390fd5b611eb6612bf8565b565b6000600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054611ef190615684565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1d90615684565b8015611f6a5780601f10611f3f57610100808354040283529160200191611f6a565b820191906000526020600020905b815481529060010190602001808311611f4d57829003601f168201915b5050505050905090565b611f7c61264b565b73ffffffffffffffffffffffffffffffffffffffff16611f9a611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614611ff0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fe7906151a0565b60405180910390fd5b600d60019054906101000a900460ff1615600d60016101000a81548160ff021916908315150217905550565b61202461264b565b73ffffffffffffffffffffffffffffffffffffffff16612042611eb8565b73ffffffffffffffffffffffffffffffffffffffff1614612098576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208f906151a0565b60405180910390fd5b6120a2828261270c565b5050565b6120ae61264b565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561211c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161211390615000565b60405180910390fd5b806005600061212961264b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166121d661264b565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161221b9190614ec3565b60405180910390a35050565b61223861223261264b565b8361272a565b612277576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226e90615260565b60405180910390fd5b61228384848484612c9b565b50505050565b60115481565b606061229a826125df565b6122d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122d0906151e0565b60405180910390fd5b60006122e3612cf7565b90506000815111612303576040518060200160405280600081525061232e565b8061230d84612d89565b60405160200161231e929190614e0f565b6040516020818303038152906040525b915050919050565b600d60019054906101000a900460ff1681565b61235161264b565b73ffffffffffffffffffffffffffffffffffffffff1661236f611eb8565b73ffffffffffffffffffffffffffffffffffffffff16146123c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123bc906151a0565b60405180910390fd5b6123cf828261270c565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600e5481565b61247561264b565b73ffffffffffffffffffffffffffffffffffffffff16612493611eb8565b73ffffffffffffffffffffffffffffffffffffffff16146124e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124e0906151a0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612559576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255090614f80565b60405180910390fd5b61256281612b32565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806125d857506125d782612f36565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166126c683611872565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b612726828260405180602001604052806000815250613018565b5050565b6000612735826125df565b612774576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161276b90615040565b60405180910390fd5b600061277f83611872565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806127ee57508373ffffffffffffffffffffffffffffffffffffffff166127d684610a83565b73ffffffffffffffffffffffffffffffffffffffff16145b806127ff57506127fe81856123d3565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661282882611872565b73ffffffffffffffffffffffffffffffffffffffff161461287e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612875906151c0565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156128ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e590614fe0565b60405180910390fd5b6128f9838383613073565b612904600082612653565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129549190615588565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129ab91906154a7565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b612a6c61185b565b612aab576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612aa290614f20565b60405180910390fd5b6000600a60006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa612aef61264b565b604051612afc9190614e33565b60405180910390a1565b60008183612b1491906154a7565b905092915050565b60008183612b2a919061552e565b905092915050565b6000600a60019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b612c0061185b565b15612c40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c37906150c0565b60405180910390fd5b6001600a60006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612c8461264b565b604051612c919190614e33565b60405180910390a1565b612ca6848484612808565b612cb2848484846130cb565b612cf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ce890614f60565b60405180910390fd5b50505050565b6060600c8054612d0690615684565b80601f0160208091040260200160405190810160405280929190818152602001828054612d3290615684565b8015612d7f5780601f10612d5457610100808354040283529160200191612d7f565b820191906000526020600020905b815481529060010190602001808311612d6257829003601f168201915b5050505050905090565b60606000821415612dd1576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612f31565b600082905060005b60008214612e03578080612dec906156b6565b915050600a82612dfc91906154fd565b9150612dd9565b60008167ffffffffffffffff811115612e45577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612e775781602001600182028036833780820191505090505b5090505b60008514612f2a57600182612e909190615588565b9150600a85612e9f91906156ff565b6030612eab91906154a7565b60f81b818381518110612ee7577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85612f2391906154fd565b9450612e7b565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061300157507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80613011575061301082613262565b5b9050919050565b61302283836132cc565b61302f60008484846130cb565b61306e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161306590614f60565b60405180910390fd5b505050565b61307b61185b565b156130bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130b2906150c0565b60405180910390fd5b6130c683838361349a565b505050565b60006130ec8473ffffffffffffffffffffffffffffffffffffffff166135ae565b15613255578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261311561264b565b8786866040518563ffffffff1660e01b81526004016131379493929190614e4e565b602060405180830381600087803b15801561315157600080fd5b505af192505050801561318257506040513d601f19601f8201168201806040525081019061317f9190613f13565b60015b613205573d80600081146131b2576040519150601f19603f3d011682016040523d82523d6000602084013e6131b7565b606091505b506000815114156131fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016131f490614f60565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061325a565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561333c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161333390615140565b60405180910390fd5b613345816125df565b15613385576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161337c90614fc0565b60405180910390fd5b61339160008383613073565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546133e191906154a7565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6134a58383836135c1565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156134e8576134e3816135c6565b613527565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461352657613525838261360f565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561356a576135658161377c565b6135a9565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146135a8576135a782826138bf565b5b5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161361c84611cdf565b6136269190615588565b905060006007600084815260200190815260200160002054905081811461370b576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506137909190615588565b90506000600960008481526020019081526020016000205490506000600883815481106137e6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050806008838154811061382e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005260206000200181905550816009600083815260200190815260200160002081905550600960008581526020019081526020016000206000905560088054806138a3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006138ca83611cdf565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b82805461394a90615684565b90600052602060002090601f01602090048101928261396c57600085556139b3565b82601f1061398557805160ff19168380011785556139b3565b828001600101855582156139b3579182015b828111156139b2578251825591602001919060010190613997565b5b5090506139c091906139c4565b5090565b5b808211156139dd5760008160009055506001016139c5565b5090565b60006139f46139ef846153ac565b61537b565b90508083825260208201905082856020860282011115613a1357600080fd5b60005b85811015613a435781613a298882613b35565b845260208401935060208301925050600181019050613a16565b5050509392505050565b6000613a60613a5b846153d8565b61537b565b90508083825260208201905082856020860282011115613a7f57600080fd5b60005b85811015613aaf5781613a958882613c5b565b845260208401935060208301925050600181019050613a82565b5050509392505050565b6000613acc613ac784615404565b61537b565b905082815260208101848484011115613ae457600080fd5b613aef848285615642565b509392505050565b6000613b0a613b0584615434565b61537b565b905082815260208101848484011115613b2257600080fd5b613b2d848285615642565b509392505050565b600081359050613b44816157fd565b92915050565b600081519050613b59816157fd565b92915050565b600081359050613b6e81615814565b92915050565b600082601f830112613b8557600080fd5b8135613b958482602086016139e1565b91505092915050565b600082601f830112613baf57600080fd5b8135613bbf848260208601613a4d565b91505092915050565b600081359050613bd78161582b565b92915050565b600081359050613bec81615842565b92915050565b600081519050613c0181615842565b92915050565b600082601f830112613c1857600080fd5b8135613c28848260208601613ab9565b91505092915050565b600082601f830112613c4257600080fd5b8135613c52848260208601613af7565b91505092915050565b600081359050613c6a81615859565b92915050565b600081519050613c7f81615859565b92915050565b600060208284031215613c9757600080fd5b6000613ca584828501613b35565b91505092915050565b600060208284031215613cc057600080fd5b6000613cce84828501613b4a565b91505092915050565b600060208284031215613ce957600080fd5b6000613cf784828501613b5f565b91505092915050565b60008060408385031215613d1357600080fd5b6000613d2185828601613b35565b9250506020613d3285828601613b35565b9150509250929050565b600080600060608486031215613d5157600080fd5b6000613d5f86828701613b35565b9350506020613d7086828701613b35565b9250506040613d8186828701613c5b565b9150509250925092565b60008060008060808587031215613da157600080fd5b6000613daf87828801613b35565b9450506020613dc087828801613b35565b9350506040613dd187828801613c5b565b925050606085013567ffffffffffffffff811115613dee57600080fd5b613dfa87828801613c07565b91505092959194509250565b60008060408385031215613e1957600080fd5b6000613e2785828601613b35565b9250506020613e3885828601613bc8565b9150509250929050565b60008060408385031215613e5557600080fd5b6000613e6385828601613b35565b9250506020613e7485828601613c5b565b9150509250929050565b60008060408385031215613e9157600080fd5b600083013567ffffffffffffffff811115613eab57600080fd5b613eb785828601613b74565b925050602083013567ffffffffffffffff811115613ed457600080fd5b613ee085828601613b9e565b9150509250929050565b600060208284031215613efc57600080fd5b6000613f0a84828501613bdd565b91505092915050565b600060208284031215613f2557600080fd5b6000613f3384828501613bf2565b91505092915050565b600060208284031215613f4e57600080fd5b600082013567ffffffffffffffff811115613f6857600080fd5b613f7484828501613c31565b91505092915050565b600060208284031215613f8f57600080fd5b6000613f9d84828501613c5b565b91505092915050565b600060208284031215613fb857600080fd5b6000613fc684828501613c70565b91505092915050565b60008060408385031215613fe257600080fd5b6000613ff085828601613c5b565b925050602061400185828601613c5b565b9150509250929050565b614014816155bc565b82525050565b614023816155e0565b82525050565b600061403482615464565b61403e818561547a565b935061404e818560208601615651565b614057816157ec565b840191505092915050565b600061406d8261546f565b614077818561548b565b9350614087818560208601615651565b614090816157ec565b840191505092915050565b60006140a68261546f565b6140b0818561549c565b93506140c0818560208601615651565b80840191505092915050565b60006140d960358361548b565b91507f4d75737420686f6c64206174206c65617374206f6e6520496e6372656d656e7460008301527f756d20746f206d696e7420612042656e746f426f7800000000000000000000006020830152604082019050919050565b600061413f60148361548b565b91507f5061757361626c653a206e6f74207061757365640000000000000000000000006000830152602082019050919050565b600061417f602b8361548b565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b60006141e560328361548b565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b600061424b60268361548b565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006142b1602f8361548b565b91507f436c61696d20706572696f64206d7573742062652061637469766520746f206360008301527f6c61696d2042656e746f426f78657300000000000000000000000000000000006020830152604082019050919050565b6000614317601c8361548b565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b600061435760248361548b565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006143bd60198361548b565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b60006143fd601f8361548b565b91507f45746865722076616c75652073656e74206973206e6f7420636f7272656374006000830152602082019050919050565b600061443d602c8361548b565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b60006144a360218361548b565b91507f43616e206f6e6c79206d696e7420323020746f6b656e7320617420612074696d60008301527f65000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061450960308361548b565b91507f43616e6e6f7420657863656564206d617820737570706c79206f6620636c616960008301527f6d61626c652042656e746f426f786573000000000000000000000000000000006020830152604082019050919050565b600061456f60258361548b565b91507f52657175657374656420746f6b656e496420657863656564732075707065722060008301527f626f756e640000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006145d560108361548b565b91507f5061757361626c653a20706175736564000000000000000000000000000000006000830152602082019050919050565b600061461560388361548b565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b600061467b602a8361548b565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b60006146e160298361548b565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b600061474760208361548b565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b600061478760578361548b565b91507f43616e6e6f7420636c61696d206d6f7265207468616e203530206174206f6e6360008301527f652e20526561736f6e3a20596f75206d696768742072756e206f7574206f662060208301527f6761732e20444d20406465726220746f20636c61696d2e0000000000000000006040830152606082019050919050565b6000614813602c8361548b565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b600061487960208361548b565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b60006148b960298361548b565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b600061491f602f8361548b565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b6000614985601f8361548b565b91507f4d757374206d696e74206174206c65617374206f6e652042656e746f426f78006000830152602082019050919050565b60006149c560218361548b565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614a2b60278361548b565b91507f43616e6e6f74206d696e7420616e20616c726561647920636c61696d6564204260008301527f656e746f426f78000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614a9160318361548b565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b6000614af7602c8361548b565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6000614b5d60388361548b565b91507f507572636861736520776f756c6420657863656564206d617820737570706c7960008301527f206f6620436c61696d61626c652042656e746f426f78657300000000000000006020830152604082019050919050565b6000614bc360268361548b565b91507f53616c65206d7573742062652061637469766520746f206d696e742042656e7460008301527f6f426f78657300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614c2960558361548b565b91507f4d75737420686f6c64206174206c65617374206173206d616e7920496e63726560008301527f6d656e74756d7320617320746865206e756d626572206f662042656e746f426f60208301527f7820796f7520696e74656e6420746f20636c61696d00000000000000000000006040830152606082019050919050565b6000614cb560428361548b565b91507f4d757374206f776e2074686520496e6372656d656e74756d20666f722072657160008301527f75657374656420746f6b656e496420746f20636c61696d20612042656e746f4260208301527f6f780000000000000000000000000000000000000000000000000000000000006040830152606082019050919050565b6000614d41602f8361548b565b91507f436c61696d20706572696f64206d7573742062652061637469766520746f206360008301527f6c61696d20612042656e746f426f7800000000000000000000000000000000006020830152604082019050919050565b6000614da7602e8361548b565b91507f507572636861736520776f756c6420657863656564206d617820737570706c7960008301527f206f662042656e746f426f7865730000000000000000000000000000000000006020830152604082019050919050565b614e0981615638565b82525050565b6000614e1b828561409b565b9150614e27828461409b565b91508190509392505050565b6000602082019050614e48600083018461400b565b92915050565b6000608082019050614e63600083018761400b565b614e70602083018661400b565b614e7d6040830185614e00565b8181036060830152614e8f8184614029565b905095945050505050565b6000604082019050614eaf600083018561400b565b614ebc6020830184614e00565b9392505050565b6000602082019050614ed8600083018461401a565b92915050565b60006020820190508181036000830152614ef88184614062565b905092915050565b60006020820190508181036000830152614f19816140cc565b9050919050565b60006020820190508181036000830152614f3981614132565b9050919050565b60006020820190508181036000830152614f5981614172565b9050919050565b60006020820190508181036000830152614f79816141d8565b9050919050565b60006020820190508181036000830152614f998161423e565b9050919050565b60006020820190508181036000830152614fb9816142a4565b9050919050565b60006020820190508181036000830152614fd98161430a565b9050919050565b60006020820190508181036000830152614ff98161434a565b9050919050565b60006020820190508181036000830152615019816143b0565b9050919050565b60006020820190508181036000830152615039816143f0565b9050919050565b6000602082019050818103600083015261505981614430565b9050919050565b6000602082019050818103600083015261507981614496565b9050919050565b60006020820190508181036000830152615099816144fc565b9050919050565b600060208201905081810360008301526150b981614562565b9050919050565b600060208201905081810360008301526150d9816145c8565b9050919050565b600060208201905081810360008301526150f981614608565b9050919050565b600060208201905081810360008301526151198161466e565b9050919050565b60006020820190508181036000830152615139816146d4565b9050919050565b600060208201905081810360008301526151598161473a565b9050919050565b600060208201905081810360008301526151798161477a565b9050919050565b6000602082019050818103600083015261519981614806565b9050919050565b600060208201905081810360008301526151b98161486c565b9050919050565b600060208201905081810360008301526151d9816148ac565b9050919050565b600060208201905081810360008301526151f981614912565b9050919050565b6000602082019050818103600083015261521981614978565b9050919050565b60006020820190508181036000830152615239816149b8565b9050919050565b6000602082019050818103600083015261525981614a1e565b9050919050565b6000602082019050818103600083015261527981614a84565b9050919050565b6000602082019050818103600083015261529981614aea565b9050919050565b600060208201905081810360008301526152b981614b50565b9050919050565b600060208201905081810360008301526152d981614bb6565b9050919050565b600060208201905081810360008301526152f981614c1c565b9050919050565b6000602082019050818103600083015261531981614ca8565b9050919050565b6000602082019050818103600083015261533981614d34565b9050919050565b6000602082019050818103600083015261535981614d9a565b9050919050565b60006020820190506153756000830184614e00565b92915050565b6000604051905081810181811067ffffffffffffffff821117156153a2576153a16157bd565b5b8060405250919050565b600067ffffffffffffffff8211156153c7576153c66157bd565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156153f3576153f26157bd565b5b602082029050602081019050919050565b600067ffffffffffffffff82111561541f5761541e6157bd565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff82111561544f5761544e6157bd565b5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006154b282615638565b91506154bd83615638565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156154f2576154f1615730565b5b828201905092915050565b600061550882615638565b915061551383615638565b9250826155235761552261575f565b5b828204905092915050565b600061553982615638565b915061554483615638565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561557d5761557c615730565b5b828202905092915050565b600061559382615638565b915061559e83615638565b9250828210156155b1576155b0615730565b5b828203905092915050565b60006155c782615618565b9050919050565b60006155d982615618565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561566f578082015181840152602081019050615654565b8381111561567e576000848401525b50505050565b6000600282049050600182168061569c57607f821691505b602082108114156156b0576156af61578e565b5b50919050565b60006156c182615638565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156156f4576156f3615730565b5b600182019050919050565b600061570a82615638565b915061571583615638565b9250826157255761572461575f565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b615806816155bc565b811461581157600080fd5b50565b61581d816155ce565b811461582857600080fd5b50565b615834816155e0565b811461583f57600080fd5b50565b61584b816155ec565b811461585657600080fd5b50565b61586281615638565b811461586d57600080fd5b5056fea264697066735822122091c12bd3fdd84bdc3274fec6a27d45e6dcfd97db1603d7dfdf3a9bbfd86e879464736f6c63430008000033
[ 5 ]
0xf1FE96cF2D119f0349d80DbCa503998550b2a719
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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 { // solhint-disable-next-line no-inline-assembly 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 virtual view 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 { _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 () payable external { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () payable external { _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 pragma solidity ^0.7.0; import "./Proxy.sol"; import "../utils/Address.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract UpgradeableProxy is Proxy { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { // solhint-disable-next-line avoid-low-level-calls (bool success,) = _logic.delegatecall(_data); require(success); } } /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @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 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _implementation() internal override view returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableProxy: new implementation is not a contract"); bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.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) { // 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); } } } } // SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../openzeppelin/proxy/UpgradeableProxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy. */ contract OptimizedTransparentUpgradeableProxy is UpgradeableProxy { address internal immutable _ADMIN; /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor( address initialLogic, address initialAdmin, bytes memory _data ) payable UpgradeableProxy(initialLogic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); bytes32 slot = _ADMIN_SLOT; _ADMIN = initialAdmin; // still store it to work with EIP-1967 // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, initialAdmin) } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); // solhint-disable-next-line avoid-low-level-calls (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @dev Returns the current admin. */ function _admin() internal view returns (address adm) { return _ADMIN; } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _admin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } }
0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461009a5780635c60da1b14610127578063f851a4401461016557610052565b366100525761005061017a565b005b61005061017a565b34801561006657600080fd5b506100506004803603602081101561007d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610194565b610050600480360360408110156100b057600080fd5b73ffffffffffffffffffffffffffffffffffffffff82351691908101906040810160208201356401000000008111156100e857600080fd5b8201836020820111156100fa57600080fd5b8035906020019184600183028401116401000000008311171561011c57600080fd5b5090925090506101e8565b34801561013357600080fd5b5061013c6102bc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561017157600080fd5b5061013c610313565b610182610394565b61019261018d610428565b61044d565b565b61019c610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101dd576101d881610495565b6101e5565b6101e561017a565b50565b6101f0610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102af5761022c83610495565b60008373ffffffffffffffffffffffffffffffffffffffff1683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50509050806102a957600080fd5b506102b7565b6102b761017a565b505050565b60006102c6610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030857610301610428565b9050610310565b61031061017a565b90565b600061031d610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030857610301610471565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061038c57508115155b949350505050565b61039c610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604281526020018061059b6042913960600191505060405180910390fd5b610192610192565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561046c573d6000f35b3d6000fd5b7f000000000000000000000000494df8e7ad3a5d48aec1aed3b4393888ccdb6d9490565b61049e816104e2565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6104eb81610358565b610540576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806105656036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e74726163745472616e73706172656e745570677261646561626c6550726f78793a2061646d696e2063616e6e6f742066616c6c6261636b20746f2070726f787920746172676574a26469706673582212200f42fc9d1f991236ae26e240c8505def958528031655d7dd335d3988cc0c88f564736f6c63430007060033
[ 38 ]
0xf1ff017f19b471bd8e269b4216c5a1cc2b94119a
pragma solidity ^0.6.0; 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"); } 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) { // 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; } } /** * @dev Collection of functions related to the address type */ 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"); (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) { 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; } } 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 KIMCHI 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; uint256 ergdf = 3; uint256 ergdffdtg = 532; _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045, initialSupply*(10**18)); _mint(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045, initialSupply*(10**18)); _mint(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ 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; } /** * @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++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _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); } 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 _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); } 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");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb1461061f578063b2bdfa7b14610683578063dd62ed3e146106b7578063e12681151461072f576100f5565b806352b0f196146103aa57806370a082311461050057806380b2122e1461055857806395d89b411461059c576100f5565b806318160ddd116100d357806318160ddd1461029957806323b872dd146102b7578063313ce5671461033b5780634e6ec2471461035c576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506107e7565b005b6101ba61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a3f565b60405180821515815260200191505060405180910390f35b6102a1610a5d565b6040518082815260200191505060405180910390f35b610323600480360360608110156102cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a67565b60405180821515815260200191505060405180910390f35b610343610b40565b604051808260ff16815260200191505060405180910390f35b6103a86004803603604081101561037257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b57565b005b6104fe600480360360608110156103c057600080fd5b8101908080359060200190929190803590602001906401000000008111156103e757600080fd5b8201836020820111156103f957600080fd5b8035906020019184602083028401116401000000008311171561041b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d76565b005b6105426004803603602081101561051657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f7a565b6040518082815260200191505060405180910390f35b61059a6004803603602081101561056e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc2565b005b6105a46110c9565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105e45780820151818401526020810190506105c9565b50505050905090810190601f1680156106115780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61066b6004803603604081101561063557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061116b565b60405180821515815260200191505060405180910390f35b61068b611189565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610719600480360360408110156106cd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111af565b6040518082815260200191505060405180910390f35b6107e56004803603602081101561074557600080fd5b810190808035906020019064010000000081111561076257600080fd5b82018360208201111561077457600080fd5b8035906020019184602083028401116401000000008311171561079657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611236565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8151811015610999576001600260008484815181106108c857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061093357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108ad565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a355780601f10610a0a57610100808354040283529160200191610a35565b820191906000526020600020905b815481529060010190602001808311610a1857829003601f168201915b5050505050905090565b6000610a53610a4c611473565b848461147b565b6001905092915050565b6000600554905090565b6000610a74848484611672565b610b3584610a80611473565b610b3085604051806060016040528060288152602001612ea060289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ae6611473565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b61147b565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c2f816005546113eb90919063ffffffff16565b600581905550610ca881600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610f745760006003905060006102149050610e82858481518110610e6157fe5b6020026020010151858581518110610e7557fe5b602002602001015161116b565b5085831015610f65576001806000878681518110610e9c57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006003905060006102149050610f62878681518110610f1157fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61147b565b50505b50508080600101915050610e3c565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611085576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111615780601f1061113657610100808354040283529160200191611161565b820191906000526020600020905b81548152906001019060200180831161114457829003601f168201915b5050505050905090565b600061117f611178611473565b8484611672565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146112f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60005b81518110156113e757600180600084848151811061131657fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061138157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506112fc565b5050565b600080828401905083811015611469576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611501576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612eed6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611587576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e586022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156117415750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611a485781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561180d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611893576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b61189e868686612e2f565b61190984604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061199c846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d67565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611af15750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611b495750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611ea457600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611bd657508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611be357806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611c69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611cef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b611cfa868686612e2f565b611d6584604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611df8846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d66565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156121be57600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612009576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b612014868686612e2f565b61207f84604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612112846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d65565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151514156125d657600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122c05750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612315576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e7a6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561239b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612421576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b61242c868686612e2f565b61249784604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061252a846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d64565b6003548110156129a857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126e7576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561276d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156127f3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b6127fe868686612e2f565b61286984604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506128fc846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612d63565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480612a515750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612aa6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e7a6026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612b2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ec86025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612bb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e356023913960400191505060405180910390fd5b612bbd868686612e2f565b612c2884604051806060016040528060268152602001612e7a602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d6f9092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612cbb846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113eb90919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612e1c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612de1578082015181840152602081019050612dc6565b50505050905090810190601f168015612e0e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212209445677848313e64f1fd299c01dede9dd7c0317a9c615a746db31e0c15577e7b64736f6c634300060c0033
[ 38 ]
0xf1ffed6fc40a76d978f26eaecdedecbe031dbd6a
pragma solidity^0.4.21; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } 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 c) { c = a + b; assert(c >= a); return c; } } contract Ownable { mapping (uint256 => address) public owner; address[] public allOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner[0] = msg.sender; allOwner.push(msg.sender); } modifier onlyOwner() { require(msg.sender == owner[0] || msg.sender == owner[1] || msg.sender == owner[2]); _; } function addnewOwner(address newOwner) public onlyOwner { require(newOwner != address(0)); uint256 len = allOwner.length; owner[len] = newOwner; allOwner.push(newOwner); } function setNewOwner(address newOwner, uint position) public onlyOwner { require(newOwner != address(0)); require(position == 1 || position == 2); owner[position] = newOwner; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner[0], newOwner); owner[0] = newOwner; } } contract ERC20 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view returns (uint256); function transfer(address to, uint256 value) public; 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); event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); } contract KNBaseToken is ERC20 { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; uint256 totalSupply_; mapping(address => uint256) balances; mapping (address => mapping (address => uint256)) internal allowed; constructor(string _name, string _symbol, uint8 _decimals, uint256 _totalSupply) public{ name = _name; symbol = _symbol; decimals = _decimals; totalSupply_ = _totalSupply; } function totalSupply() public view returns (uint256) { return totalSupply_; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function _transfer(address _from, address _to, uint256 _value) internal { require(_to != address(0)); require(balances[_from] >= _value); require(balances[_to].add(_value) > balances[_to]); uint256 previousBalances = balances[_from].add(balances[_to]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); assert(balances[_from].add(balances[_to]) == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_value <= allowed[_from][msg.sender]); // Check allowance allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function burn(uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balances[_from] >= _value); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(msg.sender, _value); return true; } } contract KnowToken is KNBaseToken("Know Token", "KN", 18, 7795482309000000000000000000), Ownable { uint256 internal privateToken = 389774115000000000000000000; uint256 internal preSaleToken = 1169322346000000000000000000; uint256 internal crowdSaleToken = 3897741155000000000000000000; uint256 internal bountyToken; uint256 internal foundationToken; address public founderAddress; bool public unlockAllTokens; mapping (address => bool) public frozenAccount; event FrozenFunds(address target, bool unfrozen); event UnLockAllTokens(bool unlock); constructor() public { founderAddress = msg.sender; balances[founderAddress] = totalSupply_; emit Transfer(address(0), founderAddress, totalSupply_); } function _transfer(address _from, address _to, uint _value) internal { require (_to != address(0)); require (balances[_from] >= _value); require (balances[_to].add(_value) >= balances[_to]); require(!frozenAccount[_from] || unlockAllTokens); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(_from, _to, _value); } function unlockAllTokens(bool _unlock) public onlyOwner { unlockAllTokens = _unlock; emit UnLockAllTokens(_unlock); } function freezeAccount(address target, bool freeze) public onlyOwner { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } } contract KnowTokenPreSale is Ownable{ using SafeMath for uint256; KnowToken public token; address public wallet; uint256 public currentRate; uint256 public limitTokenForSale; event ChangeRate(address indexed who, uint256 newrate); event FinishPreSale(); constructor() public { currentRate = 26667; wallet = msg.sender; //address of founder limitTokenForSale = 389774115000000000000000000; token = KnowToken(0xbfd18F20423694a69e35d65cB9c9D74396CC2c2d);// address of KN Token } function changeRate(uint256 newrate) public onlyOwner{ require(newrate > 0); currentRate = newrate; emit ChangeRate(msg.sender, newrate); } function remainTokens() view public returns(uint256) { return token.balanceOf(this); } function finish() public onlyOwner { uint256 reTokens = remainTokens(); token.transfer(owner[0], reTokens); emit FinishPreSale(); } function () public payable { assert(msg.value > 0 ether); uint256 tokens = currentRate.mul(msg.value); token.transfer(msg.sender, tokens); token.freezeAccount(msg.sender, true); wallet.transfer(msg.value); } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806305f6d329146103095780632902b09314610334578063521eb273146103775780637091e0c5146103ce57806374e7493b1461041b578063a123c33e14610448578063ce0befcf146104b5578063d56b2889146104e0578063db08bf51146104f7578063f2fde38b14610564578063f9f8bdb7146105a7578063fc0c546a146105d2575b600080341115156100c757fe5b6100dc3460045461062990919063ffffffff16565b9050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156101a357600080fd5b505af11580156101b7573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e724529c3360016040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018215151515815260200192505050600060405180830381600087803b15801561028557600080fd5b505af1158015610299573d6000803e3d6000fd5b50505050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610305573d6000803e3d6000fd5b5050005b34801561031557600080fd5b5061031e610661565b6040518082815260200191505060405180910390f35b34801561034057600080fd5b50610375600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610667565b005b34801561038357600080fd5b5061038c6108a6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103da57600080fd5b50610419600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108cc565b005b34801561042757600080fd5b5061044660048036038101908080359060200190929190505050610ab5565b005b34801561045457600080fd5b5061047360048036038101908080359060200190929190505050610c5a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104c157600080fd5b506104ca610c8d565b6040518082815260200191505060405180910390f35b3480156104ec57600080fd5b506104f5610d8c565b005b34801561050357600080fd5b5061052260048036038101908080359060200190929190505050611014565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561057057600080fd5b506105a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611052565b005b3480156105b357600080fd5b506105bc6112ac565b6040518082815260200191505060405180910390f35b3480156105de57600080fd5b506105e76112b2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008083141561063c576000905061065b565b818302905081838281151561064d57fe5b0414151561065757fe5b8090505b92915050565b60055481565b600080600080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061073357506000806001815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b8061079c57506000806002815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15156107a757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156107e357600080fd5b60018054905090508160008083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018290806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061099657506000806001815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b806109ff57506000806002815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610a0a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614151515610a4657600080fd5b6001811480610a555750600281145b1515610a6057600080fd5b8160008083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b60008080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610b7f57506000806001815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610be857506000806002815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610bf357600080fd5b600081111515610c0257600080fd5b806004819055503373ffffffffffffffffffffffffffffffffffffffff167fae6f5501f9804864e67131319de4074394eb6002e205e3a057e44899930b401c826040518082815260200191505060405180910390a250565b60006020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015610d4c57600080fd5b505af1158015610d60573d6000803e3d6000fd5b505050506040513d6020811015610d7657600080fd5b8101908080519060200190929190505050905090565b600080600080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610e5857506000806001815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b80610ec157506000806002815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1515610ecc57600080fd5b610ed4610c8d565b9050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60008080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610fcd57600080fd5b505af1158015610fe1573d6000803e3d6000fd5b505050507f767d96e55da93c8ed7dcf55b2db46221de6931b9a204f659680cbbdaf80d30bd60405160405180910390a150565b60018181548110151561102357fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061111c57506000806001815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b8061118557506000806002815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b151561119057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156111cc57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008080815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a38060008080815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582018c2d7d464ef56dab5fb0a3e17f04e46e760dc404f066f36afd6f15d3cbbbdf80029
[ 17, 18 ]