Feature Tip: Add private address tag to any address under My Name Tag !
ERC-721
NFT
Overview
Max Total Supply
411 EYEC
Holders
124
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Balance
1 EYECLoading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
Eyecons
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/common/ERC2981.sol) pragma solidity ^0.8.0; import "../../interfaces/IERC2981.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. * * _Available since v4.5._ */ abstract contract ERC2981 is IERC2981, ERC165 { struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } RoyaltyInfo private _defaultRoyaltyInfo; mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981 */ function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual override returns (address, uint256) { RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId]; if (royalty.receiver == address(0)) { royalty = _defaultRoyaltyInfo; } uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: invalid receiver"); _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Removes default royalty information. */ function _deleteDefaultRoyalty() internal virtual { delete _defaultRoyaltyInfo; } /** * @dev Sets the royalty information for a specific token id, overriding the global default. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice"); require(receiver != address(0), "ERC2981: Invalid parameters"); _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Resets royalty information for the token id back to the global default. */ function _resetTokenRoyalty(uint256 tokenId) internal virtual { delete _tokenRoyaltyInfo[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.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; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ 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)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ 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"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @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"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.20; import "operator-filter-registry/src/DefaultOperatorFilterer.sol"; import "@openzeppelin/contracts/token/common/ERC2981.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./interfaces/IEyecons.sol"; contract Eyecons is IEyecons, DefaultOperatorFilterer, ERC2981, ERC721Enumerable, Ownable, ReentrancyGuard { using SafeERC20 for IERC20Metadata; using ECDSA for bytes32; using SafeCast for int256; using Address for address payable; using Counters for Counters.Counter; uint256 public constant ONE_YEAR = 365 days; uint256 private constant DECIMALS = 18; uint96 public constant MAXIMUM_ROYALTY_PERCENTAGE = 1000; uint96 public constant MINIMUM_ROYALTY_PERCENTAGE = 100; uint256 public immutable maximumSupply; uint256 public tokenPrice; uint256 public subscriptionPrice; uint256 public availableAmountToMint; uint256 private _nextTokenId; address public authorizer; address payable public treasury; string public baseURI; bool public publicPeriodEnabled; bool public tradingEnabled; IERC20Metadata public immutable tether; AggregatorV3Interface public immutable priceOracle; Counters.Counter private _signatureId; mapping(uint256 => uint256) public subscriptionExpirationTimeByTokenId; mapping(bytes => bool) public notUniqueSignature; /// @param maximumSupply_ Maximum supply. /// @param tokenPrice_ Minting price per token. /// @param subscriptionPrice_ Subscription price per token. /// @param authorizer_ Authorizer address. /// @param treasury_ Treasury address. /// @param baseURI_ Base URI. /// @param tether_ Tether USD contract address. /// @param priceOracle_ ETH/USD price oracle contract address. constructor( uint256 maximumSupply_, uint256 tokenPrice_, uint256 subscriptionPrice_, address authorizer_, address payable treasury_, string memory baseURI_, IERC20Metadata tether_, AggregatorV3Interface priceOracle_ ) ERC721("EYECONS", "EYEC") { maximumSupply = maximumSupply_; tokenPrice = tokenPrice_; subscriptionPrice = subscriptionPrice_; _nextTokenId = 1; authorizer = authorizer_; treasury = treasury_; baseURI = baseURI_; tether = tether_; priceOracle = priceOracle_; _setDefaultRoyalty(treasury_, MAXIMUM_ROYALTY_PERCENTAGE); } /// @inheritdoc IEyecons function enablePublicPeriod() external onlyOwner { emit PublicPeriodEnabled(); publicPeriodEnabled = true; } /// @inheritdoc IEyecons function enableTrading() external onlyOwner { emit TradingEnabled(); tradingEnabled = true; } /// @inheritdoc IEyecons function updateDefaultRoyalty(uint96 percentage_) external onlyOwner { if (percentage_ < MINIMUM_ROYALTY_PERCENTAGE || percentage_ > MAXIMUM_ROYALTY_PERCENTAGE) { revert InvalidRoyaltyPercentage(percentage_); } _deleteDefaultRoyalty(); _setDefaultRoyalty(treasury, percentage_); emit DefaultRoyaltyUpdated(percentage_); } /// @inheritdoc IEyecons function updateAuthorizer(address authorizer_) external onlyOwner { emit AuthorizerUpdated(authorizer, authorizer_); authorizer = authorizer_; } /// @inheritdoc IEyecons function updateTreasury(address payable treasury_) external onlyOwner { emit TreasuryUpdated(treasury, treasury_); treasury = treasury_; } /// @inheritdoc IEyecons function updateBaseURI(string calldata baseURI_) external onlyOwner { emit BaseURIUpdated(baseURI, baseURI_); baseURI = baseURI_; } /// @inheritdoc IEyecons function updatePrices(uint256 tokenPrice_, uint256 subscriptionPrice_) external onlyOwner { emit TokenPriceUpdated(tokenPrice, tokenPrice_); tokenPrice = tokenPrice_; emit SubscriptionPriceUpdated(subscriptionPrice, subscriptionPrice_); subscriptionPrice = subscriptionPrice_; } /// @inheritdoc IEyecons function increaseAvailableAmountToMint(uint256 amount_) external onlyOwner { uint256 m_availableAmountToMint = availableAmountToMint; if ( totalSupply() + amount_ > maximumSupply || m_availableAmountToMint + amount_ > maximumSupply ) { revert InvalidAmountToIncrease(); } unchecked { availableAmountToMint += amount_; emit AvailableAmountToMintIncreased( m_availableAmountToMint, m_availableAmountToMint + amount_, amount_ ); } } /// @inheritdoc IEyecons function decreaseAvailableAmountToMint(uint256 amount_) external onlyOwner { uint256 m_availableAmountToMint = availableAmountToMint; availableAmountToMint -= amount_; unchecked { emit AvailableAmountToMintDecreased( m_availableAmountToMint, m_availableAmountToMint - amount_, amount_ ); } } /// @inheritdoc IEyecons function mint( address paymentCurrency_, uint256 amount_, bytes calldata signature_ ) external payable nonReentrant { if (amount_ > availableAmountToMint || amount_ == 0) { revert InvalidAmountToMint(); } if (!publicPeriodEnabled) { if (notUniqueSignature[signature_]) { revert NotUniqueSignature(signature_); } bytes32 hash = keccak256(abi.encode(msg.sender, amount_, _signatureId.current())); if (hash.toEthSignedMessageHash().recover(signature_) != authorizer) { revert InvalidSignature(signature_); } _signatureId.increment(); notUniqueSignature[signature_] = true; } _processPayment(paymentCurrency_, amount_, false); uint256 m_nextTokenId = _nextTokenId; for (uint256 i = 0; i < amount_; ) { _safeMint(msg.sender, m_nextTokenId); unchecked { subscriptionExpirationTimeByTokenId[m_nextTokenId] = block.timestamp + ONE_YEAR; m_nextTokenId++; i++; } } _nextTokenId = m_nextTokenId; unchecked { availableAmountToMint -= amount_; } } /// @inheritdoc IEyecons function renewSubscription( address paymentCurrency_, uint256[] calldata tokenIds_ ) external nonReentrant { for (uint256 i = 0; i < tokenIds_.length; i++) { if (!_exists(tokenIds_[i])) { revert NonExistentToken(tokenIds_[i]); } uint256 subscriptionExpirationTime = subscriptionExpirationTimeByTokenId[tokenIds_[i]]; unchecked { if (block.timestamp < subscriptionExpirationTime) { revert TooEarlyRenewal(tokenIds_[i], subscriptionExpirationTime - block.timestamp); } subscriptionExpirationTimeByTokenId[tokenIds_[i]] = block.timestamp + ONE_YEAR; } } _processPayment(paymentCurrency_, tokenIds_.length, true); emit SubscriptionsRenewed(msg.sender, tokenIds_); } /// @inheritdoc IEyecons function subscriptionStatus( uint256 tokenId_ ) external view returns ( bool isSubscriptionActive_, uint256 remainingSubscriptionTime_ ) { if (!_exists(tokenId_)) { revert NonExistentToken(tokenId_); } uint256 subscriptionExpirationTime = subscriptionExpirationTimeByTokenId[tokenId_]; if (block.timestamp < subscriptionExpirationTime) { unchecked { return (true, subscriptionExpirationTime - block.timestamp); } } else { return (false, 0); } } /// @inheritdoc IEyecons function currentSignatureId() external view returns (uint256) { return _signatureId.current(); } /// @inheritdoc ERC721 function setApprovalForAll( address operator_, bool approved_ ) public override(IERC721, ERC721) onlyAllowedOperatorApproval(operator_) { super.setApprovalForAll(operator_, approved_); } /// @inheritdoc ERC721 function approve( address operator_, uint256 tokenId_ ) public override(IERC721, ERC721) onlyAllowedOperatorApproval(operator_) { super.approve(operator_, tokenId_); } /// @inheritdoc ERC721 function transferFrom( address from_, address to_, uint256 tokenId_ ) public override(IERC721, ERC721) onlyAllowedOperator(from_) { super.transferFrom(from_, to_, tokenId_); } /// @inheritdoc ERC721 function safeTransferFrom( address from_, address to_, uint256 tokenId_ ) public override(IERC721, ERC721) onlyAllowedOperator(from_) { super.safeTransferFrom(from_, to_, tokenId_); } /// @inheritdoc ERC721 function safeTransferFrom( address from_, address to_, uint256 tokenId_, bytes memory data_ ) public override(IERC721, ERC721) onlyAllowedOperator(from_) { super.safeTransferFrom(from_, to_, tokenId_, data_); } /// @inheritdoc IERC165 function supportsInterface( bytes4 interfaceId_ ) public view override(ERC721Enumerable, ERC2981) returns (bool) { return super.supportsInterface(interfaceId_); } /// @inheritdoc ERC721 function _beforeTokenTransfer( address from_, address to_, uint256 firstTokenId_, uint256 batchSize_ ) internal override { if (!tradingEnabled && from_ != address(0)) { revert ForbiddenToTransferTokens(); } super._beforeTokenTransfer(from_, to_, firstTokenId_, batchSize_); } /// @inheritdoc ERC721 function _baseURI() internal view override returns (string memory) { return baseURI; } /// @notice Processes the payment for minting and/or subscription renewal. /// @param paymentCurrency_ Payment currency address /// (should be zero if the payment is supposed to be made in native currency). /// @param amount_ Amount of tokens. /// @param isSubscriptionRenewal_ Boolean value indicating whether the operation corresponds to minting or subscription renewal. function _processPayment(address paymentCurrency_, uint256 amount_, bool isSubscriptionRenewal_) private { unchecked { uint256 price; if (isSubscriptionRenewal_) { price = subscriptionPrice * amount_; } else { price = (tokenPrice + subscriptionPrice) * amount_; } if (paymentCurrency_ == address(tether)) { if (msg.value > 0) { revert NonZeroMsgValue(); } tether.safeTransferFrom(msg.sender, treasury, price / 10 ** (DECIMALS - tether.decimals())); } else if (paymentCurrency_ == address(0)) { (, int256 answer, , ,) = priceOracle.latestRoundData(); uint256 castedAnswer = answer.toUint256(); uint256 adjustmentFactor = 10 ** (DECIMALS - priceOracle.decimals()); uint256 actualPrice = msg.value * castedAnswer * adjustmentFactor / 1 ether; if (actualPrice < price) { revert InsufficientPrice(price - actualPrice); } else { uint256 nativeCurrencyPrice = price * 1 ether / (castedAnswer * adjustmentFactor); treasury.sendValue(nativeCurrencyPrice); if (msg.value > nativeCurrencyPrice) { payable(msg.sender).sendValue(msg.value - nativeCurrencyPrice); } } } else { revert InvalidPaymentCurrency(); } } } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.20; import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; interface IEyecons { error InvalidRoyaltyPercentage(uint256 invalidPercentage); error InvalidAmountToIncrease(); error InvalidAmountToMint(); error NotUniqueSignature(bytes notUniqueSignature); error InvalidSignature(bytes invalidSignature); error NonExistentToken(uint256 tokenId); error TooEarlyRenewal(uint256 tokenId, uint256 remainingSubscriptionTime); error ForbiddenToTransferTokens(); error NonZeroMsgValue(); error InsufficientPrice(uint256 difference); error InvalidPaymentCurrency(); event PublicPeriodEnabled(); event TradingEnabled(); event DefaultRoyaltyUpdated(uint96 indexed newPercentage); event AuthorizerUpdated(address indexed oldAuthorizer, address indexed newAuthorizer); event TreasuryUpdated(address indexed oldTreasury, address indexed newTreasury); event BaseURIUpdated(string indexed oldBaseURI, string indexed newBaseURI); event TokenPriceUpdated(uint256 indexed oldTokenPrice, uint256 indexed newTokenPrice); event SubscriptionPriceUpdated(uint256 indexed oldSubscriptionPrice, uint256 indexed newSubscriptionPrice); event AvailableAmountToMintIncreased( uint256 indexed oldAvailableAmountToMint, uint256 indexed newAvailableAmountToMint, uint256 indexed difference ); event AvailableAmountToMintDecreased( uint256 indexed oldAvailableAmountToMint, uint256 indexed newAvailableAmountToMint, uint256 indexed difference ); event SubscriptionsRenewed(address indexed renewedBy, uint256[] indexed tokenIds); /// @notice Enables the public period for minting. function enablePublicPeriod() external; /// @notice Enables tokens trading. function enableTrading() external; /// @notice Updates default royalty config for all tokens. /// @param percentage_ New royalty percentage. function updateDefaultRoyalty(uint96 percentage_) external; /// @notice Updates the authorizer. /// @param authorizer_ New authorizer address. function updateAuthorizer(address authorizer_) external; /// @notice Updates the treasury. /// @param treasury_ New treasury address. function updateTreasury(address payable treasury_) external; /// @notice Updates the base URI. /// @param baseURI_ New base URI. function updateBaseURI(string calldata baseURI_) external; /// @notice Updates the token price or/and the subscription price. /// @param tokenPrice_ New minting price per token. /// @param subscriptionPrice_ New subscription price per token. function updatePrices(uint256 tokenPrice_, uint256 subscriptionPrice_) external; /// @notice Increases the available amount of tokens to mint. /// @param amount_ Amount to increase. function increaseAvailableAmountToMint(uint256 amount_) external; /// @notice Decreases the available amount of tokens to mint. /// @param amount_ Amount to decrease. function decreaseAvailableAmountToMint(uint256 amount_) external; /// @notice Mints `amount_` tokens to the caller. /// @param paymentCurrency_ Payment currency address /// (should be zero if the payment is supposed to be made in a native currency). /// @param amount_ Amount of tokens to mint. /// @param signature_ Signature hash. function mint( address paymentCurrency_, uint256 amount_, bytes calldata signature_ ) external payable; /// @notice Renews subscription for token ids. /// @param paymentCurrency_ Payment currency address /// (should be zero if the payment is supposed to be made in a native currency). /// @param tokenIds_ Token ids for which the subscription is renewed. function renewSubscription(address paymentCurrency_, uint256[] calldata tokenIds_) external; /// @notice Retrieves the subscription status for token id. /// @param tokenId_ Token id. /// @return isSubscriptionActive_ Boolean value indicating whether the subscription is active. /// @return remainingSubscriptionTime_ Remaining subscription time value in seconds. function subscriptionStatus( uint256 tokenId_ ) external view returns ( bool isSubscriptionActive_, uint256 remainingSubscriptionTime_ ); /// @notice Retrieves the current _signatureId value. /// @return Current _signatureId value. function currentSignatureId() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {OperatorFilterer} from "./OperatorFilterer.sol"; import {CANONICAL_CORI_SUBSCRIPTION} from "./lib/Constants.sol"; /** * @title DefaultOperatorFilterer * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription. * @dev Please note that if your token contract does not provide an owner with EIP-173, it must provide * administration methods on the contract itself to interact with the registry otherwise the subscription * will be locked to the options set during construction. */ abstract contract DefaultOperatorFilterer is OperatorFilterer { /// @dev The constructor that is called when the contract is being deployed. constructor() OperatorFilterer(CANONICAL_CORI_SUBSCRIPTION, true) {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface IOperatorFilterRegistry { /** * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns * true if supplied registrant address is not registered. */ function isOperatorAllowed(address registrant, address operator) external view returns (bool); /** * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner. */ function register(address registrant) external; /** * @notice Registers an address with the registry and "subscribes" to another address's filtered operators and codeHashes. */ function registerAndSubscribe(address registrant, address subscription) external; /** * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another * address without subscribing. */ function registerAndCopyEntries(address registrant, address registrantToCopy) external; /** * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner. * Note that this does not remove any filtered addresses or codeHashes. * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes. */ function unregister(address addr) external; /** * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered. */ function updateOperator(address registrant, address operator, bool filtered) external; /** * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates. */ function updateOperators(address registrant, address[] calldata operators, bool filtered) external; /** * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered. */ function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external; /** * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates. */ function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external; /** * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous * subscription if present. * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case, * subscriptions will not be forwarded. Instead the former subscription's existing entries will still be * used. */ function subscribe(address registrant, address registrantToSubscribe) external; /** * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes. */ function unsubscribe(address registrant, bool copyExistingEntries) external; /** * @notice Get the subscription address of a given registrant, if any. */ function subscriptionOf(address addr) external returns (address registrant); /** * @notice Get the set of addresses subscribed to a given registrant. * Note that order is not guaranteed as updates are made. */ function subscribers(address registrant) external returns (address[] memory); /** * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant. * Note that order is not guaranteed as updates are made. */ function subscriberAt(address registrant, uint256 index) external returns (address); /** * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr. */ function copyEntriesOf(address registrant, address registrantToCopy) external; /** * @notice Returns true if operator is filtered by a given address or its subscription. */ function isOperatorFiltered(address registrant, address operator) external returns (bool); /** * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription. */ function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool); /** * @notice Returns true if a codeHash is filtered by a given address or its subscription. */ function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool); /** * @notice Returns a list of filtered operators for a given address or its subscription. */ function filteredOperators(address addr) external returns (address[] memory); /** * @notice Returns the set of filtered codeHashes for a given address or its subscription. * Note that order is not guaranteed as updates are made. */ function filteredCodeHashes(address addr) external returns (bytes32[] memory); /** * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or * its subscription. * Note that order is not guaranteed as updates are made. */ function filteredOperatorAt(address registrant, uint256 index) external returns (address); /** * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or * its subscription. * Note that order is not guaranteed as updates are made. */ function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32); /** * @notice Returns true if an address has registered */ function isRegistered(address addr) external returns (bool); /** * @dev Convenience method to compute the code hash of an arbitrary contract */ function codeHashOf(address addr) external returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; address constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E; address constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol"; import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS} from "./lib/Constants.sol"; /** * @title OperatorFilterer * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another * registrant's entries in the OperatorFilterRegistry. * @dev This smart contract is meant to be inherited by token contracts so they can use the following: * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods. * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods. * Please note that if your token contract does not provide an owner with EIP-173, it must provide * administration methods on the contract itself to interact with the registry otherwise the subscription * will be locked to the options set during construction. */ abstract contract OperatorFilterer { /// @dev Emitted when an operator is not allowed. error OperatorNotAllowed(address operator); IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY = IOperatorFilterRegistry(CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS); /// @dev The constructor that is called when the contract is being deployed. constructor(address subscriptionOrRegistrantToCopy, bool subscribe) { // If an inheriting token contract is deployed to a network without the registry deployed, the modifier // will not revert, but the contract will need to be registered with the registry once it is deployed in // order for the modifier to filter addresses. if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { if (subscribe) { OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy); } else { if (subscriptionOrRegistrantToCopy != address(0)) { OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy); } else { OPERATOR_FILTER_REGISTRY.register(address(this)); } } } } /** * @dev A helper function to check if an operator is allowed. */ modifier onlyAllowedOperator(address from) virtual { // Allow spending tokens from addresses with balance // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred // from an EOA. if (from != msg.sender) { _checkFilterOperator(msg.sender); } _; } /** * @dev A helper function to check if an operator approval is allowed. */ modifier onlyAllowedOperatorApproval(address operator) virtual { _checkFilterOperator(operator); _; } /** * @dev A helper function to check if an operator is allowed. */ function _checkFilterOperator(address operator) internal view virtual { // Check registry code length to facilitate testing in environments without a deployed registry. if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { // under normal circumstances, this function will revert rather than return false, but inheriting contracts // may specify their own OperatorFilterRegistry implementations, which may behave differently if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) { revert OperatorNotAllowed(operator); } } } }
{ "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":"uint256","name":"maximumSupply_","type":"uint256"},{"internalType":"uint256","name":"tokenPrice_","type":"uint256"},{"internalType":"uint256","name":"subscriptionPrice_","type":"uint256"},{"internalType":"address","name":"authorizer_","type":"address"},{"internalType":"address payable","name":"treasury_","type":"address"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"contract IERC20Metadata","name":"tether_","type":"address"},{"internalType":"contract AggregatorV3Interface","name":"priceOracle_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ForbiddenToTransferTokens","type":"error"},{"inputs":[{"internalType":"uint256","name":"difference","type":"uint256"}],"name":"InsufficientPrice","type":"error"},{"inputs":[],"name":"InvalidAmountToIncrease","type":"error"},{"inputs":[],"name":"InvalidAmountToMint","type":"error"},{"inputs":[],"name":"InvalidPaymentCurrency","type":"error"},{"inputs":[{"internalType":"uint256","name":"invalidPercentage","type":"uint256"}],"name":"InvalidRoyaltyPercentage","type":"error"},{"inputs":[{"internalType":"bytes","name":"invalidSignature","type":"bytes"}],"name":"InvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"NonExistentToken","type":"error"},{"inputs":[],"name":"NonZeroMsgValue","type":"error"},{"inputs":[{"internalType":"bytes","name":"notUniqueSignature","type":"bytes"}],"name":"NotUniqueSignature","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"OperatorNotAllowed","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"remainingSubscriptionTime","type":"uint256"}],"name":"TooEarlyRenewal","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAuthorizer","type":"address"},{"indexed":true,"internalType":"address","name":"newAuthorizer","type":"address"}],"name":"AuthorizerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldAvailableAmountToMint","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newAvailableAmountToMint","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"difference","type":"uint256"}],"name":"AvailableAmountToMintDecreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldAvailableAmountToMint","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newAvailableAmountToMint","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"difference","type":"uint256"}],"name":"AvailableAmountToMintIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"oldBaseURI","type":"string"},{"indexed":true,"internalType":"string","name":"newBaseURI","type":"string"}],"name":"BaseURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint96","name":"newPercentage","type":"uint96"}],"name":"DefaultRoyaltyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"PublicPeriodEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldSubscriptionPrice","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newSubscriptionPrice","type":"uint256"}],"name":"SubscriptionPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"renewedBy","type":"address"},{"indexed":true,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"SubscriptionsRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"oldTokenPrice","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"newTokenPrice","type":"uint256"}],"name":"TokenPriceUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"TradingEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldTreasury","type":"address"},{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryUpdated","type":"event"},{"inputs":[],"name":"MAXIMUM_ROYALTY_PERCENTAGE","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_ROYALTY_PERCENTAGE","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONE_YEAR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_FILTER_REGISTRY","outputs":[{"internalType":"contract IOperatorFilterRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator_","type":"address"},{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"authorizer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"availableAmountToMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentSignatureId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"decreaseAvailableAmountToMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enablePublicPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"increaseAvailableAmountToMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"paymentCurrency_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"bytes","name":"signature_","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"notUniqueSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOracle","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicPeriodEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"paymentCurrency_","type":"address"},{"internalType":"uint256[]","name":"tokenIds_","type":"uint256[]"}],"name":"renewSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator_","type":"address"},{"internalType":"bool","name":"approved_","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"subscriptionExpirationTimeByTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"subscriptionPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"subscriptionStatus","outputs":[{"internalType":"bool","name":"isSubscriptionActive_","type":"bool"},{"internalType":"uint256","name":"remainingSubscriptionTime_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId_","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tether","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"authorizer_","type":"address"}],"name":"updateAuthorizer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"}],"name":"updateBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"percentage_","type":"uint96"}],"name":"updateDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenPrice_","type":"uint256"},{"internalType":"uint256","name":"subscriptionPrice_","type":"uint256"}],"name":"updatePrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"treasury_","type":"address"}],"name":"updateTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60e060405234801562000010575f80fd5b50604051620041763803806200417683398101604081905262000033916200041a565b6040805180820182526007815266455945434f4e5360c81b602080830191909152825180840190935260048352634559454360e01b9083015290733cc6cdda760b79bafa08df41ecfa224f810dceb660016daaeb6d7670e522a718067333cd4e3b15620001bf5780156200011257604051633e9f1edf60e11b81523060048201526001600160a01b03831660248201526daaeb6d7670e522a718067333cd4e90637d3e3dbe906044015b5f604051808303815f87803b158015620000f5575f80fd5b505af115801562000108573d5f803e3d5ffd5b50505050620001bf565b6001600160a01b03821615620001635760405163a0af290360e01b81523060048201526001600160a01b03831660248201526daaeb6d7670e522a718067333cd4e9063a0af290390604401620000dd565b604051632210724360e11b81523060048201526daaeb6d7670e522a718067333cd4e90634420e486906024015f604051808303815f87803b158015620001a7575f80fd5b505af1158015620001ba573d5f803e3d5ffd5b505050505b5060029050620001d08382620005de565b506003620001df8282620005de565b505050620001fc620001f66200028360201b60201c565b62000287565b6001600d8190556080899052600e889055600f879055601155601280546001600160a01b038088166001600160a01b03199283161790925560138054928716929091169190911790556014620002538482620005de565b506001600160a01b0380831660a052811660c05262000275846103e8620002d8565b5050505050505050620006a6565b3390565b600c80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6127106001600160601b03821611156200034c5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b60648201526084015b60405180910390fd5b6001600160a01b038216620003a45760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c696420726563656976657200000000000000604482015260640162000343565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b909102175f55565b6001600160a01b0381168114620003f1575f80fd5b50565b634e487b7160e01b5f52604160045260245ffd5b80516200041581620003dc565b919050565b5f805f805f805f80610100898b03121562000433575f80fd5b885197506020808a0151975060408a0151965060608a01516200045681620003dc565b60808b01519096506200046981620003dc565b60a08b01519095506001600160401b038082111562000486575f80fd5b818c0191508c601f8301126200049a575f80fd5b815181811115620004af57620004af620003f4565b604051601f8201601f19908116603f01168101908382118183101715620004da57620004da620003f4565b816040528281528f86848701011115620004f2575f80fd5b5f93505b82841015620005155784840186015181850187015292850192620004f6565b5f8684830101528098505050505050506200053360c08a0162000408565b91506200054360e08a0162000408565b90509295985092959890939650565b600181811c908216806200056757607f821691505b6020821081036200058657634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620005d9575f81815260208120601f850160051c81016020861015620005b45750805b601f850160051c820191505b81811015620005d557828155600101620005c0565b5050505b505050565b81516001600160401b03811115620005fa57620005fa620003f4565b62000612816200060b845462000552565b846200058c565b602080601f83116001811462000648575f8415620006305750858301515b5f19600386901b1c1916600185901b178555620005d5565b5f85815260208120601f198616915b82811015620006785788860151825594840194600190910190840162000657565b50858210156200069657878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c051613a74620007025f395f818161044601528181611c360152611cc901525f81816105df01528181611ae601528181611b570152611bf601525f8181610308015281816111f2015261122e0152613a745ff3fe6080604052600436106102bf575f3560e01c806370a082311161016f578063a2506af7116100d8578063d94827ea11610092578063e89cb7c41161006d578063e89cb7c4146108aa578063e985e9c5146108c9578063ef88d7f014610910578063f2fde38b1461092f575f80fd5b8063d94827ea14610858578063e0a665781461086c578063e6be6d6f1461088b575f80fd5b8063a2506af7146107ae578063ab79e3aa146107cd578063b88d4fde146107e6578063bdc8e54c14610805578063c87b56dd1461081a578063d09edf3114610839575f80fd5b80638da5cb5b116101295780638da5cb5b14610701578063931688cb1461071e57806394d008ef1461073d57806395d89b4114610750578063a02d164e14610764578063a22cb4651461078f575f80fd5b806370a0823114610672578063713c052f14610691578063715018a6146106a55780637f51bb1f146106b95780637ff9b596146106d85780638a8c523c146106ed575f80fd5b806332f4f16e1161022b5780634f6ccce7116101e557806361d027b3116101c057806361d027b3146106015780636352211e146106205780636c0360eb1461063f5780636d595f8814610653575f80fd5b80634f6ccce71461059b57806352e6d740146105ba5780635efc071a146105ce575f80fd5b806332f4f16e146104c557806341a34011146104da57806341f434341461050757806342842e0e14610528578063492f8724146105475780634ada218b1461057d575f80fd5b806318160ddd1161027c57806318160ddd146103c8578063236c5baf146103dc57806323b872dd146104165780632630c12f146104355780632a55205a146104685780632f745c59146104a6575f80fd5b806301ffc9a7146102c35780630480e58b146102f757806306fdde0314610338578063081812fc14610359578063095ea7b31461039057806316d3bfbb146103b1575b5f80fd5b3480156102ce575f80fd5b506102e26102dd3660046130bc565b61094e565b60405190151581526020015b60405180910390f35b348015610302575f80fd5b5061032a7f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020016102ee565b348015610343575f80fd5b5061034c61095e565b6040516102ee9190613124565b348015610364575f80fd5b50610378610373366004613136565b6109ee565b6040516001600160a01b0390911681526020016102ee565b34801561039b575f80fd5b506103af6103aa366004613161565b610a13565b005b3480156103bc575f80fd5b5061032a6301e1338081565b3480156103d3575f80fd5b50600a5461032a565b3480156103e7575f80fd5b506102e26103f6366004613228565b805160208183018101805160188252928201919093012091525460ff1681565b348015610421575f80fd5b506103af61043036600461325a565b610a2c565b348015610440575f80fd5b506103787f000000000000000000000000000000000000000000000000000000000000000081565b348015610473575f80fd5b50610487610482366004613298565b610a57565b604080516001600160a01b0390931683526020830191909152016102ee565b3480156104b1575f80fd5b5061032a6104c0366004613161565b610b02565b3480156104d0575f80fd5b5061032a60105481565b3480156104e5575f80fd5b506104ef6103e881565b6040516001600160601b0390911681526020016102ee565b348015610512575f80fd5b506103786daaeb6d7670e522a718067333cd4e81565b348015610533575f80fd5b506103af61054236600461325a565b610b9b565b348015610552575f80fd5b50610566610561366004613136565b610bc0565b6040805192151583526020830191909152016102ee565b348015610588575f80fd5b506015546102e290610100900460ff1681565b3480156105a6575f80fd5b5061032a6105b5366004613136565b610c28565b3480156105c5575f80fd5b506104ef606481565b3480156105d9575f80fd5b506103787f000000000000000000000000000000000000000000000000000000000000000081565b34801561060c575f80fd5b50601354610378906001600160a01b031681565b34801561062b575f80fd5b5061037861063a366004613136565b610cb8565b34801561064a575f80fd5b5061034c610d17565b34801561065e575f80fd5b506103af61066d366004613136565b610da3565b34801561067d575f80fd5b5061032a61068c3660046132b8565b610df6565b34801561069c575f80fd5b506103af610e7a565b3480156106b0575f80fd5b506103af610eb9565b3480156106c4575f80fd5b506103af6106d33660046132b8565b610ecc565b3480156106e3575f80fd5b5061032a600e5481565b3480156106f8575f80fd5b506103af610f2f565b34801561070c575f80fd5b50600c546001600160a01b0316610378565b348015610729575f80fd5b506103af610738366004613311565b610f70565b6103af61074b366004613350565b610fdb565b34801561075b575f80fd5b5061034c6111c2565b34801561076f575f80fd5b5061032a61077e366004613136565b60176020525f908152604090205481565b34801561079a575f80fd5b506103af6107a93660046133b5565b6111d1565b3480156107b9575f80fd5b506103af6107c8366004613136565b6111e5565b3480156107d8575f80fd5b506015546102e29060ff1681565b3480156107f1575f80fd5b506103af6108003660046133ec565b6112b3565b348015610810575f80fd5b5061032a600f5481565b348015610825575f80fd5b5061034c610834366004613136565b6112e0565b348015610844575f80fd5b50601254610378906001600160a01b031681565b348015610863575f80fd5b5061032a611344565b348015610877575f80fd5b506103af6108863660046132b8565b611353565b348015610896575f80fd5b506103af6108a5366004613454565b6113b6565b3480156108b5575f80fd5b506103af6108c43660046134d5565b61154d565b3480156108d4575f80fd5b506102e26108e33660046134fb565b6001600160a01b039182165f90815260076020908152604080832093909416825291909152205460ff1690565b34801561091b575f80fd5b506103af61092a366004613298565b6115f4565b34801561093a575f80fd5b506103af6109493660046132b8565b611663565b5f610958826116dc565b92915050565b60606002805461096d90613527565b80601f016020809104026020016040519081016040528092919081815260200182805461099990613527565b80156109e45780601f106109bb576101008083540402835291602001916109e4565b820191905f5260205f20905b8154815290600101906020018083116109c757829003601f168201915b5050505050905090565b5f6109f882611700565b505f908152600660205260409020546001600160a01b031690565b81610a1d8161175e565b610a278383611815565b505050565b826001600160a01b0381163314610a4657610a463361175e565b610a51848484611924565b50505050565b5f8281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610aca5750604080518082019091525f546001600160a01b0381168252600160a01b90046001600160601b031660208201525b60208101515f9061271090610ae8906001600160601b031687613573565b610af2919061359e565b91519350909150505b9250929050565b5f610b0c83610df6565b8210610b735760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084015b60405180910390fd5b506001600160a01b03919091165f908152600860209081526040808320938352929052205490565b826001600160a01b0381163314610bb557610bb53361175e565b610a51848484611955565b5f8181526004602052604081205481906001600160a01b0316610bf9576040516338077a2b60e01b815260048101849052602401610b6a565b5f8381526017602052604090205442811115610c1d57600194429091039350915050565b505f93849350915050565b5f610c32600a5490565b8210610c955760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610b6a565b600a8281548110610ca857610ca86135bd565b905f5260205f2001549050919050565b5f818152600460205260408120546001600160a01b0316806109585760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610b6a565b60148054610d2490613527565b80601f0160208091040260200160405190810160405280929190818152602001828054610d5090613527565b8015610d9b5780601f10610d7257610100808354040283529160200191610d9b565b820191905f5260205f20905b815481529060010190602001808311610d7e57829003601f168201915b505050505081565b610dab61196f565b601080549082905f610dbd83856135d1565b909155505060405182908183039083907f5c7ad1075a587ed1bea3016e3c6d02a3068ad514bb0c0785c84731eebb06243e905f90a45050565b5f6001600160a01b038216610e5f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610b6a565b506001600160a01b03165f9081526005602052604090205490565b610e8261196f565b6040517fc87b6adefe667374a3f2c9ab7d5e602dffeafa836d7dcfa1d4390a23a74ede63905f90a16015805460ff19166001179055565b610ec161196f565b610eca5f6119c9565b565b610ed461196f565b6013546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a905f90a3601380546001600160a01b0319166001600160a01b0392909216919091179055565b610f3761196f565b6040517f799663458a5ef2936f7fa0c99b3336c69c25890f82974f04e811e5bb359186c7905f90a16015805461ff001916610100179055565b610f7861196f565b8181604051610f889291906135e4565b60405180910390206014604051610f9f91906135f3565b604051908190038120907f309b29ded109b9e28fb9885757b3e0096eb75c51d23aa4635d68bcd569f6adc1905f90a36014610a278284836136b2565b610fe3611a1a565b601054831180610ff1575082155b1561100e5760405162c0190360e11b815260040160405180910390fd5b60155460ff16611167576018828260405161102a9291906135e4565b9081526040519081900360200190205460ff161561105f5781816040516301e038ad60e21b8152600401610b6a92919061376d565b5f338461106b60165490565b604080516001600160a01b039094166020850152830191909152606082015260800160408051601f198184030181528282528051602091820120601254601f870183900483028501830190935285845293506001600160a01b03909116916110f89186908690819084018382808284375f920191909152506110f29250869150611a739050565b90611aa5565b6001600160a01b0316146111235782826040516302adfdc360e41b8152600401610b6a92919061376d565b611131601680546001019055565b6001601884846040516111459291906135e4565b908152604051908190036020019020805491151560ff19909216919091179055505b61117284845f611ac7565b6011545f5b848110156111ab576111893383611df5565b5f828152601760205260409020426301e1338001905560019182019101611177565b50601155601080548490039055610a516001600d55565b60606003805461096d90613527565b816111db8161175e565b610a278383611e12565b6111ed61196f565b6010547f00000000000000000000000000000000000000000000000000000000000000008261121b600a5490565b611225919061379b565b118061125957507f0000000000000000000000000000000000000000000000000000000000000000611257838361379b565b115b15611277576040516392432ed560e01b815260040160405180910390fd5b601080548301905560405182908282019083907f5ae85337ee5e16b54fa5319160f6ed9f832e3b8ac4706bc8a757d1aed8db70cc905f90a45050565b836001600160a01b03811633146112cd576112cd3361175e565b6112d985858585611e1d565b5050505050565b60606112eb82611700565b5f6112f4611e4f565b90505f8151116113125760405180602001604052805f81525061133d565b8061131c84611e5e565b60405160200161132d9291906137ae565b6040516020818303038152906040525b9392505050565b5f61134e60165490565b905090565b61135b61196f565b6012546040516001600160a01b038084169216907fd33a2de0a3cd6d4bc7adaf5b27ad1cae45d5bc621c76795836207895f853e279905f90a3601280546001600160a01b0319166001600160a01b0392909216919091179055565b6113be611a1a565b5f5b818110156114f5576114008383838181106113dd576113dd6135bd565b905060200201355f908152600460205260409020546001600160a01b0316151590565b61143957828282818110611416576114166135bd565b905060200201356040516338077a2b60e01b8152600401610b6a91815260200190565b5f60175f85858581811061144f5761144f6135bd565b9050602002013581526020019081526020015f20549050804210156114ad57838383818110611480576114806135bd565b6040516399672e6360e01b8152602090910292909201356004830152504282036024820152604401610b6a565b6301e13380420160175f8686868181106114c9576114c96135bd565b9050602002013581526020019081526020015f20819055505080806114ed906137dc565b9150506113c0565b5061150283826001611ac7565b81816040516115129291906137f4565b6040519081900381209033907ffaa303a03059fc3ff75242a1d08e02e4cc122118fd75dbea494c807bcc8a7cf6905f90a3610a276001600d55565b61155561196f565b60646001600160601b038216108061157757506103e86001600160601b038216115b156115a05760405163c8ba874960e01b81526001600160601b0382166004820152602401610b6a565b6115a85f8055565b6013546115be906001600160a01b031682611eee565b6040516001600160601b038216907f35804d3532228d15c4fe3fa7a4fb8100c86dc285216e9c806f5d6f2cef552839905f90a250565b6115fc61196f565b600e546040518391907fd9cc159fa79112d02593601db522a6696e6c5c82d9e9ca9332f89ec824935bb0905f90a3600e829055600f546040518291907ff68b6199a6c7e5df3005a4142808bc836237ab35986a197b454750d532b56806905f90a3600f5550565b61166b61196f565b6001600160a01b0381166116d05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b6a565b6116d9816119c9565b50565b5f6001600160e01b0319821663780e9d6360e01b1480610958575061095882611fea565b5f818152600460205260409020546001600160a01b03166116d95760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610b6a565b6daaeb6d7670e522a718067333cd4e3b156116d957604051633185c44d60e21b81523060048201526001600160a01b03821660248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa1580156117c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117ed919061381b565b6116d957604051633b79c77360e21b81526001600160a01b0382166004820152602401610b6a565b5f61181f82610cb8565b9050806001600160a01b0316836001600160a01b03160361188c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610b6a565b336001600160a01b03821614806118a857506118a881336108e3565b61191a5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610b6a565b610a278383612029565b61192e3382612096565b61194a5760405162461bcd60e51b8152600401610b6a90613836565b610a27838383612113565b610a2783838360405180602001604052805f8152506112b3565b600c546001600160a01b03163314610eca5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b6a565b600c80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6002600d5403611a6c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b6a565b6002600d55565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f908152601c91909152603c902090565b5f805f611ab28585612282565b91509150611abf816122c1565b509392505050565b5f8115611ad95750600f548202611ae4565b50600f54600e540182025b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031603611c25573415611b3c57604051630e68856160e31b815260040160405180910390fd5b611c203360135f9054906101000a90046001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bb1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611bd59190613883565b60ff16601203600a0a8481611bec57611bec61358a565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016939291900461240a565b610a51565b6001600160a01b038416611ddc575f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611c90573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cb491906138c1565b5050509150505f611cc482612464565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d23573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d479190613883565b60ff16601203600a0a9050670de0b6b3a764000034830282020484811015611d8657604051632f04b8af60e11b81528186036004820152602401610b6a565b5f82840286670de0b6b3a76400000281611da257611da261358a565b6013549190049150611dbd906001600160a01b0316826124b9565b80341115611dd257611dd233348390036124b9565b5050505050610a51565b604051639ce7fa5560e01b815260040160405180910390fd5b611e0e828260405180602001604052805f8152506125ce565b5050565b611e0e338383612600565b611e273383612096565b611e435760405162461bcd60e51b8152600401610b6a90613836565b610a51848484846126cd565b60606014805461096d90613527565b60605f611e6a83612700565b60010190505f8167ffffffffffffffff811115611e8957611e8961318b565b6040519080825280601f01601f191660200182016040528015611eb3576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611ebd57509392505050565b6127106001600160601b0382161115611f5c5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b6064820152608401610b6a565b6001600160a01b038216611fb25760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401610b6a565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b909102175f55565b5f6001600160e01b031982166380ac58cd60e01b148061201a57506001600160e01b03198216635b5e139f60e01b145b806109585750610958826127d7565b5f81815260066020526040902080546001600160a01b0319166001600160a01b038416908117909155819061205d82610cb8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b5f806120a183610cb8565b9050806001600160a01b0316846001600160a01b031614806120e757506001600160a01b038082165f9081526007602090815260408083209388168352929052205460ff165b8061210b5750836001600160a01b0316612100846109ee565b6001600160a01b0316145b949350505050565b826001600160a01b031661212682610cb8565b6001600160a01b03161461214c5760405162461bcd60e51b8152600401610b6a9061390d565b6001600160a01b0382166121ae5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610b6a565b6121bb838383600161280b565b826001600160a01b03166121ce82610cb8565b6001600160a01b0316146121f45760405162461bcd60e51b8152600401610b6a9061390d565b5f81815260066020908152604080832080546001600160a01b03199081169091556001600160a01b038781168086526005855283862080545f1901905590871680865283862080546001019055868652600490945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b5f8082516041036122b6576020830151604084015160608501515f1a6122aa87828585612855565b94509450505050610afb565b505f90506002610afb565b5f8160048111156122d4576122d4613952565b036122dc5750565b60018160048111156122f0576122f0613952565b0361233d5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610b6a565b600281600481111561235157612351613952565b0361239e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610b6a565b60038160048111156123b2576123b2613952565b036116d95760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610b6a565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610a51908590612912565b5f808212156124b55760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610b6a565b5090565b804710156125095760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610b6a565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114612552576040519150601f19603f3d011682016040523d82523d5f602084013e612557565b606091505b5050905080610a275760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610b6a565b6125d883836129e5565b6125e45f848484612b7a565b610a275760405162461bcd60e51b8152600401610b6a90613966565b816001600160a01b0316836001600160a01b0316036126615760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610b6a565b6001600160a01b038381165f81815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6126d8848484612113565b6126e484848484612b7a565b610a515760405162461bcd60e51b8152600401610b6a90613966565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061273e5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061276a576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061278857662386f26fc10000830492506010015b6305f5e10083106127a0576305f5e100830492506008015b61271083106127b457612710830492506004015b606483106127c6576064830492506002015b600a83106109585760010192915050565b5f6001600160e01b0319821663152a902d60e11b148061095857506301ffc9a760e01b6001600160e01b0319831614610958565b601554610100900460ff1615801561282b57506001600160a01b03841615155b156128495760405163a1616ce760e01b815260040160405180910390fd5b610a5184848484612c77565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561288a57505f90506003612909565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156128db573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116612903575f60019250925050612909565b91505f90505b94509492505050565b5f612966826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612da39092919063ffffffff16565b905080515f1480612986575080806020019051810190612986919061381b565b610a275760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b6a565b6001600160a01b038216612a3b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610b6a565b5f818152600460205260409020546001600160a01b031615612a9f5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610b6a565b612aac5f8383600161280b565b5f818152600460205260409020546001600160a01b031615612b105760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610b6a565b6001600160a01b0382165f81815260056020908152604080832080546001019055848352600490915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b5f6001600160a01b0384163b15612c6c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612bbd9033908990889088906004016139b8565b6020604051808303815f875af1925050508015612bf7575060408051601f3d908101601f19168201909252612bf4918101906139f4565b60015b612c52573d808015612c24576040519150601f19603f3d011682016040523d82523d5f602084013e612c29565b606091505b5080515f03612c4a5760405162461bcd60e51b8152600401610b6a90613966565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061210b565b506001949350505050565b6001811115612ce65760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610b6a565b816001600160a01b038516612d4157612d3c81600a80545f838152600b60205260408120829055600182018355919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155565b612d64565b836001600160a01b0316856001600160a01b031614612d6457612d648582612db1565b6001600160a01b038416612d8057612d7b81612e4a565b6112d9565b846001600160a01b0316846001600160a01b0316146112d9576112d98482612ef1565b606061210b84845f85612f33565b5f6001612dbd84610df6565b612dc791906135d1565b5f83815260096020526040902054909150808214612e18576001600160a01b0384165f9081526008602090815260408083208584528252808320548484528184208190558352600990915290208190555b505f9182526009602090815260408084208490556001600160a01b039094168352600881528383209183525290812055565b600a545f90612e5b906001906135d1565b5f838152600b6020526040812054600a8054939450909284908110612e8257612e826135bd565b905f5260205f200154905080600a8381548110612ea157612ea16135bd565b5f918252602080832090910192909255828152600b9091526040808220849055858252812055600a805480612ed857612ed8613a0f565b600190038181905f5260205f20015f9055905550505050565b5f612efb83610df6565b6001600160a01b039093165f908152600860209081526040808320868452825280832085905593825260099052919091209190915550565b606082471015612f945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b6a565b5f80866001600160a01b03168587604051612faf9190613a23565b5f6040518083038185875af1925050503d805f8114612fe9576040519150601f19603f3d011682016040523d82523d5f602084013e612fee565b606091505b5091509150612fff8783838761300a565b979650505050505050565b606083156130785782515f03613071576001600160a01b0385163b6130715760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b6a565b508161210b565b61210b838381511561308d5781518083602001fd5b8060405162461bcd60e51b8152600401610b6a9190613124565b6001600160e01b0319811681146116d9575f80fd5b5f602082840312156130cc575f80fd5b813561133d816130a7565b5f5b838110156130f15781810151838201526020016130d9565b50505f910152565b5f81518084526131108160208601602086016130d7565b601f01601f19169290920160200192915050565b602081525f61133d60208301846130f9565b5f60208284031215613146575f80fd5b5035919050565b6001600160a01b03811681146116d9575f80fd5b5f8060408385031215613172575f80fd5b823561317d8161314d565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126131ae575f80fd5b813567ffffffffffffffff808211156131c9576131c961318b565b604051601f8301601f19908116603f011681019082821181831017156131f1576131f161318b565b81604052838152866020858801011115613209575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f60208284031215613238575f80fd5b813567ffffffffffffffff81111561324e575f80fd5b61210b8482850161319f565b5f805f6060848603121561326c575f80fd5b83356132778161314d565b925060208401356132878161314d565b929592945050506040919091013590565b5f80604083850312156132a9575f80fd5b50508035926020909101359150565b5f602082840312156132c8575f80fd5b813561133d8161314d565b5f8083601f8401126132e3575f80fd5b50813567ffffffffffffffff8111156132fa575f80fd5b602083019150836020828501011115610afb575f80fd5b5f8060208385031215613322575f80fd5b823567ffffffffffffffff811115613338575f80fd5b613344858286016132d3565b90969095509350505050565b5f805f8060608587031215613363575f80fd5b843561336e8161314d565b935060208501359250604085013567ffffffffffffffff811115613390575f80fd5b61339c878288016132d3565b95989497509550505050565b80151581146116d9575f80fd5b5f80604083850312156133c6575f80fd5b82356133d18161314d565b915060208301356133e1816133a8565b809150509250929050565b5f805f80608085870312156133ff575f80fd5b843561340a8161314d565b9350602085013561341a8161314d565b925060408501359150606085013567ffffffffffffffff81111561343c575f80fd5b6134488782880161319f565b91505092959194509250565b5f805f60408486031215613466575f80fd5b83356134718161314d565b9250602084013567ffffffffffffffff8082111561348d575f80fd5b818601915086601f8301126134a0575f80fd5b8135818111156134ae575f80fd5b8760208260051b85010111156134c2575f80fd5b6020830194508093505050509250925092565b5f602082840312156134e5575f80fd5b81356001600160601b038116811461133d575f80fd5b5f806040838503121561350c575f80fd5b82356135178161314d565b915060208301356133e18161314d565b600181811c9082168061353b57607f821691505b60208210810361355957634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176109585761095861355f565b634e487b7160e01b5f52601260045260245ffd5b5f826135b857634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffd5b818103818111156109585761095861355f565b818382375f9101908152919050565b5f80835461360081613527565b60018281168015613618576001811461362d57613659565b60ff1984168752821515830287019450613659565b875f526020805f205f5b858110156136505781548a820152908401908201613637565b50505082870194505b50929695505050505050565b601f821115610a27575f81815260208120601f850160051c8101602086101561368b5750805b601f850160051c820191505b818110156136aa57828155600101613697565b505050505050565b67ffffffffffffffff8311156136ca576136ca61318b565b6136de836136d88354613527565b83613665565b5f601f84116001811461370f575f85156136f85750838201355b5f19600387901b1c1916600186901b1783556112d9565b5f83815260209020601f19861690835b8281101561373f578685013582556020948501946001909201910161371f565b508682101561375b575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152816020820152818360408301375f818301604090810191909152601f909201601f19160101919050565b808201808211156109585761095861355f565b5f83516137bf8184602088016130d7565b8351908301906137d38183602088016130d7565b01949350505050565b5f600182016137ed576137ed61355f565b5060010190565b5f6001600160fb1b03831115613808575f80fd5b8260051b80858437919091019392505050565b5f6020828403121561382b575f80fd5b815161133d816133a8565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b5f60208284031215613893575f80fd5b815160ff8116811461133d575f80fd5b805169ffffffffffffffffffff811681146138bc575f80fd5b919050565b5f805f805f60a086880312156138d5575f80fd5b6138de866138a3565b9450602086015193506040860151925060608601519150613901608087016138a3565b90509295509295909350565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b634e487b7160e01b5f52602160045260245ffd5b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906139ea908301846130f9565b9695505050505050565b5f60208284031215613a04575f80fd5b815161133d816130a7565b634e487b7160e01b5f52603160045260245ffd5b5f8251613a348184602087016130d7565b919091019291505056fea26469706673582212202bac9b29aa681da631b2e5cedbf17aaab2ae7527c372f2d8035d9904cfd0469464736f6c63430008140033000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022b1c8c1227a000000000000000000000000000002ad2084e2582d054cca4c4a1fac8b1abf60efc580000000000000000000000001302818823b63b8c8313a1d1444b07110cccf99b0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b841900000000000000000000000000000000000000000000000000000000000000056e756c6c2f000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106102bf575f3560e01c806370a082311161016f578063a2506af7116100d8578063d94827ea11610092578063e89cb7c41161006d578063e89cb7c4146108aa578063e985e9c5146108c9578063ef88d7f014610910578063f2fde38b1461092f575f80fd5b8063d94827ea14610858578063e0a665781461086c578063e6be6d6f1461088b575f80fd5b8063a2506af7146107ae578063ab79e3aa146107cd578063b88d4fde146107e6578063bdc8e54c14610805578063c87b56dd1461081a578063d09edf3114610839575f80fd5b80638da5cb5b116101295780638da5cb5b14610701578063931688cb1461071e57806394d008ef1461073d57806395d89b4114610750578063a02d164e14610764578063a22cb4651461078f575f80fd5b806370a0823114610672578063713c052f14610691578063715018a6146106a55780637f51bb1f146106b95780637ff9b596146106d85780638a8c523c146106ed575f80fd5b806332f4f16e1161022b5780634f6ccce7116101e557806361d027b3116101c057806361d027b3146106015780636352211e146106205780636c0360eb1461063f5780636d595f8814610653575f80fd5b80634f6ccce71461059b57806352e6d740146105ba5780635efc071a146105ce575f80fd5b806332f4f16e146104c557806341a34011146104da57806341f434341461050757806342842e0e14610528578063492f8724146105475780634ada218b1461057d575f80fd5b806318160ddd1161027c57806318160ddd146103c8578063236c5baf146103dc57806323b872dd146104165780632630c12f146104355780632a55205a146104685780632f745c59146104a6575f80fd5b806301ffc9a7146102c35780630480e58b146102f757806306fdde0314610338578063081812fc14610359578063095ea7b31461039057806316d3bfbb146103b1575b5f80fd5b3480156102ce575f80fd5b506102e26102dd3660046130bc565b61094e565b60405190151581526020015b60405180910390f35b348015610302575f80fd5b5061032a7f000000000000000000000000000000000000000000000000000000000000271081565b6040519081526020016102ee565b348015610343575f80fd5b5061034c61095e565b6040516102ee9190613124565b348015610364575f80fd5b50610378610373366004613136565b6109ee565b6040516001600160a01b0390911681526020016102ee565b34801561039b575f80fd5b506103af6103aa366004613161565b610a13565b005b3480156103bc575f80fd5b5061032a6301e1338081565b3480156103d3575f80fd5b50600a5461032a565b3480156103e7575f80fd5b506102e26103f6366004613228565b805160208183018101805160188252928201919093012091525460ff1681565b348015610421575f80fd5b506103af61043036600461325a565b610a2c565b348015610440575f80fd5b506103787f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b841981565b348015610473575f80fd5b50610487610482366004613298565b610a57565b604080516001600160a01b0390931683526020830191909152016102ee565b3480156104b1575f80fd5b5061032a6104c0366004613161565b610b02565b3480156104d0575f80fd5b5061032a60105481565b3480156104e5575f80fd5b506104ef6103e881565b6040516001600160601b0390911681526020016102ee565b348015610512575f80fd5b506103786daaeb6d7670e522a718067333cd4e81565b348015610533575f80fd5b506103af61054236600461325a565b610b9b565b348015610552575f80fd5b50610566610561366004613136565b610bc0565b6040805192151583526020830191909152016102ee565b348015610588575f80fd5b506015546102e290610100900460ff1681565b3480156105a6575f80fd5b5061032a6105b5366004613136565b610c28565b3480156105c5575f80fd5b506104ef606481565b3480156105d9575f80fd5b506103787f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b34801561060c575f80fd5b50601354610378906001600160a01b031681565b34801561062b575f80fd5b5061037861063a366004613136565b610cb8565b34801561064a575f80fd5b5061034c610d17565b34801561065e575f80fd5b506103af61066d366004613136565b610da3565b34801561067d575f80fd5b5061032a61068c3660046132b8565b610df6565b34801561069c575f80fd5b506103af610e7a565b3480156106b0575f80fd5b506103af610eb9565b3480156106c4575f80fd5b506103af6106d33660046132b8565b610ecc565b3480156106e3575f80fd5b5061032a600e5481565b3480156106f8575f80fd5b506103af610f2f565b34801561070c575f80fd5b50600c546001600160a01b0316610378565b348015610729575f80fd5b506103af610738366004613311565b610f70565b6103af61074b366004613350565b610fdb565b34801561075b575f80fd5b5061034c6111c2565b34801561076f575f80fd5b5061032a61077e366004613136565b60176020525f908152604090205481565b34801561079a575f80fd5b506103af6107a93660046133b5565b6111d1565b3480156107b9575f80fd5b506103af6107c8366004613136565b6111e5565b3480156107d8575f80fd5b506015546102e29060ff1681565b3480156107f1575f80fd5b506103af6108003660046133ec565b6112b3565b348015610810575f80fd5b5061032a600f5481565b348015610825575f80fd5b5061034c610834366004613136565b6112e0565b348015610844575f80fd5b50601254610378906001600160a01b031681565b348015610863575f80fd5b5061032a611344565b348015610877575f80fd5b506103af6108863660046132b8565b611353565b348015610896575f80fd5b506103af6108a5366004613454565b6113b6565b3480156108b5575f80fd5b506103af6108c43660046134d5565b61154d565b3480156108d4575f80fd5b506102e26108e33660046134fb565b6001600160a01b039182165f90815260076020908152604080832093909416825291909152205460ff1690565b34801561091b575f80fd5b506103af61092a366004613298565b6115f4565b34801561093a575f80fd5b506103af6109493660046132b8565b611663565b5f610958826116dc565b92915050565b60606002805461096d90613527565b80601f016020809104026020016040519081016040528092919081815260200182805461099990613527565b80156109e45780601f106109bb576101008083540402835291602001916109e4565b820191905f5260205f20905b8154815290600101906020018083116109c757829003601f168201915b5050505050905090565b5f6109f882611700565b505f908152600660205260409020546001600160a01b031690565b81610a1d8161175e565b610a278383611815565b505050565b826001600160a01b0381163314610a4657610a463361175e565b610a51848484611924565b50505050565b5f8281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610aca5750604080518082019091525f546001600160a01b0381168252600160a01b90046001600160601b031660208201525b60208101515f9061271090610ae8906001600160601b031687613573565b610af2919061359e565b91519350909150505b9250929050565b5f610b0c83610df6565b8210610b735760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084015b60405180910390fd5b506001600160a01b03919091165f908152600860209081526040808320938352929052205490565b826001600160a01b0381163314610bb557610bb53361175e565b610a51848484611955565b5f8181526004602052604081205481906001600160a01b0316610bf9576040516338077a2b60e01b815260048101849052602401610b6a565b5f8381526017602052604090205442811115610c1d57600194429091039350915050565b505f93849350915050565b5f610c32600a5490565b8210610c955760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610b6a565b600a8281548110610ca857610ca86135bd565b905f5260205f2001549050919050565b5f818152600460205260408120546001600160a01b0316806109585760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610b6a565b60148054610d2490613527565b80601f0160208091040260200160405190810160405280929190818152602001828054610d5090613527565b8015610d9b5780601f10610d7257610100808354040283529160200191610d9b565b820191905f5260205f20905b815481529060010190602001808311610d7e57829003601f168201915b505050505081565b610dab61196f565b601080549082905f610dbd83856135d1565b909155505060405182908183039083907f5c7ad1075a587ed1bea3016e3c6d02a3068ad514bb0c0785c84731eebb06243e905f90a45050565b5f6001600160a01b038216610e5f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610b6a565b506001600160a01b03165f9081526005602052604090205490565b610e8261196f565b6040517fc87b6adefe667374a3f2c9ab7d5e602dffeafa836d7dcfa1d4390a23a74ede63905f90a16015805460ff19166001179055565b610ec161196f565b610eca5f6119c9565b565b610ed461196f565b6013546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a905f90a3601380546001600160a01b0319166001600160a01b0392909216919091179055565b610f3761196f565b6040517f799663458a5ef2936f7fa0c99b3336c69c25890f82974f04e811e5bb359186c7905f90a16015805461ff001916610100179055565b610f7861196f565b8181604051610f889291906135e4565b60405180910390206014604051610f9f91906135f3565b604051908190038120907f309b29ded109b9e28fb9885757b3e0096eb75c51d23aa4635d68bcd569f6adc1905f90a36014610a278284836136b2565b610fe3611a1a565b601054831180610ff1575082155b1561100e5760405162c0190360e11b815260040160405180910390fd5b60155460ff16611167576018828260405161102a9291906135e4565b9081526040519081900360200190205460ff161561105f5781816040516301e038ad60e21b8152600401610b6a92919061376d565b5f338461106b60165490565b604080516001600160a01b039094166020850152830191909152606082015260800160408051601f198184030181528282528051602091820120601254601f870183900483028501830190935285845293506001600160a01b03909116916110f89186908690819084018382808284375f920191909152506110f29250869150611a739050565b90611aa5565b6001600160a01b0316146111235782826040516302adfdc360e41b8152600401610b6a92919061376d565b611131601680546001019055565b6001601884846040516111459291906135e4565b908152604051908190036020019020805491151560ff19909216919091179055505b61117284845f611ac7565b6011545f5b848110156111ab576111893383611df5565b5f828152601760205260409020426301e1338001905560019182019101611177565b50601155601080548490039055610a516001600d55565b60606003805461096d90613527565b816111db8161175e565b610a278383611e12565b6111ed61196f565b6010547f00000000000000000000000000000000000000000000000000000000000027108261121b600a5490565b611225919061379b565b118061125957507f0000000000000000000000000000000000000000000000000000000000002710611257838361379b565b115b15611277576040516392432ed560e01b815260040160405180910390fd5b601080548301905560405182908282019083907f5ae85337ee5e16b54fa5319160f6ed9f832e3b8ac4706bc8a757d1aed8db70cc905f90a45050565b836001600160a01b03811633146112cd576112cd3361175e565b6112d985858585611e1d565b5050505050565b60606112eb82611700565b5f6112f4611e4f565b90505f8151116113125760405180602001604052805f81525061133d565b8061131c84611e5e565b60405160200161132d9291906137ae565b6040516020818303038152906040525b9392505050565b5f61134e60165490565b905090565b61135b61196f565b6012546040516001600160a01b038084169216907fd33a2de0a3cd6d4bc7adaf5b27ad1cae45d5bc621c76795836207895f853e279905f90a3601280546001600160a01b0319166001600160a01b0392909216919091179055565b6113be611a1a565b5f5b818110156114f5576114008383838181106113dd576113dd6135bd565b905060200201355f908152600460205260409020546001600160a01b0316151590565b61143957828282818110611416576114166135bd565b905060200201356040516338077a2b60e01b8152600401610b6a91815260200190565b5f60175f85858581811061144f5761144f6135bd565b9050602002013581526020019081526020015f20549050804210156114ad57838383818110611480576114806135bd565b6040516399672e6360e01b8152602090910292909201356004830152504282036024820152604401610b6a565b6301e13380420160175f8686868181106114c9576114c96135bd565b9050602002013581526020019081526020015f20819055505080806114ed906137dc565b9150506113c0565b5061150283826001611ac7565b81816040516115129291906137f4565b6040519081900381209033907ffaa303a03059fc3ff75242a1d08e02e4cc122118fd75dbea494c807bcc8a7cf6905f90a3610a276001600d55565b61155561196f565b60646001600160601b038216108061157757506103e86001600160601b038216115b156115a05760405163c8ba874960e01b81526001600160601b0382166004820152602401610b6a565b6115a85f8055565b6013546115be906001600160a01b031682611eee565b6040516001600160601b038216907f35804d3532228d15c4fe3fa7a4fb8100c86dc285216e9c806f5d6f2cef552839905f90a250565b6115fc61196f565b600e546040518391907fd9cc159fa79112d02593601db522a6696e6c5c82d9e9ca9332f89ec824935bb0905f90a3600e829055600f546040518291907ff68b6199a6c7e5df3005a4142808bc836237ab35986a197b454750d532b56806905f90a3600f5550565b61166b61196f565b6001600160a01b0381166116d05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b6a565b6116d9816119c9565b50565b5f6001600160e01b0319821663780e9d6360e01b1480610958575061095882611fea565b5f818152600460205260409020546001600160a01b03166116d95760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610b6a565b6daaeb6d7670e522a718067333cd4e3b156116d957604051633185c44d60e21b81523060048201526001600160a01b03821660248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa1580156117c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117ed919061381b565b6116d957604051633b79c77360e21b81526001600160a01b0382166004820152602401610b6a565b5f61181f82610cb8565b9050806001600160a01b0316836001600160a01b03160361188c5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610b6a565b336001600160a01b03821614806118a857506118a881336108e3565b61191a5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610b6a565b610a278383612029565b61192e3382612096565b61194a5760405162461bcd60e51b8152600401610b6a90613836565b610a27838383612113565b610a2783838360405180602001604052805f8152506112b3565b600c546001600160a01b03163314610eca5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b6a565b600c80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6002600d5403611a6c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b6a565b6002600d55565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000005f908152601c91909152603c902090565b5f805f611ab28585612282565b91509150611abf816122c1565b509392505050565b5f8115611ad95750600f548202611ae4565b50600f54600e540182025b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76001600160a01b0316846001600160a01b031603611c25573415611b3c57604051630e68856160e31b815260040160405180910390fd5b611c203360135f9054906101000a90046001600160a01b03167f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec76001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bb1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611bd59190613883565b60ff16601203600a0a8481611bec57611bec61358a565b6001600160a01b037f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec716939291900461240a565b610a51565b6001600160a01b038416611ddc575f7f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84196001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015611c90573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cb491906138c1565b5050509150505f611cc482612464565b90505f7f0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84196001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d23573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d479190613883565b60ff16601203600a0a9050670de0b6b3a764000034830282020484811015611d8657604051632f04b8af60e11b81528186036004820152602401610b6a565b5f82840286670de0b6b3a76400000281611da257611da261358a565b6013549190049150611dbd906001600160a01b0316826124b9565b80341115611dd257611dd233348390036124b9565b5050505050610a51565b604051639ce7fa5560e01b815260040160405180910390fd5b611e0e828260405180602001604052805f8152506125ce565b5050565b611e0e338383612600565b611e273383612096565b611e435760405162461bcd60e51b8152600401610b6a90613836565b610a51848484846126cd565b60606014805461096d90613527565b60605f611e6a83612700565b60010190505f8167ffffffffffffffff811115611e8957611e8961318b565b6040519080825280601f01601f191660200182016040528015611eb3576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611ebd57509392505050565b6127106001600160601b0382161115611f5c5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b6064820152608401610b6a565b6001600160a01b038216611fb25760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401610b6a565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b909102175f55565b5f6001600160e01b031982166380ac58cd60e01b148061201a57506001600160e01b03198216635b5e139f60e01b145b806109585750610958826127d7565b5f81815260066020526040902080546001600160a01b0319166001600160a01b038416908117909155819061205d82610cb8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b5f806120a183610cb8565b9050806001600160a01b0316846001600160a01b031614806120e757506001600160a01b038082165f9081526007602090815260408083209388168352929052205460ff165b8061210b5750836001600160a01b0316612100846109ee565b6001600160a01b0316145b949350505050565b826001600160a01b031661212682610cb8565b6001600160a01b03161461214c5760405162461bcd60e51b8152600401610b6a9061390d565b6001600160a01b0382166121ae5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610b6a565b6121bb838383600161280b565b826001600160a01b03166121ce82610cb8565b6001600160a01b0316146121f45760405162461bcd60e51b8152600401610b6a9061390d565b5f81815260066020908152604080832080546001600160a01b03199081169091556001600160a01b038781168086526005855283862080545f1901905590871680865283862080546001019055868652600490945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b5f8082516041036122b6576020830151604084015160608501515f1a6122aa87828585612855565b94509450505050610afb565b505f90506002610afb565b5f8160048111156122d4576122d4613952565b036122dc5750565b60018160048111156122f0576122f0613952565b0361233d5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610b6a565b600281600481111561235157612351613952565b0361239e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610b6a565b60038160048111156123b2576123b2613952565b036116d95760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610b6a565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610a51908590612912565b5f808212156124b55760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610b6a565b5090565b804710156125095760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610b6a565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114612552576040519150601f19603f3d011682016040523d82523d5f602084013e612557565b606091505b5050905080610a275760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610b6a565b6125d883836129e5565b6125e45f848484612b7a565b610a275760405162461bcd60e51b8152600401610b6a90613966565b816001600160a01b0316836001600160a01b0316036126615760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610b6a565b6001600160a01b038381165f81815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6126d8848484612113565b6126e484848484612b7a565b610a515760405162461bcd60e51b8152600401610b6a90613966565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061273e5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061276a576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061278857662386f26fc10000830492506010015b6305f5e10083106127a0576305f5e100830492506008015b61271083106127b457612710830492506004015b606483106127c6576064830492506002015b600a83106109585760010192915050565b5f6001600160e01b0319821663152a902d60e11b148061095857506301ffc9a760e01b6001600160e01b0319831614610958565b601554610100900460ff1615801561282b57506001600160a01b03841615155b156128495760405163a1616ce760e01b815260040160405180910390fd5b610a5184848484612c77565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561288a57505f90506003612909565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156128db573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b038116612903575f60019250925050612909565b91505f90505b94509492505050565b5f612966826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612da39092919063ffffffff16565b905080515f1480612986575080806020019051810190612986919061381b565b610a275760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b6a565b6001600160a01b038216612a3b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610b6a565b5f818152600460205260409020546001600160a01b031615612a9f5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610b6a565b612aac5f8383600161280b565b5f818152600460205260409020546001600160a01b031615612b105760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610b6a565b6001600160a01b0382165f81815260056020908152604080832080546001019055848352600490915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b5f6001600160a01b0384163b15612c6c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612bbd9033908990889088906004016139b8565b6020604051808303815f875af1925050508015612bf7575060408051601f3d908101601f19168201909252612bf4918101906139f4565b60015b612c52573d808015612c24576040519150601f19603f3d011682016040523d82523d5f602084013e612c29565b606091505b5080515f03612c4a5760405162461bcd60e51b8152600401610b6a90613966565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061210b565b506001949350505050565b6001811115612ce65760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610b6a565b816001600160a01b038516612d4157612d3c81600a80545f838152600b60205260408120829055600182018355919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155565b612d64565b836001600160a01b0316856001600160a01b031614612d6457612d648582612db1565b6001600160a01b038416612d8057612d7b81612e4a565b6112d9565b846001600160a01b0316846001600160a01b0316146112d9576112d98482612ef1565b606061210b84845f85612f33565b5f6001612dbd84610df6565b612dc791906135d1565b5f83815260096020526040902054909150808214612e18576001600160a01b0384165f9081526008602090815260408083208584528252808320548484528184208190558352600990915290208190555b505f9182526009602090815260408084208490556001600160a01b039094168352600881528383209183525290812055565b600a545f90612e5b906001906135d1565b5f838152600b6020526040812054600a8054939450909284908110612e8257612e826135bd565b905f5260205f200154905080600a8381548110612ea157612ea16135bd565b5f918252602080832090910192909255828152600b9091526040808220849055858252812055600a805480612ed857612ed8613a0f565b600190038181905f5260205f20015f9055905550505050565b5f612efb83610df6565b6001600160a01b039093165f908152600860209081526040808320868452825280832085905593825260099052919091209190915550565b606082471015612f945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610b6a565b5f80866001600160a01b03168587604051612faf9190613a23565b5f6040518083038185875af1925050503d805f8114612fe9576040519150601f19603f3d011682016040523d82523d5f602084013e612fee565b606091505b5091509150612fff8783838761300a565b979650505050505050565b606083156130785782515f03613071576001600160a01b0385163b6130715760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b6a565b508161210b565b61210b838381511561308d5781518083602001fd5b8060405162461bcd60e51b8152600401610b6a9190613124565b6001600160e01b0319811681146116d9575f80fd5b5f602082840312156130cc575f80fd5b813561133d816130a7565b5f5b838110156130f15781810151838201526020016130d9565b50505f910152565b5f81518084526131108160208601602086016130d7565b601f01601f19169290920160200192915050565b602081525f61133d60208301846130f9565b5f60208284031215613146575f80fd5b5035919050565b6001600160a01b03811681146116d9575f80fd5b5f8060408385031215613172575f80fd5b823561317d8161314d565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f8301126131ae575f80fd5b813567ffffffffffffffff808211156131c9576131c961318b565b604051601f8301601f19908116603f011681019082821181831017156131f1576131f161318b565b81604052838152866020858801011115613209575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f60208284031215613238575f80fd5b813567ffffffffffffffff81111561324e575f80fd5b61210b8482850161319f565b5f805f6060848603121561326c575f80fd5b83356132778161314d565b925060208401356132878161314d565b929592945050506040919091013590565b5f80604083850312156132a9575f80fd5b50508035926020909101359150565b5f602082840312156132c8575f80fd5b813561133d8161314d565b5f8083601f8401126132e3575f80fd5b50813567ffffffffffffffff8111156132fa575f80fd5b602083019150836020828501011115610afb575f80fd5b5f8060208385031215613322575f80fd5b823567ffffffffffffffff811115613338575f80fd5b613344858286016132d3565b90969095509350505050565b5f805f8060608587031215613363575f80fd5b843561336e8161314d565b935060208501359250604085013567ffffffffffffffff811115613390575f80fd5b61339c878288016132d3565b95989497509550505050565b80151581146116d9575f80fd5b5f80604083850312156133c6575f80fd5b82356133d18161314d565b915060208301356133e1816133a8565b809150509250929050565b5f805f80608085870312156133ff575f80fd5b843561340a8161314d565b9350602085013561341a8161314d565b925060408501359150606085013567ffffffffffffffff81111561343c575f80fd5b6134488782880161319f565b91505092959194509250565b5f805f60408486031215613466575f80fd5b83356134718161314d565b9250602084013567ffffffffffffffff8082111561348d575f80fd5b818601915086601f8301126134a0575f80fd5b8135818111156134ae575f80fd5b8760208260051b85010111156134c2575f80fd5b6020830194508093505050509250925092565b5f602082840312156134e5575f80fd5b81356001600160601b038116811461133d575f80fd5b5f806040838503121561350c575f80fd5b82356135178161314d565b915060208301356133e18161314d565b600181811c9082168061353b57607f821691505b60208210810361355957634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176109585761095861355f565b634e487b7160e01b5f52601260045260245ffd5b5f826135b857634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffd5b818103818111156109585761095861355f565b818382375f9101908152919050565b5f80835461360081613527565b60018281168015613618576001811461362d57613659565b60ff1984168752821515830287019450613659565b875f526020805f205f5b858110156136505781548a820152908401908201613637565b50505082870194505b50929695505050505050565b601f821115610a27575f81815260208120601f850160051c8101602086101561368b5750805b601f850160051c820191505b818110156136aa57828155600101613697565b505050505050565b67ffffffffffffffff8311156136ca576136ca61318b565b6136de836136d88354613527565b83613665565b5f601f84116001811461370f575f85156136f85750838201355b5f19600387901b1c1916600186901b1783556112d9565b5f83815260209020601f19861690835b8281101561373f578685013582556020948501946001909201910161371f565b508682101561375b575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152816020820152818360408301375f818301604090810191909152601f909201601f19160101919050565b808201808211156109585761095861355f565b5f83516137bf8184602088016130d7565b8351908301906137d38183602088016130d7565b01949350505050565b5f600182016137ed576137ed61355f565b5060010190565b5f6001600160fb1b03831115613808575f80fd5b8260051b80858437919091019392505050565b5f6020828403121561382b575f80fd5b815161133d816133a8565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b5f60208284031215613893575f80fd5b815160ff8116811461133d575f80fd5b805169ffffffffffffffffffff811681146138bc575f80fd5b919050565b5f805f805f60a086880312156138d5575f80fd5b6138de866138a3565b9450602086015193506040860151925060608601519150613901608087016138a3565b90509295509295909350565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b634e487b7160e01b5f52602160045260245ffd5b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906139ea908301846130f9565b9695505050505050565b5f60208284031215613a04575f80fd5b815161133d816130a7565b634e487b7160e01b5f52603160045260245ffd5b5f8251613a348184602087016130d7565b919091019291505056fea26469706673582212202bac9b29aa681da631b2e5cedbf17aaab2ae7527c372f2d8035d9904cfd0469464736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000271000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022b1c8c1227a000000000000000000000000000002ad2084e2582d054cca4c4a1fac8b1abf60efc580000000000000000000000001302818823b63b8c8313a1d1444b07110cccf99b0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b841900000000000000000000000000000000000000000000000000000000000000056e756c6c2f000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : maximumSupply_ (uint256): 10000
Arg [1] : tokenPrice_ (uint256): 0
Arg [2] : subscriptionPrice_ (uint256): 40000000000000000000
Arg [3] : authorizer_ (address): 0x2ad2084e2582D054CCa4C4a1fAC8b1aBF60EFC58
Arg [4] : treasury_ (address): 0x1302818823b63B8C8313A1D1444B07110CCCF99B
Arg [5] : baseURI_ (string): null/
Arg [6] : tether_ (address): 0xdAC17F958D2ee523a2206206994597C13D831ec7
Arg [7] : priceOracle_ (address): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000002710
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 0000000000000000000000000000000000000000000000022b1c8c1227a00000
Arg [3] : 0000000000000000000000002ad2084e2582d054cca4c4a1fac8b1abf60efc58
Arg [4] : 0000000000000000000000001302818823b63b8c8313a1d1444b07110cccf99b
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [6] : 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7
Arg [7] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [9] : 6e756c6c2f000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.