Contract Overview
Balance:
0.00315 Ether
More Info
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
Leasing
Compiler Version
v0.8.11+commit.d7f03943
Optimization Enabled:
Yes with 200 runs
Other Settings:
byzantium EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.9 <0.9.0; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/interfaces/IERC20.sol"; import "@openzeppelin/contracts/access/AccessControlEnumerable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; interface IFYC is IERC721 { function totalSupply() external view returns(uint256 number); function getTierNumberOf(uint256 _tokenId) external view returns(uint8 tierNumber); function getTierPrice(uint8 tierNumber) external view returns(uint256 tierPrice); function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address roalityReceiver, uint256 royaltyAmount); function setRoality(address receiver, uint96 feeNumerator) external; function getLatestPrice() external view returns (int price); } contract Leasing is Ownable, ReentrancyGuard, AccessControlEnumerable { // Protect uint using safemath using SafeMath for uint256; // Log more in depth events such as withdrawals and cancelled txns event ApproveLeasing(uint tokenId); event LogWithdrawal(address indexed withdrawer, address indexed withdrawalAccount, uint amount); event LogCanceled(); IERC20 _weth = IERC20(0xc778417E063141139Fce010982780140Aa0cD5Ab); IFYC _nft; uint8 private _refundPercentFee = 98; uint16 private _blocksPerDay = 5760; struct LeaseOffer { address from; uint256 price; uint32 expiresIn; uint256 createdAt; } struct LeasableToken { uint256 tokenId; uint256 price; uint32 duration; } mapping (uint256 => LeaseOffer) private _lease; mapping (address => uint256[]) private _addrToLeasingTokens; mapping(uint256 => mapping(address => bool)) _offerState; mapping (uint256 => LeaseOffer[]) leaseOffers; mapping (uint256 => bool) leasable; LeasableToken[] private _leasableTokens; uint256[] _leasedTokens; modifier onlyOwnerOf(uint256 _tokenId) { require(msg.sender == address(_nft.ownerOf(_tokenId)), "caller is not the owner of token"); _; } function getNFTAddress() external view returns(address) { return address(_nft); } function setNFTAddress(address nft_address) external onlyOwner { _nft = IFYC(nft_address); } function getBlocksPerDay() external view returns(uint16) { return _blocksPerDay; } function setBlocksPerDay(uint16 _blocks) external { _blocksPerDay = _blocks; } function withDraw() nonReentrant external onlyOwner { address payable tgt = payable(owner()); (bool success1, ) = tgt.call{value:address(this).balance}(""); require(success1, "Failed to Withdraw VET"); } function getRoalityInfo(uint256 _tokenId, uint256 _salePrice) public view returns(address, uint256) { (address roalityReceiver, uint256 royaltyAmount) = _nft.royaltyInfo(_tokenId, _salePrice); return (roalityReceiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points. */ function setRoality(address receiver, uint96 feeNumerator) external onlyOwner { _nft.setRoality(receiver, feeNumerator); } function getRefundFee() external view returns(uint8) { return _refundPercentFee; } function setRefundFee(uint8 fee) external onlyOwner { require(fee > 0 && fee <100, "Invalied percentage value"); _refundPercentFee = fee; } function getLeasable(uint256 _tokenId) external view returns(bool) { if(leasable[_tokenId]) return true; else return false; } function setTokenLeasable(uint256 _tokenId, uint256 _price, uint32 _duration) nonReentrant external onlyOwnerOf(_tokenId) { require(_price >= _nft.getTierPrice(_nft.getTierNumberOf(_tokenId)) / 10, "Amount of ether sent is not correct."); require(_duration >= 30, "The minimum to lease the membership is 30 days."); LeasableToken memory leasableToken = getLeasableToken(_tokenId); require(leasableToken.tokenId == 0, "Token is already leasable"); _leasableTokens.push(LeasableToken(_tokenId, _price, _duration)); leasable[_tokenId] = true; } function getLeasableToken(uint256 _tokenId) public view returns(LeasableToken memory) { LeasableToken memory leasableToken; for(uint256 i = 0; i < _leasableTokens.length; i++) { if(_leasableTokens[i].tokenId == _tokenId) { leasableToken = _leasableTokens[i]; break; } } return leasableToken; } function getLease(uint256 _tokenId) external view returns(LeaseOffer memory) { LeaseOffer memory leaseItem = _lease[_tokenId]; if (leaseItem.price > 0 && (block.number - leaseItem.createdAt) > (leaseItem.expiresIn * _blocksPerDay)) { leaseItem.from = address(0); leaseItem.price = 0; leaseItem.expiresIn = 0; leaseItem.createdAt = 0; } return leaseItem; } function getLeasedTokens() external view returns(uint256[] memory) { uint256[] memory leasedTokens = _leasedTokens; for(uint256 i = 0; i < _leasedTokens.length; i++) { LeaseOffer memory leaseItem = _lease[leasedTokens[i]]; if (leaseItem.price > 0 && (block.number - leaseItem.createdAt) > (leaseItem.expiresIn * _blocksPerDay)) { leasedTokens[i] = leasedTokens[leasedTokens.length - 1]; delete leasedTokens[leasedTokens.length - 1]; } } return leasedTokens; } function updateLeasableToken(uint256 _tokenId, uint256 _price, uint32 _duration) external onlyOwnerOf(_tokenId) { require(_price >= _nft.getTierPrice(_nft.getTierNumberOf(_tokenId)) / 10, "Amount of ether sent is not correct."); require(_duration >= 30, "The minimum to lease the membership is 30 days."); LeasableToken memory leasableToken = getLeasableToken(_tokenId); require(leasableToken.tokenId != 0, "Token is not leasable"); for(uint256 i = 0; i < _leasableTokens.length; i++) { if(_leasableTokens[i].tokenId == _tokenId) { _leasableTokens[i].price = _price; _leasableTokens[i].duration = _duration; break; } } } function cancelTokenLeasable(uint256 _tokenId) external onlyOwnerOf(_tokenId) { for(uint256 i = 0; i < _leasableTokens.length; i++) { if (_leasableTokens[i].tokenId == _tokenId) { _leasableTokens[i] = _leasableTokens[_leasableTokens.length - 1]; _leasableTokens.pop(); break; } } } function getLeasableTokens() external view returns(LeasableToken[] memory) { return _leasableTokens; } function getLeaseOffers(uint256 _tokenId) external view returns(LeaseOffer[] memory) { return leaseOffers[_tokenId]; } function getLeasingTokens(address _address) external view returns (uint256[] memory) { uint256[] memory leasingTokens = _addrToLeasingTokens[_address]; for(uint256 i = 0; i < _addrToLeasingTokens[_address].length; i++) { LeaseOffer memory leaseItem = _lease[leasingTokens[i]]; if (leaseItem.price > 0 && (block.number - leaseItem.createdAt) > (leaseItem.expiresIn * _blocksPerDay)) { leasingTokens[i] = leasingTokens[leasingTokens.length - 1]; delete leasingTokens[leasingTokens.length - 1]; } } return leasingTokens; } function trasferWeth(address from, address to, uint256 amount) public returns(bool) { return _weth.transferFrom(from, to, amount); } function approveLeaseOffer(uint256 _tokenId, address _from) nonReentrant external onlyOwnerOf(_tokenId) { LeaseOffer[] memory tokenLeaseOffers = leaseOffers[_tokenId]; for(uint256 i = 0; i < tokenLeaseOffers.length; i++) { if(tokenLeaseOffers[i].from == _from) { (address royaltyReceiver, uint256 roaltyAmount) = getRoalityInfo(_tokenId, tokenLeaseOffers[i].price); // transfer WETH from lease offer maker to the owner bool success1 = trasferWeth(_from, address(_nft.ownerOf(_tokenId)), (tokenLeaseOffers[i].price * 9) / 10); require(success1, "Failed to Pay Royalty fee"); // transfer royalty fee from lease offer maker to royalty receiver bool success2 = trasferWeth(_from, royaltyReceiver, roaltyAmount); require(success2, "Failed to Pay Royalty fee"); tokenLeaseOffers[i].createdAt = block.number; _lease[_tokenId] = tokenLeaseOffers[i]; leaseOffers[_tokenId][i] = leaseOffers[_tokenId][leaseOffers[_tokenId].length -1]; leaseOffers[_tokenId].pop(); _addrToLeasingTokens[_from].push(_tokenId); emit ApproveLeasing(_tokenId); break; } } _offerState[_tokenId][_from] = false; } function calcenLeaseOffer(uint256 _tokenId) nonReentrant external { require(_nft.ownerOf(_tokenId) != msg.sender, "You can't buy yours."); require(_nft.ownerOf(_tokenId) != address(0), "You can't send offer no-owner token"); LeaseOffer[] memory tokenLeaseOffers = leaseOffers[_tokenId]; for(uint256 i = 0; i < tokenLeaseOffers.length; i++) { if(tokenLeaseOffers[i].from == msg.sender) { leaseOffers[_tokenId][i] = leaseOffers[_tokenId][leaseOffers[_tokenId].length - 1]; leaseOffers[_tokenId].pop(); emit ApproveLeasing(_tokenId); break; } } _offerState[_tokenId][msg.sender] = false; } function sendLeaseOffer(uint256 _tokenId, uint256 _amount, uint32 _expiresIn) nonReentrant public payable { require(_nft.ownerOf(_tokenId) != msg.sender, "You can't buy yours."); require(_nft.ownerOf(_tokenId) != address(0), "You can't send offer no-owner token"); require(_amount >= _nft.getTierPrice(_nft.getTierNumberOf(_tokenId)) / 10, "Amount of ether sent is not correct."); require(_weth.balanceOf(msg.sender) >= _amount, "You don't have enough WETH."); require(_expiresIn >= 30, "The minimum to lease the membership is 30 days."); require(_offerState[_tokenId][msg.sender] != true, "You can't send mutli offer"); leaseOffers[_tokenId].push(LeaseOffer(msg.sender, _amount, _expiresIn, block.number)); _offerState[_tokenId][msg.sender] = true; } function lease(uint256 _tokenId, uint32 _expiresIn) nonReentrant external payable { require(_nft.ownerOf(_tokenId) != msg.sender, "You can't buy yours."); require(leasable[_tokenId], "Token is not public"); require(_nft.ownerOf(_tokenId) != address(0), "You can't send offer no-owner token"); require(msg.value >= _nft.getTierPrice(_nft.getTierNumberOf(_tokenId)) / 10, "Amount of ether sent is not correct."); (address royaltyReceiver, uint256 roaltyAmount) = getRoalityInfo(_tokenId, msg.value); address payable _royaltyReceiver = payable(royaltyReceiver); (bool success1, ) = _royaltyReceiver.call{ value: roaltyAmount }(""); require(success1, "Failed to Pay Royalty fee"); _lease[_tokenId] = LeaseOffer(msg.sender, msg.value, _expiresIn, block.number); leasable[_tokenId] = false; _leasedTokens.push(_tokenId); for(uint256 i = 0; i < _leasableTokens.length; i++) { if (_leasableTokens[i].tokenId == _tokenId) { _leasableTokens[i] = _leasableTokens[_leasableTokens.length - 1]; _leasableTokens.pop(); break; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^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; if (lastIndex != toDeleteIndex) { 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] = valueIndex; // Replace lastvalue's index to valueIndex } // 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) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // 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); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // 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)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// 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); }
// 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/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 (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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @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) external view returns (address); /** * @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) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @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 {AccessControl-_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) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @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) external; /** * @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) external; /** * @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) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @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 virtual override returns (address) { return _roleMembers[role].at(index); } /** * @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 virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @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 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]{40}) is missing role (0x[0-9a-f]{64})$/ * * _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 virtual 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]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { 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 virtual 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 revoked `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}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ 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 { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "byzantium", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ApproveLeasing","type":"event"},{"anonymous":false,"inputs":[],"name":"LogCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"withdrawalAccount","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LogWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_from","type":"address"}],"name":"approveLeaseOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"calcenLeaseOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelTokenLeasable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBlocksPerDay","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getLeasable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getLeasableToken","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint32","name":"duration","type":"uint32"}],"internalType":"struct Leasing.LeasableToken","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLeasableTokens","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint32","name":"duration","type":"uint32"}],"internalType":"struct Leasing.LeasableToken[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getLease","outputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint32","name":"expiresIn","type":"uint32"},{"internalType":"uint256","name":"createdAt","type":"uint256"}],"internalType":"struct Leasing.LeaseOffer","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getLeaseOffers","outputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint32","name":"expiresIn","type":"uint32"},{"internalType":"uint256","name":"createdAt","type":"uint256"}],"internalType":"struct Leasing.LeaseOffer[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLeasedTokens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"getLeasingTokens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNFTAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRefundFee","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"getRoalityInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint32","name":"_expiresIn","type":"uint32"}],"name":"lease","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint32","name":"_expiresIn","type":"uint32"}],"name":"sendLeaseOffer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_blocks","type":"uint16"}],"name":"setBlocksPerDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nft_address","type":"address"}],"name":"setNFTAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"fee","type":"uint8"}],"name":"setRefundFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"name":"setRoality","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint32","name":"_duration","type":"uint32"}],"name":"setTokenLeasable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"trasferWeth","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint32","name":"_duration","type":"uint32"}],"name":"updateLeasableToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withDraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405260048054600160a060020a03191673c778417e063141139fce010982780140aa0cd5ab1790556005805476168062000000000000000000000000000000000000000060a060020a62ffffff02199091161790553480156200006457600080fd5b506200008b6200007c64010000000062000095810204565b64010000000062000099810204565b60018055620000e9565b3390565b60008054600160a060020a03838116600160a060020a0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b613e0380620000f96000396000f3fe6080604052600436106102135760003560e060020a90048063836807fc1161011c578063b9618478116100a4578063d547741f11610073578063d547741f14610699578063db7aa090146106b9578063f2fde38b146106e6578063f41f098a14610706578063fbedd8401461072657600080fd5b8063b96184781461061b578063c98100b114610639578063ca15c87314610659578063d2d3b7051461067957600080fd5b806391d14854116100eb57806391d148541461053c5780639f44657c1461055c578063a217fddf14610589578063a308fb641461059e578063aa716c7d146105ed57600080fd5b8063836807fc1461049a57806388ea92d8146104d75780638da5cb5b146104ea5780639010d07c1461051c57600080fd5b806339b6a2c21161019f578063501a1c511161016e578063501a1c511461040557806369d03738146104255780636da6dfb2146104455780636dd15b3e14610465578063715018a61461048557600080fd5b806339b6a2c21461038e57806342eb98c1146103b05780634815df1d146103c35780634af2f58d146103e357600080fd5b80631eaab324116101e65780631eaab324146102b1578063248a9ca3146102f0578063298d73f21461032e5780632f2ff15d1461034e57806336568abe1461036e57600080fd5b806301ffc9a7146102185780630fdb1c101461024d578063192be5f1146102645780631a8e4ef914610291575b600080fd5b34801561022457600080fd5b5061023861023336600461356c565b610746565b60405190151581526020015b60405180910390f35b34801561025957600080fd5b5061026261078a565b005b34801561027057600080fd5b5061028461027f366004613596565b61089d565b60405161024491906135af565b34801561029d57600080fd5b506102626102ac366004613641565b610940565b3480156102bd57600080fd5b506102d16102cc366004613676565b610c76565b60408051600160a060020a039093168352602083019190915201610244565b3480156102fc57600080fd5b5061032061030b366004613596565b60009081526002602052604090206001015490565b604051908152602001610244565b34801561033a57600080fd5b50610238610349366004613596565b610d18565b34801561035a57600080fd5b506102626103693660046136ad565b610d44565b34801561037a57600080fd5b506102626103893660046136ad565b610d6f565b34801561039a57600080fd5b506103a3610dfe565b60405161024491906136dd565b6102626103be366004613739565b610e7d565b3480156103cf57600080fd5b506102626103de366004613765565b6113a6565b3480156103ef57600080fd5b506103f8611463565b60405161024491906137a4565b34801561041157600080fd5b506102626104203660046137eb565b611606565b34801561043157600080fd5b50610262610440366004613808565b6116da565b34801561045157600080fd5b50610262610460366004613596565b611729565b34801561047157600080fd5b50610238610480366004613825565b611afa565b34801561049157600080fd5b50610262611ba0565b3480156104a657600080fd5b5060055474010000000000000000000000000000000000000000900460ff1660405160ff9091168152602001610244565b6102626104e5366004613641565b611bd9565b3480156104f657600080fd5b50600054600160a060020a03165b604051600160a060020a039091168152602001610244565b34801561052857600080fd5b50610504610537366004613676565b61206e565b34801561054857600080fd5b506102386105573660046136ad565b61208d565b34801561056857600080fd5b5061057c610577366004613596565b6120b8565b6040516102449190613866565b34801561059557600080fd5b50610320600081565b3480156105aa57600080fd5b506102626105b93660046138a0565b6005805461ffff90921660a860020a0276ffff00000000000000000000000000000000000000000019909216919091179055565b3480156105f957600080fd5b5060055460a860020a900461ffff1660405161ffff9091168152602001610244565b34801561062757600080fd5b50600554600160a060020a0316610504565b34801561064557600080fd5b506102626106543660046136ad565b61218a565b34801561066557600080fd5b50610320610674366004613596565b6126d0565b34801561068557600080fd5b50610262610694366004613596565b6126e7565b3480156106a557600080fd5b506102626106b43660046136ad565b61289a565b3480156106c557600080fd5b506106d96106d4366004613596565b6128c0565b60405161024491906138c4565b3480156106f257600080fd5b50610262610701366004613808565b6129c0565b34801561071257600080fd5b50610262610721366004613641565b612a78565b34801561073257600080fd5b506103f8610741366004613808565b612d65565b6000600160e060020a031982167f5a05180f000000000000000000000000000000000000000000000000000000001480610784575061078482612f27565b92915050565b600260015414156107b95760405160e560020a62461bcd0281526004016107b0906138eb565b60405180910390fd5b6002600155600054600160a060020a031633146107eb5760405160e560020a62461bcd0281526004016107b090613922565b60008054604051600160a060020a03909116919082903031908381818185875af1925050503d806000811461083c576040519150601f19603f3d011682016040523d82523d6000602084013e610841565b606091505b50509050806108955760405160e560020a62461bcd02815260206004820152601660248201527f4661696c656420746f205769746864726177205645540000000000000000000060448201526064016107b0565b505060018055565b606060096000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561093557600084815260209081902060408051608081018252600486029092018054600160a060020a0316835260018082015484860152600282015463ffffffff169284019290925260030154606083015290835290920191016108d2565b505050509050919050565b600260015414156109665760405160e560020a62461bcd0281526004016107b0906138eb565b600260015560055460405160e160020a6331a9108f028152600481018590528491600160a060020a031690636352211e90602401602060405180830381865afa1580156109b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109db9190613957565b600160a060020a031633600160a060020a031614610a0e5760405160e560020a62461bcd0281526004016107b090613974565b60055460405160e060020a63669aa2a302815260048101869052600a91600160a060020a031690635586402d90829063669aa2a390602401602060405180830381865afa158015610a63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8791906139a9565b60405160e060020a63ffffffff841602815260ff9091166004820152602401602060405180830381865afa158015610ac3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae791906139c6565b610af191906139f8565b831015610b135760405160e560020a62461bcd0281526004016107b090613a1d565b601e8263ffffffff161015610b3d5760405160e560020a62461bcd0281526004016107b090613a7a565b6000610b48856128c0565b805190915015610b9d5760405160e560020a62461bcd02815260206004820152601960248201527f546f6b656e20697320616c7265616479206c65617361626c650000000000000060448201526064016107b0565b505060408051606081018252848152602080820194855263ffffffff938416828401908152600b805460018082018355600092835294517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db960039092029182015596517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dba88015590517f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dbb909601805463ffffffff19169690951695909517909355938352600a9091529020805460ff1916821790558055565b6005546040517f2a55205a0000000000000000000000000000000000000000000000000000000081526004810184905260248101839052600091829182918291600160a060020a0390911690632a55205a906044016040805180830381865afa158015610ce7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0b9190613ad7565b9097909650945050505050565b6000818152600a602052604081205460ff1615610d3757506001919050565b506000919050565b919050565b600082815260026020526040902060010154610d608133612f8e565b610d6a8383612ff5565b505050565b600160a060020a0381163314610df05760405160e560020a62461bcd02815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107b0565b610dfa8282613017565b5050565b6060600b805480602002602001604051908101604052809291908181526020016000905b82821015610e745760008481526020908190206040805160608101825260038602909201805483526001808201548486015260029091015463ffffffff16918301919091529083529092019101610e22565b50505050905090565b60026001541415610ea35760405160e560020a62461bcd0281526004016107b0906138eb565b600260015560055460405160e160020a6331a9108f028152600481018490523391600160a060020a031690636352211e90602401602060405180830381865afa158015610ef4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f189190613957565b600160a060020a03161415610f425760405160e560020a62461bcd0281526004016107b090613b05565b6000828152600a602052604090205460ff16610fa35760405160e560020a62461bcd02815260206004820152601360248201527f546f6b656e206973206e6f74207075626c69630000000000000000000000000060448201526064016107b0565b60055460405160e160020a6331a9108f02815260048101849052600091600160a060020a031690636352211e90602401602060405180830381865afa158015610ff0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110149190613957565b600160a060020a0316141561103e5760405160e560020a62461bcd0281526004016107b090613b3c565b60055460405160e060020a63669aa2a302815260048101849052600a91600160a060020a031690635586402d90829063669aa2a390602401602060405180830381865afa158015611093573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b791906139a9565b60405160e060020a63ffffffff841602815260ff9091166004820152602401602060405180830381865afa1580156110f3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061111791906139c6565b61112191906139f8565b3410156111435760405160e560020a62461bcd0281526004016107b090613a1d565b6000806111508434610c76565b60405191935091508290600090600160a060020a0383169084908381818185875af1925050503d80600081146111a2576040519150601f19603f3d011682016040523d82523d6000602084013e6111a7565b606091505b50509050806111cb5760405160e560020a62461bcd0281526004016107b090613b99565b6040805160808101825233815234602080830191825263ffffffff898116848601908152436060860190815260008d81526006855287812096518754600160a060020a031916600160a060020a039091161787559451600180880191909155915160028701805463ffffffff191691909416179092559051600390940193909355600a9052918220805460ff19169055600c8054918201815582527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7018790555b600b548110156113995786600b82815481106112aa576112aa613bd0565b906000526020600020906003020160000154141561138757600b80546112d290600190613be9565b815481106112e2576112e2613bd0565b9060005260206000209060030201600b828154811061130357611303613bd0565b600091825260209091208254600390920201908155600180830154908201556002918201549101805463ffffffff191663ffffffff909216919091179055600b80548061135257611352613c00565b6000828152602081206003600019909301928302018181556001810191909155600201805463ffffffff191690559055611399565b8061139181613c19565b91505061128c565b5050600180555050505050565b600054600160a060020a031633146113d35760405160e560020a62461bcd0281526004016107b090613922565b6005546040517f4815df1d000000000000000000000000000000000000000000000000000000008152600160a060020a0384811660048301526bffffffffffffffffffffffff8416602483015290911690634815df1d90604401600060405180830381600087803b15801561144757600080fd5b505af115801561145b573d6000803e3d6000fd5b505050505050565b60606000600c8054806020026020016040519081016040528092919081815260200182805480156114b357602002820191906000526020600020905b81548152602001906001019080831161149f575b5050505050905060005b600c54811015611600576000600660008484815181106114df576114df613bd0565b602090810291909101810151825281810192909252604090810160002081516080810183528154600160a060020a031681526001820154938101849052600282015463ffffffff16928101929092526003015460608201529150158015906115775750600554604082015161155f9160a860020a900461ffff1690613c34565b63ffffffff168160600151436115759190613be9565b115b156115ed57826001845161158b9190613be9565b8151811061159b5761159b613bd0565b60200260200101518383815181106115b5576115b5613bd0565b60200260200101818152505082600184516115d09190613be9565b815181106115e0576115e0613bd0565b6020026020010160008152505b50806115f881613c19565b9150506114bd565b50919050565b600054600160a060020a031633146116335760405160e560020a62461bcd0281526004016107b090613922565b60008160ff16118015611649575060648160ff16105b6116985760405160e560020a62461bcd02815260206004820152601960248201527f496e76616c6965642070657263656e746167652076616c75650000000000000060448201526064016107b0565b6005805460ff909216740100000000000000000000000000000000000000000274ff000000000000000000000000000000000000000019909216919091179055565b600054600160a060020a031633146117075760405160e560020a62461bcd0281526004016107b090613922565b60058054600160a060020a031916600160a060020a0392909216919091179055565b6002600154141561174f5760405160e560020a62461bcd0281526004016107b0906138eb565b600260015560055460405160e160020a6331a9108f028152600481018390523391600160a060020a031690636352211e90602401602060405180830381865afa1580156117a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c49190613957565b600160a060020a031614156117ee5760405160e560020a62461bcd0281526004016107b090613b05565b60055460405160e160020a6331a9108f02815260048101839052600091600160a060020a031690636352211e90602401602060405180830381865afa15801561183b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185f9190613957565b600160a060020a031614156118895760405160e560020a62461bcd0281526004016107b090613b3c565b600081815260096020908152604080832080548251818502810185019093528083529192909190849084015b8282101561191857600084815260209081902060408051608081018252600486029092018054600160a060020a0316835260018082015484860152600282015463ffffffff169284019290925260030154606083015290835290920191016118b5565b50505050905060005b8151811015611ad15733600160a060020a031682828151811061194657611946613bd0565b602002602001015160000151600160a060020a03161415611abf576000838152600960205260409020805461197d90600190613be9565b8154811061198d5761198d613bd0565b90600052602060002090600402016009600085815260200190815260200160002082815481106119bf576119bf613bd0565b6000918252602080832084546004909302018054600160a060020a031916600160a060020a0390931692909217825560018085015490830155600280850154908301805463ffffffff191663ffffffff9092169190911790556003938401549390910192909255848152600990915260409020805480611a4157611a41613c00565b6000828152602081206004600019909301928302018054600160a060020a03191681556001810182905560028101805463ffffffff191690556003015590556040517f5df43fd1d761a6f554d17dc183de87d3f3567edb7dccd3a5116bf5e3d06d540e90611ab29085815260200190565b60405180910390a1611ad1565b80611ac981613c19565b915050611921565b505060009081526008602090815260408083203384529091529020805460ff1916905560018055565b600480546040517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0386811693820193909352848316602482015260448101849052600092909116906323b872dd906064016020604051808303816000875af1158015611b74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b989190613c60565b949350505050565b600054600160a060020a03163314611bcd5760405160e560020a62461bcd0281526004016107b090613922565b611bd76000613039565b565b60026001541415611bff5760405160e560020a62461bcd0281526004016107b0906138eb565b600260015560055460405160e160020a6331a9108f028152600481018590523391600160a060020a031690636352211e90602401602060405180830381865afa158015611c50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c749190613957565b600160a060020a03161415611c9e5760405160e560020a62461bcd0281526004016107b090613b05565b60055460405160e160020a6331a9108f02815260048101859052600091600160a060020a031690636352211e90602401602060405180830381865afa158015611ceb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d0f9190613957565b600160a060020a03161415611d395760405160e560020a62461bcd0281526004016107b090613b3c565b60055460405160e060020a63669aa2a302815260048101859052600a91600160a060020a031690635586402d90829063669aa2a390602401602060405180830381865afa158015611d8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db291906139a9565b60405160e060020a63ffffffff841602815260ff9091166004820152602401602060405180830381865afa158015611dee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1291906139c6565b611e1c91906139f8565b821015611e3e5760405160e560020a62461bcd0281526004016107b090613a1d565b600480546040517f70a0823100000000000000000000000000000000000000000000000000000000815233928101929092528391600160a060020a03909116906370a0823190602401602060405180830381865afa158015611ea4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec891906139c6565b1015611f195760405160e560020a62461bcd02815260206004820152601b60248201527f596f7520646f6e2774206861766520656e6f75676820574554482e000000000060448201526064016107b0565b601e8163ffffffff161015611f435760405160e560020a62461bcd0281526004016107b090613a7a565b600083815260086020908152604080832033845290915290205460ff16151560011415611fb55760405160e560020a62461bcd02815260206004820152601a60248201527f596f752063616e27742073656e64206d75746c69206f6666657200000000000060448201526064016107b0565b600083815260096020908152604080832081516080810183523380825281850197885263ffffffff9687168285019081524360608401908152845460018082018755958952878920945160049091029094018054600160a060020a031916600160a060020a039095169490941784559851838501555160028301805463ffffffff191691909816179096559551600390960195909555948252600881528482209282529190915291909120805460ff1916821790558055565b60008281526003602052604081206120869083613089565b9392505050565b6000918252600260209081526040808420600160a060020a0393909316845291905290205460ff1690565b60408051608081018252600080825260208201819052918101829052606081019190915260008281526006602090815260409182902082516080810184528154600160a060020a031681526001820154928101839052600282015463ffffffff1693810193909352600301546060830152158015906121675750600554604082015161214f9160a860020a900461ffff1690613c34565b63ffffffff168160600151436121659190613be9565b115b156107845760008082526020820181905260408201819052606082015292915050565b600260015414156121b05760405160e560020a62461bcd0281526004016107b0906138eb565b600260015560055460405160e160020a6331a9108f028152600481018490528391600160a060020a031690636352211e90602401602060405180830381865afa158015612201573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122259190613957565b600160a060020a031633600160a060020a0316146122585760405160e560020a62461bcd0281526004016107b090613974565b600083815260096020908152604080832080548251818502810185019093528083529192909190849084015b828210156122e757600084815260209081902060408051608081018252600486029092018054600160a060020a0316835260018082015484860152600282015463ffffffff16928401929092526003015460608301529083529092019101612284565b50505050905060005b815181101561269c5783600160a060020a031682828151811061231557612315613bd0565b602002602001015160000151600160a060020a0316141561268a5760008061235a8785858151811061234957612349613bd0565b602002602001015160200151610c76565b60055460405160e160020a6331a9108f028152600481018b905292945090925060009161240f918991600160a060020a0390911690636352211e90602401602060405180830381865afa1580156123b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123d99190613957565b600a8888815181106123ed576123ed613bd0565b60200260200101516020015160096124059190613c82565b61048091906139f8565b9050806124315760405160e560020a62461bcd0281526004016107b090613b99565b600061243e888585611afa565b9050806124605760405160e560020a62461bcd0281526004016107b090613b99565b4386868151811061247357612473613bd0565b6020026020010151606001818152505085858151811061249557612495613bd0565b60209081029190910181015160008b815260068352604080822083518154600160a060020a031916600160a060020a03909116178155838501516001808301919091558285015160028301805463ffffffff191663ffffffff9092169190911790556060909401516003909101556009909352919091208054909161251991613be9565b8154811061252957612529613bd0565b9060005260206000209060040201600960008b8152602001908152602001600020868154811061255b5761255b613bd0565b6000918252602080832084546004909302018054600160a060020a031916600160a060020a0390931692909217825560018085015490830155600280850154908301805463ffffffff191663ffffffff90921691909117905560039384015493909101929092558a81526009909152604090208054806125dd576125dd613c00565b600082815260208082206004600019909401938402018054600160a060020a0319168155600181810184905560028201805463ffffffff19169055600390910183905592909355600160a060020a038b168152600783526040808220805493840181558252929020018a9055517f5df43fd1d761a6f554d17dc183de87d3f3567edb7dccd3a5116bf5e3d06d540e90612679908b815260200190565b60405180910390a15050505061269c565b8061269481613c19565b9150506122f0565b5050506000918252600860209081526040808420600160a060020a0390931684529190529020805460ff1916905560018055565b600081815260036020526040812061078490613095565b60055460405160e160020a6331a9108f028152600481018390528291600160a060020a031690636352211e90602401602060405180830381865afa158015612733573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127579190613957565b600160a060020a031633600160a060020a03161461278a5760405160e560020a62461bcd0281526004016107b090613974565b60005b600b54811015610d6a5782600b82815481106127ab576127ab613bd0565b906000526020600020906003020160000154141561288857600b80546127d390600190613be9565b815481106127e3576127e3613bd0565b9060005260206000209060030201600b828154811061280457612804613bd0565b600091825260209091208254600390920201908155600180830154908201556002918201549101805463ffffffff191663ffffffff909216919091179055600b80548061285357612853613c00565b6000828152602081206003600019909301928302018181556001810191909155600201805463ffffffff191690559055505050565b8061289281613c19565b91505061278d565b6000828152600260205260409020600101546128b68133612f8e565b610d6a8383613017565b6128ea60405180606001604052806000815260200160008152602001600063ffffffff1681525090565b61291460405180606001604052806000815260200160008152602001600063ffffffff1681525090565b60005b600b548110156129b95783600b828154811061293557612935613bd0565b90600052602060002090600302016000015414156129a757600b818154811061296057612960613bd0565b60009182526020918290206040805160608101825260039093029091018054835260018101549383019390935260029092015463ffffffff169181019190915291506129b9565b806129b181613c19565b915050612917565b5092915050565b600054600160a060020a031633146129ed5760405160e560020a62461bcd0281526004016107b090613922565b600160a060020a038116612a6c5760405160e560020a62461bcd02815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107b0565b612a7581613039565b50565b60055460405160e160020a6331a9108f028152600481018590528491600160a060020a031690636352211e90602401602060405180830381865afa158015612ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ae89190613957565b600160a060020a031633600160a060020a031614612b1b5760405160e560020a62461bcd0281526004016107b090613974565b60055460405160e060020a63669aa2a302815260048101869052600a91600160a060020a031690635586402d90829063669aa2a390602401602060405180830381865afa158015612b70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b9491906139a9565b60405160e060020a63ffffffff841602815260ff9091166004820152602401602060405180830381865afa158015612bd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bf491906139c6565b612bfe91906139f8565b831015612c205760405160e560020a62461bcd0281526004016107b090613a1d565b601e8263ffffffff161015612c4a5760405160e560020a62461bcd0281526004016107b090613a7a565b6000612c55856128c0565b8051909150612ca95760405160e560020a62461bcd02815260206004820152601560248201527f546f6b656e206973206e6f74206c65617361626c65000000000000000000000060448201526064016107b0565b60005b600b5481101561145b5785600b8281548110612cca57612cca613bd0565b9060005260206000209060030201600001541415612d535784600b8281548110612cf657612cf6613bd0565b90600052602060002090600302016001018190555083600b8281548110612d1f57612d1f613bd0565b906000526020600020906003020160020160006101000a81548163ffffffff021916908363ffffffff16021790555061145b565b80612d5d81613c19565b915050612cac565b600160a060020a0381166000908152600760209081526040808320805482518185028101850190935280835260609493830182828015612dc457602002820191906000526020600020905b815481526020019060010190808311612db0575b5050505050905060005b600160a060020a0384166000908152600760205260409020548110156129b957600060066000848481518110612e0657612e06613bd0565b602090810291909101810151825281810192909252604090810160002081516080810183528154600160a060020a031681526001820154938101849052600282015463ffffffff1692810192909252600301546060820152915015801590612e9e57506005546040820151612e869160a860020a900461ffff1690613c34565b63ffffffff16816060015143612e9c9190613be9565b115b15612f14578260018451612eb29190613be9565b81518110612ec257612ec2613bd0565b6020026020010151838381518110612edc57612edc613bd0565b6020026020010181815250508260018451612ef79190613be9565b81518110612f0757612f07613bd0565b6020026020010160008152505b5080612f1f81613c19565b915050612dce565b6000600160e060020a031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061078457507f01ffc9a700000000000000000000000000000000000000000000000000000000600160e060020a0319831614610784565b612f98828261208d565b610dfa57612fb081600160a060020a0316601461309f565b612fbb83602061309f565b604051602001612fcc929190613cd1565b60408051601f198184030181529082905260e560020a62461bcd0282526107b091600401613d52565b612fff82826132e9565b6000828152600360205260409020610d6a908261336f565b6130218282613384565b6000828152600360205260409020610d6a90826133eb565b60008054600160a060020a03838116600160a060020a0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006120868383613400565b6000610784825490565b606060006130ae836002613c82565b6130b9906002613d85565b67ffffffffffffffff8111156130d1576130d1613d9d565b6040519080825280601f01601f1916602001820160405280156130fb576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061313257613132613bd0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061319557613195613bd0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006131d1846002613c82565b6131dc906001613d85565b90505b6001811115613297577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061321d5761321d613bd0565b1a7f01000000000000000000000000000000000000000000000000000000000000000282828151811061325257613252613bd0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060109094049361329081613db6565b90506131df565b5083156120865760405160e560020a62461bcd02815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107b0565b6132f3828261208d565b610dfa576000828152600260209081526040808320600160a060020a03851684529091529020805460ff1916600117905561332b3390565b600160a060020a031681600160a060020a0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061208683600160a060020a03841661342a565b61338e828261208d565b15610dfa576000828152600260209081526040808320600160a060020a0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600061208683600160a060020a038416613479565b600082600001828154811061341757613417613bd0565b9060005260206000200154905092915050565b600081815260018301602052604081205461347157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610784565b506000610784565b6000818152600183016020526040812054801561356257600061349d600183613be9565b85549091506000906134b190600190613be9565b90508181146135165760008660000182815481106134d1576134d1613bd0565b90600052602060002001549050808760000184815481106134f4576134f4613bd0565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061352757613527613c00565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610784565b6000915050610784565b60006020828403121561357e57600080fd5b8135600160e060020a03198116811461208657600080fd5b6000602082840312156135a857600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156136215761360e838551600160a060020a0381511682526020810151602083015263ffffffff6040820151166040830152606081015160608301525050565b92840192608092909201916001016135cb565b50909695505050505050565b803563ffffffff81168114610d3f57600080fd5b60008060006060848603121561365657600080fd5b833592506020840135915061366d6040850161362d565b90509250925092565b6000806040838503121561368957600080fd5b50508035926020909101359150565b600160a060020a0381168114612a7557600080fd5b600080604083850312156136c057600080fd5b8235915060208301356136d281613698565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561362157613726838551805182526020808201519083015260409081015163ffffffff16910152565b92840192606092909201916001016136f9565b6000806040838503121561374c57600080fd5b8235915061375c6020840161362d565b90509250929050565b6000806040838503121561377857600080fd5b823561378381613698565b915060208301356bffffffffffffffffffffffff811681146136d257600080fd5b6020808252825182820181905260009190848201906040850190845b81811015613621578351835292840192918401916001016137c0565b60ff81168114612a7557600080fd5b6000602082840312156137fd57600080fd5b8135612086816137dc565b60006020828403121561381a57600080fd5b813561208681613698565b60008060006060848603121561383a57600080fd5b833561384581613698565b9250602084013561385581613698565b929592945050506040919091013590565b8151600160a060020a031681526020808301519082015260408083015163ffffffff16908201526060808301519082015260808101610784565b6000602082840312156138b257600080fd5b813561ffff8116811461208657600080fd5b815181526020808301519082015260408083015163ffffffff169082015260608101610784565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020828403121561396957600080fd5b815161208681613698565b6020808252818101527f63616c6c6572206973206e6f7420746865206f776e6572206f6620746f6b656e604082015260600190565b6000602082840312156139bb57600080fd5b8151612086816137dc565b6000602082840312156139d857600080fd5b5051919050565b60e060020a634e487b7102600052601160045260246000fd5b600082613a185760e060020a634e487b7102600052601260045260246000fd5b500490565b60208082526024908201527f416d6f756e74206f662065746865722073656e74206973206e6f7420636f727260408201527f6563742e00000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f546865206d696e696d756d20746f206c6561736520746865206d656d6265727360408201527f68697020697320333020646179732e0000000000000000000000000000000000606082015260800190565b60008060408385031215613aea57600080fd5b8251613af581613698565b6020939093015192949293505050565b60208082526014908201527f596f752063616e27742062757920796f7572732e000000000000000000000000604082015260600190565b60208082526023908201527f596f752063616e27742073656e64206f66666572206e6f2d6f776e657220746f60408201527f6b656e0000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f4661696c656420746f2050617920526f79616c74792066656500000000000000604082015260600190565b60e060020a634e487b7102600052603260045260246000fd5b600082821015613bfb57613bfb6139df565b500390565b60e060020a634e487b7102600052603160045260246000fd5b6000600019821415613c2d57613c2d6139df565b5060010190565b600063ffffffff80831681851681830481118215151615613c5757613c576139df565b02949350505050565b600060208284031215613c7257600080fd5b8151801515811461208657600080fd5b6000816000190483118215151615613c9c57613c9c6139df565b500290565b60005b83811015613cbc578181015183820152602001613ca4565b83811115613ccb576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613d09816017850160208801613ca1565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613d46816028840160208801613ca1565b01602801949350505050565b6020815260008251806020840152613d71816040850160208701613ca1565b601f01601f19169190910160400192915050565b60008219821115613d9857613d986139df565b500190565b60e060020a634e487b7102600052604160045260246000fd5b600081613dc557613dc56139df565b50600019019056fea2646970667358221220088d85a538b388ba4ab3815c4a9fbc00b52ed9d19056aa1d011466f012957fc864736f6c634300080b0033
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.