Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
GrimweedQuest
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "./Questable.sol"; contract GrimweedQuest is Questable { // ---------- CONSTRUCTOR ---------- constructor( address _raiders, address _questing, address _boosted, address _rewardAddress, address _professions, uint _professionId, uint _returnHomeTimeDivisor, uint _experienceAmount, uint _baseRewardTime, uint _twentyFivePercentBoostExperience, uint _fiftyPercentRewardsBoostExperience, uint _minProfessionExp) { require(_professionId > 0, "Invalid profession id"); require(_returnHomeTimeDivisor > 0, "Invalid return home time value"); require(_experienceAmount > 0, "Invalid xp amount"); require(_baseRewardTime > 0, "Invalid base reward time"); require(_twentyFivePercentBoostExperience > 0, "Invalid 25% xp boost"); require(_fiftyPercentRewardsBoostExperience > 0, "Invalid 50% xp boost"); raidersAddress = _raiders; questingRaiders = _questing; boostedRaiders = _boosted; rewardAddress = _rewardAddress; professionsAddress = _professions; minProfessionExp = _minProfessionExp; professionId = _professionId; returnHomeTimeDivisor = _returnHomeTimeDivisor; experienceAmount = _experienceAmount; baseRewardTime = _baseRewardTime; twentyFivePercentBoostExperience = _twentyFivePercentBoostExperience; fiftyPercentRewardsBoostExperience = _fiftyPercentRewardsBoostExperience; } //OVERRIDE EXAMPLE - TEST WILL FAILS TO INDICATE CHANGE IN PLACE. /* function calcReturnTime(uint _raiderId) onQuest(_raiderId) public view override returns (uint) { return 500; } */ }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "./QuestingRaiders.sol"; import "./BoostedRaiders.sol"; import "./RaiderProfessions.sol"; contract Questable is Pausable, Ownable { using SafeMath for uint; using SafeERC20 for IERC20; address raidersAddress; address questingRaiders; address professionsAddress; address boostedRaiders; address rewardAddress; uint public professionId; uint public minProfessionExp; // how much XP they need to do this quest uint public returnHomeTimeDivisor; uint public experienceAmount; uint public baseRewardTime; uint public twentyFivePercentBoostExperience; uint public fiftyPercentRewardsBoostExperience; mapping(uint => uint) public questStartedTime; mapping(uint => uint) public questEndedTime; mapping(uint => uint) public rewardEarned; mapping(uint => uint) public timeHome; mapping(uint => address) public transferredRaider; enum Status { None, Questing, Returning } mapping(uint => Status) public raiderStatus; // ---------- HELPERS ---------- function raiders() internal view returns(IERC721) { return IERC721(raidersAddress); } function questing() internal view returns(QuestingRaiders) { return QuestingRaiders(questingRaiders); } function boosted() internal view returns(BoostedRaiders) { return BoostedRaiders(boostedRaiders); } function professions() internal view returns(RaiderProfessions) { return RaiderProfessions(professionsAddress); } // ---------- MODIFIERS ---------- modifier onQuest(uint _raiderId) { require(questing().onQuest(_raiderId), "This Raider is not on a quest!"); _; } modifier notOnQuest(uint _raiderId) { require(!questing().onQuest(_raiderId), "This Raider is on a quest!"); _; } modifier ownsRaider(uint _raiderId) { require(raiders().ownerOf(_raiderId) == msg.sender, "You dont own this Raider!"); _; } modifier sentRaider(uint _raiderId) { require(transferredRaider[_raiderId] == msg.sender, "You dont own this Raider!"); _; } modifier humanOnly() { require(msg.sender == tx.origin, "Bad robot!"); _; } // ---------- INTERNAL FUNCTIONS ---------- function timeQuesting(uint _raiderId) public view returns(uint) { return (block.timestamp).sub(questStartedTime[_raiderId]); } // ---------- MAIN FUNCTIONS ---------- function startQuest(uint _raiderId) notOnQuest(_raiderId) ownsRaider(_raiderId) humanOnly external whenNotPaused { require(professions().getRaiderExp(_raiderId, professionId) >= minProfessionExp, "You're not a high enough level for this quest!"); questStartedTime[_raiderId] = block.timestamp; transferredRaider[_raiderId] = msg.sender; raiderStatus[_raiderId] = Status.Questing; questing().startQuest(_raiderId, msg.sender); } function endQuest(uint _raiderId) onQuest(_raiderId) sentRaider(_raiderId) humanOnly external whenNotPaused { rewardEarned[_raiderId] = calcEarned(_raiderId); raiderStatus[_raiderId] = Status.Returning; questEndedTime[_raiderId] = block.timestamp; timeHome[_raiderId] = block.timestamp.add(calcReturnTime(_raiderId)); } function getRewards(uint _raiderId) onQuest(_raiderId) sentRaider(_raiderId) humanOnly external whenNotPaused { require(block.timestamp > timeHome[_raiderId], "Your Raider is still coming home!"); require(raiderStatus[_raiderId] == Status.Returning, "Your Raider is still on their quest!"); questStartedTime[_raiderId] = 0; timeHome[_raiderId] = 0; uint rewards = rewardEarned[_raiderId]; rewardEarned[_raiderId] = 0; transferredRaider[_raiderId] = address(0); raiderStatus[_raiderId] = Status.None; questing().endQuest(_raiderId, msg.sender); professions().addExperience(_raiderId, professionId, rewards.mul(experienceAmount)); ERC20PresetMinterPauser(rewardAddress).mint(msg.sender, rewards); } function runHome(uint _raiderId) onQuest(_raiderId) sentRaider(_raiderId) humanOnly external whenNotPaused { require(raiderStatus[_raiderId] == Status.Returning, "Your Raider is still on their quest!"); require(block.timestamp < timeHome[_raiderId], "Your Raider is already home!"); rewardEarned[_raiderId] = 0; questStartedTime[_raiderId] = 0; timeHome[_raiderId] = 0; transferredRaider[_raiderId] = address(0); raiderStatus[_raiderId] = Status.None; questing().endQuest(_raiderId, msg.sender); } // ---------- MATH ---------- function calcEarned(uint _raiderId) onQuest(_raiderId) public view virtual returns(uint) { uint timePassed = timeQuesting(_raiderId); uint rewardRate = calcRaiderRewardTime(_raiderId); return timePassed.div(rewardRate); } function nextReward(uint _raiderId) onQuest(_raiderId) external view virtual returns(uint) { uint timePassed = timeQuesting(_raiderId); uint rewardRate = calcRaiderRewardTime(_raiderId); return rewardRate.sub(timePassed.mod(rewardRate)); } function calcRaiderRewardTime(uint _raiderId) public view virtual returns(uint) { uint speedBoost = boosted().raiderSpeedBoost(_raiderId); uint professionBoost = boosted().getProfessionBoost(_raiderId, professionId); uint experience = professions().getRaiderExp(_raiderId, professionId); uint boost = speedBoost + professionBoost; if (speedBoost >= 100 && professionBoost >= 100) { // also need to count for the extra hundred here boost = boost.sub(100); } uint levelBoost = 100; if (experience > twentyFivePercentBoostExperience && experience < fiftyPercentRewardsBoostExperience) { levelBoost = 125; } else if (experience > fiftyPercentRewardsBoostExperience) { levelBoost = 150; } uint totalBoost = levelBoost; if (boost > 0) { totalBoost = boost + totalBoost - 100; // this will be in the hundreds, like 300%. Since both start at 100, we need to sub out one of the 100s here too } return (baseRewardTime.mul(100)).div(totalBoost); } function calcReturnTime(uint _raiderId) onQuest(_raiderId) public view virtual returns (uint) { uint returnBoost = boosted().raiderSpeedBoost(_raiderId); uint returnTime = timeQuesting(_raiderId).div(returnHomeTimeDivisor); if (returnBoost > 0) { returnTime = returnTime.mul(100).div(returnBoost); } return returnTime; } // ---------- ADMIN FUNCTIONS ---------- function changeRewardTime(uint _time) external onlyOwner { baseRewardTime = _time; } function changeReturnHomeTimeDivisor(uint _amount) external onlyOwner { returnHomeTimeDivisor = _amount; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function changeBoostedContract(address _boosted) external onlyOwner { boostedRaiders = _boosted; } function changeTwentyFivePercentBoostAmount(uint _amount) external onlyOwner { twentyFivePercentBoostExperience = _amount; } function changeFiftyPercentBoostAmount(uint _amount) external onlyOwner { fiftyPercentRewardsBoostExperience = _amount; } function changeExperienceAmount(uint _amount) external onlyOwner { experienceAmount = _amount; } function changeMinExpAmount(uint _amount) external onlyOwner { minProfessionExp = _amount; } // ---------- VIEW FUNCTIONS ---------- function timeTillHome(uint _raiderId) external view virtual returns(uint) { return timeHome[_raiderId].sub(block.timestamp); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/presets/ERC20PresetMinterPauser.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../extensions/ERC20Burnable.sol"; import "../extensions/ERC20Pausable.sol"; import "../../../access/AccessControlEnumerable.sol"; import "../../../utils/Context.sol"; /** * @dev {ERC20} token, including: * * - ability for holders to burn (destroy) their tokens * - a minter role that allows for token minting (creation) * - a pauser role that allows to stop all token transfers * * This contract uses {AccessControl} to lock permissioned functions using the * different roles - head to its documentation for details. * * The account that deploys the contract will be granted the minter and pauser * roles, as well as the default admin role, which will let it grant both minter * and pauser roles to other accounts. */ contract ERC20PresetMinterPauser is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); /** * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the * account that deploys the contract. * * See {ERC20-constructor}. */ constructor(string memory name, string memory symbol) ERC20(name, symbol) { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(MINTER_ROLE, _msgSender()); _setupRole(PAUSER_ROLE, _msgSender()); } /** * @dev Creates `amount` new tokens for `to`. * * See {ERC20-_mint}. * * Requirements: * * - the caller must have the `MINTER_ROLE`. */ function mint(address to, uint256 amount) public virtual { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint"); _mint(to, amount); } /** * @dev Pauses all token transfers. * * See {ERC20Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function pause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to pause"); _pause(); } /** * @dev Unpauses all token transfers. * * See {ERC20Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `PAUSER_ROLE`. */ function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have pauser role to unpause"); _unpause(); } function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override(ERC20, ERC20Pausable) { super._beforeTokenTransfer(from, to, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; contract QuestingRaiders is Ownable, Pausable, IERC721Receiver { address immutable raidersAddress; mapping(uint => bool) public onQuest; mapping(address => bool) approvedQuests; mapping(address => uint[]) public ownedRaiders; mapping(uint => address) public raiderQuest; mapping(uint => address) public ownsRaider; constructor(address _raiders) { raidersAddress = _raiders; } // ---------- HELPERS ---------- function raiders() internal view returns(IERC721) { return IERC721(raidersAddress); } function removeRaider(uint _raider, address _raiderOwner) internal { uint raiderIndex; for (uint i = 0; i < ownedRaiders[_raiderOwner].length; i++) { if (ownedRaiders[_raiderOwner][i] == _raider) { raiderIndex = i; } } uint length = ownedRaiders[_raiderOwner].length; ownedRaiders[_raiderOwner][raiderIndex] = ownedRaiders[_raiderOwner][length - 1]; // change the index to the last item in the array delete ownedRaiders[_raiderOwner][length - 1]; ownedRaiders[_raiderOwner].pop(); } // ---------- MODIFIERS ---------- modifier onlyQuest { require(approvedQuests[msg.sender]); _; } // ---------- PRIMARY FUNCTIONS ---------- function startQuest(uint _raiderId, address _raiderOwner) onlyQuest external whenNotPaused { require(!onQuest[_raiderId], "This Raider is already on a Quest!"); onQuest[_raiderId] = true; ownsRaider[_raiderId] = _raiderOwner; ownedRaiders[_raiderOwner].push(_raiderId); raiderQuest[_raiderId] = msg.sender; raiders().safeTransferFrom(_raiderOwner, address(this), _raiderId); } function endQuest(uint _raiderId, address _raiderOwner) onlyQuest external whenNotPaused { require(onQuest[_raiderId], "This Raider is not on a Quest!"); onQuest[_raiderId] = false; removeRaider(_raiderId, _raiderOwner); raiders().safeTransferFrom(address(this), _raiderOwner, _raiderId); } // ----------- ADMIN ONLY ---------- function addQuest(address _quest) onlyOwner external whenNotPaused { approvedQuests[_quest] = true; } function removeQuest(address _quest) onlyOwner external whenNotPaused { approvedQuests[_quest] = false; } function pause() external onlyOwner { _pause(); } function unpause() external onlyOwner { _unpause(); } function emergencyRemoveRaider(uint _raiderId) external onlyOwner { raiders().safeTransferFrom(address(this), msg.sender, _raiderId); } function emergencyReturnRaider(uint _raiderId) external onlyOwner { address raiderOwner = ownsRaider[_raiderId]; raiders().safeTransferFrom(address(this), raiderOwner, _raiderId); } function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) { return this.onERC721Received.selector; } // ----------- VIEW FUNCTIONS ---------- function getOwnedRaiders(address _address) external view returns(uint[] memory) { return ownedRaiders[_address]; } }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; contract BoostedRaiders is Ownable, Pausable { using SafeMath for uint; mapping(address => bool) approvedBoosts; mapping(uint => uint) public raiderSpeedBoost; mapping(uint => mapping(uint => uint)) public raiderProfessionBoost; // Boosts are in 100s to get around decimal issues. So if you want to give a 20% boost, you add 20. Then on the contract side, you have to adjust the time by 20% // Professions are based on the profession keys which you can see internally. Make sure they line up properly! modifier onlyBoost { require(approvedBoosts[msg.sender] == true); _; } function addSpeedBoost(uint _raiderId, uint _amount) onlyBoost public { raiderSpeedBoost[_raiderId] = raiderSpeedBoost[_raiderId].add(_amount); } function subSpeedBoost(uint _raiderId, uint _amount) onlyBoost public { raiderSpeedBoost[_raiderId] = raiderSpeedBoost[_raiderId].sub(_amount); } function addProfessionBoost(uint _raiderId, uint _profession, uint _amount) onlyBoost public { raiderProfessionBoost[_raiderId][_profession] = raiderProfessionBoost[_raiderId][_profession].add(_amount); } function subProfessionBoost(uint _raiderId, uint _profession, uint _amount) onlyBoost public { raiderProfessionBoost[_raiderId][_profession] = raiderProfessionBoost[_raiderId][_profession].sub(_amount); } // ----------- VIEWS ---------- function getProfessionBoost(uint _raiderId, uint _profession) external view returns(uint) { return raiderProfessionBoost[_raiderId][_profession]; } // ----------- ADMIN ONLY ---------- function addBoost(address _Boost) onlyOwner public { approvedBoosts[_Boost] = true; } function removeBoost(address _Boost) onlyOwner public { approvedBoosts[_Boost] = false; } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function adminSpeedBoostChange(uint _raiderId, uint _value) onlyOwner public { raiderSpeedBoost[_raiderId] = _value; } function adminProfessionBoostChange(uint _raiderId, uint _profession, uint _value) onlyOwner public { raiderProfessionBoost[_raiderId][_profession] = _value; } }
//SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; contract RaiderProfessions is Ownable, Pausable { using SafeMath for uint; mapping(address => bool) approvedQuests; mapping(uint => string) public professions; mapping(uint => mapping(uint => uint)) raiderProfessionExp; // raider -> profession -> experience modifier onlyQuest { require(approvedQuests[msg.sender] == true); _; } function addExperience(uint raider, uint profession, uint experience) onlyQuest public whenNotPaused { raiderProfessionExp[raider][profession] = (raiderProfessionExp[raider][profession]).add(experience); } function subExperience(uint raider, uint profession, uint experience) onlyQuest public whenNotPaused { raiderProfessionExp[raider][profession] = (raiderProfessionExp[raider][profession]).sub(experience); } function getRaiderExp(uint _raider, uint _profession) public view returns(uint) { return raiderProfessionExp[_raider][_profession]; } // ----------- ADMIN ONLY ---------- function addQuest(address _quest) onlyOwner public { approvedQuests[_quest] = true; } function removeQuest(address _quest) onlyOwner public { approvedQuests[_quest] = false; } function manualExpUpdate(uint raider, uint profession, uint experience) onlyOwner public { raiderProfessionExp[raider][profession] = experience; } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); unchecked { _approve(account, _msgSender(), currentAllowance - amount); } _burn(account, amount); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/ERC20Pausable.sol) pragma solidity ^0.8.0; import "../ERC20.sol"; import "../../../security/Pausable.sol"; /** * @dev ERC20 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. */ abstract contract ERC20Pausable is ERC20, Pausable { /** * @dev See {ERC20-_beforeTokenTransfer}. * * Requirements: * * - the contract must not be paused. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual override { super._beforeTokenTransfer(from, to, amount); require(!paused(), "ERC20Pausable: token transfer while paused"); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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 v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_raiders","type":"address"},{"internalType":"address","name":"_questing","type":"address"},{"internalType":"address","name":"_boosted","type":"address"},{"internalType":"address","name":"_rewardAddress","type":"address"},{"internalType":"address","name":"_professions","type":"address"},{"internalType":"uint256","name":"_professionId","type":"uint256"},{"internalType":"uint256","name":"_returnHomeTimeDivisor","type":"uint256"},{"internalType":"uint256","name":"_experienceAmount","type":"uint256"},{"internalType":"uint256","name":"_baseRewardTime","type":"uint256"},{"internalType":"uint256","name":"_twentyFivePercentBoostExperience","type":"uint256"},{"internalType":"uint256","name":"_fiftyPercentRewardsBoostExperience","type":"uint256"},{"internalType":"uint256","name":"_minProfessionExp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"baseRewardTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"calcEarned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"calcRaiderRewardTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"calcReturnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_boosted","type":"address"}],"name":"changeBoostedContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"changeExperienceAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"changeFiftyPercentBoostAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"changeMinExpAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"changeReturnHomeTimeDivisor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_time","type":"uint256"}],"name":"changeRewardTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"changeTwentyFivePercentBoostAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"endQuest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"experienceAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fiftyPercentRewardsBoostExperience","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"getRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minProfessionExp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"nextReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"professionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"questEndedTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"questStartedTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"raiderStatus","outputs":[{"internalType":"enum Questable.Status","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"returnHomeTimeDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardEarned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"runHome","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"startQuest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"timeHome","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"timeQuesting","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raiderId","type":"uint256"}],"name":"timeTillHome","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferredRaider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"twentyFivePercentBoostExperience","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b50604051620021013803806200210183398101604081905262000034916200032b565b6000805460ff191690556200004933620002b5565b600087116200009f5760405162461bcd60e51b815260206004820152601560248201527f496e76616c69642070726f66657373696f6e206964000000000000000000000060448201526064015b60405180910390fd5b60008611620000f15760405162461bcd60e51b815260206004820152601e60248201527f496e76616c69642072657475726e20686f6d652074696d652076616c75650000604482015260640162000096565b60008511620001375760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081e1c08185b5bdd5b9d607a1b604482015260640162000096565b60008411620001895760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642062617365207265776172642074696d650000000000000000604482015260640162000096565b60008311620001db5760405162461bcd60e51b815260206004820152601460248201527f496e76616c69642032352520787020626f6f7374000000000000000000000000604482015260640162000096565b600082116200022d5760405162461bcd60e51b815260206004820152601460248201527f496e76616c69642035302520787020626f6f7374000000000000000000000000604482015260640162000096565b600180546001600160a01b03199081166001600160a01b039e8f16179091556002805482169c8e169c909c17909b55600480548c169a8d169a909a17909955600580548b16988c1698909817909755600380549099169590991694909417909655600794909455600655600892909255600992909255600a55600b91909155600c55620003e0565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b80516001600160a01b03811681146200032657600080fd5b919050565b6000806000806000806000806000806000806101808d8f0312156200034e578788fd5b620003598d6200030e565b9b506200036960208e016200030e565b9a506200037960408e016200030e565b99506200038960608e016200030e565b98506200039960808e016200030e565b975060a08d0151965060c08d0151955060e08d015194506101008d015193506101208d015192506101408d015191506101608d015190509295989b509295989b509295989b565b611d1180620003f06000396000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c80637e1bd01111610125578063a7214762116100ad578063cf0f6fed1161007c578063cf0f6fed1461049b578063dc4a3be6146104c4578063e84ee067146104cd578063f2fde38b146104d6578063f3c5c7b8146104e957600080fd5b8063a721476214610435578063b7f8b67f14610455578063c0d8012c14610475578063cb6c784e1461048857600080fd5b80638da5cb5b116100f45780638da5cb5b146103bf57806394ebe471146103e957806398eb5d96146103fc5780639e5635441461040f578063a3cd2d781461042257600080fd5b80637e1bd011146103925780638269b22d146103a55780638456cb59146103ae57806385faddf8146103b657600080fd5b80635c975abb116101a857806367448d9c1161017757806367448d9c14610352578063715018a61461035b57806372157b42146103635780637928522c1461036c5780637a8684dc1461037f57600080fd5b80635c975abb146102d95780635e79e899146102ef57806361753027146103025780636183a8511461033257600080fd5b806337a9d6ea116101ef57806337a9d6ea146102825780633f4ba83a1461029557806342564ada1461029d578063444dc542146102a657806356c91c8c146102c657600080fd5b8063020350af146102215780632213936814610247578063235dad5b1461025c5780633667a0bb1461026f575b600080fd5b61023461022f366004611a97565b6104fc565b6040519081526020015b60405180910390f35b61025a610255366004611a97565b61051c565b005b61025a61026a366004611a97565b61055a565b61025a61027d366004611a97565b6106e2565b61025a610290366004611a97565b610717565b61025a61074c565b610234600b5481565b6102346102b4366004611a97565b60106020526000908152604090205481565b6102346102d4366004611a97565b610786565b60005460ff16604051901515815260200161023e565b6102346102fd366004611a97565b61079f565b610325610310366004611a97565b60126020526000908152604090205460ff1681565b60405161023e9190611ac7565b610234610340366004611a97565b600d6020526000908152604090205481565b61023460075481565b61025a610919565b610234600a5481565b61025a61037a366004611a97565b610953565b61023461038d366004611a97565b610988565b61025a6103a0366004611a97565b610a63565b610234600c5481565b61025a610a98565b61023460085481565b60005461010090046001600160a01b03165b6040516001600160a01b03909116815260200161023e565b61025a6103f7366004611a3f565b610ad0565b61023461040a366004611a97565b610b22565b61025a61041d366004611a97565b610d9b565b610234610430366004611a97565b611113565b610234610443366004611a97565b600f6020526000908152604090205481565b610234610463366004611a97565b600e6020526000908152604090205481565b61025a610483366004611a97565b6111ef565b61025a610496366004611a97565b61158b565b6103d16104a9366004611a97565b6011602052600090815260409020546001600160a01b031681565b61023460065481565b61023460095481565b61025a6104e4366004611a3f565b6117e2565b61025a6104f7366004611a97565b611883565b6000818152600d60205260408120546105169042906118b8565b92915050565b6000546001600160a01b036101009091041633146105555760405162461bcd60e51b815260040161054c90611bef565b60405180910390fd5b600755565b8061056d6002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b815260040161059a91815260200190565b60206040518083038186803b1580156105b257600080fd5b505afa1580156105c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ea9190611a77565b6106065760405162461bcd60e51b815260040161054c90611b26565b60008281526011602052604090205482906001600160a01b0316331461063e5760405162461bcd60e51b815260040161054c90611aef565b33321461065d5760405162461bcd60e51b815260040161054c90611b5d565b60005460ff16156106805760405162461bcd60e51b815260040161054c90611b81565b61068983610988565b6000848152600f602090815260408083209390935560128152828220805460ff19166002179055600e9052204290556106cb6106c48461079f565b42906118cb565b600093845260106020526040909320929092555050565b6000546001600160a01b036101009091041633146107125760405162461bcd60e51b815260040161054c90611bef565b600c55565b6000546001600160a01b036101009091041633146107475760405162461bcd60e51b815260040161054c90611bef565b600955565b6000546001600160a01b0361010090910416331461077c5760405162461bcd60e51b815260040161054c90611bef565b6107846118d7565b565b60008181526010602052604081205461051690426118b8565b6000816107b46002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b81526004016107e191815260200190565b60206040518083038186803b1580156107f957600080fd5b505afa15801561080d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108319190611a77565b61084d5760405162461bcd60e51b815260040161054c90611b26565b60006108616004546001600160a01b031690565b6001600160a01b031663f21114a9856040518263ffffffff1660e01b815260040161088e91815260200190565b60206040518083038186803b1580156108a657600080fd5b505afa1580156108ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108de9190611aaf565b905060006108f76008546108f1876104fc565b9061196a565b905081156109115761090e826108f1836064611976565b90505b949350505050565b6000546001600160a01b036101009091041633146109495760405162461bcd60e51b815260040161054c90611bef565b6107846000611982565b6000546001600160a01b036101009091041633146109835760405162461bcd60e51b815260040161054c90611bef565b600a55565b60008161099d6002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b81526004016109ca91815260200190565b60206040518083038186803b1580156109e257600080fd5b505afa1580156109f6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1a9190611a77565b610a365760405162461bcd60e51b815260040161054c90611b26565b6000610a41846104fc565b90506000610a4e85610b22565b9050610a5a828261196a565b95945050505050565b6000546001600160a01b03610100909104163314610a935760405162461bcd60e51b815260040161054c90611bef565b600b55565b6000546001600160a01b03610100909104163314610ac85760405162461bcd60e51b815260040161054c90611bef565b6107846119db565b6000546001600160a01b03610100909104163314610b005760405162461bcd60e51b815260040161054c90611bef565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600080610b376004546001600160a01b031690565b6001600160a01b031663f21114a9846040518263ffffffff1660e01b8152600401610b6491815260200190565b60206040518083038186803b158015610b7c57600080fd5b505afa158015610b90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb49190611aaf565b90506000610bca6004546001600160a01b031690565b6001600160a01b03166370412af5856006546040518363ffffffff1660e01b8152600401610c02929190918252602082015260400190565b60206040518083038186803b158015610c1a57600080fd5b505afa158015610c2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c529190611aaf565b90506000610c686003546001600160a01b031690565b6001600160a01b0316634bb16115866006546040518363ffffffff1660e01b8152600401610ca0929190918252602082015260400190565b60206040518083038186803b158015610cb857600080fd5b505afa158015610ccc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf09190611aaf565b90506000610cfe8385611c24565b905060648410158015610d12575060648310155b15610d2557610d228160646118b8565b90505b600b5460649083118015610d3a5750600c5483105b15610d475750607d610d55565b600c54831115610d55575060965b808215610d75576064610d688285611c24565b610d729190611c6f565b90505b610d8f816108f16064600a5461197690919063ffffffff16565b98975050505050505050565b80610dae6002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b8152600401610ddb91815260200190565b60206040518083038186803b158015610df357600080fd5b505afa158015610e07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2b9190611a77565b15610e785760405162461bcd60e51b815260206004820152601a60248201527f5468697320526169646572206973206f6e206120717565737421000000000000604482015260640161054c565b8133610e8c6001546001600160a01b031690565b6001600160a01b0316636352211e836040518263ffffffff1660e01b8152600401610eb991815260200190565b60206040518083038186803b158015610ed157600080fd5b505afa158015610ee5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f099190611a5b565b6001600160a01b031614610f2f5760405162461bcd60e51b815260040161054c90611aef565b333214610f4e5760405162461bcd60e51b815260040161054c90611b5d565b60005460ff1615610f715760405162461bcd60e51b815260040161054c90611b81565b600754600354600654604051634bb1611560e01b81526004810187905260248101919091526001600160a01b0390911690634bb161159060440160206040518083038186803b158015610fc357600080fd5b505afa158015610fd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ffb9190611aaf565b10156110605760405162461bcd60e51b815260206004820152602e60248201527f596f75277265206e6f742061206869676820656e6f756768206c6576656c206660448201526d6f7220746869732071756573742160901b606482015260840161054c565b6000838152600d60209081526040808320429055601182528083208054336001600160a01b031990911617905560129091529020805460ff191660011790556002546001600160a01b03166040516395efb90b60e01b8152600481018590523360248201526001600160a01b0391909116906395efb90b906044015b600060405180830381600087803b1580156110f657600080fd5b505af115801561110a573d6000803e3d6000fd5b50505050505050565b6000816111286002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b815260040161115591815260200190565b60206040518083038186803b15801561116d57600080fd5b505afa158015611181573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a59190611a77565b6111c15760405162461bcd60e51b815260040161054c90611b26565b60006111cc846104fc565b905060006111d985610b22565b9050610a5a6111e88383611a33565b82906118b8565b806112026002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b815260040161122f91815260200190565b60206040518083038186803b15801561124757600080fd5b505afa15801561125b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127f9190611a77565b61129b5760405162461bcd60e51b815260040161054c90611b26565b60008281526011602052604090205482906001600160a01b031633146112d35760405162461bcd60e51b815260040161054c90611aef565b3332146112f25760405162461bcd60e51b815260040161054c90611b5d565b60005460ff16156113155760405162461bcd60e51b815260040161054c90611b81565b600083815260106020526040902054421161137c5760405162461bcd60e51b815260206004820152602160248201527f596f757220526169646572206973207374696c6c20636f6d696e6720686f6d656044820152602160f81b606482015260840161054c565b600260008481526012602052604090205460ff1660028111156113af57634e487b7160e01b600052602160045260246000fd5b146113cc5760405162461bcd60e51b815260040161054c90611bab565b6000838152600d6020908152604080832083905560108252808320839055600f82528083208054908490556011835281842080546001600160a01b03191690556012909252909120805460ff191690556002546001600160a01b03166040516369415ec360e11b8152600481018690523360248201526001600160a01b03919091169063d282bd8690604401600060405180830381600087803b15801561147257600080fd5b505af1158015611486573d6000803e3d6000fd5b5050505061149c6003546001600160a01b031690565b6001600160a01b03166327cba502856006546114c36009548661197690919063ffffffff16565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526044820152606401600060405180830381600087803b15801561150957600080fd5b505af115801561151d573d6000803e3d6000fd5b50506005546040516340c10f1960e01b8152336004820152602481018590526001600160a01b0390911692506340c10f199150604401600060405180830381600087803b15801561156d57600080fd5b505af1158015611581573d6000803e3d6000fd5b5050505050505050565b8061159e6002546001600160a01b031690565b6001600160a01b0316631bf74f8f826040518263ffffffff1660e01b81526004016115cb91815260200190565b60206040518083038186803b1580156115e357600080fd5b505afa1580156115f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161b9190611a77565b6116375760405162461bcd60e51b815260040161054c90611b26565b60008281526011602052604090205482906001600160a01b0316331461166f5760405162461bcd60e51b815260040161054c90611aef565b33321461168e5760405162461bcd60e51b815260040161054c90611b5d565b60005460ff16156116b15760405162461bcd60e51b815260040161054c90611b81565b600260008481526012602052604090205460ff1660028111156116e457634e487b7160e01b600052602160045260246000fd5b146117015760405162461bcd60e51b815260040161054c90611bab565b600083815260106020526040902054421061175e5760405162461bcd60e51b815260206004820152601c60248201527f596f75722052616964657220697320616c726561647920686f6d652100000000604482015260640161054c565b6000838152600f60209081526040808320839055600d8252808320839055601082528083208390556011825280832080546001600160a01b0319169055601290915290819020805460ff1916905560025490516369415ec360e11b8152600481018590523360248201526001600160a01b039091169063d282bd86906044016110dc565b6000546001600160a01b036101009091041633146118125760405162461bcd60e51b815260040161054c90611bef565b6001600160a01b0381166118775760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161054c565b61188081611982565b50565b6000546001600160a01b036101009091041633146118b35760405162461bcd60e51b815260040161054c90611bef565b600855565b60006118c48284611c6f565b9392505050565b60006118c48284611c24565b60005460ff166119205760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161054c565b6000805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60006118c48284611c3c565b60006118c48284611c50565b600080546001600160a01b03838116610100818102610100600160a81b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b60005460ff16156119fe5760405162461bcd60e51b815260040161054c90611b81565b6000805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861194d3390565b60006118c48284611c86565b600060208284031215611a50578081fd5b81356118c481611cc6565b600060208284031215611a6c578081fd5b81516118c481611cc6565b600060208284031215611a88578081fd5b815180151581146118c4578182fd5b600060208284031215611aa8578081fd5b5035919050565b600060208284031215611ac0578081fd5b5051919050565b6020810160038310611ae957634e487b7160e01b600052602160045260246000fd5b91905290565b60208082526019908201527f596f7520646f6e74206f776e2074686973205261696465722100000000000000604082015260600190565b6020808252601e908201527f5468697320526169646572206973206e6f74206f6e2061207175657374210000604082015260600190565b6020808252600a908201526942616420726f626f742160b01b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526024908201527f596f757220526169646572206973207374696c6c206f6e2074686569722071756040820152636573742160e01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115611c3757611c37611c9a565b500190565b600082611c4b57611c4b611cb0565b500490565b6000816000190483118215151615611c6a57611c6a611c9a565b500290565b600082821015611c8157611c81611c9a565b500390565b600082611c9557611c95611cb0565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b038116811461188057600080fdfea2646970667358221220fad199e79d4b6d5c1e90495be6a8ed4d408f6c8ea25c9fbdc0ac8fc8c55f406264736f6c63430008040033000000000000000000000000fd12ec7ea4b381a79c78fe8b2248b4c559011ffb0000000000000000000000005a4fcdd54d483808080e0588c1e7d73e2a8afda800000000000000000000000000db9ba25a5fd0a7f7caeb75955df2c386b5b47200000000000000000000000006f34105b7dfedc95125348a8349bda2099287300000000000000000000000002c44d894850ff39281d6e999bb4b5a6212ab91a600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000007e9000000000000000000000000000000000000000000000000000000000000004c60000000000000000000000000000000000000000000000000000000000001f1d0000000000000000000000000000000000000000000000000000000000000000
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000fd12ec7ea4b381a79c78fe8b2248b4c559011ffb0000000000000000000000005a4fcdd54d483808080e0588c1e7d73e2a8afda800000000000000000000000000db9ba25a5fd0a7f7caeb75955df2c386b5b47200000000000000000000000006f34105b7dfedc95125348a8349bda2099287300000000000000000000000002c44d894850ff39281d6e999bb4b5a6212ab91a600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000007e9000000000000000000000000000000000000000000000000000000000000004c60000000000000000000000000000000000000000000000000000000000001f1d0000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _raiders (address): 0xfd12ec7ea4b381a79c78fe8b2248b4c559011ffb
Arg [1] : _questing (address): 0x5a4fcdd54d483808080e0588c1e7d73e2a8afda8
Arg [2] : _boosted (address): 0x00db9ba25a5fd0a7f7caeb75955df2c386b5b472
Arg [3] : _rewardAddress (address): 0x06f34105b7dfedc95125348a8349bda209928730
Arg [4] : _professions (address): 0x2c44d894850ff39281d6e999bb4b5a6212ab91a6
Arg [5] : _professionId (uint256): 1
Arg [6] : _returnHomeTimeDivisor (uint256): 4
Arg [7] : _experienceAmount (uint256): 10
Arg [8] : _baseRewardTime (uint256): 32400
Arg [9] : _twentyFivePercentBoostExperience (uint256): 1222
Arg [10] : _fiftyPercentRewardsBoostExperience (uint256): 7965
Arg [11] : _minProfessionExp (uint256): 0
-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 000000000000000000000000fd12ec7ea4b381a79c78fe8b2248b4c559011ffb
Arg [1] : 0000000000000000000000005a4fcdd54d483808080e0588c1e7d73e2a8afda8
Arg [2] : 00000000000000000000000000db9ba25a5fd0a7f7caeb75955df2c386b5b472
Arg [3] : 00000000000000000000000006f34105b7dfedc95125348a8349bda209928730
Arg [4] : 0000000000000000000000002c44d894850ff39281d6e999bb4b5a6212ab91a6
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [7] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [8] : 0000000000000000000000000000000000000000000000000000000000007e90
Arg [9] : 00000000000000000000000000000000000000000000000000000000000004c6
Arg [10] : 0000000000000000000000000000000000000000000000000000000000001f1d
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000000
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.