Verified contractExactMIT
FearWolfDistributor
Address0x8be7dbc73a9e1bb40d1d7741783b0a8fa003acf7
- Balance
0.6 ETH
- Transactions
195
- Compiler
solc 0.8.9
- Same code
Only this contract
Details
- Compiler
- solc 0.8.9+commit.e5eed63a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- london
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 14,721,418
- Creation transaction
- 0x089aff2eb3…34cd942d0b
contracts/deployed/FearWolfDistributor.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
/**
* @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);
}
function toString(bytes32 value) internal pure returns (string memory) {
uint8 i = 0;
while(i < 32 && value[i] != 0) {
i++;
}
bytes memory bytesArray = new bytes(i);
for (i = 0; i < 32 && value[i] != 0; i++) {
bytesArray[i] = value[i];
}
return string(bytesArray);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*/
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;
}
/**
* @dev Interface of a contract containing identifier for Root role.
*/
interface IRoleContainerRoot {
/**
* @dev Returns Root role identifier.
*/
function ROOT_ROLE() external view returns (bytes32);
}
/**
* @dev Interface of a contract containing identifier for Admin role.
*/
interface IRoleContainerAdmin {
/**
* @dev Returns Admin role identifier.
*/
function ADMIN_ROLE() external view returns (bytes32);
}
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via _msgSender() and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
/**
* @dev Storage based implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract contract ERC165Storage is ERC165 {
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
}
/**
* @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, _msgSender()));
* ...
* }
* ```
*
* 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}.
*/
abstract contract AccessControl is Context, ERC165Storage, IAccessControl, IRoleContainerAdmin {
/**
* @dev Root Admin role identifier.
*/
bytes32 public constant ROOT_ROLE = "Root";
/**
* @dev Admin role identifier.
*/
bytes32 public constant ADMIN_ROLE = "Admin";
/**
* @dev Manager role identifier.
*/
bytes32 public constant MANAGER_ROLE = "Manager";
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
constructor() {
_registerInterface(type(IAccessControl).interfaceId);
_setupRole(ROOT_ROLE, _msgSender());
_setupRole(ADMIN_ROLE, _msgSender());
_setRoleAdmin(MANAGER_ROLE, ROOT_ROLE);
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @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`.
*/
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.toString(role)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) private {
_grantRole(role, account);
_setRoleAdmin(role, ROOT_ROLE);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
/**
* @dev Interface for contract which allows to pause and unpause the contract.
*/
interface IPausable {
/**
* @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);
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() external view returns (bool);
/**
* @dev Pauses the contract.
*/
function pause() external;
/**
* @dev Unpauses the contract.
*/
function unpause() external;
}
/**
* @dev Interface of a contract containing identifier for Pauser role.
*/
interface IRoleContainerPauser {
/**
* @dev Returns Pauser role identifier.
*/
function PAUSER_ROLE() external view returns (bytes32);
}
/**
* @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.
*/
contract Pausable is AccessControl, IPausable, IRoleContainerPauser {
/**
* @dev Pauser role identifier.
*/
bytes32 public constant PAUSER_ROLE = "Pauser";
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () {
_registerInterface(type(IPausable).interfaceId);
_setRoleAdmin(PAUSER_ROLE, ROOT_ROLE);
_paused = true;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
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());
}
/**
* @dev This function is called before pausing the contract.
* Override to add custom pausing conditions or actions.
*/
function _beforePause() internal virtual {
}
/**
* @dev This function is called before unpausing the contract.
* Override to add custom unpausing conditions or actions.
*/
function _beforeUnpause() internal virtual {
}
/**
* @dev Pauses the contract.
* Requirements:
* - Caller must have 'PAUSER_ROLE';
* - Contract must be unpaused.
*/
function pause() external onlyRole(PAUSER_ROLE) whenNotPaused {
_beforePause();
_pause();
}
/**
* @dev Unpauses the contract.
* Requirements:
* - Caller must have 'PAUSER_ROLE';
* - Contract must be unpaused;
*/
function unpause() external onlyRole(PAUSER_ROLE) whenPaused {
_beforeUnpause();
_unpause();
}
}
/**
* @dev Interface of a contract module which allows to withdraw assets.
*/
interface IWithdrawable {
/**
* @dev Emitted when network main currency withdrawal occurs.
*/
event Withdrawal(address to, string reason);
/**
* @dev Emitted when ERC20 asset withdrawal occurs.
*/
event WithdrawalERC20(address asset, address to, string reason);
/**
* @dev Emitted when ERC721 asset withdrawal occurs.
*/
event WithdrawalERC721(address asset, uint256[] ids, address to, string reason);
/**
* @dev Emitted when ERC1155 asset withdrawal occurs.
*/
event WithdrawalERC1155(address asset, uint256[] ids, address to, string reason);
/**
* @dev Withdraws all balance of the network main currency.
* Emits a {Withdrawal} event.
*/
function withdraw(address payable to, string calldata reason) external;
/**
* @dev Withdraws all balance of specified ERC20 asset.
* Emits a {WithdrawalERC20} event.
*/
function withdrawERC20(address asset, address to, string calldata reason) external;
/**
* @dev Withdraws all of specified ERC721 asset with ids.
* Emits a {WithdrawalERC721} event.
*/
function withdrawERC721(address asset, uint256[] calldata ids, address to, string calldata reason) external;
/**
* @dev Withdraws all balances of specified ERC1155 asset with ids.
* Emits a {WithdrawalERC1155} event.
*/
function withdrawERC1155(address asset, uint256[] calldata ids, address to, string calldata reason) external;
}
/**
* @dev Contract module which allows to perform basic checks on arguments.
*/
abstract contract RequirementsChecker {
uint256 internal constant inf = type(uint256).max;
function _requireNonZeroAddress(address _address, string memory paramName) internal pure {
require(_address != address(0), string(abi.encodePacked(paramName, ": cannot use zero address")));
}
function _requireArrayData(address[] memory _array, string memory paramName) internal pure {
require(_array.length != 0, string(abi.encodePacked(paramName, ": cannot be empty")));
}
function _requireArrayData(uint256[] memory _array, string memory paramName) internal pure {
require(_array.length != 0, string(abi.encodePacked(paramName, ": cannot be empty")));
}
function _requireStringData(string memory _string, string memory paramName) internal pure {
require(bytes(_string).length != 0, string(abi.encodePacked(paramName, ": cannot be empty")));
}
function _requireSameLengthArrays(address[] memory _array1, uint256[] memory _array2, string memory paramName1, string memory paramName2) internal pure {
require(_array1.length == _array2.length, string(abi.encodePacked(paramName1, ", ", paramName2, ": lengths must be equal")));
}
function _requireInRange(uint256 value, uint256 minValue, uint256 maxValue, string memory paramName) internal pure {
string memory maxValueString = maxValue == inf ? "inf" : Strings.toString(maxValue);
require(minValue <= value && (maxValue == inf || value <= maxValue), string(abi.encodePacked(paramName, ": must be in [", Strings.toString(minValue), "..", maxValueString, "] range")));
}
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers from ERC721 asset contracts.
*/
interface IERC721Receiver is IERC165 {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @dev Implementation of the {IERC721Receiver} interface.
*/
abstract contract ERC721Holder is ERC165Storage, IERC721Receiver {
constructor() {
_registerInterface(type(IERC721Receiver).interfaceId);
}
/**
* @dev See {IERC721Receiver-onERC721Received}.
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC721Received.selector;
}
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
/**
* @dev Interface of extension of {IERC165} that allows to handle receipts on receiving {IERC1155} assets.
*/
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. _msgSender())
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. _msgSender())
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
/**
* Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be stuck.
*/
contract ERC1155Holder is ERC165Storage, IERC1155Receiver {
constructor() {
_registerInterface(type(IERC1155Receiver).interfaceId);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transfered from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}
/**
* @dev Contract module which allows authorized account to withdraw assets in case of emergency.
*/
abstract contract Withdrawable is AccessControl, RequirementsChecker, ERC721Holder, ERC1155Holder, IWithdrawable {
constructor () {
_registerInterface(type(IWithdrawable).interfaceId);
}
/**
* @dev Withdraws all balance of the network main currency.
* Emits a {Withdrawal} event.
*/
function withdraw(address payable to, string calldata reason) external onlyRole(ADMIN_ROLE) {
_requireNonZeroAddress(to, "to");
_requireStringData(reason, "reason");
_beforeWithdrawal(to);
(bool success,) = to.call{value: address(this).balance}("");
require(success, "Withdraw failed");
emit Withdrawal(to, reason);
}
/**
* @dev Withdraws all balance of specified ERC20 asset.
* Emits a {WithdrawalERC20} event.
*/
function withdrawERC20(address asset, address to, string calldata reason) external onlyRole(ADMIN_ROLE) {
_requireNonZeroAddress(asset, "asset");
_requireNonZeroAddress(to, "to");
_requireStringData(reason, "reason");
_beforeWithdrawalERC20(asset, to);
IERC20 token = IERC20(asset);
token.transfer(to, token.balanceOf(address(this)));
emit WithdrawalERC20(asset, to, reason);
}
/**
* @dev Withdraws all of specified ERC721 asset with ids.
* Emits a {WithdrawalERC721} event.
*/
function withdrawERC721(address asset, uint256[] calldata ids, address to, string calldata reason) external onlyRole(ADMIN_ROLE) {
_requireNonZeroAddress(asset, "asset");
_requireNonZeroAddress(to, "to");
_requireArrayData(ids, "ids");
_requireStringData(reason, "reason");
_beforeWithdrawalERC721(asset, ids, to);
IERC721 token = IERC721(asset);
for(uint i = 0; i < ids.length; i++)
token.safeTransferFrom(address(this), to, ids[i], "");
emit WithdrawalERC721(asset, ids, to, reason);
}
/**
* @dev Withdraws all balances of specified ERC1155 asset with ids.
* Emits a {WithdrawalERC1155} event.
*/
function withdrawERC1155(address asset, uint256[] calldata ids, address to, string calldata reason) external onlyRole(ADMIN_ROLE) {
_requireNonZeroAddress(asset, "asset");
_requireNonZeroAddress(to, "to");
_requireArrayData(ids, "ids");
_requireStringData(reason, "reason");
_beforeWithdrawalERC1155(asset, ids, to);
IERC1155 token = IERC1155(asset);
address[] memory addresses = new address[](ids.length);
for(uint i = 0; i < ids.length; i++)
addresses[i] = address(this); // actually only this one, but multiple times to call balanceOfBatch
uint256[] memory balances = token.balanceOfBatch(addresses, ids);
token.safeBatchTransferFrom(address(this), to, ids, balances, "");
emit WithdrawalERC1155(asset, ids, to, reason);
}
/**
* @dev This function is called before withdrawal takes place.
* Override to add custom conditions or actions.
*/
function _beforeWithdrawal(address to) internal virtual {
}
/**
* @dev This function is called before ERC20 withdrawal takes place.
* Override to add custom conditions or actions.
*/
function _beforeWithdrawalERC20(address asset, address to) internal virtual {
}
/**
* @dev This function is called before ERC721 withdrawal takes place.
* Override to add custom conditions or actions.
*/
function _beforeWithdrawalERC721(address asset, uint256[] calldata ids, address to) internal virtual {
}
/**
* @dev This function is called before ERC1155 withdrawal takes place.
* Override to add custom conditions or actions.
*/
function _beforeWithdrawalERC1155(address asset, uint256[] calldata ids, address to) internal virtual {
}
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
/**
* @dev Partial interface for FearWolf contract (only what we need from it here).
*/
interface IFearWolf is IAccessControl {
function setInitialOwner(address initialOwner, uint256 wolvesCount) external;
function DISTRIBUTOR_ROLE() external view returns (bytes32);
}
/**
* @dev Contract for distribution FEAR Wolf NFT within INO Sale and public sale phases.
*/
contract FearWolfDistributor is AccessControl, Pausable, Withdrawable, ReentrancyGuard {
using SafeMath for uint256;
using Strings for uint256;
/**
* @dev Emitted when number of wolves an account can reserve on INO Sale is changed.
*/
event PresaleWolvesPerAccountLimitChanged(uint256 presaleWolvesPerAccountLimit);
/**
* @dev Emitted when number of wolves possible to mint in one call is changed.
*/
event BatchMintingLimitChanged(uint256 batchMintingLimit);
/**
* @dev Emitted when INO Sale / Public Sale start timestamps are changed.
*/
event DatesChanged(uint256 whitelistedPresaleStart, uint256 publicPresaleStart, uint256 saleStart, uint256 claimingStart);
/**
* @dev Emitted when prices are changed.
*/
event PricesChanged(uint256 presalePrice, uint256 salePriceMax, uint256 salePriceMin);
/**
* @dev Emitted when dutch auction parameters are changed.
*/
event DutchAuctionParametersChanged(uint256 dutchAuctionStep, uint256 dutchAuctionStepDuration);
/**
* @dev Emitted when wolves count is changed.
*/
event WolvesCountChanged(uint256 presaleWolvesCount, uint256 saleWolvesCount, uint256 giftWolvesCount);
/**
* @dev Emitted when FEAR Wolf contract address is set.
*/
event FearWolfContractAddressSet(address fearWolfContractAddress);
/**
* @dev Emitted when FEAR Wolf is reserved.
*/
event WolvesReserved(address indexed account, uint256 amount);
/**
* @dev Emitted when FEAR Wolf is claimed.
*/
event WolvesClaimed(address indexed account, uint256 amount);
/**
* @dev Emitted when FEAR Wolf is bought.
*/
event WolvesBought(address indexed account, uint256 price, uint256 amount);
/**
* @dev Emitted when FEAR Wolf is gifted.
*/
event WolvesGifted(address indexed account, uint256 amount);
/**
* @dev Number of wolves an account can reserve on INO Sale.
*/
uint256 public presaleWolvesPerAccountLimit = 5;
/**
* @dev Number of wolves available for minting at once.
*/
uint256 public batchMintingLimit = 10;
/**
* @dev Total numbers of wolves reserved during INO Sale.
*/
uint256 public totalWolvesReserved;
/**
* @dev Total numbers of wolves bought during Public Sale.
*/
uint256 public totalWolvesBought;
// Timestamps
uint256 public whitelistedPresaleStart;
uint256 public publicPresaleStart;
uint256 public saleStart;
uint256 public claimingStart;
// Prices in ETH
uint256 public presalePrice = 1 * 10 ** 17; // 0.10 ETH
uint256 public salePriceMax = 2 * 10 ** 17; // 0.20 ETH
uint256 public salePriceMin = 18 * 10 ** 16; // 0.18 ETH
// Dutch Auction - 0.001 ETH price drop every 2 hours, 40 hours totally
uint256 public dutchAuctionStep = 1 * 10 ** 15;
uint256 public dutchAuctionStepDuration = 2 hours;
// Wolves Counts
uint256 public initialPresaleWolvesCount = 2000;
uint256 public initialSaleWolvesCount = 4000;
uint256 private presaleWolvesCount = 2000;
uint256 private saleWolvesCount = 4000;
uint256 private giftWolvesCount = 66;
/**
* @dev FEAR Wolf contract address.
*/
address public fearWolfContractAddress;
IFearWolf private fearWolfContract;
// address => wolves reserved on INO Sale
mapping (address => uint256) private wolvesReserved;
// address => wolves bought on Public Sale
mapping (address => uint256) private wolvesBought;
// address => true for already claimed reserved wolves
mapping (address => bool) private claimed;
// address => true for whitelisted
mapping (address => bool) private whitelisted;
constructor() {
whitelistedPresaleStart = block.timestamp + 7 days;
publicPresaleStart = whitelistedPresaleStart + 4 days;
saleStart = whitelistedPresaleStart + 7 days;
claimingStart = whitelistedPresaleStart + 14 days;
}
function _beforeUnpause() internal view virtual override {
require(fearWolfContractAddress != address(0), "FEAR Wolf contract must be set before unpausing");
require(fearWolfContract.hasRole(fearWolfContract.DISTRIBUTOR_ROLE(), address(this)), "Distributor role missing");
}
/**
* @dev Returns whitelisted status for the caller.
* @return True if the caller is whitelisted, false - otherwise.
*/
function getMyWhitelistedStatus() external view returns (bool) {
return whitelisted[_msgSender()];
}
/**
* @dev Returns number of FEAR Wolves reserved for the caller.
* @return Number of FEAR Wolves.
*/
function getMyNumberOfWolvesReserved() external view returns (uint256) {
return wolvesReserved[_msgSender()];
}
/**
* @dev Returns number of FEAR Wolves claimed by the caller.
* @return Number of FEAR Wolves.
*/
function getMyNumberOfWolvesClaimed() external view returns (uint256) {
return claimed[_msgSender()] ? wolvesReserved[_msgSender()] : 0;
}
/**
* @dev Returns number of FEAR Wolves bought by the caller.
* @return Number of FEAR Wolves.
*/
function getMyNumberOfWolvesBought() external view returns (uint256) {
return wolvesBought[_msgSender()];
}
/**
* @dev Returns number of FEAR Wolves left available for reservation on INO Sale.
* @return Number of FEAR Wolves.
*/
function getPresaleWolvesAvailable() external view returns (uint256) {
if (block.timestamp < saleStart)
return presaleWolvesCount;
else
return 0;
}
/**
* @dev Returns number of FEAR Wolves left available for buying on Public Sale.
* @return Number of FEAR Wolves.
*/
function getPublicSaleWolvesAvailable() external view returns (uint256) {
if (block.timestamp < saleStart)
return saleWolvesCount;
else
return presaleWolvesCount + saleWolvesCount; // unsold INO Sale wolves are added to wolves available for sale
}
/**
* @dev Returns number of FEAR Wolves left available for gifting.
* @return Number of FEAR Wolves.
*/
function getGiftWolvesAvailable() external view returns (uint256) {
return giftWolvesCount;
}
/**
* @dev Returns current FEAR Wolf price in ETH for Public Sale.
* @return Amount of ETH.
*/
function getCurrentPrice() public view returns (uint256) {
if (block.timestamp < saleStart)
return salePriceMax;
uint256 stepsCount = (block.timestamp - saleStart) / dutchAuctionStepDuration;
if (stepsCount < (salePriceMax - salePriceMin) / dutchAuctionStep)
return salePriceMax - stepsCount * dutchAuctionStep;
else
return salePriceMin;
}
/**
* @dev Allows caller to reserve FEAR Wolf by paying ETH at INO Sale's price.
* @param wolvesCount Number of wolves to reserve.
* Requirements:
* - Contract must not be paused;
* - INO Sale phase must be active;
* - Unless Public INO Sale is active, user must be whitelisted to reserve a wolf;
* - Caller must be a wallet address and not a contract;
* - Number of wolves to reserve must be greater than zero;
* - Number of wolves to reserve must be less than or equal to wolves left available for reservation;
* - The sum of wolves to reserve and wolves reserved by the caller already must be less or equal to maximum allowed number of reserved wolves per account;
* - Sum of ETH sent must be exactly equal to INO Sale's price multiplied by number of wolves to reserve.
* Emits {WolvesReserved} event on success.
*/
function reserveWolves(uint256 wolvesCount) external payable whenNotPaused nonReentrant {
address caller = _msgSender();
require(block.timestamp >= whitelistedPresaleStart, "INO phase is not active yet");
require(block.timestamp < saleStart, "INO phase is over");
require(block.timestamp >= publicPresaleStart || whitelisted[caller], "Only whitelisted users can reserve a wolf now");
require(tx.origin == caller, "Contracts are not allowed");
require(wolvesCount > 0, "Cannot reserve zero wolves");
require(presaleWolvesCount >= wolvesCount, "Not enough wolves available for reservation");
require(wolvesReserved[caller] + wolvesCount <= presaleWolvesPerAccountLimit, "Amount of wolves to reserve exceeds INO wolves per account limit");
require(msg.value >= wolvesCount.mul(presalePrice), "Insufficient ETH sent");
require(msg.value <= wolvesCount.mul(presalePrice), "Too much ETH sent");
presaleWolvesCount -= wolvesCount;
totalWolvesReserved += wolvesCount;
wolvesReserved[caller] += wolvesCount;
emit WolvesReserved(caller, wolvesCount);
}
/**
* @dev Allows caller to claim reserved FEAR Wolf.
* Requirements:
* - Contract must not be paused;
* - Claiming phase must already started;
* - Caller must have at least one FEAR wolf reserved;
* - Caller have not claimed their FEAR wolves yet.
* Emits {WolvesClaimed} event on success.
*/
function claimWolves() external whenNotPaused nonReentrant {
address caller = _msgSender();
uint256 wolvesCount = wolvesReserved[caller];
require(block.timestamp >= claimingStart, "Claiming is not active yet");
require(wolvesCount > 0, "You don't have any wolves reserved");
require(!claimed[caller], "You have claimed your wolves already");
claimed[caller] = true;
fearWolfContract.setInitialOwner(caller, wolvesCount);
emit WolvesClaimed(caller, wolvesCount);
}
/**
* @dev Allows caller to buy FEAR Wolf during Public Sale phase.
* @param wolvesCount Number of wolves to buy.
* Requirements:
* - Contract must not be paused;
* - Public Sale phase must be active;
* - Caller must be a wallet address and not a contract;
* - Number of wolves to buy must be greater than zero;
* - Number of wolves to buy must be less than or equal to wolves left available for buying at Public Sale;
* - Number of wolves to buy must be less than or equal to number of wolves available for minting at once;
* - Sum of ETH sent must be greater or equal to current price (dutch auction takes place) multiplied by number of wolves to buy.
* Emits {WolvesBought} event on success.
*/
function buyWolves(uint256 wolvesCount) external payable whenNotPaused nonReentrant {
address caller = _msgSender();
uint256 price = getCurrentPrice();
require(block.timestamp >= saleStart, "Public sale is not active yet");
require(tx.origin == caller, "Contracts are not allowed");
require(wolvesCount > 0, "Cannot buy zero wolves");
require(presaleWolvesCount + saleWolvesCount >= wolvesCount, "Not enough wolves available for buying");
require(wolvesCount <= batchMintingLimit, string(abi.encodePacked("Cannot buy more than ", batchMintingLimit.toString(), " at once")));
require(msg.value >= wolvesCount.mul(price), "Insufficient ETH sent");
if (presaleWolvesCount > 0) {
// moving any wolves left after presale to public sale
saleWolvesCount += presaleWolvesCount;
presaleWolvesCount = 0;
}
saleWolvesCount -= wolvesCount;
totalWolvesBought += wolvesCount;
wolvesBought[caller] += wolvesCount;
fearWolfContract.setInitialOwner(caller, wolvesCount);
emit WolvesBought(caller, price, wolvesCount);
}
function setDates(uint256 _whitelistedPresaleStart, uint256 _publicPresaleStart, uint256 _saleStart, uint256 _claimingStart) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < whitelistedPresaleStart ||
(whitelistedPresaleStart == _whitelistedPresaleStart
&& publicPresaleStart == _publicPresaleStart), "Too late, presale is already active");
require(block.timestamp < saleStart, "Too late, sale is already active");
require((block.timestamp < _whitelistedPresaleStart || whitelistedPresaleStart == _whitelistedPresaleStart)
&& (block.timestamp < _publicPresaleStart || publicPresaleStart == _publicPresaleStart)
&& block.timestamp < _saleStart
&& block.timestamp < _claimingStart, "Cannot set timestamps to the past");
require(_whitelistedPresaleStart < _publicPresaleStart
&& _publicPresaleStart < _saleStart
&& _saleStart < _claimingStart, "Wrong timestamps order");
whitelistedPresaleStart = _whitelistedPresaleStart;
publicPresaleStart = _publicPresaleStart;
saleStart = _saleStart;
claimingStart = _claimingStart;
emit DatesChanged(whitelistedPresaleStart, publicPresaleStart, saleStart, claimingStart);
}
function setPrices(uint256 _presalePrice, uint256 _salePriceMax, uint256 _salePriceMin) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < whitelistedPresaleStart || _presalePrice == presalePrice, "Too late, presale is already active");
require(block.timestamp < saleStart, "Too late, sale is already active");
require(_salePriceMax >= _salePriceMin, "Wrong max/min sale prices order");
presalePrice = _presalePrice;
salePriceMax = _salePriceMax;
salePriceMin = _salePriceMin;
emit PricesChanged(presalePrice, salePriceMax, salePriceMin);
}
function setPresaleWolvesPerAccountLimit(uint256 _presaleWolvesPerAccountLimit) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < whitelistedPresaleStart, "Too late, presale is already active");
require(_presaleWolvesPerAccountLimit <= batchMintingLimit, "Cannot set presaleWolvesPerAccountLimit greater than batchMintingLimit");
presaleWolvesPerAccountLimit = _presaleWolvesPerAccountLimit;
emit PresaleWolvesPerAccountLimitChanged(presaleWolvesPerAccountLimit);
}
function setBatchMintingLimit(uint256 _batchMintingLimit) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < saleStart, "Too late, sale is already active");
require(presaleWolvesPerAccountLimit <= _batchMintingLimit, "Cannot set batchMintingLimit less than presaleWolvesPerAccountLimit");
batchMintingLimit = _batchMintingLimit;
emit BatchMintingLimitChanged(batchMintingLimit);
}
function setDutchAuctionParameters(uint256 _dutchAuctionStep, uint256 _dutchAuctionStepDuration) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < saleStart, "Too late, sale is already active");
dutchAuctionStep = _dutchAuctionStep;
dutchAuctionStepDuration = _dutchAuctionStepDuration;
emit DutchAuctionParametersChanged(dutchAuctionStep, dutchAuctionStepDuration);
}
function setWolvesCount(uint256 _presaleWolvesCount, uint256 _saleWolvesCount, uint256 _giftWolvesCount) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < whitelistedPresaleStart || initialPresaleWolvesCount == _presaleWolvesCount, "Too late, presale is already active");
require(block.timestamp < saleStart, "Too late, sale is already active");
presaleWolvesCount = _presaleWolvesCount;
initialPresaleWolvesCount = _presaleWolvesCount;
saleWolvesCount = _saleWolvesCount;
initialSaleWolvesCount = _saleWolvesCount;
giftWolvesCount = _giftWolvesCount;
emit WolvesCountChanged(presaleWolvesCount, saleWolvesCount, giftWolvesCount);
}
function setFearWolfContractAddress(address _address) external onlyRole(MANAGER_ROLE) {
require(block.timestamp < whitelistedPresaleStart, "Too late, presale is already active");
require(_address != address(0), "Cannot set zero address");
fearWolfContractAddress = _address;
fearWolfContract = IFearWolf(fearWolfContractAddress);
emit FearWolfContractAddressSet(fearWolfContractAddress);
}
function addWhitelistedAddress(address _address) external onlyRole(ADMIN_ROLE) {
whitelisted[_address] = true;
}
function addWhitelistedAddresses(address[] calldata _addresses) external onlyRole(ADMIN_ROLE) {
for (uint i = 0; i < _addresses.length; i++)
whitelisted[_addresses[i]] = true;
}
function giftWolves(address _address, uint256 wolvesCount) external whenNotPaused nonReentrant onlyRole(ADMIN_ROLE) {
require(giftWolvesCount >= wolvesCount, "Not enough wolves left to gift");
require(wolvesCount <= batchMintingLimit, string(abi.encodePacked("Cannot gift more than ", batchMintingLimit.toString(), " at once")));
giftWolvesCount -= wolvesCount;
fearWolfContract.setInitialOwner(_address, wolvesCount);
emit WolvesGifted(_address, wolvesCount);
}
}Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "london",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.