Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- SNDNFTMinter
- Optimization enabled
- true
- Compiler version
- v0.8.24+commit.e11b9ed9
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2024-07-19T07:27:51.077284Z
Constructor Arguments
0x0000000000000000000000009b51ede29970e78eed3287a1785f7acdebe765070000000000000000000000001d4f4c4c1247063593256cfa0845a9181d6731b6000000000000000000000000fb63b729bd47df406a8ee969c47ef23c13fe0864000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000001718a9dd27c6f01d2cec34f3ac5c8f29dd61a1bd0000000000000000000000000000000000000000000000000000000014dc9380
Arg [0] (address) : 0x9b51ede29970e78eed3287a1785f7acdebe76507
Arg [1] (address) : 0x1d4f4c4c1247063593256cfa0845a9181d6731b6
Arg [2] (address) : 0xfb63b729bd47df406a8ee969c47ef23c13fe0864
Arg [3] (uint256) : 100000000000000000
Arg [4] (address) : 0x1718a9dd27c6f01d2cec34f3ac5c8f29dd61a1bd
Arg [5] (uint256) : 350000000
contracts/SNDNFTMinter.sol
// SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity ^0.8.20; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; interface ISNDNFT is IERC721 { function safeMint(address to) external returns (uint256 tokenId); function safeBatchMint(address to, int32 amount) external; } contract SNDNFTMinter is Ownable, EIP712 { using ECDSA for bytes32; using SafeERC20 for IERC20; address public treasurer; address public signer; uint32 public MaxWhiteList = 1000; uint32 public MaxSuperWhiteList = 3000; uint32 public mintedWhiteList; uint32 public mintedSuperWhiteList; uint32 public whitelistStart; uint32 public whitelistEnd; ISNDNFT public nft; uint256 public ethPrice; IERC20 public USDC; uint256 public usdcPrice; mapping(address => uint256) public nonces; event Received(address who, uint amount); event Withdraw(address who, uint amount); event Minted(address recipient, uint256 tokenId, uint8 category); struct MintInfo { address recipient; uint256 nonce; uint8 category; uint32 expired; } bytes32 constant MINTINFO_TYPEHASH = keccak256( "MintInfo(address recipient,uint256 nonce,uint8 category,uint32 expired)" ); constructor( address _treasurer, address _signer, address _nft, uint256 _ethPrice, address _usdc, uint256 _usdcPrice ) EIP712("Swords Dungeons NFT Minter", "v1") Ownable(msg.sender) { treasurer = _treasurer; nft = ISNDNFT(_nft); ethPrice = _ethPrice; signer = _signer; usdcPrice = _usdcPrice; USDC = IERC20(_usdc); } receive() external payable { payable(treasurer).transfer(msg.value); emit Received(msg.sender, msg.value); } function withdraw(address payable to) external onlyOwner { uint amount = address(this).balance; to.transfer(amount); emit Withdraw(to, amount); } function setPrice( uint256 _ethPrice, uint256 _usdcPrice ) external onlyOwner { ethPrice = _ethPrice; usdcPrice = _usdcPrice; } function setSigner(address _signer) public onlyOwner { require(_signer != address(0)); signer = _signer; } function setTreasurer(address _treasurer) public onlyOwner { require(_treasurer != address(0)); treasurer = _treasurer; } // for test function setMax( uint32 _whiteList, uint32 _superWhiteList ) external onlyOwner { MaxWhiteList = _whiteList; MaxSuperWhiteList = _superWhiteList; } function setTime(uint32 _wlStart, uint32 _wlEnd) public onlyOwner { whitelistStart = _wlStart; whitelistEnd = _wlEnd; } // max super white list decrease, max white list increase the number function changeMax(uint32 _num) public onlyOwner { MaxSuperWhiteList -= _num; MaxWhiteList += _num; require(MaxSuperWhiteList >= mintedSuperWhiteList); } function airdrop(address[] memory _tos) external onlyOwner { for (uint32 i = 0; i < _tos.length; i++) { uint256 tokenId = nft.safeMint(_tos[i]); emit Minted(_tos[i], tokenId, 0); } mintedWhiteList += uint32(_tos.length); require( MaxWhiteList >= mintedWhiteList, "SNDNFTMinter: reach max, can't mint" ); } // regular mint after white list minted function mint(bool payEth) external payable { require(block.timestamp > whitelistEnd, "SNDNFTMinter: not start yet"); address recipient = _msgSender(); if (payEth) { require(msg.value >= ethPrice, "SNDNFTMinter: insufficient eth"); payable(treasurer).transfer(ethPrice); if (msg.value > ethPrice) { uint256 rest = msg.value - ethPrice; payable(recipient).transfer(rest); } } else { USDC.safeTransferFrom(recipient, treasurer, usdcPrice); } uint256 tokenId = nft.safeMint(recipient); mintedWhiteList++; require( MaxWhiteList >= mintedWhiteList, "SNDNFTMinter: reach max, can't mint" ); emit Minted(recipient, tokenId, 3); } // white list mint, category: 1-regular whitelist, 2-super whitelist; function permitMint( bool payEth, uint8 category, uint32 expired, bytes memory signature ) external payable { require( block.timestamp >= whitelistStart && block.timestamp <= whitelistEnd, "SNDNFTMinter: not within the whitelist minting period" ); address recipient = _msgSender(); MintInfo memory info = MintInfo({ recipient: recipient, nonce: nonces[recipient], category: category, expired: expired }); require(verify(info, signature), "SNDNFTMinter: signature is wrong!"); require(expired > block.timestamp, "SNDNFTMinter: expired!"); if (payEth) { require(msg.value >= ethPrice, "SNDNFTMinter: insufficient eth"); payable(treasurer).transfer(ethPrice); if (msg.value > ethPrice) { uint256 rest = msg.value - ethPrice; payable(recipient).transfer(rest); } } else { USDC.safeTransferFrom(recipient, treasurer, usdcPrice); } uint256 tokenId = nft.safeMint(recipient); emit Minted(recipient, tokenId, category); nonces[recipient] += 1; if (category == 1) { mintedWhiteList++; require( MaxWhiteList >= mintedWhiteList, "SNDNFTMinter: reach max, can't mint" ); } else { mintedSuperWhiteList++; require( MaxSuperWhiteList >= mintedSuperWhiteList, "SNDNFTMinter: reach max, can't mint" ); } } function getNonce(address user) public view returns (uint256 nonce) { nonce = nonces[user]; } function hash(MintInfo memory info) internal pure returns (bytes32) { return keccak256( abi.encode( MINTINFO_TYPEHASH, info.recipient, info.nonce, info.category, info.expired ) ); } function verify( MintInfo memory info, bytes memory signature ) internal view returns (bool) { bytes32 digest = _hashTypedDataV4(hash(info)); address addr = digest.recover(signature); return addr == signer; } function getPools() public view returns (uint32 maxSwl, uint32 maxWl, uint32 mintedSwl, uint32 mintedWl) { maxSwl = MaxSuperWhiteList; maxWl = MaxWhiteList; mintedSwl = mintedSuperWhiteList; mintedWl = mintedWhiteList; } }
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../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. * * The initial owner is set to the address provided by the deployer. 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; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @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 { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @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 { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _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); } }
@openzeppelin/contracts/interfaces/IERC5267.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @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. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ 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]. * * CAUTION: See Security Considerations above. */ 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); }
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../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 An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @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); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @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(token).code.length > 0; } }
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../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 address zero. * * 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); }
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) 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 FailedInnerCall(); } } }
@openzeppelin/contracts/utils/ShortStrings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
@openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @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), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(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) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } 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 bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
@openzeppelin/contracts/utils/cryptography/ECDSA.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @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 } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile 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 {MessageHashUtils-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] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { 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, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile 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 {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); 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] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. 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. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // 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, s); } // 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, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @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, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
@openzeppelin/contracts/utils/cryptography/EIP712.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @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); }
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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 towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (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 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) 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. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 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. uint256 twos = denominator & (0 - denominator); 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 (unsignedRoundsUp(rounding) && 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 * towards zero. * * 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * 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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * 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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @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); } } }
contracts/DiamondMarket.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; // diamond exchange market by usdt contract DiamondMarket is EIP712, Ownable { using ECDSA for bytes32; address public treasurer; address public signer; IERC20 public USD; // USDC IERC20 public GOLD; IERC20 public testUSD; // test usd for sell bool public isTest = true; uint public buyPrice; // 1 diamond cost X U; uint public sellPrice; mapping(address => uint256) public nonces; event Bought(address who, uint quantity, uint amount); event Sold(address who, uint quantity, uint amount); event Withdraw(address who, uint amount); event Received(address who, uint amount); struct Selling { address recipient; uint256 nonce; uint32 quantity; uint32 expired; } bytes32 constant SELLING_TYPEHASH = keccak256( "Selling(address recipient,uint256 nonce,uint32 quantity,uint32 expired)" ); constructor( address _treasurer, address _signer, address _usd, address _testUsd, address _gold, uint _buyPrice, uint _sellPrice ) EIP712("Swords Dungeons Diamond Market", "v1") Ownable(msg.sender) { treasurer = _treasurer; USD = IERC20(_usd); testUSD = IERC20(_testUsd); GOLD = IERC20(_gold); buyPrice = _buyPrice; sellPrice = _sellPrice; signer = _signer; } receive() external payable { emit Received(msg.sender, msg.value); } function withdraw(address payable to) external onlyOwner { uint amount = address(this).balance; to.transfer(amount); emit Withdraw(to, amount); } function setPrice(uint _buy, uint _sell) external onlyOwner { buyPrice = _buy; sellPrice = _sell; } function setSigner(address _signer) public onlyOwner { require(_signer != address(0)); signer = _signer; } function setTreasurer(address _treasurer) public onlyOwner { require(_treasurer != address(0)); treasurer = _treasurer; } function setUsd(address _usd) public onlyOwner { require(_usd != address(0)); USD = IERC20(_usd); } function setGold(address _gold) public onlyOwner { require(_gold != address(0)); GOLD = IERC20(_gold); } function setTestUsd(address _testUsd) public onlyOwner { require(_testUsd != address(0)); testUSD = IERC20(_testUsd); } function setTest(bool _isTest) public onlyOwner { isTest = _isTest; } // refund usdc to buyers in test stage function refund( address[] memory recipients, uint256[] memory amounts ) public onlyOwner { require( recipients.length == amounts.length, "wrong number of recipients" ); for (uint32 i = 0; i < recipients.length; i++) { USD.transferFrom(treasurer, recipients[i], amounts[i]); } } function rechargeGold(uint256 amount, uint32 expired) external { require( expired > block.timestamp, "DiamondMarket rechargeGold: expired!" ); GOLD.transferFrom(msg.sender, treasurer, amount); } function buy(uint32 quantity, uint32 expired) external { require(expired > block.timestamp, "DiamondMarket buy: expired!"); uint amount = quantity * buyPrice; USD.transferFrom(msg.sender, treasurer, amount); emit Bought(msg.sender, quantity, amount); } function permitSell( uint32 quantity, uint32 expired, bytes memory signature ) external { address recipient = _msgSender(); Selling memory selling = Selling({ recipient: recipient, nonce: nonces[recipient], quantity: quantity, expired: expired }); require( verify(selling, signature), "DiamondMarket: signature is wrong!" ); require(expired > block.timestamp, "DiamondMarket: expired!"); uint amount = quantity * sellPrice; if (isTest) { testUSD.transferFrom(treasurer, recipient, amount); } else { USD.transferFrom(treasurer, recipient, amount); } emit Sold(recipient, quantity, amount); nonces[recipient] += 1; } function getNonce(address user) public view returns (uint256 nonce) { nonce = nonces[user]; } function hash(Selling memory selling) internal pure returns (bytes32) { return keccak256( abi.encode( SELLING_TYPEHASH, selling.recipient, selling.nonce, selling.quantity, selling.expired ) ); } function verify( Selling memory selling, bytes memory signature ) internal view returns (bool) { bytes32 digest = _hashTypedDataV4(hash(selling)); address addr = digest.recover(signature); return addr == signer; } }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_treasurer","internalType":"address"},{"type":"address","name":"_signer","internalType":"address"},{"type":"address","name":"_nft","internalType":"address"},{"type":"uint256","name":"_ethPrice","internalType":"uint256"},{"type":"address","name":"_usdc","internalType":"address"},{"type":"uint256","name":"_usdcPrice","internalType":"uint256"}]},{"type":"error","name":"AddressEmptyCode","inputs":[{"type":"address","name":"target","internalType":"address"}]},{"type":"error","name":"AddressInsufficientBalance","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"ECDSAInvalidSignature","inputs":[]},{"type":"error","name":"ECDSAInvalidSignatureLength","inputs":[{"type":"uint256","name":"length","internalType":"uint256"}]},{"type":"error","name":"ECDSAInvalidSignatureS","inputs":[{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"error","name":"FailedInnerCall","inputs":[]},{"type":"error","name":"InvalidShortString","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"SafeERC20FailedOperation","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"error","name":"StringTooLong","inputs":[{"type":"string","name":"str","internalType":"string"}]},{"type":"event","name":"EIP712DomainChanged","inputs":[],"anonymous":false},{"type":"event","name":"Minted","inputs":[{"type":"address","name":"recipient","internalType":"address","indexed":false},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint8","name":"category","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Received","inputs":[{"type":"address","name":"who","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Withdraw","inputs":[{"type":"address","name":"who","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"MaxSuperWhiteList","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"MaxWhiteList","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"USDC","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"airdrop","inputs":[{"type":"address[]","name":"_tos","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeMax","inputs":[{"type":"uint32","name":"_num","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes1","name":"fields","internalType":"bytes1"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"version","internalType":"string"},{"type":"uint256","name":"chainId","internalType":"uint256"},{"type":"address","name":"verifyingContract","internalType":"address"},{"type":"bytes32","name":"salt","internalType":"bytes32"},{"type":"uint256[]","name":"extensions","internalType":"uint256[]"}],"name":"eip712Domain","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"ethPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"nonce","internalType":"uint256"}],"name":"getNonce","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"maxSwl","internalType":"uint32"},{"type":"uint32","name":"maxWl","internalType":"uint32"},{"type":"uint32","name":"mintedSwl","internalType":"uint32"},{"type":"uint32","name":"mintedWl","internalType":"uint32"}],"name":"getPools","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"mint","inputs":[{"type":"bool","name":"payEth","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"mintedSuperWhiteList","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"mintedWhiteList","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ISNDNFT"}],"name":"nft","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nonces","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"permitMint","inputs":[{"type":"bool","name":"payEth","internalType":"bool"},{"type":"uint8","name":"category","internalType":"uint8"},{"type":"uint32","name":"expired","internalType":"uint32"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMax","inputs":[{"type":"uint32","name":"_whiteList","internalType":"uint32"},{"type":"uint32","name":"_superWhiteList","internalType":"uint32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPrice","inputs":[{"type":"uint256","name":"_ethPrice","internalType":"uint256"},{"type":"uint256","name":"_usdcPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSigner","inputs":[{"type":"address","name":"_signer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTime","inputs":[{"type":"uint32","name":"_wlStart","internalType":"uint32"},{"type":"uint32","name":"_wlEnd","internalType":"uint32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTreasurer","inputs":[{"type":"address","name":"_treasurer","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"signer","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"treasurer","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"usdcPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"whitelistEnd","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"whitelistStart","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"address","name":"to","internalType":"address payable"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x61016060405260048054600160a01b600160e01b0319166501770000007d60a31b1790553480156200003057600080fd5b5060405162002563380380620025638339810160408190526200005391620002e7565b604080518082018252601a81527f53776f7264732044756e67656f6e73204e4654204d696e74657200000000000060208083019190915282518084019093526002835261763160f01b90830152903380620000c957604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000d481620001fe565b50620000e28260016200024e565b61012052620000f38160026200024e565b61014052815160208084019190912060e052815190820120610100524660a0526200018160e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052600380546001600160a01b039788166001600160a01b031991821617909155600580549588166c01000000000000000000000000026001600160601b03909616959095179094556006929092556004805494861694841694909417909355600855600780549290931691161790556200053f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020835110156200026e57620002668362000287565b905062000281565b816200027b8482620003fd565b5060ff90505b92915050565b600080829050601f81511115620002b5578260405163305a27a960e01b8152600401620000c09190620004c9565b8051620002c2826200051a565b179392505050565b80516001600160a01b0381168114620002e257600080fd5b919050565b60008060008060008060c087890312156200030157600080fd5b6200030c87620002ca565b95506200031c60208801620002ca565b94506200032c60408801620002ca565b9350606087015192506200034360808801620002ca565b915060a087015190509295509295509295565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200038157607f821691505b602082108103620003a257634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620003f8576000816000526020600020601f850160051c81016020861015620003d35750805b601f850160051c820191505b81811015620003f457828155600101620003df565b5050505b505050565b81516001600160401b0381111562000419576200041962000356565b62000431816200042a84546200036c565b84620003a8565b602080601f831160018114620004695760008415620004505750858301515b600019600386901b1c1916600185901b178555620003f4565b600085815260208120601f198616915b828110156200049a5788860151825594840194600190910190840162000479565b5085821015620004b95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020808352835180602085015260005b81811015620004f957858101830151858201604001528201620004db565b506000604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620003a25760001960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051611fc96200059a600039600061135701526000611325015260006116eb015260006116c30152600061161e01526000611648015260006116720152611fc96000f3fe6080604052600436106101c65760003560e01c8063729ad39e116100f7578063bfb6e0e711610095578063f41fbe7f11610064578063f41fbe7f146105ea578063f7d975771461060e578063fda49eb41461062e578063ff186b2e1461064e57600080fd5b8063bfb6e0e71461056c578063dacee34714610590578063dca968c4146105a6578063f2fde38b146105ca57600080fd5b806389a30271116100d157806389a30271146104f65780638da5cb5b14610516578063994d396914610534578063bb62da931461055957600080fd5b8063729ad39e146104815780637ecebe00146104a157806384b0196e146104ce57600080fd5b806347ccca0211610164578063671d64291161013e578063671d6429146103d7578063673a2a1f146103f75780636c19e7831461044c578063715018a61461046c57600080fd5b806347ccca021461036c57806351cff8d9146103935780635e3b6a13146103b357600080fd5b8063238ac933116101a0578063238ac933146102b0578063267f45d5146102e85780632d0335ab146103085780633f3645171461034c57600080fd5b80630f6df8f714610244578063120b86ad1461027b57806318c41a801461029d57600080fd5b3661023f576003546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015610204573d6000803e3d6000fd5b50604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a1005b600080fd5b34801561025057600080fd5b506005546102619063ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b34801561028757600080fd5b5061029b610296366004611a78565b610664565b005b61029b6102ab366004611ab9565b6106ac565b3480156102bc57600080fd5b506004546102d0906001600160a01b031681565b6040516001600160a01b039091168152602001610272565b3480156102f457600080fd5b5061029b610303366004611a78565b61095f565b34801561031457600080fd5b5061033e610323366004611aeb565b6001600160a01b031660009081526009602052604090205490565b604051908152602001610272565b34801561035857600080fd5b5061029b610367366004611b08565b6109ae565b34801561037857600080fd5b506005546102d090600160601b90046001600160a01b031681565b34801561039f57600080fd5b5061029b6103ae366004611aeb565b610a57565b3480156103bf57600080fd5b5060045461026190600160c01b900463ffffffff1681565b3480156103e357600080fd5b5061029b6103f2366004611aeb565b610ade565b34801561040357600080fd5b506004546005546040805163ffffffff600160c01b850481168252600160a01b85048116602083015292831691810191909152600160e01b909204166060820152608001610272565b34801561045857600080fd5b5061029b610467366004611aeb565b610b1b565b34801561047857600080fd5b5061029b610b58565b34801561048d57600080fd5b5061029b61049c366004611b6a565b610b6c565b3480156104ad57600080fd5b5061033e6104bc366004611aeb565b60096020526000908152604090205481565b3480156104da57600080fd5b506104e3610d32565b6040516102729796959493929190611c6c565b34801561050257600080fd5b506007546102d0906001600160a01b031681565b34801561052257600080fd5b506000546001600160a01b03166102d0565b34801561054057600080fd5b5060055461026190640100000000900463ffffffff1681565b61029b610567366004611d05565b610d78565b34801561057857600080fd5b5060055461026190600160401b900463ffffffff1681565b34801561059c57600080fd5b5061033e60085481565b3480156105b257600080fd5b5060045461026190600160e01b900463ffffffff1681565b3480156105d657600080fd5b5061029b6105e5366004611aeb565b6111f3565b3480156105f657600080fd5b5060045461026190600160a01b900463ffffffff1681565b34801561061a57600080fd5b5061029b610629366004611dd6565b61122e565b34801561063a57600080fd5b506003546102d0906001600160a01b031681565b34801561065a57600080fd5b5061033e60065481565b61066c611241565b6004805467ffffffffffffffff60a01b1916600160a01b63ffffffff9485160263ffffffff60c01b191617600160c01b9290931691909102919091179055565b600554600160401b900463ffffffff16421161070f5760405162461bcd60e51b815260206004820152601b60248201527f534e444e46544d696e7465723a206e6f7420737461727420796574000000000060448201526064015b60405180910390fd5b338115610800576006543410156107685760405162461bcd60e51b815260206004820152601e60248201527f534e444e46544d696e7465723a20696e73756666696369656e742065746800006044820152606401610706565b6003546006546040516001600160a01b039092169181156108fc0291906000818181858888f193505050501580156107a4573d6000803e3d6000fd5b506006543411156107fb576000600654346107bf9190611e0e565b6040519091506001600160a01b0383169082156108fc029083906000818181858888f193505050501580156107f8573d6000803e3d6000fd5b50505b610824565b600354600854600754610824926001600160a01b039182169285929091169061126e565b6005546040516340d097c360e01b81526001600160a01b038381166004830152600092600160601b900416906340d097c3906024016020604051808303816000875af1158015610878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089c9190611e21565b60048054919250600160e01b90910463ffffffff1690601c6108bd83611e3a565b82546101009290920a63ffffffff818102199093169183160217909155600454600160e01b81048216600160a01b909104909116101590506109115760405162461bcd60e51b815260040161070690611e5d565b604080516001600160a01b03841681526020810183905260038183015290517fdcb23284f3935b5557998e99dcc286e29744c5000723d99eecd5d6f5694f6e119181900360600190a1505050565b610967611241565b600580546bffffffffffffffff00000000191664010000000063ffffffff948516026bffffffff0000000000000000191617600160401b9290931691909102919091179055565b6109b6611241565b80600460188282829054906101000a900463ffffffff166109d79190611ea0565b92506101000a81548163ffffffff021916908363ffffffff16021790555080600460148282829054906101000a900463ffffffff16610a169190611ec4565b82546101009290920a63ffffffff818102199093169183160217909155600554600454908216600160c01b90910490911610159050610a5457600080fd5b50565b610a5f611241565b60405147906001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610a97573d6000803e3d6000fd5b50604080516001600160a01b0384168152602081018390527f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364910160405180910390a15050565b610ae6611241565b6001600160a01b038116610af957600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b610b23611241565b6001600160a01b038116610b3657600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b610b60611241565b610b6a60006112ce565b565b610b74611241565b60005b81518163ffffffff161015610cbc5760006005600c9054906101000a90046001600160a01b03166001600160a01b03166340d097c3848463ffffffff1681518110610bc457610bc4611ee1565b60200260200101516040518263ffffffff1660e01b8152600401610bf791906001600160a01b0391909116815260200190565b6020604051808303816000875af1158015610c16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3a9190611e21565b90507fdcb23284f3935b5557998e99dcc286e29744c5000723d99eecd5d6f5694f6e11838363ffffffff1681518110610c7557610c75611ee1565b602090810291909101810151604080516001600160a01b03909216825291810184905260008183015290519081900360600190a15080610cb481611e3a565b915050610b77565b50805160048054601c90610cde908490600160e01b900463ffffffff16611ec4565b82546101009290920a63ffffffff818102199093169183160217909155600454600160e01b81048216600160a01b90910490911610159050610a545760405162461bcd60e51b815260040161070690611e5d565b600060608060008060006060610d4661131e565b610d4e611350565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b600554640100000000900463ffffffff164210801590610da75750600554600160401b900463ffffffff164211155b610e115760405162461bcd60e51b815260206004820152603560248201527f534e444e46544d696e7465723a206e6f742077697468696e20746865207768696044820152741d195b1a5cdd081b5a5b9d1a5b99c81c195c9a5bd9605a1b6064820152608401610706565b604080516080810182523380825260008181526009602090815290849020549083015260ff86169282019290925263ffffffff84166060820152610e55818461137d565b610eab5760405162461bcd60e51b815260206004820152602160248201527f534e444e46544d696e7465723a207369676e61747572652069732077726f6e676044820152602160f81b6064820152608401610706565b428463ffffffff1611610ef95760405162461bcd60e51b8152602060048201526016602482015275534e444e46544d696e7465723a20657870697265642160501b6044820152606401610706565b8515610fe957600654341015610f515760405162461bcd60e51b815260206004820152601e60248201527f534e444e46544d696e7465723a20696e73756666696369656e742065746800006044820152606401610706565b6003546006546040516001600160a01b039092169181156108fc0291906000818181858888f19350505050158015610f8d573d6000803e3d6000fd5b50600654341115610fe457600060065434610fa89190611e0e565b6040519091506001600160a01b0384169082156108fc029083906000818181858888f19350505050158015610fe1573d6000803e3d6000fd5b50505b61100d565b60035460085460075461100d926001600160a01b039182169286929091169061126e565b6005546040516340d097c360e01b81526001600160a01b038481166004830152600092600160601b900416906340d097c3906024016020604051808303816000875af1158015611061573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110859190611e21565b604080516001600160a01b03861681526020810183905260ff89168183015290519192507fdcb23284f3935b5557998e99dcc286e29744c5000723d99eecd5d6f5694f6e11919081900360600190a16001600160a01b03831660009081526009602052604081208054600192906110fd908490611ef7565b909155505060ff86166001036111835760048054600160e01b900463ffffffff1690601c61112a83611e3a565b82546101009290920a63ffffffff818102199093169183160217909155600454600160e01b81048216600160a01b9091049091161015905061117e5760405162461bcd60e51b815260040161070690611e5d565b6111ea565b6005805463ffffffff1690600061119983611e3a565b82546101009290920a63ffffffff818102199093169183160217909155600554600454908216600160c01b909104909116101590506111ea5760405162461bcd60e51b815260040161070690611e5d565b50505050505050565b6111fb611241565b6001600160a01b03811661122557604051631e4fbdf760e01b815260006004820152602401610706565b610a54816112ce565b611236611241565b600691909155600855565b6000546001600160a01b03163314610b6a5760405163118cdaa760e01b8152336004820152602401610706565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526112c89085906113bb565b50505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606061134b7f00000000000000000000000000000000000000000000000000000000000000006001611423565b905090565b606061134b7f00000000000000000000000000000000000000000000000000000000000000006002611423565b60008061139161138c856114ce565b611566565b9050600061139f8285611593565b6004546001600160a01b03918216911614925050505b92915050565b60006113d06001600160a01b038416836115bd565b905080516000141580156113f55750808060200190518101906113f39190611f0a565b155b1561141e57604051635274afe760e01b81526001600160a01b0384166004820152602401610706565b505050565b606060ff831461143d57611436836115d2565b90506113b5565b81805461144990611f27565b80601f016020809104026020016040519081016040528092919081815260200182805461147590611f27565b80156114c25780601f10611497576101008083540402835291602001916114c2565b820191906000526020600020905b8154815290600101906020018083116114a557829003601f168201915b505050505090506113b5565b60007fca8dec6befa381195fba41428934ff6abfcf6ab57da750d19b08c208d34a04bd82600001518360200151846040015185606001516040516020016115499594939291909485526001600160a01b03939093166020850152604084019190915260ff16606083015263ffffffff16608082015260a00190565b604051602081830303815290604052805190602001209050919050565b60006113b5611573611611565b8360405161190160f01b8152600281019290925260228201526042902090565b6000806000806115a3868661173c565b9250925092506115b38282611789565b5090949350505050565b60606115cb83836000611846565b9392505050565b606060006115df836118e3565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801561166a57507f000000000000000000000000000000000000000000000000000000000000000046145b1561169457507f000000000000000000000000000000000000000000000000000000000000000090565b61134b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080600083516041036117765760208401516040850151606086015160001a6117688882858561190b565b955095509550505050611782565b50508151600091506002905b9250925092565b600082600381111561179d5761179d611f61565b036117a6575050565b60018260038111156117ba576117ba611f61565b036117d85760405163f645eedf60e01b815260040160405180910390fd5b60028260038111156117ec576117ec611f61565b0361180d5760405163fce698f760e01b815260048101829052602401610706565b600382600381111561182157611821611f61565b03611842576040516335e2f38360e21b815260048101829052602401610706565b5050565b60608147101561186b5760405163cd78605960e01b8152306004820152602401610706565b600080856001600160a01b031684866040516118879190611f77565b60006040518083038185875af1925050503d80600081146118c4576040519150601f19603f3d011682016040523d82523d6000602084013e6118c9565b606091505b50915091506118d98683836119da565b9695505050505050565b600060ff8216601f8111156113b557604051632cd44ac360e21b815260040160405180910390fd5b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561194657506000915060039050826119d0565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561199a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166119c6575060009250600191508290506119d0565b9250600091508190505b9450945094915050565b6060826119ef576119ea82611a36565b6115cb565b8151158015611a0657506001600160a01b0384163b155b15611a2f57604051639996b31560e01b81526001600160a01b0385166004820152602401610706565b50806115cb565b805115611a465780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b803563ffffffff81168114611a7357600080fd5b919050565b60008060408385031215611a8b57600080fd5b611a9483611a5f565b9150611aa260208401611a5f565b90509250929050565b8015158114610a5457600080fd5b600060208284031215611acb57600080fd5b81356115cb81611aab565b6001600160a01b0381168114610a5457600080fd5b600060208284031215611afd57600080fd5b81356115cb81611ad6565b600060208284031215611b1a57600080fd5b6115cb82611a5f565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611b6257611b62611b23565b604052919050565b60006020808385031215611b7d57600080fd5b823567ffffffffffffffff80821115611b9557600080fd5b818501915085601f830112611ba957600080fd5b813581811115611bbb57611bbb611b23565b8060051b9150611bcc848301611b39565b8181529183018401918481019088841115611be657600080fd5b938501935b83851015611c105784359250611c0083611ad6565b8282529385019390850190611beb565b98975050505050505050565b60005b83811015611c37578181015183820152602001611c1f565b50506000910152565b60008151808452611c58816020860160208601611c1c565b601f01601f19169290920160200192915050565b60ff60f81b881681526000602060e06020840152611c8d60e084018a611c40565b8381036040850152611c9f818a611c40565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015611cf357835183529284019291840191600101611cd7565b50909c9b505050505050505050505050565b60008060008060808587031215611d1b57600080fd5b8435611d2681611aab565b935060208581013560ff81168114611d3d57600080fd5b9350611d4b60408701611a5f565b9250606086013567ffffffffffffffff80821115611d6857600080fd5b818801915088601f830112611d7c57600080fd5b813581811115611d8e57611d8e611b23565b611da0601f8201601f19168501611b39565b91508082528984828501011115611db657600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060408385031215611de957600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b818103818111156113b5576113b5611df8565b600060208284031215611e3357600080fd5b5051919050565b600063ffffffff808316818103611e5357611e53611df8565b6001019392505050565b60208082526023908201527f534e444e46544d696e7465723a207265616368206d61782c2063616e2774206d6040820152621a5b9d60ea1b606082015260800190565b63ffffffff828116828216039080821115611ebd57611ebd611df8565b5092915050565b63ffffffff818116838216019080821115611ebd57611ebd611df8565b634e487b7160e01b600052603260045260246000fd5b808201808211156113b5576113b5611df8565b600060208284031215611f1c57600080fd5b81516115cb81611aab565b600181811c90821680611f3b57607f821691505b602082108103611f5b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052602160045260246000fd5b60008251611f89818460208701611c1c565b919091019291505056fea26469706673582212202465ec0a7d0daab90172b6a4de0ce107b5e87448c408c0b842e3f9a9f37d356264736f6c634300081800330000000000000000000000009b51ede29970e78eed3287a1785f7acdebe765070000000000000000000000001d4f4c4c1247063593256cfa0845a9181d6731b6000000000000000000000000fb63b729bd47df406a8ee969c47ef23c13fe0864000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000001718a9dd27c6f01d2cec34f3ac5c8f29dd61a1bd0000000000000000000000000000000000000000000000000000000014dc9380
Deployed ByteCode
0x6080604052600436106101c65760003560e01c8063729ad39e116100f7578063bfb6e0e711610095578063f41fbe7f11610064578063f41fbe7f146105ea578063f7d975771461060e578063fda49eb41461062e578063ff186b2e1461064e57600080fd5b8063bfb6e0e71461056c578063dacee34714610590578063dca968c4146105a6578063f2fde38b146105ca57600080fd5b806389a30271116100d157806389a30271146104f65780638da5cb5b14610516578063994d396914610534578063bb62da931461055957600080fd5b8063729ad39e146104815780637ecebe00146104a157806384b0196e146104ce57600080fd5b806347ccca0211610164578063671d64291161013e578063671d6429146103d7578063673a2a1f146103f75780636c19e7831461044c578063715018a61461046c57600080fd5b806347ccca021461036c57806351cff8d9146103935780635e3b6a13146103b357600080fd5b8063238ac933116101a0578063238ac933146102b0578063267f45d5146102e85780632d0335ab146103085780633f3645171461034c57600080fd5b80630f6df8f714610244578063120b86ad1461027b57806318c41a801461029d57600080fd5b3661023f576003546040516001600160a01b03909116903480156108fc02916000818181858888f19350505050158015610204573d6000803e3d6000fd5b50604080513381523460208201527f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f88525874910160405180910390a1005b600080fd5b34801561025057600080fd5b506005546102619063ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b34801561028757600080fd5b5061029b610296366004611a78565b610664565b005b61029b6102ab366004611ab9565b6106ac565b3480156102bc57600080fd5b506004546102d0906001600160a01b031681565b6040516001600160a01b039091168152602001610272565b3480156102f457600080fd5b5061029b610303366004611a78565b61095f565b34801561031457600080fd5b5061033e610323366004611aeb565b6001600160a01b031660009081526009602052604090205490565b604051908152602001610272565b34801561035857600080fd5b5061029b610367366004611b08565b6109ae565b34801561037857600080fd5b506005546102d090600160601b90046001600160a01b031681565b34801561039f57600080fd5b5061029b6103ae366004611aeb565b610a57565b3480156103bf57600080fd5b5060045461026190600160c01b900463ffffffff1681565b3480156103e357600080fd5b5061029b6103f2366004611aeb565b610ade565b34801561040357600080fd5b506004546005546040805163ffffffff600160c01b850481168252600160a01b85048116602083015292831691810191909152600160e01b909204166060820152608001610272565b34801561045857600080fd5b5061029b610467366004611aeb565b610b1b565b34801561047857600080fd5b5061029b610b58565b34801561048d57600080fd5b5061029b61049c366004611b6a565b610b6c565b3480156104ad57600080fd5b5061033e6104bc366004611aeb565b60096020526000908152604090205481565b3480156104da57600080fd5b506104e3610d32565b6040516102729796959493929190611c6c565b34801561050257600080fd5b506007546102d0906001600160a01b031681565b34801561052257600080fd5b506000546001600160a01b03166102d0565b34801561054057600080fd5b5060055461026190640100000000900463ffffffff1681565b61029b610567366004611d05565b610d78565b34801561057857600080fd5b5060055461026190600160401b900463ffffffff1681565b34801561059c57600080fd5b5061033e60085481565b3480156105b257600080fd5b5060045461026190600160e01b900463ffffffff1681565b3480156105d657600080fd5b5061029b6105e5366004611aeb565b6111f3565b3480156105f657600080fd5b5060045461026190600160a01b900463ffffffff1681565b34801561061a57600080fd5b5061029b610629366004611dd6565b61122e565b34801561063a57600080fd5b506003546102d0906001600160a01b031681565b34801561065a57600080fd5b5061033e60065481565b61066c611241565b6004805467ffffffffffffffff60a01b1916600160a01b63ffffffff9485160263ffffffff60c01b191617600160c01b9290931691909102919091179055565b600554600160401b900463ffffffff16421161070f5760405162461bcd60e51b815260206004820152601b60248201527f534e444e46544d696e7465723a206e6f7420737461727420796574000000000060448201526064015b60405180910390fd5b338115610800576006543410156107685760405162461bcd60e51b815260206004820152601e60248201527f534e444e46544d696e7465723a20696e73756666696369656e742065746800006044820152606401610706565b6003546006546040516001600160a01b039092169181156108fc0291906000818181858888f193505050501580156107a4573d6000803e3d6000fd5b506006543411156107fb576000600654346107bf9190611e0e565b6040519091506001600160a01b0383169082156108fc029083906000818181858888f193505050501580156107f8573d6000803e3d6000fd5b50505b610824565b600354600854600754610824926001600160a01b039182169285929091169061126e565b6005546040516340d097c360e01b81526001600160a01b038381166004830152600092600160601b900416906340d097c3906024016020604051808303816000875af1158015610878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089c9190611e21565b60048054919250600160e01b90910463ffffffff1690601c6108bd83611e3a565b82546101009290920a63ffffffff818102199093169183160217909155600454600160e01b81048216600160a01b909104909116101590506109115760405162461bcd60e51b815260040161070690611e5d565b604080516001600160a01b03841681526020810183905260038183015290517fdcb23284f3935b5557998e99dcc286e29744c5000723d99eecd5d6f5694f6e119181900360600190a1505050565b610967611241565b600580546bffffffffffffffff00000000191664010000000063ffffffff948516026bffffffff0000000000000000191617600160401b9290931691909102919091179055565b6109b6611241565b80600460188282829054906101000a900463ffffffff166109d79190611ea0565b92506101000a81548163ffffffff021916908363ffffffff16021790555080600460148282829054906101000a900463ffffffff16610a169190611ec4565b82546101009290920a63ffffffff818102199093169183160217909155600554600454908216600160c01b90910490911610159050610a5457600080fd5b50565b610a5f611241565b60405147906001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610a97573d6000803e3d6000fd5b50604080516001600160a01b0384168152602081018390527f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364910160405180910390a15050565b610ae6611241565b6001600160a01b038116610af957600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b610b23611241565b6001600160a01b038116610b3657600080fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b610b60611241565b610b6a60006112ce565b565b610b74611241565b60005b81518163ffffffff161015610cbc5760006005600c9054906101000a90046001600160a01b03166001600160a01b03166340d097c3848463ffffffff1681518110610bc457610bc4611ee1565b60200260200101516040518263ffffffff1660e01b8152600401610bf791906001600160a01b0391909116815260200190565b6020604051808303816000875af1158015610c16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3a9190611e21565b90507fdcb23284f3935b5557998e99dcc286e29744c5000723d99eecd5d6f5694f6e11838363ffffffff1681518110610c7557610c75611ee1565b602090810291909101810151604080516001600160a01b03909216825291810184905260008183015290519081900360600190a15080610cb481611e3a565b915050610b77565b50805160048054601c90610cde908490600160e01b900463ffffffff16611ec4565b82546101009290920a63ffffffff818102199093169183160217909155600454600160e01b81048216600160a01b90910490911610159050610a545760405162461bcd60e51b815260040161070690611e5d565b600060608060008060006060610d4661131e565b610d4e611350565b60408051600080825260208201909252600f60f81b9b939a50919850469750309650945092509050565b600554640100000000900463ffffffff164210801590610da75750600554600160401b900463ffffffff164211155b610e115760405162461bcd60e51b815260206004820152603560248201527f534e444e46544d696e7465723a206e6f742077697468696e20746865207768696044820152741d195b1a5cdd081b5a5b9d1a5b99c81c195c9a5bd9605a1b6064820152608401610706565b604080516080810182523380825260008181526009602090815290849020549083015260ff86169282019290925263ffffffff84166060820152610e55818461137d565b610eab5760405162461bcd60e51b815260206004820152602160248201527f534e444e46544d696e7465723a207369676e61747572652069732077726f6e676044820152602160f81b6064820152608401610706565b428463ffffffff1611610ef95760405162461bcd60e51b8152602060048201526016602482015275534e444e46544d696e7465723a20657870697265642160501b6044820152606401610706565b8515610fe957600654341015610f515760405162461bcd60e51b815260206004820152601e60248201527f534e444e46544d696e7465723a20696e73756666696369656e742065746800006044820152606401610706565b6003546006546040516001600160a01b039092169181156108fc0291906000818181858888f19350505050158015610f8d573d6000803e3d6000fd5b50600654341115610fe457600060065434610fa89190611e0e565b6040519091506001600160a01b0384169082156108fc029083906000818181858888f19350505050158015610fe1573d6000803e3d6000fd5b50505b61100d565b60035460085460075461100d926001600160a01b039182169286929091169061126e565b6005546040516340d097c360e01b81526001600160a01b038481166004830152600092600160601b900416906340d097c3906024016020604051808303816000875af1158015611061573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110859190611e21565b604080516001600160a01b03861681526020810183905260ff89168183015290519192507fdcb23284f3935b5557998e99dcc286e29744c5000723d99eecd5d6f5694f6e11919081900360600190a16001600160a01b03831660009081526009602052604081208054600192906110fd908490611ef7565b909155505060ff86166001036111835760048054600160e01b900463ffffffff1690601c61112a83611e3a565b82546101009290920a63ffffffff818102199093169183160217909155600454600160e01b81048216600160a01b9091049091161015905061117e5760405162461bcd60e51b815260040161070690611e5d565b6111ea565b6005805463ffffffff1690600061119983611e3a565b82546101009290920a63ffffffff818102199093169183160217909155600554600454908216600160c01b909104909116101590506111ea5760405162461bcd60e51b815260040161070690611e5d565b50505050505050565b6111fb611241565b6001600160a01b03811661122557604051631e4fbdf760e01b815260006004820152602401610706565b610a54816112ce565b611236611241565b600691909155600855565b6000546001600160a01b03163314610b6a5760405163118cdaa760e01b8152336004820152602401610706565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526112c89085906113bb565b50505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b606061134b7f53776f7264732044756e67656f6e73204e4654204d696e74657200000000001a6001611423565b905090565b606061134b7f76310000000000000000000000000000000000000000000000000000000000026002611423565b60008061139161138c856114ce565b611566565b9050600061139f8285611593565b6004546001600160a01b03918216911614925050505b92915050565b60006113d06001600160a01b038416836115bd565b905080516000141580156113f55750808060200190518101906113f39190611f0a565b155b1561141e57604051635274afe760e01b81526001600160a01b0384166004820152602401610706565b505050565b606060ff831461143d57611436836115d2565b90506113b5565b81805461144990611f27565b80601f016020809104026020016040519081016040528092919081815260200182805461147590611f27565b80156114c25780601f10611497576101008083540402835291602001916114c2565b820191906000526020600020905b8154815290600101906020018083116114a557829003601f168201915b505050505090506113b5565b60007fca8dec6befa381195fba41428934ff6abfcf6ab57da750d19b08c208d34a04bd82600001518360200151846040015185606001516040516020016115499594939291909485526001600160a01b03939093166020850152604084019190915260ff16606083015263ffffffff16608082015260a00190565b604051602081830303815290604052805190602001209050919050565b60006113b5611573611611565b8360405161190160f01b8152600281019290925260228201526042902090565b6000806000806115a3868661173c565b9250925092506115b38282611789565b5090949350505050565b60606115cb83836000611846565b9392505050565b606060006115df836118e3565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b6000306001600160a01b037f000000000000000000000000b876afa06cb0b043d7860cef16c529d39087a9fd1614801561166a57507f0000000000000000000000000000000000000000000000000000000000028c6146145b1561169457507f269a748cf72fce2d1e4533dcff2d569c6670c135d470e368a5719cbc8766c23090565b61134b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f4f32632abd7e6a52321af5ab09db8c418cc8c62124da9ebf87f816a8085ba99e918101919091527f0984d5efd47d99151ae1be065a709e56c602102f24c1abc4008eb3f815a8d21760608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b600080600083516041036117765760208401516040850151606086015160001a6117688882858561190b565b955095509550505050611782565b50508151600091506002905b9250925092565b600082600381111561179d5761179d611f61565b036117a6575050565b60018260038111156117ba576117ba611f61565b036117d85760405163f645eedf60e01b815260040160405180910390fd5b60028260038111156117ec576117ec611f61565b0361180d5760405163fce698f760e01b815260048101829052602401610706565b600382600381111561182157611821611f61565b03611842576040516335e2f38360e21b815260048101829052602401610706565b5050565b60608147101561186b5760405163cd78605960e01b8152306004820152602401610706565b600080856001600160a01b031684866040516118879190611f77565b60006040518083038185875af1925050503d80600081146118c4576040519150601f19603f3d011682016040523d82523d6000602084013e6118c9565b606091505b50915091506118d98683836119da565b9695505050505050565b600060ff8216601f8111156113b557604051632cd44ac360e21b815260040160405180910390fd5b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561194657506000915060039050826119d0565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa15801561199a573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166119c6575060009250600191508290506119d0565b9250600091508190505b9450945094915050565b6060826119ef576119ea82611a36565b6115cb565b8151158015611a0657506001600160a01b0384163b155b15611a2f57604051639996b31560e01b81526001600160a01b0385166004820152602401610706565b50806115cb565b805115611a465780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b803563ffffffff81168114611a7357600080fd5b919050565b60008060408385031215611a8b57600080fd5b611a9483611a5f565b9150611aa260208401611a5f565b90509250929050565b8015158114610a5457600080fd5b600060208284031215611acb57600080fd5b81356115cb81611aab565b6001600160a01b0381168114610a5457600080fd5b600060208284031215611afd57600080fd5b81356115cb81611ad6565b600060208284031215611b1a57600080fd5b6115cb82611a5f565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611b6257611b62611b23565b604052919050565b60006020808385031215611b7d57600080fd5b823567ffffffffffffffff80821115611b9557600080fd5b818501915085601f830112611ba957600080fd5b813581811115611bbb57611bbb611b23565b8060051b9150611bcc848301611b39565b8181529183018401918481019088841115611be657600080fd5b938501935b83851015611c105784359250611c0083611ad6565b8282529385019390850190611beb565b98975050505050505050565b60005b83811015611c37578181015183820152602001611c1f565b50506000910152565b60008151808452611c58816020860160208601611c1c565b601f01601f19169290920160200192915050565b60ff60f81b881681526000602060e06020840152611c8d60e084018a611c40565b8381036040850152611c9f818a611c40565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b81811015611cf357835183529284019291840191600101611cd7565b50909c9b505050505050505050505050565b60008060008060808587031215611d1b57600080fd5b8435611d2681611aab565b935060208581013560ff81168114611d3d57600080fd5b9350611d4b60408701611a5f565b9250606086013567ffffffffffffffff80821115611d6857600080fd5b818801915088601f830112611d7c57600080fd5b813581811115611d8e57611d8e611b23565b611da0601f8201601f19168501611b39565b91508082528984828501011115611db657600080fd5b808484018584013760008482840101525080935050505092959194509250565b60008060408385031215611de957600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b818103818111156113b5576113b5611df8565b600060208284031215611e3357600080fd5b5051919050565b600063ffffffff808316818103611e5357611e53611df8565b6001019392505050565b60208082526023908201527f534e444e46544d696e7465723a207265616368206d61782c2063616e2774206d6040820152621a5b9d60ea1b606082015260800190565b63ffffffff828116828216039080821115611ebd57611ebd611df8565b5092915050565b63ffffffff818116838216019080821115611ebd57611ebd611df8565b634e487b7160e01b600052603260045260246000fd5b808201808211156113b5576113b5611df8565b600060208284031215611f1c57600080fd5b81516115cb81611aab565b600181811c90821680611f3b57607f821691505b602082108103611f5b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052602160045260246000fd5b60008251611f89818460208701611c1c565b919091019291505056fea26469706673582212202465ec0a7d0daab90172b6a4de0ce107b5e87448c408c0b842e3f9a9f37d356264736f6c63430008180033