Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 6,096 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
End Mission | 21404391 | 9 days ago | IN | 0 ETH | 0.00257784 | ||||
Evaluate | 21403582 | 9 days ago | IN | 0 ETH | 0.00155604 | ||||
Evaluate | 21403566 | 9 days ago | IN | 0 ETH | 0.00025488 | ||||
Evaluate | 21403562 | 9 days ago | IN | 0 ETH | 0.00212638 | ||||
Evaluate | 21403533 | 9 days ago | IN | 0 ETH | 0.00024526 | ||||
Evaluate | 21403523 | 9 days ago | IN | 0 ETH | 0.00142654 | ||||
Evaluate | 21403466 | 9 days ago | IN | 0 ETH | 0.00027829 | ||||
Evaluate | 21403460 | 9 days ago | IN | 0 ETH | 0.00025675 | ||||
Evaluate | 21403454 | 9 days ago | IN | 0 ETH | 0.00128797 | ||||
Evaluate | 21403441 | 9 days ago | IN | 0 ETH | 0.00026757 | ||||
Evaluate | 21403435 | 9 days ago | IN | 0 ETH | 0.00099901 | ||||
End Mission | 21400446 | 9 days ago | IN | 0 ETH | 0.00054446 | ||||
Evaluate | 21400410 | 9 days ago | IN | 0 ETH | 0.00099994 | ||||
Add Token To Tro... | 21396591 | 10 days ago | IN | 0 ETH | 0.00238045 | ||||
Start Mission | 21352268 | 16 days ago | IN | 0 ETH | 0.00316707 | ||||
Evaluate | 21276464 | 26 days ago | IN | 0 ETH | 0.00098876 | ||||
Evaluate | 21276430 | 26 days ago | IN | 0 ETH | 0.00169191 | ||||
Evaluate | 21261240 | 29 days ago | IN | 0 ETH | 0.00248675 | ||||
Evaluate | 21229107 | 33 days ago | IN | 0 ETH | 0.00308718 | ||||
Evaluate | 21229100 | 33 days ago | IN | 0 ETH | 0.00305863 | ||||
Evaluate | 21229087 | 33 days ago | IN | 0 ETH | 0.00309786 | ||||
Evaluate | 21229069 | 33 days ago | IN | 0 ETH | 0.00311373 | ||||
Add Token To Tro... | 21164623 | 42 days ago | IN | 0 ETH | 0.00322509 | ||||
Evaluate | 21150021 | 44 days ago | IN | 0 ETH | 0.00185072 | ||||
Evaluate | 21150017 | 44 days ago | IN | 0 ETH | 0.00161935 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
RegularMission
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 50 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "./HasPower.sol"; import "../libs/EnumerableTokenSet.sol"; import "../libs/TimestampStorage.sol"; import "../Locker/ITMAsLocker.sol"; import "../Rewarder/IRewarder.sol"; import "../AMTManager/IAMTManager.sol"; import "../libs/NFT.sol"; import "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; contract RegularMission is AccessControl { using BitMaps for BitMaps.BitMap; using EnumerableSet for EnumerableSet.AddressSet; using EnumerableTokenSet for EnumerableTokenSet.Set; using NFT for NFT.TokenStruct; using TimestampStorage for TimestampStorage.Storage; struct Mission { uint128 term; uint64 reward; // 100% = 10000 uint64 successRate; } struct PowerEffectUnit { uint128 powerUnit; // 1% = 100 uint128 reductionUnit; } event StartMission( address indexed user, uint256 indexed troopId, uint256 indexed missionId ); event AddedTokenToTroop( address indexed user, uint256 indexed troopId, address collection, uint256 tokenId ); event MissionResult( address indexed user, uint256 indexed troopId, uint256 indexed missionIed, bool isSuccess, uint256 reward ); bytes32 public constant ADMIN = "ADMIN"; constructor() { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _setRoleAdmin(ADMIN, DEFAULT_ADMIN_ROLE); _grantRole(ADMIN, msg.sender); // power = 50 => reduce risk 5% powerEffect = PowerEffectUnit(50, 500); } // troopId is start at 1 // user => troopId => member mapping(address => mapping(uint256 => EnumerableTokenSet.Set)) private _troop; // user => troopId => block.timestamp list mapping(address => mapping(uint256 => TimestampStorage.Storage)) private _lastEvaluateTimestamp; // user => troop num mapping(address => uint256) maxTroopNumOf; uint256 public constant DEFAULT_TROOP_NUM = 3; uint256 public maxTroopNum = 5; uint256 public maxMemberPerTroop = 5; EnumerableSet.AddressSet private _allowedCollections; address public tma; address public tmas; address public tmasMetadata; ITMAsLocker public locker; IRewarder public rewarder; IAMTManager public amtManager; // missionId => mission mapping(uint256 => Mission) public missions; BitMaps.BitMap private _pauseMission; // user => troopId => missionId mapping(address => mapping(uint256 => uint256)) public currentMission; // For TMA uint256 public bonusUnit = 2; uint256 public maxBonus = 4; uint256 public tmaPower = 50; uint256 public rewardForFailure = 1; PowerEffectUnit public powerEffect; function getMaxTroopNum(address user) public view returns (uint256) { uint256 _maxTroopNum = maxTroopNumOf[user]; if (_maxTroopNum == 0) { return DEFAULT_TROOP_NUM; } else { return _maxTroopNum; } } function getTroopsInMission( address user ) external view returns (uint256[] memory) { uint256 _maxTroopNum = getMaxTroopNum(user); uint256[] memory _troopIdInMissions = new uint256[](_maxTroopNum); uint256 n = 0; for (uint256 i = 1; i <= _maxTroopNum; i++) { if (_troop[user][i].length() > 0) { _troopIdInMissions[n++] = i; } } assembly ("memory-safe") { mstore(_troopIdInMissions, n) } return _troopIdInMissions; } function getMissionNumAndStartTimestamp( address user, uint256 troopId ) public view returns (uint256, uint256) { EnumerableTokenSet.Set storage tokens = _troop[user][troopId]; if (tokens.length() == 0) { return (0, 0); } // because troop is add only. uint256 evaluateTimestamp = _lastEvaluateTimestamp[user][troopId].get( 0 ); uint128 term = missions[currentMission[user][troopId]].term; uint256 evaluateCount = (block.timestamp - evaluateTimestamp) / term; return (evaluateCount, evaluateTimestamp); } function getTroopMembers( address user, uint256 troopId ) external view returns (address[] memory, uint256[] memory) { NFT.TokenStruct[] memory tokens = _troop[user][troopId].values(); uint256 length = tokens.length; address[] memory collections = new address[](length); uint256[] memory tokenIds = new uint256[](length); for (uint256 i = 0; i < length; i++) { NFT.TokenStruct memory token = tokens[i]; collections[i] = token.collectionAddress; tokenIds[i] = token.tokenId; } return (collections, tokenIds); } function startMission( uint256 missionId, uint256 troopId, NFT.TokenStruct[] calldata tokens ) external { address user = msg.sender; require(missions[missionId].term != 0, "invalid missionId."); require( _pauseMission.get(missionId) == false, "the mission is paused." ); require( currentMission[user][troopId] == 0, "the troop alread go to mission." ); currentMission[user][troopId] = missionId; _addTokenToTroop(user, troopId, tokens); emit StartMission(user, troopId, missionId); } function addTokenToTroop( uint256 troopId, NFT.TokenStruct[] calldata tokens ) external { address user = msg.sender; require( currentMission[user][troopId] != 0, "the troop is not started mission yet." ); _addTokenToTroop(user, troopId, tokens); } function _addTokenToTroop( address user, uint256 troopId, NFT.TokenStruct[] calldata tokens ) internal { // Assuming that the owner and lock status is verified by Locker. uint256 currentNumInTroop = _troop[user][troopId].length(); uint40 currentTimestamp = uint40(block.timestamp); require(tokens.length > 0, "tokens length must be over 1."); require( troopId >= 1 && troopId <= getMaxTroopNum(user), "invalid troopId." ); require( currentNumInTroop + tokens.length <= maxMemberPerTroop, "over max number per troop." ); for (uint256 i = 0; i < tokens.length; i++) { require( _allowedCollections.contains(tokens[i].collectionAddress), "no supported collection." ); for (uint256 j = i + 1; j < tokens.length; j++) { require( tokens[i].collectionAddress != tokens[j].collectionAddress || tokens[i].tokenId != tokens[j].tokenId, "dupplicate token." ); } } locker.lock(tokens); for (uint256 i = 0; i < tokens.length; i++) { _troop[user][troopId].add(tokens[i]); _lastEvaluateTimestamp[user][troopId].set( currentNumInTroop + i, currentTimestamp ); emit AddedTokenToTroop( user, troopId, tokens[i].collectionAddress, tokens[i].tokenId ); } } function _evaluate(address user, uint256 troopId) private { EnumerableTokenSet.Set storage tokens = _troop[user][troopId]; uint256 length = tokens.length(); ( uint256 evaluateCount, uint256 evaluateTimestamp ) = getMissionNumAndStartTimestamp(user, troopId); if (evaluateCount == 0) { return; } uint256 missionId = currentMission[user][troopId]; Mission memory mission = missions[missionId]; uint256 reward = 0; uint256[] memory powerOfTokens = new uint256[](length); uint256[] memory timestamps = new uint256[](length); uint256 blockNumber = block.number; for (uint256 i = 0; i < length; i++) { NFT.TokenStruct memory token = tokens.at(i); timestamps[i] = _lastEvaluateTimestamp[user][troopId].get(i); if (token.collectionAddress == tmas) { powerOfTokens[i] = HasPower(tmasMetadata).power(token.tokenId); } } for (uint256 i = 0; i < evaluateCount; i++) { uint256 bonus = 1; uint256 power = 0; uint256 memberNum = 0; for (uint256 j = 0; j < length; j++) { NFT.TokenStruct memory token = tokens.at(j); if (timestamps[j] > evaluateTimestamp + (mission.term * i)) { continue; } memberNum++; if (token.collectionAddress == tma) { power += tmaPower; bonus *= bonusUnit; } else if (token.collectionAddress == tmas) { power += powerOfTokens[j]; } } if (bonus > maxBonus) { bonus = maxBonus; } uint256 successRate = mission.successRate + ((power / powerEffect.powerUnit) * powerEffect.reductionUnit); uint256 _reward = rewardForFailure * memberNum; bool isSuccess = false; if (successRate >= 10000) { _reward = mission.reward * bonus * memberNum; isSuccess = true; } else { uint256 rand = uint256( keccak256(abi.encodePacked(blockhash(blockNumber - 1), i)) ) % 10000; if (rand <= successRate) { _reward = mission.reward * bonus * memberNum; isSuccess = true; } } emit MissionResult(user, troopId, missionId, isSuccess, _reward); reward += _reward; } uint40 currentTimestamp = uint40(block.timestamp); for (uint256 i = 0; i < tokens.length(); i++) { _lastEvaluateTimestamp[user][troopId].set(i, currentTimestamp); } rewarder.reward(user, reward); } function evaluate(uint256 troopId) external { _evaluate(msg.sender, troopId); } function endMission(address user, uint256 troopId) external { // Assuming that the Locker guarantees that only the holder or ADMIN can operate it. locker.unlock(_troop[user][troopId].values()); _evaluate(user, troopId); currentMission[user][troopId] = 0; NFT.TokenStruct[] memory tokens = _troop[user][troopId].values(); for (uint256 i = 0; i < tokens.length; i++) { _troop[user][troopId].remove(tokens[i]); } } function resetForEmergency(address user, uint256 troopId) external { require( user == msg.sender || hasRole(ADMIN, user), "you are not user or admin." ); currentMission[user][troopId] = 0; NFT.TokenStruct[] memory tokens = _troop[user][troopId].values(); for (uint256 i = 0; i < tokens.length; i++) { _troop[user][troopId].remove(tokens[i]); } } uint256 public addTroopCost = 3000; function addTroop() external { address user = msg.sender; uint256 _maxTroopNum = getMaxTroopNum(user); require(_maxTroopNum < maxTroopNum, "already max troop."); amtManager.use(user, addTroopCost, "add troop"); maxTroopNumOf[user] = _maxTroopNum + 1; } function setLocker(address value) external onlyRole(ADMIN) { locker = ITMAsLocker(value); } function setTMA(address value) external onlyRole(ADMIN) { tma = value; } function setTMAs(address value) external onlyRole(ADMIN) { tmas = value; } function setTMAsMetadata(address value) external onlyRole(ADMIN) { tmasMetadata = value; } function setRewarder(address value) external onlyRole(ADMIN) { rewarder = IRewarder(value); } function setAmtManager(address value) external onlyRole(ADMIN) { amtManager = IAMTManager(value); } function setAddTroopCost(uint256 value) external onlyRole(ADMIN) { addTroopCost = value; } function setMaxMemberPerTroop(uint256 value) external onlyRole(ADMIN) { maxMemberPerTroop = value; } function setMaxTroopNum(uint256 value) external onlyRole(ADMIN) { maxTroopNum = value; } function setBonusUnit(uint256 value) external onlyRole(ADMIN) { bonusUnit = value; } function setMaxBonus(uint256 value) external onlyRole(ADMIN) { maxBonus = value; } function setRewardForFailure(uint256 value) external onlyRole(ADMIN) { rewardForFailure = value; } function setTMAPower(uint256 value) external onlyRole(ADMIN) { tmaPower = value; } function setPowerEffect( PowerEffectUnit calldata value ) external onlyRole(ADMIN) { powerEffect = value; } function setMission( uint256 missionId, Mission calldata mission ) external onlyRole(ADMIN) { require(missionId > 0, "missionId must be over than 0."); require(mission.term > 0, "term must be over than 0."); missions[missionId] = mission; } function pauseMission( uint256[] calldata missionIds ) external onlyRole(ADMIN) { for (uint256 i = 0; i < missionIds.length; i++) { _pauseMission.set(missionIds[i]); } } function unpauseMission( uint256[] calldata missionIds ) external onlyRole(ADMIN) { for (uint256 i = 0; i < missionIds.length; i++) { _pauseMission.unset(missionIds[i]); } } function isMissionPaused(uint256 missionId) external view returns (bool) { return _pauseMission.get(missionId); } function addAllowedCollection( address[] calldata addresses ) external onlyRole(ADMIN) { for (uint256 i = 0; i < addresses.length; i++) { _allowedCollections.add(addresses[i]); } } function removeAllowedCollection( address[] calldata addresses ) external onlyRole(ADMIN) { for (uint256 i = 0; i < addresses.length; i++) { _allowedCollections.remove(addresses[i]); } } function getAllowedCollection() external view returns (address[] memory) { return _allowedCollections.values(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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); _; } /** * @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 `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @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(account), " 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. * * May emit a {RoleGranted} event. */ 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. * * May emit a {RoleRevoked} event. */ 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`. * * May emit a {RoleRevoked} event. */ 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. * * May emit a {RoleGranted} event. * * [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. * * May emit a {RoleGranted} event. */ 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. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// 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.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { 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 (last updated v4.8.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; } if (to != address(0)) { _balances[to] += batchSize; } } } /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev 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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/BitMaps.sol) pragma solidity ^0.8.0; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. * Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. */ library BitMaps { struct BitMap { mapping(uint256 => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo( BitMap storage bitmap, uint256 index, bool value ) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. 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. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ 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) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // 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; /// @solidity memory-safe-assembly 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 in 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; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "./IAMTManager.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract AMTManager is IAMTManager, AccessControl { bytes32 public constant ADMIN = "ADMIN"; bytes32 public constant AMT_ADD_OPERATOR = "AMT_ADD_OPERATOR"; bytes32 public constant AMT_USE_OPERATOR = "AMT_USE_OPERATOR"; event AddedAMT(address indexed user, uint256 amount); event UsedAMT(address indexed user, string indexed action, uint256 amount); constructor() { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _setRoleAdmin(ADMIN, DEFAULT_ADMIN_ROLE); _setRoleAdmin(AMT_ADD_OPERATOR, ADMIN); _setRoleAdmin(AMT_USE_OPERATOR, ADMIN); _grantRole(ADMIN, msg.sender); } mapping(address => uint256) public amt; function add( address to, uint256 value ) external onlyRole(AMT_ADD_OPERATOR) { amt[to] += value; emit AddedAMT(to, value); } function use( address from, uint256 value, string calldata action ) external onlyRole(AMT_USE_OPERATOR) { require( tx.origin == from || hasRole(ADMIN, tx.origin), "only use myself." ); require(amt[from] >= value, "not enough AMT."); amt[from] -= value; emit UsedAMT(from, action, value); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; interface IAMTManager { function amt(address user) external view returns (uint256); function add(address to, uint256 value) external; function use(address from, uint256 value, string calldata action) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "./NFT.sol"; library EnumerableTokenSet { using NFT for NFT.TokenStruct; struct Set { NFT.TokenStruct[] _values; mapping(string => uint256) _indexes; } function add(Set storage set, NFT.TokenStruct memory token) internal returns (bool) { if (!contains(set, token)) { set._values.push(token); set._indexes[token.createKey()] = set._values.length; return true; } else { return false; } } function update(Set storage set, NFT.TokenStruct memory token) internal returns (bool) { if (contains(set, token)) { uint256 idx = set._indexes[token.createKey()]; set._values[idx - 1] = token; return true; } else { return false; } } function remove(Set storage set, NFT.TokenStruct memory token) internal returns (bool) { string memory deleteKey = token.createKey(); uint256 valueIndex = set._indexes[deleteKey]; if (valueIndex != 0) { uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { NFT.TokenStruct storage lastValue = set._values[lastIndex]; set._values[toDeleteIndex] = lastValue; set._indexes[lastValue.createKey()] = valueIndex; } set._values.pop(); delete set._indexes[deleteKey]; return true; } else { return false; } } function contains(Set storage set, NFT.TokenStruct memory token) internal view returns (bool) { return set._indexes[token.createKey()] != 0; } function length(Set storage set) internal view returns (uint256) { return set._values.length; } function at(Set storage set, uint256 index) internal view returns (NFT.TokenStruct memory) { return set._values[index]; } function values(Set storage set) internal view returns (NFT.TokenStruct[] memory) { return set._values; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "@openzeppelin/contracts/utils/Strings.sol"; library NFT { struct TokenStruct { address collectionAddress; uint256 tokenId; } function createKey(TokenStruct memory token) internal pure returns (string memory) { return string( abi.encodePacked( Strings.toHexString(token.collectionAddress), "-", token.tokenId ) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.15; library TimestampStorage { struct Storage { mapping(uint256 => uint256) _data; } uint256 private constant BIT_MASK = 0xFFFFFFFFFF; uint256 private constant BIT_SIZE = 40; uint256 private constant MAX_SIZE = 6; function get( Storage storage s, uint256 index ) internal view returns (uint256) { uint256 bucket = index % MAX_SIZE; return (s._data[bucket] >> ((BIT_SIZE * index) / MAX_SIZE)) & BIT_MASK; } function set(Storage storage s, uint256 index, uint40 timestamp) internal { uint256 bucket = index % MAX_SIZE; uint256 maskdata = s._data[bucket] & ~(BIT_MASK << ((BIT_SIZE * index) / MAX_SIZE)); uint256 setdata = (timestamp & BIT_MASK) << ((BIT_SIZE * index) / MAX_SIZE); s._data[bucket] = maskdata | setdata; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../libs/NFT.sol"; interface ITMAsLocker { function lock(NFT.TokenStruct[] memory tokens) external; function unlock(NFT.TokenStruct[] memory tokens) external; function isLocked(address collectionAddress, uint256 tokenId) external view returns (bool); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "./ITMAsLocker.sol"; abstract contract StakingCollection { ITMAsLocker public locker; modifier whenNotStaking(uint256 tokenId) { require( isLocked(tokenId) == false, "The token is loked now." ); _; } function isLocked(uint256 tokenId) public virtual view returns(bool) { return address(locker) != address(0) && locker.isLocked(address(this), tokenId) == true; } function _setLocker(address value) internal virtual { locker = ITMAsLocker(value); } function setLocker(address value) virtual external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "./ITMAsLocker.sol"; import "../libs/NFT.sol"; import "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; contract TMAsLocker is ITMAsLocker, AccessControl { using BitMaps for BitMaps.BitMap; using NFT for NFT.TokenStruct; bytes32 public constant ADMIN = "ADMIN"; bytes32 public constant LOCK_OPERATOR = "LOCK_OPERATOR"; constructor() { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _setRoleAdmin(ADMIN, DEFAULT_ADMIN_ROLE); _setRoleAdmin(LOCK_OPERATOR, ADMIN); _grantRole(ADMIN, msg.sender); } // ================================================== // For Lock status // ================================================== // collectionAddress => lock status mapping(address => BitMaps.BitMap) private _isLocked; function lock( NFT.TokenStruct[] memory tokens ) external onlyRole(LOCK_OPERATOR) { require(tokens.length > 0, "tokens length must be over 1."); for (uint256 i = 0; i < tokens.length; i++) { require( _isLocked[tokens[i].collectionAddress].get(tokens[i].tokenId) == false, "the token is already locked." ); require( IERC721(tokens[i].collectionAddress).ownerOf( tokens[i].tokenId ) == tx.origin, "you are not holder." ); } for (uint256 i = 0; i < tokens.length; i++) { _isLocked[tokens[i].collectionAddress].set(tokens[i].tokenId); } } function unlock( NFT.TokenStruct[] memory tokens ) external onlyRole(LOCK_OPERATOR) { require(tokens.length > 0, "tokens length must be over 1."); for (uint256 i = 0; i < tokens.length; i++) { require( IERC721(tokens[i].collectionAddress).ownerOf( tokens[i].tokenId ) == tx.origin || hasRole(ADMIN, tx.origin), "you are not holder." ); } for (uint256 i = 0; i < tokens.length; i++) { _isLocked[tokens[i].collectionAddress].unset(tokens[i].tokenId); } } function isLocked( address collectionAddress, uint256 tokenId ) external view returns (bool) { return _isLocked[collectionAddress].get(tokenId); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../Locker/StakingCollection.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract MockTMA is ERC721, Ownable, StakingCollection { constructor() ERC721("TMAs", "TMAs") {} uint256 public totalSupply = 0; mapping(uint256 => uint256) public power; function mint(uint256 amount) external { for (uint256 i = 0; i < amount; i++) { _mint(msg.sender, totalSupply + i + 1); } totalSupply += amount; } function setLocker(address value) external override onlyOwner { _setLocker(value); } // For Lock function transferFrom( address from, address to, uint256 tokenId ) public virtual override whenNotStaking(tokenId) { super.transferFrom(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override whenNotStaking(tokenId) { super.safeTransferFrom(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override whenNotStaking(tokenId) { super.safeTransferFrom(from, to, tokenId, data); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../Locker/StakingCollection.sol"; import "../RegularMission/HasPower.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract MockTMAs is ERC721, Ownable, StakingCollection, HasPower { constructor() ERC721("TMAs", "TMAs") {} uint256 public totalSupply = 0; mapping(uint256 => uint256) public power; function mint(uint256 amount) external { for (uint256 i = 0; i < amount; i++) { _mint(msg.sender, totalSupply + i + 1); } totalSupply += amount; } function setLocker(address value) external override onlyOwner { _setLocker(value); } function setPower(uint256 tokenId, uint256 value) external { power[tokenId] = value; } // For Lock function transferFrom( address from, address to, uint256 tokenId ) public virtual override whenNotStaking(tokenId) { super.transferFrom(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override whenNotStaking(tokenId) { super.safeTransferFrom(from, to, tokenId); } function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override whenNotStaking(tokenId) { super.safeTransferFrom(from, to, tokenId, data); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../libs/TimestampStorage.sol"; contract TimestampStorageTest { using TimestampStorage for TimestampStorage.Storage; TimestampStorage.Storage private ts; function set(uint256 index, uint40 timestamp) external { ts.set(index, timestamp); } function get(uint256 index) external view returns(uint256) { return ts.get(index); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "../Locker/ITMAsLocker.sol"; import "../libs/NFT.sol"; import "@openzeppelin/contracts/utils/structs/BitMaps.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; contract TMAsProtector is AccessControl { using BitMaps for BitMaps.BitMap; using EnumerableSet for EnumerableSet.AddressSet; using NFT for NFT.TokenStruct; bytes32 public constant ADMIN = "ADMIN"; ITMAsLocker public locker; EnumerableSet.AddressSet private _allowedCollections; constructor() { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _setRoleAdmin(ADMIN, DEFAULT_ADMIN_ROLE); _grantRole(ADMIN, msg.sender); } /** @dev ステーキング中のトークンをProtectorからアンロックしてしまわないようにここでも状態管理する */ // collectionAddress => lock status mapping(address => BitMaps.BitMap) private _isLocked; function lock(NFT.TokenStruct[] memory tokens) external { require(tokens.length > 0, "tokens length must be over 1."); locker.lock(tokens); for (uint256 i = 0; i < tokens.length; i++) { require( _allowedCollections.contains(tokens[i].collectionAddress), "no supported collection." ); _isLocked[tokens[i].collectionAddress].set(tokens[i].tokenId); } } function unlock(NFT.TokenStruct[] memory tokens) external { // Assuming that the Locker guarantees that only the holder or ADMIN can operate it. require(tokens.length > 0, "tokens length must be over 1."); for (uint256 i = 0; i < tokens.length; i++) { require( _isLocked[tokens[i].collectionAddress].get(tokens[i].tokenId) == true, "the token is not protected." ); } locker.unlock(tokens); } function isProtected( address collectionAddress, uint256 tokenId ) external view returns (bool) { return _isLocked[collectionAddress].get(tokenId); } function setLocker(address value) external onlyRole(ADMIN) { locker = ITMAsLocker(value); } function addAllowedCollection( address[] calldata addresses ) external onlyRole(ADMIN) { for (uint256 i = 0; i < addresses.length; i++) { _allowedCollections.add(addresses[i]); } } function removeAllowedCollection( address[] calldata addresses ) external onlyRole(ADMIN) { for (uint256 i = 0; i < addresses.length; i++) { _allowedCollections.remove(addresses[i]); } } function getAllowedCollection() external view returns (address[] memory) { return _allowedCollections.values(); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; interface HasPower { function power(uint256 tokenId) external view returns(uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "./IRewarder.sol"; import "../AMTManager/IAMTManager.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; contract AMTRewarder is IRewarder, AccessControl { bytes32 public constant ADMIN = "ADMIN"; bytes32 public constant OPERATOR = "OPERATOR"; constructor() { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _setRoleAdmin(ADMIN, DEFAULT_ADMIN_ROLE); _setRoleAdmin(OPERATOR, ADMIN); _grantRole(ADMIN, msg.sender); } IAMTManager public amtManager; function reward(address to, uint256 amount) external onlyRole(OPERATOR) { amtManager.add(to, amount); } function setAmtManager(address value) external onlyRole(ADMIN) { amtManager = IAMTManager(value); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; interface IRewarder { function reward(address to, uint256 amount) external; }
{ "optimizer": { "enabled": true, "runs": 50 }, "viaIR": true, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"troopId","type":"uint256"},{"indexed":false,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"AddedTokenToTroop","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"troopId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"missionIed","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isSuccess","type":"bool"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"MissionResult","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"troopId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"missionId","type":"uint256"}],"name":"StartMission","type":"event"},{"inputs":[],"name":"ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_TROOP_NUM","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"addAllowedCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"troopId","type":"uint256"},{"components":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT.TokenStruct[]","name":"tokens","type":"tuple[]"}],"name":"addTokenToTroop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addTroop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addTroopCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amtManager","outputs":[{"internalType":"contract IAMTManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonusUnit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"currentMission","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"troopId","type":"uint256"}],"name":"endMission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"troopId","type":"uint256"}],"name":"evaluate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAllowedCollection","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getMaxTroopNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"troopId","type":"uint256"}],"name":"getMissionNumAndStartTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"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":"address","name":"user","type":"address"},{"internalType":"uint256","name":"troopId","type":"uint256"}],"name":"getTroopMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getTroopsInMission","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":"missionId","type":"uint256"}],"name":"isMissionPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"locker","outputs":[{"internalType":"contract ITMAsLocker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBonus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMemberPerTroop","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTroopNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"missions","outputs":[{"internalType":"uint128","name":"term","type":"uint128"},{"internalType":"uint64","name":"reward","type":"uint64"},{"internalType":"uint64","name":"successRate","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"missionIds","type":"uint256[]"}],"name":"pauseMission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"powerEffect","outputs":[{"internalType":"uint128","name":"powerUnit","type":"uint128"},{"internalType":"uint128","name":"reductionUnit","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"removeAllowedCollection","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":"address","name":"user","type":"address"},{"internalType":"uint256","name":"troopId","type":"uint256"}],"name":"resetForEmergency","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":[],"name":"rewardForFailure","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewarder","outputs":[{"internalType":"contract IRewarder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setAddTroopCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setAmtManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setBonusUnit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setLocker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setMaxBonus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setMaxMemberPerTroop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setMaxTroopNum","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"missionId","type":"uint256"},{"components":[{"internalType":"uint128","name":"term","type":"uint128"},{"internalType":"uint64","name":"reward","type":"uint64"},{"internalType":"uint64","name":"successRate","type":"uint64"}],"internalType":"struct RegularMission.Mission","name":"mission","type":"tuple"}],"name":"setMission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint128","name":"powerUnit","type":"uint128"},{"internalType":"uint128","name":"reductionUnit","type":"uint128"}],"internalType":"struct RegularMission.PowerEffectUnit","name":"value","type":"tuple"}],"name":"setPowerEffect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setRewardForFailure","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setRewarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setTMA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setTMAPower","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setTMAs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setTMAsMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"missionId","type":"uint256"},{"internalType":"uint256","name":"troopId","type":"uint256"},{"components":[{"internalType":"address","name":"collectionAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NFT.TokenStruct[]","name":"tokens","type":"tuple[]"}],"name":"startMission","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":[],"name":"tma","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tmaPower","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tmas","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tmasMetadata","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"missionIds","type":"uint256[]"}],"name":"unpauseMission","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080346200018f5760056004818155908055600260115560125560326013556001601455610bb86016553360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb560209081526040808320549293909260ff161562000157575b6420a226a4a760d91b8085528483528385206001018054908690558590827fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff8380a4838520338652835260ff8486205416156200011d575b508083016001600160401b0381118282101762000109578352603281526101f49101527101f40000000000000000000000000000003260155551612e70915081620001958239f35b634e487b7160e01b85526041600452602485fd5b8085528483528385203386528352838520600160ff1982541617905533903390600080516020620030058339815191528780a438620000c1565b8380528382528284203385528252828420600160ff19825416179055333385600080516020620030058339815191528180a462000069565b600080fdfe6102a06040908082526004918236101561001857600080fd5b600092833560e01c92836301c4ab72146117565750826301ffc9a7146116ff578263026279c5146116e05782630b2c0a94146115bd57826314d6704914611594578263171060ec1461154f57826318cc62c3146114af5782631e5815b91461146c5782631e9069d31461143b5782631ed7724c1461141957826323cc56b4146113fa578263248a9ca3146113cf5782632a0acc6a146113ac5782632ac0d8f5146113835782632c8fe526146113365782632f2ff15d1461128c57826336568abe146111fb57826337143233146111dd57826337ede9f61461116b5782633a6462e4146111265782633e6824e51461101b5782633eed0b1414610ff95782635401178a14610f4b57826354c5b69614610f2c578263601e477414610ee757826360f7a4f614610e79578263683c817814610e46578263721de0b614610e275782637666f10014610e0557826379368cf614610d875782637b8c40a214610d655782637bd770b114610b545782638b1c339b14610b0f5782638e3655a914610ae657826391d1485414610aa057826395c37d4d14610a5f57826397eb494c14610a405782639a56330314610a1e578263a217fddf14610a03578263a51c485b146109bb578263a56becb214610999578263a81562a414610970578263abc383ce146107d8578263b0016fa3146107b6578263c5cff11014610689578263caab78be14610616578263ccf21c901461058f578263d3aca9c71461041b578263d547741f146103da57508163d77bd5f7146103bb578163d7b96d4e14610392578163da76865d14610365578163dcc3e06e1461033c578163e4d6d4c3146102f7578163f9f3e9ad146102d7575063fd2a7b271461029057600080fd5b346102d45760203660031901126102d4576102a9611772565b6102b1611883565b600980546001600160a01b0319166001600160a01b039290921691909117905580f35b80fd5b9050346102f357816003193601126102f3576020905160038152f35b5080fd5b82346102d45760203660031901126102d457610311611772565b610319611883565b600d80546001600160a01b0319166001600160a01b039290921691909117905580f35b9050346102f357816003193601126102f357600c5490516001600160a01b039091168152602090f35b9050346102f35760203660031901126102f35760209061038b610386611772565b611e2a565b9051908152f35b9050346102f357816003193601126102f357600b5490516001600160a01b039091168152602090f35b9050346102f357816003193601126102f3576020906005549051908152f35b915034610417578060031936011261041757610414913561040f60016103fe611788565b938387528660205286200154611a9d565b611c4b565b80f35b8280fd5b90915034610417578160031936011261041757610436611772565b602435926001600160a01b03909116913383148015610568575b156105295750818452602092601084528185208186528452848281205582855260019384815282862082875281528483872094855461048e81611e50565b9661049b87519889611c2a565b8188528952838920899085808a015b84841061050457505050505087915b6104c1578780f35b8551821015610500576104fa8792828a52838552868a20868b5285526104f4878b206104ed838b611ea8565b5190612c78565b50611e99565b916104b9565b8780f35b90600291610516849596979894612c51565b815201920192019091858a9594936104aa565b6020606492519162461bcd60e51b8352820152601a6024820152793cb7ba9030b932903737ba103ab9b2b91037b91030b236b4b71760311b6044820152fd5b506420a226a4a760d91b8552846020528185208360005260205260ff826000205416610450565b909150346104175760209081600319360112610612578035906001600160401b03821161060e576105c291369101611853565b6105cd939193611883565b845b8181106105da578580f35b806105e96106099284886129e1565b358060081c8852600f8652600160ff868a2092161b198154169055611e99565b6105cf565b8480fd5b8380fd5b8390346102f35760203660031901126102f3578035906001600160401b0382116104175761064691369101611853565b9061064f611883565b825b82811061065c578380f35b610684906104f46001600160a01b0361067e6106798488886129e1565b611fa0565b16612a8b565b610651565b9150346104175760803660031901126104175781356060366023190112610612576106b2611883565b8015610773576001600160801b0392836106ca6129cb565b161561073457508352600e6020528220906106e36129cb565b16604435906001600160401b03808316830361072f57606435908116810361072f5760809290921b67ffffffffffffffff60801b161760c09190911b6001600160c01b03191617905580f35b600080fd5b606490602084519162461bcd60e51b835282015260196024820152783a32b9369036bab9ba1031329037bb32b9103a3430b710181760391b6044820152fd5b815162461bcd60e51b8152602081850152601e60248201527f6d697373696f6e4964206d757374206265206f766572207468616e20302e00006044820152606490fd5b8390346102f35760203660031901126102f3576107d1611883565b3560135580f35b9091503461041757606036600319011261041757803591602435916044356001600160401b03811161096c576108119036908301611823565b858752600e6020908152848820549194929390916001600160801b031615610936576108568760ff6001918060081c600052600f602052161b60406000205416151590565b6108fc57338852601082528288208689528252828820546108bb575061089393929186913389526010815281892090878a52528720558333611fb4565b337fdef5703ca13a253124b6220f97948346540b87ad01ef24b8e064d5f1f74c56038480a480f35b915162461bcd60e51b815291820152601f60248201527f7468652074726f6f7020616c7265616420676f20746f206d697373696f6e2e006044820152606490fd5b915162461bcd60e51b81529182015260166024820152753a34329036b4b9b9b4b7b71034b9903830bab9b2b21760511b6044820152606490fd5b915162461bcd60e51b815291820152601260248201527134b73b30b634b21036b4b9b9b4b7b724b21760711b6044820152606490fd5b8580fd5b8382346102f357816003193601126102f35760085490516001600160a01b039091168152602090f35b8390346102f35760203660031901126102f3576109b4611883565b8035905580f35b915034610417573660031901126102f3576109d4611883565b356001600160801b0381169081900361072f576001600160801b03196109f86129cb565b60801b161760155580f35b8382346102f357816003193601126102f35751908152602090f35b8390346102f35760203660031901126102f357610a39611883565b3560055580f35b8382346102f357816003193601126102f3576020906014549051908152f35b8382346102f357806003193601126102f35760209181906001600160a01b03610a86611772565b168152601084528181206024358252845220549051908152f35b9091503461041757816003193601126104175781602093610abf611788565b92358152808552209060018060a01b0316600052825260ff81600020541690519015158152f35b8382346102f357816003193601126102f357600d5490516001600160a01b039091168152602090f35b83346102d45760203660031901126102d457610b29611772565b610b31611883565b600a80546001600160a01b0319166001600160a01b039290921691909117905580f35b90915034610417578160031936011261041757610b6f611772565b9160243560018060a01b039283600b54169484811694858852600196886020948986528782208783528652878220938454610ba981611e50565b95610bb68b519788611c2a565b818752888701908195528d8d8a822091925b8b858510610d4957505050505050833b15610d45578b94939291895194630ed7afff60e11b86528860248701928701525180915260448501929186905b8d8a8d858510610d1c57505050505050508391838381809403925af18015610d125790859291610cf7575b5050610c3b91612419565b8386526010815282862082875281528583812055838652848152828620828752815284838720948554610c6d81611e50565b96610c7a87519889611c2a565b8188528952838920899085808a015b848410610cd257505050505087915b610ca0578780f35b855182101561050057610ccc8792828a52838552868a20868b5285526104f4878b206104ed838b611ea8565b91610c98565b90600291610ce4849596979894612c51565b815201920192019091858a959493610c89565b610d02919250611bcb565b610d0e57828738610c30565b8680fd5b86513d84823e3d90fd5b9193959798995091939582885186815116835201518382015201950192018d9695949391610c05565b8b80fd5b600291610d5585612c51565b8152019201920191908e90610bc8565b8390346102f35760203660031901126102f357610d80611883565b3560145580f35b909150346104175760209081600319360112610612578035906001600160401b03821161060e57610dba91369101611853565b610dc5939193611883565b845b818110610dd2578580f35b80610de1610e009284886129e1565b358060081c8852600f8652600160ff868a2092161b8154179055611e99565b610dc7565b8390346102f35760203660031901126102f357610e20611883565b3560115580f35b9091503461041757826003193601126104175760209250549051908152f35b5082346102d457816003193601126102d45750610e6d610e64611772565b60243590611edc565b82519182526020820152f35b8390346102f35760203660031901126102f3578035906001600160401b03821161041757610ea991369101611853565b90610eb2611883565b825b828110610ebf578380f35b610ee2906104f46001600160a01b03610edc6106798488886129e1565b16612a0c565b610eb4565b83346102d45760203660031901126102d457610f01611772565b610f09611883565b600880546001600160a01b0319166001600160a01b039290921691909117905580f35b8382346102f357816003193601126102f3576020906012549051908152f35b8390346102f357826003193601126102f3578035906024356001600160401b03811161061257610f7e9036908301611823565b92909133855260106020528585208286526020528585205415610fa8575061041493945033611fb4565b608490602087519162461bcd60e51b8352820152602560248201527f7468652074726f6f70206973206e6f742073746172746564206d697373696f6e604482015264103cb2ba1760d91b6064820152fd5b8390346102f35760203660031901126102f357611014611883565b3560125580f35b91503461041757826003193601126104175761103633611e2a565b9180548310156110ef57600d5460165485916001600160a01b0316803b156104175760a48392865194859384926307030cd160e51b84523389850152602484015260606044840152600960648401526806164642074726f6f760bc1b60848401525af180156110e5576110d2575b50600183018093116110bf5750338352600360205282205580f35b634e487b7160e01b845260119052602483fd5b6110de90949194611bcb565b92386110a4565b83513d87823e3d90fd5b6020606492519162461bcd60e51b8352820152601260248201527130b63932b0b23c9036b0bc103a3937b7b81760711b6044820152fd5b83346102d45760203660031901126102d457611140611772565b611148611883565b600c80546001600160a01b0319166001600160a01b039290921691909117905580f35b8382346102f357816003193601126102f3578051908180936006549081855260208095019160068252858220915b868282106111c65785906111c2886111b384890385611c2a565b519282849384528301906117b2565b0390f35b835485528895509093019260019283019201611199565b8390346102f35760203660031901126102f357610414903533612419565b8390346102f357826003193601126102f357611215611788565b90336001600160a01b0383160361123157906104149135611c4b565b608490602085519162461bcd60e51b8352820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152fd5b9091503461041757816003193601126104175735906112a9611788565b90828452836020526112c060018286200154611a9d565b82845260208481528185206001600160a01b039093168086529290528084205460ff16156112ec578380f35b828452836020528084208285526020528320600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a43880808380f35b90915034610417576020366003190112610417576060928291358152600e60205220549080519160018060801b03811683526001600160401b038160801c16602084015260c01c90820152f35b8382346102f357816003193601126102f357600a5490516001600160a01b039091168152602090f35b8382346102f357816003193601126102f357516420a226a4a760d91b8152602090f35b9091503461041757602036600319011261041757816020936001923581528085522001549051908152f35b8382346102f357816003193601126102f3576020906011549051908152f35b8390346102f35760203660031901126102f357611434611883565b3560165580f35b5082346102d457806003193601126102d4575060155481516001600160801b038216815260809190911c6020820152f35b9083346102d45760203660031901126102d457506114a66020923560ff6001918060081c600052600f602052161b60406000205416151590565b90519015158152f35b8382346102f3576020806003193601126104175782906114cd611772565b926114d784611e2a565b926114e184611e67565b60019590949082906001600160a01b0316875b83811115611511578488528551878152806111c2818a018b6117ef565b6115309082845289885286842081855288528684205461153557611e99565b6114f4565b8061154961154288611e99565b978b611ea8565b52611e99565b83346102d45760203660031901126102d457611569611772565b611571611883565b600b80546001600160a01b0319166001600160a01b039290921691909117905580f35b8382346102f357816003193601126102f35760095490516001600160a01b039091168152602090f35b8382346102f357806003193601126102f3576001600160a01b03806115e0611772565b1683526001926020918483528382206024358352835283822094855461160581611e50565b9661161287519889611c2a565b8188528452848420849086808a015b8484106116c25750505050505084519061163a82611e50565b9561164786519788611c2a565b828752601f1961165684611e50565b01368689013761166583611e67565b935b838110611692578651878152806111c28888611685848d018e6117b2565b91848303908501526117ef565b80866116a16116bd9385611ea8565b51858151166116b0848d611ea8565b5201516115498288611ea8565b611667565b85916002916116d085612c51565b8152019201920191908790611621565b8382346102f357816003193601126102f3576020906013549051908152f35b9091503461041757602036600319011261041757359063ffffffff60e01b82168092036104175760209250637965db0b60e01b8214918215611745575b50519015158152f35b6301ffc9a760e01b1491503861173c565b8490346102f357816003193601126102f3576020906016548152f35b600435906001600160a01b038216820361072f57565b602435906001600160a01b038216820361072f57565b35906001600160a01b038216820361072f57565b90815180825260208080930193019160005b8281106117d2575050505090565b83516001600160a01b0316855293810193928101926001016117c4565b90815180825260208080930193019160005b82811061180f575050505090565b835185529381019392810192600101611801565b9181601f8401121561072f578235916001600160401b03831161072f576020808501948460061b01011161072f57565b9181601f8401121561072f578235916001600160401b03831161072f576020808501948460051b01011161072f57565b3360009081527fff164f808567eb9100129b1d5aead1611f532533c7a4cedced7e7f0a6271f5316020908152604080832054909291906420a226a4a760d91b9060ff16156118d15750505050565b6118da33611d1c565b908451906118e782611c0f565b60428252838201946060368737825115611a895760308653825190600191821015611a895790607860218501536041915b818311611a1b575050506119d957846119a760486119cb9360449798519889916119988984019876020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8a5261196f815180928d603789019101611ba8565b8401917001034b99036b4b9b9b4b733903937b6329607d1b603784015251809386840190611ba8565b01036028810189520187611c2a565b5194859362461bcd60e51b8552600485015251809281602486015285850190611ba8565b601f01601f19168101030190fd5b60648386519062461bcd60e51b825280600483015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b909192600f81166010811015611a75576f181899199a1a9b1b9c1cb0b131b232b360811b901a611a4b8587611cf5565b5360041c928015611a6157600019019190611918565b634e487b7160e01b82526011600452602482fd5b634e487b7160e01b83526032600452602483fd5b634e487b7160e01b81526032600452602490fd5b60008181526020818152604092838320338452825260ff848420541615611ac45750505050565b611acd33611d1c565b90845190611ada82611c0f565b60428252838201946060368737825115611a895760308653825190600191821015611a895790607860218501536041915b818311611b62575050506119d957846119a760486119cb9360449798519889916119988984019876020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8a5261196f815180928d603789019101611ba8565b909192600f81166010811015611a75576f181899199a1a9b1b9c1cb0b131b232b360811b901a611b928587611cf5565b5360041c928015611a6157600019019190611b0b565b60005b838110611bbb5750506000910152565b8181015183820152602001611bab565b6001600160401b038111611bde57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117611bde57604052565b608081019081106001600160401b03821117611bde57604052565b90601f801991011681019081106001600160401b03821117611bde57604052565b9060009180835282602052604083209160018060a01b03169182845260205260ff604084205416611c7b57505050565b80835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4565b81810292918115918404141715611cd257565b634e487b7160e01b600052601160045260246000fd5b91908201809211611cd257565b908151811015611d06570160200190565b634e487b7160e01b600052603260045260246000fd5b60405190606082018281106001600160401b03821117611bde57604052602a8252602082016040368237825115611d0657603090538151600190811015611d0657607860218401536029905b808211611dbc575050611d785790565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b9091600f81166010811015611e15576f181899199a1a9b1b9c1cb0b131b232b360811b901a611deb8486611cf5565b5360041c918015611e00576000190190611d68565b60246000634e487b7160e01b81526011600452fd5b60246000634e487b7160e01b81526032600452fd5b6001600160a01b031660009081526003602052604090205480611e4d5750600390565b90565b6001600160401b038111611bde5760051b60200190565b90611e7182611e50565b611e7e6040519182611c2a565b8281528092611e8f601f1991611e50565b0190602036910137565b6000198114611cd25760010190565b8051821015611d065760209160051b010190565b8115611ec6570490565b634e487b7160e01b600052601260045260246000fd5b6001600160a01b03166000818152600160209081526040808320858452825280832054939594929390929015611f8657858452600282528284208185528252828420848052825282842054958452601082528284209084528152818320548352600e905281205464ffffffffff909316926001600160801b0316904284810391908211611f72575090611f6e91611ebc565b9190565b634e487b7160e01b81526011600452602490fd5b5050508092509190565b9190811015611d065760061b0190565b356001600160a01b038116810361072f5790565b9160009260018060a01b038116845260016020526040842083855260205260408420549085156123d4576001841015806123c2575b1561238a57611ff88683611ce8565b6005541061234857845b8681106121fe5750600b546001600160a01b0316803b1561096c578560405180926303b37c4760e41b8252602060048301528960248301526044820187845b8c81106121c35750508383809203925af180156121b8576121a5575b50845b8681106120705750505050505050565b6001600160a01b038216865260016020908152604080882087895290915286209061209c818987611f90565b916040833603126121a1576040518060408101106001600160401b03604083011117611bde577f79c4752fee93ffd06996e78922a45fe429500cd5e201710ac5231e59b5cb7198612194602061216d866121668f968f8f998f8f8f9061219c9f88958f8f969461212e8a8f9761216198604097886106799f0189526121208161179e565b845201356020830152612bb7565b506001600160a01b0316825260028d528282209082528c52204264ffffffffff169161215b908790611ce8565b90612df0565b611f90565b958c611f90565b604080516001600160a01b0396871681529190920135602082015293881693918291820190565b0390a3611e99565b612060565b8780fd5b6121b190959195611bcb565b933861205d565b6040513d88823e3d90fd5b929450925060019060409081906001600160a01b036121e18761179e565b168152602086013560208201520193019101918993918593612041565b6001600160a01b03612214610679838a88611f90565b168652600760205260408620541561230857600181018082116122f4575b878110612248575061224390611e99565b612002565b612256610679838a88611f90565b6001600160a01b0361226c610679848c8a611f90565b6001600160a01b039092169116148015906122ce575b156122955761229090611e99565b612232565b60405162461bcd60e51b8152602060048201526011602482015270323ab8383634b1b0ba32903a37b5b2b71760791b6044820152606490fd5b5060206122dc838a88611f90565b013560206122eb838b89611f90565b01351415612282565b634e487b7160e01b87526011600452602487fd5b60405162461bcd60e51b815260206004820152601860248201527737379039bab83837b93a32b21031b7b63632b1ba34b7b71760411b6044820152606490fd5b60405162461bcd60e51b815260206004820152601a60248201527937bb32b91036b0bc10373ab6b132b9103832b9103a3937b7b81760311b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b2103a3937b7b824b21760811b6044820152606490fd5b506123cc81611e2a565b841115611fe9565b60405162461bcd60e51b815260206004820152601d60248201527f746f6b656e73206c656e677468206d757374206265206f76657220312e0000006044820152606490fd5b906124579180610120528160c05260018060a01b0381166000526001602052604060002082600052602052604060002080608052546101a052611edc565b60a0528061018052156129c95760018060a01b0361012051166000526010602052604060002060c0516000526020526040600020548061016052600052600e60205260406000206040519081610240528160608101106001600160401b03606084011117611bde5760608201604052549060018060801b03821690526001600160401b038160801c16602061024051015260c01c60406102405101526000610140526125056101a051611e67565b6101c0526125156101a051611e67565b610100526009546001600160a01b03166102605260005b6101a05181101561265a5761254381608051612d78565b9060018060a01b0361012051166000526002602052604060002060c05160005260205260406000206006820660005260205260406000205460289081838102048303611cd25760068364ffffffffff9302041c166125a48261010051611ea8565b526102605182516001600160a01b0316146125c9575b6125c49150611e99565b61252c565b60208060018060a01b03600a5416930151602460405180958193630cc193fb60e41b835260048301525afa801561264e5760009061261a575b6125c49250612614826101c051611ea8565b526125ba565b506020823d602011612646575b8161263460209383611c2a565b8101031261072f576125c49151612602565b3d9150612627565b6040513d6000823e3d90fd5b50600060e0526008546001600160a01b03166102805260125461022052601554610200526014546101e0525b6101805160e051101561291457600090816001815b6101a051831015612781576126b283608051612d78565b946126c08461010051611ea8565b5160e05161024051516126e7916126df916001600160801b0316611cbf565b60a051611ce8565b10612774576126f590611e99565b9451610280516001600160a01b03909116908103612739575061272b6127216127329260135490611ce8565b9260115490611cbf565b925b611e99565b919061269b565b610260939192935114612750575b61273290611e99565b9061276c61273291612765846101c051611ea8565b5190611ce8565b919050612747565b9450909161273290611e99565b9091509291926102205180831161290a575b506127d3906127cd6001600160401b03604061024051015116916127c861020051918260801c9260018060801b031690611ebc565b611cbf565b90611ce8565b6127e0836101e051611cbf565b6000612710831061287a57505050612863916127c861280f926001600160401b03602061024051015116611cbf565b60015b6040519015158152816020820152610160519060c051907fae8be22cbaf20807479362a93c939905a5c4316623047c18c83ec5abfcba55e3604060018060a01b03610120511692a461014051611ce8565b6101405261287260e051611e99565b60e052612686565b9193909243600019810111611cd25760405194600019430140602087015260e0516040870152604086528560608101106001600160401b03606088011117611bde576127108660606128639801604052602081519101200611156128e0575b5050612812565b61290193506127c89192506001600160401b03602061024051015116611cbf565b600138806128d9565b91506127d3612793565b64ffffffffff42169060005b60805154811015612965576129609060018060a01b0361012051166000526002602052604060002060c05160005260205261272d84826040600020612df0565b612920565b50600c549091506001600160a01b0316803b1561072f576040516310b3879160e11b815261014051610120516001600160a01b031660048301526024820152906000908290604490829084905af1801561264e576129c05750565b6129c990611bcb565b565b6024356001600160801b038116810361072f5790565b9190811015611d065760051b0190565b600654811015611d0657600660005260206000200190600090565b600081815260076020526040812054612a8657600654600160401b811015612a72579082612a5e612a45846001604096016006556129f1565b819391549060031b600019811b9283911b169119161790565b905560065492815260076020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b6000818152600760205260408120549091908015612b705760001990808201818111612b5c5760065490838201918211612b4857808203612b14575b5050506006548015612b0057810190612adf826129f1565b909182549160031b1b19169055600655815260076020526040812055600190565b634e487b7160e01b84526031600452602484fd5b612b32612b23612a45936129f1565b90549060031b1c9283926129f1565b9055845260076020526040842055388080612ac7565b634e487b7160e01b86526011600452602486fd5b634e487b7160e01b85526011600452602485fd5b505090565b8054821015611d065760005260206000209060011b0190600090565b602090612bab928260405194838680955193849201611ba8565b82019081520301902090565b60018101612bcd81612bc885612d9a565b612b91565b54612c49578154600160401b811015611bde57806001612bf09201845583612b75565b612c3357835181546001600160a01b0319166001600160a01b03919091161781556020840151600190910155905491612c2d9190612bc890612d9a565b55600190565b634e487b7160e01b600052600060045260246000fd5b505050600090565b90604051612c5e81611bf4565b82546001600160a01b031681526001909201546020830152565b90612c8290612d9a565b60018201612c908183612b91565b548015612d6f5760001990808201818111611cd2578554838101908111611cd257818103612d02575b50505083548015612cec570191612cd08385612b75565b939093612c33576000948560018682612c2d9855015555612b91565b634e487b7160e01b600052603160045260246000fd5b612d0f612d179188612b75565b509187612b75565b612c3357612bc8612d358383612d3a95899503612d43575b50612c51565b612d9a565b55388080612cb9565b815481546001600160a01b0319166001600160a01b039190911617815560018281015491015538612d2f565b50505050600090565b611e4d91612d2f9160006020604051612d9081611bf4565b8281520152612b75565b611e4d60416020612db360018060a01b03855116611d1c565b930151926040519381612dd0869351809260208087019101611ba8565b820190602d60f81b60208301526021820152036021810184520182611c2a565b9291909260068406906000928284528160205260408420549186602802966028880403612b5c57600660409596970493865260205264ffffffffff809116831b921b19161791205556fea26469706673582212206c077053b526004545bcabd6e8b4ee1932c1d33d9b60508c0e4b69ebbe86cdfd64736f6c634300081100332f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d
Deployed Bytecode
0x6102a06040908082526004918236101561001857600080fd5b600092833560e01c92836301c4ab72146117565750826301ffc9a7146116ff578263026279c5146116e05782630b2c0a94146115bd57826314d6704914611594578263171060ec1461154f57826318cc62c3146114af5782631e5815b91461146c5782631e9069d31461143b5782631ed7724c1461141957826323cc56b4146113fa578263248a9ca3146113cf5782632a0acc6a146113ac5782632ac0d8f5146113835782632c8fe526146113365782632f2ff15d1461128c57826336568abe146111fb57826337143233146111dd57826337ede9f61461116b5782633a6462e4146111265782633e6824e51461101b5782633eed0b1414610ff95782635401178a14610f4b57826354c5b69614610f2c578263601e477414610ee757826360f7a4f614610e79578263683c817814610e46578263721de0b614610e275782637666f10014610e0557826379368cf614610d875782637b8c40a214610d655782637bd770b114610b545782638b1c339b14610b0f5782638e3655a914610ae657826391d1485414610aa057826395c37d4d14610a5f57826397eb494c14610a405782639a56330314610a1e578263a217fddf14610a03578263a51c485b146109bb578263a56becb214610999578263a81562a414610970578263abc383ce146107d8578263b0016fa3146107b6578263c5cff11014610689578263caab78be14610616578263ccf21c901461058f578263d3aca9c71461041b578263d547741f146103da57508163d77bd5f7146103bb578163d7b96d4e14610392578163da76865d14610365578163dcc3e06e1461033c578163e4d6d4c3146102f7578163f9f3e9ad146102d7575063fd2a7b271461029057600080fd5b346102d45760203660031901126102d4576102a9611772565b6102b1611883565b600980546001600160a01b0319166001600160a01b039290921691909117905580f35b80fd5b9050346102f357816003193601126102f3576020905160038152f35b5080fd5b82346102d45760203660031901126102d457610311611772565b610319611883565b600d80546001600160a01b0319166001600160a01b039290921691909117905580f35b9050346102f357816003193601126102f357600c5490516001600160a01b039091168152602090f35b9050346102f35760203660031901126102f35760209061038b610386611772565b611e2a565b9051908152f35b9050346102f357816003193601126102f357600b5490516001600160a01b039091168152602090f35b9050346102f357816003193601126102f3576020906005549051908152f35b915034610417578060031936011261041757610414913561040f60016103fe611788565b938387528660205286200154611a9d565b611c4b565b80f35b8280fd5b90915034610417578160031936011261041757610436611772565b602435926001600160a01b03909116913383148015610568575b156105295750818452602092601084528185208186528452848281205582855260019384815282862082875281528483872094855461048e81611e50565b9661049b87519889611c2a565b8188528952838920899085808a015b84841061050457505050505087915b6104c1578780f35b8551821015610500576104fa8792828a52838552868a20868b5285526104f4878b206104ed838b611ea8565b5190612c78565b50611e99565b916104b9565b8780f35b90600291610516849596979894612c51565b815201920192019091858a9594936104aa565b6020606492519162461bcd60e51b8352820152601a6024820152793cb7ba9030b932903737ba103ab9b2b91037b91030b236b4b71760311b6044820152fd5b506420a226a4a760d91b8552846020528185208360005260205260ff826000205416610450565b909150346104175760209081600319360112610612578035906001600160401b03821161060e576105c291369101611853565b6105cd939193611883565b845b8181106105da578580f35b806105e96106099284886129e1565b358060081c8852600f8652600160ff868a2092161b198154169055611e99565b6105cf565b8480fd5b8380fd5b8390346102f35760203660031901126102f3578035906001600160401b0382116104175761064691369101611853565b9061064f611883565b825b82811061065c578380f35b610684906104f46001600160a01b0361067e6106798488886129e1565b611fa0565b16612a8b565b610651565b9150346104175760803660031901126104175781356060366023190112610612576106b2611883565b8015610773576001600160801b0392836106ca6129cb565b161561073457508352600e6020528220906106e36129cb565b16604435906001600160401b03808316830361072f57606435908116810361072f5760809290921b67ffffffffffffffff60801b161760c09190911b6001600160c01b03191617905580f35b600080fd5b606490602084519162461bcd60e51b835282015260196024820152783a32b9369036bab9ba1031329037bb32b9103a3430b710181760391b6044820152fd5b815162461bcd60e51b8152602081850152601e60248201527f6d697373696f6e4964206d757374206265206f766572207468616e20302e00006044820152606490fd5b8390346102f35760203660031901126102f3576107d1611883565b3560135580f35b9091503461041757606036600319011261041757803591602435916044356001600160401b03811161096c576108119036908301611823565b858752600e6020908152848820549194929390916001600160801b031615610936576108568760ff6001918060081c600052600f602052161b60406000205416151590565b6108fc57338852601082528288208689528252828820546108bb575061089393929186913389526010815281892090878a52528720558333611fb4565b337fdef5703ca13a253124b6220f97948346540b87ad01ef24b8e064d5f1f74c56038480a480f35b915162461bcd60e51b815291820152601f60248201527f7468652074726f6f7020616c7265616420676f20746f206d697373696f6e2e006044820152606490fd5b915162461bcd60e51b81529182015260166024820152753a34329036b4b9b9b4b7b71034b9903830bab9b2b21760511b6044820152606490fd5b915162461bcd60e51b815291820152601260248201527134b73b30b634b21036b4b9b9b4b7b724b21760711b6044820152606490fd5b8580fd5b8382346102f357816003193601126102f35760085490516001600160a01b039091168152602090f35b8390346102f35760203660031901126102f3576109b4611883565b8035905580f35b915034610417573660031901126102f3576109d4611883565b356001600160801b0381169081900361072f576001600160801b03196109f86129cb565b60801b161760155580f35b8382346102f357816003193601126102f35751908152602090f35b8390346102f35760203660031901126102f357610a39611883565b3560055580f35b8382346102f357816003193601126102f3576020906014549051908152f35b8382346102f357806003193601126102f35760209181906001600160a01b03610a86611772565b168152601084528181206024358252845220549051908152f35b9091503461041757816003193601126104175781602093610abf611788565b92358152808552209060018060a01b0316600052825260ff81600020541690519015158152f35b8382346102f357816003193601126102f357600d5490516001600160a01b039091168152602090f35b83346102d45760203660031901126102d457610b29611772565b610b31611883565b600a80546001600160a01b0319166001600160a01b039290921691909117905580f35b90915034610417578160031936011261041757610b6f611772565b9160243560018060a01b039283600b54169484811694858852600196886020948986528782208783528652878220938454610ba981611e50565b95610bb68b519788611c2a565b818752888701908195528d8d8a822091925b8b858510610d4957505050505050833b15610d45578b94939291895194630ed7afff60e11b86528860248701928701525180915260448501929186905b8d8a8d858510610d1c57505050505050508391838381809403925af18015610d125790859291610cf7575b5050610c3b91612419565b8386526010815282862082875281528583812055838652848152828620828752815284838720948554610c6d81611e50565b96610c7a87519889611c2a565b8188528952838920899085808a015b848410610cd257505050505087915b610ca0578780f35b855182101561050057610ccc8792828a52838552868a20868b5285526104f4878b206104ed838b611ea8565b91610c98565b90600291610ce4849596979894612c51565b815201920192019091858a959493610c89565b610d02919250611bcb565b610d0e57828738610c30565b8680fd5b86513d84823e3d90fd5b9193959798995091939582885186815116835201518382015201950192018d9695949391610c05565b8b80fd5b600291610d5585612c51565b8152019201920191908e90610bc8565b8390346102f35760203660031901126102f357610d80611883565b3560145580f35b909150346104175760209081600319360112610612578035906001600160401b03821161060e57610dba91369101611853565b610dc5939193611883565b845b818110610dd2578580f35b80610de1610e009284886129e1565b358060081c8852600f8652600160ff868a2092161b8154179055611e99565b610dc7565b8390346102f35760203660031901126102f357610e20611883565b3560115580f35b9091503461041757826003193601126104175760209250549051908152f35b5082346102d457816003193601126102d45750610e6d610e64611772565b60243590611edc565b82519182526020820152f35b8390346102f35760203660031901126102f3578035906001600160401b03821161041757610ea991369101611853565b90610eb2611883565b825b828110610ebf578380f35b610ee2906104f46001600160a01b03610edc6106798488886129e1565b16612a0c565b610eb4565b83346102d45760203660031901126102d457610f01611772565b610f09611883565b600880546001600160a01b0319166001600160a01b039290921691909117905580f35b8382346102f357816003193601126102f3576020906012549051908152f35b8390346102f357826003193601126102f3578035906024356001600160401b03811161061257610f7e9036908301611823565b92909133855260106020528585208286526020528585205415610fa8575061041493945033611fb4565b608490602087519162461bcd60e51b8352820152602560248201527f7468652074726f6f70206973206e6f742073746172746564206d697373696f6e604482015264103cb2ba1760d91b6064820152fd5b8390346102f35760203660031901126102f357611014611883565b3560125580f35b91503461041757826003193601126104175761103633611e2a565b9180548310156110ef57600d5460165485916001600160a01b0316803b156104175760a48392865194859384926307030cd160e51b84523389850152602484015260606044840152600960648401526806164642074726f6f760bc1b60848401525af180156110e5576110d2575b50600183018093116110bf5750338352600360205282205580f35b634e487b7160e01b845260119052602483fd5b6110de90949194611bcb565b92386110a4565b83513d87823e3d90fd5b6020606492519162461bcd60e51b8352820152601260248201527130b63932b0b23c9036b0bc103a3937b7b81760711b6044820152fd5b83346102d45760203660031901126102d457611140611772565b611148611883565b600c80546001600160a01b0319166001600160a01b039290921691909117905580f35b8382346102f357816003193601126102f3578051908180936006549081855260208095019160068252858220915b868282106111c65785906111c2886111b384890385611c2a565b519282849384528301906117b2565b0390f35b835485528895509093019260019283019201611199565b8390346102f35760203660031901126102f357610414903533612419565b8390346102f357826003193601126102f357611215611788565b90336001600160a01b0383160361123157906104149135611c4b565b608490602085519162461bcd60e51b8352820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152fd5b9091503461041757816003193601126104175735906112a9611788565b90828452836020526112c060018286200154611a9d565b82845260208481528185206001600160a01b039093168086529290528084205460ff16156112ec578380f35b828452836020528084208285526020528320600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a43880808380f35b90915034610417576020366003190112610417576060928291358152600e60205220549080519160018060801b03811683526001600160401b038160801c16602084015260c01c90820152f35b8382346102f357816003193601126102f357600a5490516001600160a01b039091168152602090f35b8382346102f357816003193601126102f357516420a226a4a760d91b8152602090f35b9091503461041757602036600319011261041757816020936001923581528085522001549051908152f35b8382346102f357816003193601126102f3576020906011549051908152f35b8390346102f35760203660031901126102f357611434611883565b3560165580f35b5082346102d457806003193601126102d4575060155481516001600160801b038216815260809190911c6020820152f35b9083346102d45760203660031901126102d457506114a66020923560ff6001918060081c600052600f602052161b60406000205416151590565b90519015158152f35b8382346102f3576020806003193601126104175782906114cd611772565b926114d784611e2a565b926114e184611e67565b60019590949082906001600160a01b0316875b83811115611511578488528551878152806111c2818a018b6117ef565b6115309082845289885286842081855288528684205461153557611e99565b6114f4565b8061154961154288611e99565b978b611ea8565b52611e99565b83346102d45760203660031901126102d457611569611772565b611571611883565b600b80546001600160a01b0319166001600160a01b039290921691909117905580f35b8382346102f357816003193601126102f35760095490516001600160a01b039091168152602090f35b8382346102f357806003193601126102f3576001600160a01b03806115e0611772565b1683526001926020918483528382206024358352835283822094855461160581611e50565b9661161287519889611c2a565b8188528452848420849086808a015b8484106116c25750505050505084519061163a82611e50565b9561164786519788611c2a565b828752601f1961165684611e50565b01368689013761166583611e67565b935b838110611692578651878152806111c28888611685848d018e6117b2565b91848303908501526117ef565b80866116a16116bd9385611ea8565b51858151166116b0848d611ea8565b5201516115498288611ea8565b611667565b85916002916116d085612c51565b8152019201920191908790611621565b8382346102f357816003193601126102f3576020906013549051908152f35b9091503461041757602036600319011261041757359063ffffffff60e01b82168092036104175760209250637965db0b60e01b8214918215611745575b50519015158152f35b6301ffc9a760e01b1491503861173c565b8490346102f357816003193601126102f3576020906016548152f35b600435906001600160a01b038216820361072f57565b602435906001600160a01b038216820361072f57565b35906001600160a01b038216820361072f57565b90815180825260208080930193019160005b8281106117d2575050505090565b83516001600160a01b0316855293810193928101926001016117c4565b90815180825260208080930193019160005b82811061180f575050505090565b835185529381019392810192600101611801565b9181601f8401121561072f578235916001600160401b03831161072f576020808501948460061b01011161072f57565b9181601f8401121561072f578235916001600160401b03831161072f576020808501948460051b01011161072f57565b3360009081527fff164f808567eb9100129b1d5aead1611f532533c7a4cedced7e7f0a6271f5316020908152604080832054909291906420a226a4a760d91b9060ff16156118d15750505050565b6118da33611d1c565b908451906118e782611c0f565b60428252838201946060368737825115611a895760308653825190600191821015611a895790607860218501536041915b818311611a1b575050506119d957846119a760486119cb9360449798519889916119988984019876020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8a5261196f815180928d603789019101611ba8565b8401917001034b99036b4b9b9b4b733903937b6329607d1b603784015251809386840190611ba8565b01036028810189520187611c2a565b5194859362461bcd60e51b8552600485015251809281602486015285850190611ba8565b601f01601f19168101030190fd5b60648386519062461bcd60e51b825280600483015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b909192600f81166010811015611a75576f181899199a1a9b1b9c1cb0b131b232b360811b901a611a4b8587611cf5565b5360041c928015611a6157600019019190611918565b634e487b7160e01b82526011600452602482fd5b634e487b7160e01b83526032600452602483fd5b634e487b7160e01b81526032600452602490fd5b60008181526020818152604092838320338452825260ff848420541615611ac45750505050565b611acd33611d1c565b90845190611ada82611c0f565b60428252838201946060368737825115611a895760308653825190600191821015611a895790607860218501536041915b818311611b62575050506119d957846119a760486119cb9360449798519889916119988984019876020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8a5261196f815180928d603789019101611ba8565b909192600f81166010811015611a75576f181899199a1a9b1b9c1cb0b131b232b360811b901a611b928587611cf5565b5360041c928015611a6157600019019190611b0b565b60005b838110611bbb5750506000910152565b8181015183820152602001611bab565b6001600160401b038111611bde57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b03821117611bde57604052565b608081019081106001600160401b03821117611bde57604052565b90601f801991011681019081106001600160401b03821117611bde57604052565b9060009180835282602052604083209160018060a01b03169182845260205260ff604084205416611c7b57505050565b80835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4565b81810292918115918404141715611cd257565b634e487b7160e01b600052601160045260246000fd5b91908201809211611cd257565b908151811015611d06570160200190565b634e487b7160e01b600052603260045260246000fd5b60405190606082018281106001600160401b03821117611bde57604052602a8252602082016040368237825115611d0657603090538151600190811015611d0657607860218401536029905b808211611dbc575050611d785790565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b9091600f81166010811015611e15576f181899199a1a9b1b9c1cb0b131b232b360811b901a611deb8486611cf5565b5360041c918015611e00576000190190611d68565b60246000634e487b7160e01b81526011600452fd5b60246000634e487b7160e01b81526032600452fd5b6001600160a01b031660009081526003602052604090205480611e4d5750600390565b90565b6001600160401b038111611bde5760051b60200190565b90611e7182611e50565b611e7e6040519182611c2a565b8281528092611e8f601f1991611e50565b0190602036910137565b6000198114611cd25760010190565b8051821015611d065760209160051b010190565b8115611ec6570490565b634e487b7160e01b600052601260045260246000fd5b6001600160a01b03166000818152600160209081526040808320858452825280832054939594929390929015611f8657858452600282528284208185528252828420848052825282842054958452601082528284209084528152818320548352600e905281205464ffffffffff909316926001600160801b0316904284810391908211611f72575090611f6e91611ebc565b9190565b634e487b7160e01b81526011600452602490fd5b5050508092509190565b9190811015611d065760061b0190565b356001600160a01b038116810361072f5790565b9160009260018060a01b038116845260016020526040842083855260205260408420549085156123d4576001841015806123c2575b1561238a57611ff88683611ce8565b6005541061234857845b8681106121fe5750600b546001600160a01b0316803b1561096c578560405180926303b37c4760e41b8252602060048301528960248301526044820187845b8c81106121c35750508383809203925af180156121b8576121a5575b50845b8681106120705750505050505050565b6001600160a01b038216865260016020908152604080882087895290915286209061209c818987611f90565b916040833603126121a1576040518060408101106001600160401b03604083011117611bde577f79c4752fee93ffd06996e78922a45fe429500cd5e201710ac5231e59b5cb7198612194602061216d866121668f968f8f998f8f8f9061219c9f88958f8f969461212e8a8f9761216198604097886106799f0189526121208161179e565b845201356020830152612bb7565b506001600160a01b0316825260028d528282209082528c52204264ffffffffff169161215b908790611ce8565b90612df0565b611f90565b958c611f90565b604080516001600160a01b0396871681529190920135602082015293881693918291820190565b0390a3611e99565b612060565b8780fd5b6121b190959195611bcb565b933861205d565b6040513d88823e3d90fd5b929450925060019060409081906001600160a01b036121e18761179e565b168152602086013560208201520193019101918993918593612041565b6001600160a01b03612214610679838a88611f90565b168652600760205260408620541561230857600181018082116122f4575b878110612248575061224390611e99565b612002565b612256610679838a88611f90565b6001600160a01b0361226c610679848c8a611f90565b6001600160a01b039092169116148015906122ce575b156122955761229090611e99565b612232565b60405162461bcd60e51b8152602060048201526011602482015270323ab8383634b1b0ba32903a37b5b2b71760791b6044820152606490fd5b5060206122dc838a88611f90565b013560206122eb838b89611f90565b01351415612282565b634e487b7160e01b87526011600452602487fd5b60405162461bcd60e51b815260206004820152601860248201527737379039bab83837b93a32b21031b7b63632b1ba34b7b71760411b6044820152606490fd5b60405162461bcd60e51b815260206004820152601a60248201527937bb32b91036b0bc10373ab6b132b9103832b9103a3937b7b81760311b6044820152606490fd5b60405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b2103a3937b7b824b21760811b6044820152606490fd5b506123cc81611e2a565b841115611fe9565b60405162461bcd60e51b815260206004820152601d60248201527f746f6b656e73206c656e677468206d757374206265206f76657220312e0000006044820152606490fd5b906124579180610120528160c05260018060a01b0381166000526001602052604060002082600052602052604060002080608052546101a052611edc565b60a0528061018052156129c95760018060a01b0361012051166000526010602052604060002060c0516000526020526040600020548061016052600052600e60205260406000206040519081610240528160608101106001600160401b03606084011117611bde5760608201604052549060018060801b03821690526001600160401b038160801c16602061024051015260c01c60406102405101526000610140526125056101a051611e67565b6101c0526125156101a051611e67565b610100526009546001600160a01b03166102605260005b6101a05181101561265a5761254381608051612d78565b9060018060a01b0361012051166000526002602052604060002060c05160005260205260406000206006820660005260205260406000205460289081838102048303611cd25760068364ffffffffff9302041c166125a48261010051611ea8565b526102605182516001600160a01b0316146125c9575b6125c49150611e99565b61252c565b60208060018060a01b03600a5416930151602460405180958193630cc193fb60e41b835260048301525afa801561264e5760009061261a575b6125c49250612614826101c051611ea8565b526125ba565b506020823d602011612646575b8161263460209383611c2a565b8101031261072f576125c49151612602565b3d9150612627565b6040513d6000823e3d90fd5b50600060e0526008546001600160a01b03166102805260125461022052601554610200526014546101e0525b6101805160e051101561291457600090816001815b6101a051831015612781576126b283608051612d78565b946126c08461010051611ea8565b5160e05161024051516126e7916126df916001600160801b0316611cbf565b60a051611ce8565b10612774576126f590611e99565b9451610280516001600160a01b03909116908103612739575061272b6127216127329260135490611ce8565b9260115490611cbf565b925b611e99565b919061269b565b610260939192935114612750575b61273290611e99565b9061276c61273291612765846101c051611ea8565b5190611ce8565b919050612747565b9450909161273290611e99565b9091509291926102205180831161290a575b506127d3906127cd6001600160401b03604061024051015116916127c861020051918260801c9260018060801b031690611ebc565b611cbf565b90611ce8565b6127e0836101e051611cbf565b6000612710831061287a57505050612863916127c861280f926001600160401b03602061024051015116611cbf565b60015b6040519015158152816020820152610160519060c051907fae8be22cbaf20807479362a93c939905a5c4316623047c18c83ec5abfcba55e3604060018060a01b03610120511692a461014051611ce8565b6101405261287260e051611e99565b60e052612686565b9193909243600019810111611cd25760405194600019430140602087015260e0516040870152604086528560608101106001600160401b03606088011117611bde576127108660606128639801604052602081519101200611156128e0575b5050612812565b61290193506127c89192506001600160401b03602061024051015116611cbf565b600138806128d9565b91506127d3612793565b64ffffffffff42169060005b60805154811015612965576129609060018060a01b0361012051166000526002602052604060002060c05160005260205261272d84826040600020612df0565b612920565b50600c549091506001600160a01b0316803b1561072f576040516310b3879160e11b815261014051610120516001600160a01b031660048301526024820152906000908290604490829084905af1801561264e576129c05750565b6129c990611bcb565b565b6024356001600160801b038116810361072f5790565b9190811015611d065760051b0190565b600654811015611d0657600660005260206000200190600090565b600081815260076020526040812054612a8657600654600160401b811015612a72579082612a5e612a45846001604096016006556129f1565b819391549060031b600019811b9283911b169119161790565b905560065492815260076020522055600190565b634e487b7160e01b82526041600452602482fd5b905090565b6000818152600760205260408120549091908015612b705760001990808201818111612b5c5760065490838201918211612b4857808203612b14575b5050506006548015612b0057810190612adf826129f1565b909182549160031b1b19169055600655815260076020526040812055600190565b634e487b7160e01b84526031600452602484fd5b612b32612b23612a45936129f1565b90549060031b1c9283926129f1565b9055845260076020526040842055388080612ac7565b634e487b7160e01b86526011600452602486fd5b634e487b7160e01b85526011600452602485fd5b505090565b8054821015611d065760005260206000209060011b0190600090565b602090612bab928260405194838680955193849201611ba8565b82019081520301902090565b60018101612bcd81612bc885612d9a565b612b91565b54612c49578154600160401b811015611bde57806001612bf09201845583612b75565b612c3357835181546001600160a01b0319166001600160a01b03919091161781556020840151600190910155905491612c2d9190612bc890612d9a565b55600190565b634e487b7160e01b600052600060045260246000fd5b505050600090565b90604051612c5e81611bf4565b82546001600160a01b031681526001909201546020830152565b90612c8290612d9a565b60018201612c908183612b91565b548015612d6f5760001990808201818111611cd2578554838101908111611cd257818103612d02575b50505083548015612cec570191612cd08385612b75565b939093612c33576000948560018682612c2d9855015555612b91565b634e487b7160e01b600052603160045260246000fd5b612d0f612d179188612b75565b509187612b75565b612c3357612bc8612d358383612d3a95899503612d43575b50612c51565b612d9a565b55388080612cb9565b815481546001600160a01b0319166001600160a01b039190911617815560018281015491015538612d2f565b50505050600090565b611e4d91612d2f9160006020604051612d9081611bf4565b8281520152612b75565b611e4d60416020612db360018060a01b03855116611d1c565b930151926040519381612dd0869351809260208087019101611ba8565b820190602d60f81b60208301526021820152036021810184520182611c2a565b9291909260068406906000928284528160205260408420549186602802966028880403612b5c57600660409596970493865260205264ffffffffff809116831b921b19161791205556fea26469706673582212206c077053b526004545bcabd6e8b4ee1932c1d33d9b60508c0e4b69ebbe86cdfd64736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
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.