Feature Tip: Add private address tag to any address under My Name Tag !
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60a06040 | 19894004 | 94 days ago | IN | 0 ETH | 0.01229683 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
MoonpassNFTDropCollection
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 20 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.13; import { MoonpassInitializer, RequestSignature } from "../interfaces/IMoonpassContract.sol"; import { NFTCollectionInitializer } from "../interfaces/nft/IMoonpassNFTCollection.sol"; import { IMoonpassNFTDropCollection, ClaimRequest, AirdropRequest } from "../interfaces/nft/IMoonpassNFTDropCollection.sol"; import { MoonpassNFTCollection } from "./MoonpassNFTCollection.sol"; import { MoonpassRoles } from "../auth/MoonpassRoles.sol"; contract MoonpassNFTDropCollection is IMoonpassNFTDropCollection, MoonpassNFTCollection { bytes32 internal constant CLAIM_TYPEHASH = keccak256("ClaimRequest(address to,uint256 quantity,RequestContext context)RequestContext(address requester,uint256 expiry,uint256 nonce)"); bytes32 internal constant AIRDROP_TYPEHASH = keccak256("AirdropRequest(address[] to,uint256[] quantity,RequestContext context)RequestContext(address requester,uint256 expiry,uint256 nonce)"); function initialize( NFTCollectionInitializer calldata data, MoonpassInitializer calldata moonpass ) public initializer initializerERC721A { __MoonpassNFTCollection_init(data, moonpass); __Nonces_init(); } function claim( address to, uint256 quantity ) external onlyRole(MoonpassRoles.NFT_MINTER_ROLE) { _claim(to, quantity); } function claim( ClaimRequest calldata request, RequestSignature calldata signature ) external { bytes memory data = abi.encode( CLAIM_TYPEHASH, request.to, request.quantity, _encodeContext(signature) ); _checkRole(MoonpassRoles.NFT_MINTER_TRUSTEE_ROLE, _signerFrom(data, signature)); _useCheckedNonce(_msgSender(), signature.nonce); _claim(request.to, request.quantity); } function _claim( address to, uint256 quantity ) internal { _mint(to, quantity); } function airdrop( address[] calldata to, uint256[] calldata quantity ) external onlyRole(MoonpassRoles.NFT_MINTER_ROLE) { _airdrop(to, quantity); } function airdrop( AirdropRequest calldata request, RequestSignature calldata signature ) external { bytes memory data = abi.encode( AIRDROP_TYPEHASH, request.to, request.quantity, _encodeContext(signature) ); _checkRole(MoonpassRoles.NFT_MINTER_TRUSTEE_ROLE, _signerFrom(data, signature)); _useCheckedNonce(_msgSender(), signature.nonce); _airdrop(request.to, request.quantity); } function _airdrop( address[] calldata to, uint256[] calldata quantity ) internal { uint256 len = to.length; if(len != quantity.length) { revert InvalidAirdropRequest(); } for(uint256 i = 0; i < len;) { _mint(to[i], quantity[i]); unchecked { i++; } } } }
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.18; interface IMoonpassContract { function authorizer() external view returns(address authorizerAddress); function setAuthorizer(address authorizerAddress) external; function setAuthorizer(SetAuthorizerRequest calldata request, RequestSignature calldata signature) external; function version() external view returns (uint64); error InvalidAddressError(); error InvalidRequestError(); event AuthorizerChange(address authorizationManager); } struct MoonpassInitializer { address owner; address authorizer; } struct SetAuthorizerRequest { address authorizerAddress; } struct RequestSignature { uint8 v; bytes32 r; bytes32 s; uint256 expiry; uint256 nonce; }
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.18; import { IERC721AUpgradeable } from "erc721a-upgradeable/contracts/IERC721AUpgradeable.sol"; import { IERC2981 } from "@openzeppelin/contracts/interfaces/IERC2981.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { RequestSignature } from "../IMoonpassContract.sol"; interface IMoonpassNFTCollection { function setRoyaltyInfo(address feeCollector, uint96 feeNumerator) external; function setRoyaltyInfo(SetRoyaltyInfoRequest calldata request, RequestSignature calldata signature) external; function contractURI() external view returns (string memory); function setContractURI(string memory uri) external; function setContractURI(SetContractURIRequest calldata request, RequestSignature calldata signature) external; function setBaseURI(string memory uri) external; function setBaseURI(SetBaseURIRequest calldata request, RequestSignature calldata signature) external; event NFTCollectionRoyaltyInfoChange(address feeCollector, uint96 feeNumerator); event NFTCollectionContractURIChange(); event NFTCollectionBaseURIChange(); } struct NFTCollectionInitializer { string name; string symbol; string baseUri; string contractUri; } struct SetRoyaltyInfoRequest { address feeCollector; uint96 feeNumerator; } struct SetContractURIRequest { string uri; } struct SetBaseURIRequest { string uri; }
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.18; import { MoonpassInitializer, RequestSignature } from "../IMoonpassContract.sol"; import { NFTCollectionInitializer } from "./IMoonpassNFTCollection.sol"; interface IMoonpassNFTDropCollection { function initialize(NFTCollectionInitializer calldata data, MoonpassInitializer calldata moonpass) external; function claim(address to, uint256 quantity) external; function claim(ClaimRequest calldata request, RequestSignature calldata signature) external; function airdrop(address[] calldata to, uint256[] calldata quantity) external; function airdrop(AirdropRequest calldata request, RequestSignature calldata signature) external; error InvalidAirdropRequest(); } struct ClaimRequest { address to; uint256 quantity; } struct AirdropRequest { address[] to; uint256[] quantity; }
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.13; import { ERC721AUpgradeable } from "erc721a-upgradeable/contracts/ERC721AUpgradeable.sol"; import { NoncesUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/NoncesUpgradeable.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { ERC2981Upgradeable } from "@openzeppelin/contracts-upgradeable/token/common/ERC2981Upgradeable.sol"; import { ERC165Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import { MoonpassInitializer, RequestSignature } from "../interfaces/IMoonpassContract.sol"; import { IMoonpassNFTCollection, NFTCollectionInitializer, SetBaseURIRequest, SetContractURIRequest, SetRoyaltyInfoRequest } from "../interfaces/nft/IMoonpassNFTCollection.sol"; import { MoonpassContract } from "../MoonpassContract.sol"; import { MoonpassRoles } from "../auth/MoonpassRoles.sol"; contract MoonpassNFTCollection is IMoonpassNFTCollection, ERC721AUpgradeable, ERC2981Upgradeable, ReentrancyGuardUpgradeable, NoncesUpgradeable, MoonpassContract { bytes32 internal constant SET_ROYALTY_INFO_TYPEHASH = keccak256("SetRoyaltyInfoRequest(address feeCollector,uint96 feeNumerator,RequestContext context)RequestContext(address requester,uint256 expiry,uint256 nonce)"); bytes32 internal constant SET_CONTRACT_URI_TYPEHASH = keccak256("SetContractURIRequest(string uri,RequestContext context)RequestContext(address requester,uint256 expiry,uint256 nonce)"); bytes32 internal constant SET_BASE_URI_TYPEHASH = keccak256("SetBaseURIRequest(string uri,RequestContext context)RequestContext(address requester,uint256 expiry,uint256 nonce)"); struct MoonpassNFTCollectionStorage { string _baseUri; string _contractUri; } bytes32 private constant MoonpassNFTCollectionStorageLocation = 0x4fe52371adf1fc5bb26ee736cbfc7fb9f2892e83072eda9f832b3d4a9428cb99; function _getMoonpassNFTCollectionStorage() private pure returns (MoonpassNFTCollectionStorage storage $) { assembly { $.slot := MoonpassNFTCollectionStorageLocation } } function __MoonpassNFTCollection_init( NFTCollectionInitializer calldata data, MoonpassInitializer calldata moonpass ) internal onlyInitializing onlyInitializingERC721A { __Moonpass_init(moonpass); __ERC721A_init(data.name, data.symbol); __ERC2981_init(); __ReentrancyGuard_init(); _setContractURI(data.contractUri); _setBaseURI(data.baseUri); } function _mint( address to, uint256 quantity ) internal override nonReentrant { super._mint(to, quantity); } function setRoyaltyInfo( address feeCollector, uint96 feeNumerator ) external onlyRole(MoonpassRoles.NFT_ADMIN_ROLE) { _setRoyaltyInfo(feeCollector, feeNumerator); } function setRoyaltyInfo( SetRoyaltyInfoRequest calldata request, RequestSignature calldata signature ) external { bytes memory data = abi.encode( SET_ROYALTY_INFO_TYPEHASH, request.feeCollector, request.feeNumerator, _encodeContext(signature) ); _checkRole(MoonpassRoles.NFT_TRUSTEE_ROLE, _signerFrom(data, signature)); _useCheckedNonce(_msgSender(), signature.nonce); _setRoyaltyInfo(request.feeCollector, request.feeNumerator); } function _setRoyaltyInfo( address feeCollector, uint96 feeNumerator ) internal { _setDefaultRoyalty(feeCollector, feeNumerator); emit NFTCollectionRoyaltyInfoChange(feeCollector, feeNumerator); } function contractURI() external view returns (string memory) { MoonpassNFTCollectionStorage storage $ = _getMoonpassNFTCollectionStorage(); return $._contractUri; } function setContractURI( string memory uri ) external onlyRole(MoonpassRoles.NFT_MANAGER_ROLE) { _setContractURI(uri); } function setContractURI( SetContractURIRequest calldata request, RequestSignature calldata signature ) external { bytes memory data = abi.encode( SET_CONTRACT_URI_TYPEHASH, request.uri, _encodeContext(signature) ); _checkRole(MoonpassRoles.NFT_TRUSTEE_ROLE, _signerFrom(data, signature)); _useCheckedNonce(_msgSender(), signature.nonce); _setContractURI(request.uri); } function _setContractURI( string memory uri ) internal { MoonpassNFTCollectionStorage storage $ = _getMoonpassNFTCollectionStorage(); $._contractUri = uri; emit NFTCollectionContractURIChange(); } function setBaseURI( string memory uri ) external onlyRole(MoonpassRoles.NFT_MANAGER_ROLE) { _setBaseURI(uri); } function setBaseURI( SetBaseURIRequest calldata request, RequestSignature calldata signature ) external { bytes memory data = abi.encode( SET_BASE_URI_TYPEHASH, request.uri, _encodeContext(signature) ); _checkRole(MoonpassRoles.NFT_TRUSTEE_ROLE, _signerFrom(data, signature)); _useCheckedNonce(_msgSender(), signature.nonce); _setBaseURI(request.uri); } function _setBaseURI( string memory uri ) internal { MoonpassNFTCollectionStorage storage $ = _getMoonpassNFTCollectionStorage(); $._baseUri = uri; emit NFTCollectionBaseURIChange(); } function _baseURI() internal view override returns (string memory) { MoonpassNFTCollectionStorage storage $ = _getMoonpassNFTCollectionStorage(); return $._baseUri; } function supportsInterface( bytes4 interfaceId ) public view override(ERC721AUpgradeable, ERC2981Upgradeable) returns (bool) { return ERC2981Upgradeable.supportsInterface(interfaceId) || ERC721AUpgradeable.supportsInterface(interfaceId); } function _feeDenominator() internal pure override returns (uint96) { return 1000000; } function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal override whenNotPaused {} function _startTokenId() internal pure override returns (uint256) { return 1; } }
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.18; library MoonpassRoles { bytes32 public constant FACTORY_MANAGER_ROLE = keccak256("FACTORY_MANAGER_ROLE"); bytes32 public constant DISTRIBUTION_MANAGER_ROLE = keccak256("DISTRIBUTION_MANAGER_ROLE"); bytes32 public constant NFT_DISTRIBUTION_WITHDRAW_ROLE = keccak256("NFT_DISTRIBUTION_WITHDRAW_ROLE"); bytes32 public constant ACCOUNT_DISTRIBUTION_WITHDRAW_ROLE = keccak256("ACCOUNT_DISTRIBUTION_WITHDRAW_ROLE"); bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant CLAIM_ADMIN_ROLE = keccak256("CLAIM_ADMIN_ROLE"); bytes32 public constant CLAIM_MANAGER_ROLE = keccak256("CLAIM_MANAGER_ROLE"); bytes32 public constant CLAIM_TRUSTEE_ROLE = keccak256("CLAIM_TRUSTEE_ROLE"); bytes32 public constant VAULT_TRUSTEE_ROLE = keccak256("VAULT_TRUSTEE_ROLE"); bytes32 public constant AUTH_DEFAULT_ADMIN_ROLE = 0x00; bytes32 public constant AUTH_MANAGER_ROLE = keccak256("AUTH_MANAGER_ROLE"); bytes32 public constant AUTH_MASTER_ROLE = keccak256("AUTH_MASTER_ROLE"); bytes32 public constant NFT_ADMIN_ROLE = keccak256("NFT_ADMIN_ROLE"); bytes32 public constant NFT_MANAGER_ROLE = keccak256("NFT_MANAGER_ROLE"); bytes32 public constant NFT_MINTER_ROLE = keccak256("NFT_MINTER_ROLE"); bytes32 public constant STAKING_MANAGER_ROLE = keccak256("STAKING_MANAGER_ROLE"); bytes32 public constant PROPOSAL_MANAGER_ROLE = keccak256("PROPOSAL_MANAGER_ROLE"); bytes32 public constant FUNDRAISER_MANAGER_ROLE = keccak256("FUNDRAISER_MANAGER_ROLE"); bytes32 public constant NFT_MINTER_TRUSTEE_ROLE = keccak256("NFT_MINTER_TRUSTEE_ROLE"); bytes32 public constant NFT_TRUSTEE_ROLE = keccak256("NFT_TRUSTEE_ROLE"); bytes32 public constant PROPOSAL_TRUSTEE_ROLE = keccak256("PROPOSAL_TRUSTEE_ROLE"); bytes32 public constant STAKING_TRUSTEE_ROLE = keccak256("STAKING_TRUSTEE_ROLE"); bytes32 public constant FUNDRAISER_TRUSTEE_ROLE = keccak256("FUNDRAISER_TRUSTEE_ROLE"); }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721AUpgradeable { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external payable; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external payable; /** * @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 payable; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated 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); }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721AUpgradeable.sol'; import {ERC721AStorage} from './ERC721AStorage.sol'; import './ERC721A__Initializable.sol'; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721ReceiverUpgradeable { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721AUpgradeable is ERC721A__Initializable, IERC721AUpgradeable { using ERC721AStorage for ERC721AStorage.Layout; // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // CONSTRUCTOR // ============================================================= function __ERC721A_init(string memory name_, string memory symbol_) internal onlyInitializingERC721A { __ERC721A_init_unchained(name_, symbol_); } function __ERC721A_init_unchained(string memory name_, string memory symbol_) internal onlyInitializingERC721A { ERC721AStorage.layout()._name = name_; ERC721AStorage.layout()._symbol = symbol_; ERC721AStorage.layout()._currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return ERC721AStorage.layout()._currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return ERC721AStorage.layout()._currentIndex - ERC721AStorage.layout()._burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return ERC721AStorage.layout()._currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return ERC721AStorage.layout()._burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return ERC721AStorage.layout()._packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = ERC721AStorage.layout()._packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); ERC721AStorage.layout()._packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return ERC721AStorage.layout()._name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return ERC721AStorage.layout()._symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(ERC721AStorage.layout()._packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (ERC721AStorage.layout()._packedOwnerships[index] == 0) { ERC721AStorage.layout()._packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) { if (_startTokenId() <= tokenId) { packed = ERC721AStorage.layout()._packedOwnerships[tokenId]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // If the data at the starting slot does not exist, start the scan. if (packed == 0) { if (tokenId >= ERC721AStorage.layout()._currentIndex) revert OwnerQueryForNonexistentToken(); // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `tokenId` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. for (;;) { unchecked { packed = ERC721AStorage.layout()._packedOwnerships[--tokenId]; } if (packed == 0) continue; return packed; } } // Otherwise, the data exists and is not burned. We can skip the scan. // This is possible because we have already achieved the target condition. // This saves 2143 gas on transfers of initialized tokens. return packed; } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}. * * Requirements: * * - The caller must own the token or be an approved operator. */ function approve(address to, uint256 tokenId) public payable virtual override { _approve(to, tokenId, true); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return ERC721AStorage.layout()._tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) public virtual override { ERC721AStorage.layout()._operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return ERC721AStorage.layout()._operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _startTokenId() <= tokenId && tokenId < ERC721AStorage.layout()._currentIndex && // If within bounds, ERC721AStorage.layout()._packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress) { ERC721AStorage.TokenApprovalRef storage tokenApproval = ERC721AStorage.layout()._tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --ERC721AStorage.layout()._packedAddressData[from]; // Updates: `balance -= 1`. ++ERC721AStorage.layout()._packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public payable virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @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 memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (bytes4 retval) { return retval == ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) // The `iszero(eq(,))` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. // The compiler will optimize the `iszero` away for performance. for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); ERC721AStorage.layout()._currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); ERC721AStorage.layout()._currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = ERC721AStorage.layout()._currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (ERC721AStorage.layout()._currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Equivalent to `_approve(to, tokenId, false)`. */ function _approve(address to, uint256 tokenId) internal virtual { _approve(to, tokenId, false); } /** * @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: * * - `tokenId` must exist. * * Emits an {Approval} event. */ function _approve( address to, uint256 tokenId, bool approvalCheck ) internal virtual { address owner = ownerOf(tokenId); if (approvalCheck) if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } ERC721AStorage.layout()._tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. ERC721AStorage.layout()._packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { ERC721AStorage.layout()._burnCounter++; } } // ============================================================= // EXTRA DATA OPERATIONS // ============================================================= /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual { uint256 packed = ERC721AStorage.layout()._packedOwnerships[index]; if (packed == 0) revert OwnershipNotInitializedForExtraData(); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA); ERC721AStorage.layout()._packedOwnerships[index] = packed; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract NoncesUpgradeable is Initializable { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); /// @custom:storage-location erc7201:openzeppelin.storage.Nonces struct NoncesStorage { mapping(address account => uint256) _nonces; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Nonces")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant NoncesStorageLocation = 0x5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb00; function _getNoncesStorage() private pure returns (NoncesStorage storage $) { assembly { $.slot := NoncesStorageLocation } } function __Nonces_init() internal onlyInitializing { } function __Nonces_init_unchained() internal onlyInitializing { } /** * @dev Returns the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { NoncesStorage storage $ = _getNoncesStorage(); return $._nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { NoncesStorage storage $ = _getNoncesStorage(); // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return $._nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/common/ERC2981.sol) pragma solidity ^0.8.20; import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {ERC165Upgradeable} from "../../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. */ abstract contract ERC2981Upgradeable is Initializable, IERC2981, ERC165Upgradeable { struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } /// @custom:storage-location erc7201:openzeppelin.storage.ERC2981 struct ERC2981Storage { RoyaltyInfo _defaultRoyaltyInfo; mapping(uint256 tokenId => RoyaltyInfo) _tokenRoyaltyInfo; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC2981")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC2981StorageLocation = 0xdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b00; function _getERC2981Storage() private pure returns (ERC2981Storage storage $) { assembly { $.slot := ERC2981StorageLocation } } /** * @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1). */ error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator); /** * @dev The default royalty receiver is invalid. */ error ERC2981InvalidDefaultRoyaltyReceiver(address receiver); /** * @dev The royalty set for an specific `tokenId` is invalid (eg. (numerator / denominator) >= 1). */ error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator); /** * @dev The royalty receiver for `tokenId` is invalid. */ error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver); function __ERC2981_init() internal onlyInitializing { } function __ERC2981_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165Upgradeable) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981 */ function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual returns (address, uint256) { ERC2981Storage storage $ = _getERC2981Storage(); RoyaltyInfo memory royalty = $._tokenRoyaltyInfo[tokenId]; if (royalty.receiver == address(0)) { royalty = $._defaultRoyaltyInfo; } uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { ERC2981Storage storage $ = _getERC2981Storage(); uint256 denominator = _feeDenominator(); if (feeNumerator > denominator) { // Royalty fee will exceed the sale price revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator); } if (receiver == address(0)) { revert ERC2981InvalidDefaultRoyaltyReceiver(address(0)); } $._defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Removes default royalty information. */ function _deleteDefaultRoyalty() internal virtual { ERC2981Storage storage $ = _getERC2981Storage(); delete $._defaultRoyaltyInfo; } /** * @dev Sets the royalty information for a specific token id, overriding the global default. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual { ERC2981Storage storage $ = _getERC2981Storage(); uint256 denominator = _feeDenominator(); if (feeNumerator > denominator) { // Royalty fee will exceed the sale price revert ERC2981InvalidTokenRoyalty(tokenId, feeNumerator, denominator); } if (receiver == address(0)) { revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0)); } $._tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator); } /** * @dev Resets royalty information for the token id back to the global default. */ function _resetTokenRoyalty(uint256 tokenId) internal virtual { ERC2981Storage storage $ = _getERC2981Storage(); delete $._tokenRoyaltyInfo[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: Proprietary /** Moonpass Token Management Platform. All rights reserved. Access https://moonpass.io to learn more. */ pragma solidity ^0.8.18; import { IMoonpassContract, MoonpassInitializer, SetAuthorizerRequest, RequestSignature } from "./interfaces/IMoonpassContract.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { MoonpassRoles } from "./auth/MoonpassRoles.sol"; contract MoonpassContract is IMoonpassContract, OwnableUpgradeable, PausableUpgradeable, EIP712Upgradeable, UUPSUpgradeable { using ECDSA for bytes32; using ERC165Checker for address; bytes32 public constant SET_AUTHORIZER_TYPEHASH = keccak256("SetAuthorizerRequest(address authorizerAddress,RequestContext context)RequestContext(address requester,uint256 expiry,uint256 nonce)"); bytes32 public constant CONTEXT_TYPEHASH = 0x08c0db72018bde0ea5215618bdbdfe278d6c1fae34ae3cfa2ef60ce156906175; struct MoonpassContractStorage { address _authorizer; } bytes32 private constant MoonpassContractStorageLocation = 0xcf1e3c2eec56b7a457652c54121209bbbd2922d418d6ab903c014713a5d410e2; function _getMoonpassContractStorage() private pure returns (MoonpassContractStorage storage $) { assembly { $.slot := MoonpassContractStorageLocation } } function __Moonpass_init( MoonpassInitializer calldata data ) internal onlyInitializing { __Pausable_init(); __EIP712_init("moonpass", "1.1"); __Ownable_init(data.owner); __UUPSUpgradeable_init(); _setAuthorizer(data.authorizer); } function setAuthorizer( address authorizerAddress ) external onlyRole(MoonpassRoles.AUTH_MANAGER_ROLE) { _setAuthorizer(authorizerAddress); } function setAuthorizer( SetAuthorizerRequest calldata request, RequestSignature calldata signature ) external { bytes memory data = abi.encode( SET_AUTHORIZER_TYPEHASH, request.authorizerAddress, _encodeContext(signature) ); _checkRole(MoonpassRoles.AUTH_MANAGER_ROLE, _signerFrom(data, signature)); _setAuthorizer(request.authorizerAddress); } function version() external view returns (uint64) { return _getInitializedVersion(); } function _encodeContext( RequestSignature calldata signature ) internal view returns( bytes32 hashed ) { _checkContext(signature); hashed = keccak256( abi.encode( CONTEXT_TYPEHASH, _msgSender(), signature.expiry, signature.nonce ) ); } function _checkContext( RequestSignature calldata signature ) internal virtual view { // Nonce check is optional for child implentations if(signature.expiry < block.timestamp) { revert InvalidRequestError(); } } function _signerFrom( bytes memory data, RequestSignature calldata signature ) internal view returns( address signer ) { return _hashTypedDataV4(keccak256(data)).recover(signature.v, signature.r, signature.s); } function pause() public onlyRole(MoonpassRoles.PAUSER_ROLE) { _pause(); } function unpause() public onlyRole(MoonpassRoles.PAUSER_ROLE) { _unpause(); } function authorizer() public view returns(address authorizerAddress) { MoonpassContractStorage storage $ = _getMoonpassContractStorage(); authorizerAddress = $._authorizer; } function _hasRole( bytes32 role ) internal view returns (bool) { return _hasRole(role, _msgSender()); } function _hasRole( bytes32 role, address account ) internal view returns (bool) { return IAccessControl(authorizer()).hasRole(role, account); } function _checkRole( bytes32 role ) internal view { _checkRole(role, _msgSender()); } function _checkRole( bytes32 role, address account ) internal view { if(!_hasRole(role, account)) { revert IAccessControl.AccessControlUnauthorizedAccount(account, role); } } function _setAuthorizer( address authorizerAddress ) internal { if(!authorizerAddress.supportsInterface(type(IAccessControl).interfaceId)) { revert InvalidAddressError(); } MoonpassContractStorage storage $ = _getMoonpassContractStorage(); $._authorizer = authorizerAddress; emit AuthorizerChange(authorizerAddress); } function _authorizeUpgrade( address newImplementation ) internal override { // Recover from bad upgrades if(authorizer() == address(0)) { return; } _checkRole(MoonpassRoles.UPGRADER_ROLE); } modifier onlyRole( bytes32 role ) { _checkRole(role); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library ERC721AStorage { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } struct Layout { // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 _currentIndex; // The number of tokens burned. uint256 _burnCounter; // Token name string _name; // Token symbol string _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => ERC721AStorage.TokenApprovalRef) _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) _operatorApprovals; } bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.ERC721A'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable diamond facet contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ import {ERC721A__InitializableStorage} from './ERC721A__InitializableStorage.sol'; abstract contract ERC721A__Initializable { using ERC721A__InitializableStorage for ERC721A__InitializableStorage.Layout; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializerERC721A() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require( ERC721A__InitializableStorage.layout()._initializing ? _isConstructor() : !ERC721A__InitializableStorage.layout()._initialized, 'ERC721A__Initializable: contract is already initialized' ); bool isTopLevelCall = !ERC721A__InitializableStorage.layout()._initializing; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = true; ERC721A__InitializableStorage.layout()._initialized = true; } _; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializingERC721A() { require( ERC721A__InitializableStorage.layout()._initializing, 'ERC721A__Initializable: contract is not initializing' ); _; } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Pausable struct PausableStorage { bool _paused; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300; function _getPausableStorage() private pure returns (PausableStorage storage $) { assembly { $.slot := PausableStorageLocation } } /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { PausableStorage storage $ = _getPausableStorage(); $._paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { PausableStorage storage $ = _getPausableStorage(); return $._paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC1967-compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol"; import {Initializable} from "../../proxy/utils/Initializable.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. */ abstract contract EIP712Upgradeable is Initializable, IERC5267 { bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /// @custom:storage-location erc7201:openzeppelin.storage.EIP712 struct EIP712Storage { /// @custom:oz-renamed-from _HASHED_NAME bytes32 _hashedName; /// @custom:oz-renamed-from _HASHED_VERSION bytes32 _hashedVersion; string _name; string _version; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100; function _getEIP712Storage() private pure returns (EIP712Storage storage $) { assembly { $.slot := EIP712StorageLocation } } /** * @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]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { EIP712Storage storage $ = _getEIP712Storage(); $._name = name; $._version = version; // Reset prior values in storage if upgrading $._hashedName = 0; $._hashedVersion = 0; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(); } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), 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 ) { EIP712Storage storage $ = _getEIP712Storage(); // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized // and the EIP712 domain is not reliable, as it will be missing name and version. require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized"); return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Name() internal view virtual returns (string memory) { EIP712Storage storage $ = _getEIP712Storage(); return $._name; } /** * @dev The version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Version() internal view virtual returns (string memory) { EIP712Storage storage $ = _getEIP712Storage(); return $._version; } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead. */ function _EIP712NameHash() internal view returns (bytes32) { EIP712Storage storage $ = _getEIP712Storage(); string memory name = _EIP712Name(); if (bytes(name).length > 0) { return keccak256(bytes(name)); } else { // If the name is empty, the contract may have been upgraded without initializing the new storage. // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design. bytes32 hashedName = $._hashedName; if (hashedName != 0) { return hashedName; } else { return keccak256(""); } } } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead. */ function _EIP712VersionHash() internal view returns (bytes32) { EIP712Storage storage $ = _getEIP712Storage(); string memory version = _EIP712Version(); if (bytes(version).length > 0) { return keccak256(bytes(version)); } else { // If the version is empty, the contract may have been upgraded without initializing the new storage. // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design. bytes32 hashedVersion = $._hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else { return keccak256(""); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @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. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { 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) { OwnableStorage storage $ = _getOwnableStorage(); 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 { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface. */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) && !supportsERC165InterfaceUnchecked(account, INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. */ function getSupportedInterfaces( address account, bytes4[] memory interfaceIds ) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * * Some precompiled contracts will falsely indicate support for a given interface, so caution * should be exercised when using this function. * * Interface identification is specified in ERC-165. */ function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) { // prepare call bytes memory encodedParams = abi.encodeCall(IERC165.supportsInterface, (interfaceId)); // perform static call bool success; uint256 returnSize; uint256 returnValue; assembly { success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20) returnSize := returndatasize() returnValue := mload(0x00) } return success && returnSize >= 0x20 && returnValue > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// 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); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base storage for the initialization function for upgradeable diamond facet contracts **/ library ERC721A__InitializableStorage { struct Layout { /* * Indicates that the contract has been initialized. */ bool _initialized; /* * Indicates that the contract is in the process of being initialized. */ bool _initializing; } bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.initializable.facet'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// 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) } } }
// 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 ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// 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(); } } }
// 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 } } }
// 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)); } }
// 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; } }
// 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); } } }
{ "remappings": [ "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "erc721a-upgradeable/=lib/ERC721A-Upgradeable/", "@1inch/spot-price-aggregator/=lib/spot-price-aggregator/contracts/", "ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/", "chainlink/=lib/chainlink/", "spot-price-aggregator/=lib/spot-price-aggregator/contracts/" ], "optimizer": { "enabled": true, "runs": 20 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidDefaultRoyalty","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidDefaultRoyaltyReceiver","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidTokenRoyalty","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidTokenRoyaltyReceiver","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidAddressError","type":"error"},{"inputs":[],"name":"InvalidAirdropRequest","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidRequestError","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"authorizationManager","type":"address"}],"name":"AuthorizerChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[],"name":"NFTCollectionBaseURIChange","type":"event"},{"anonymous":false,"inputs":[],"name":"NFTCollectionContractURIChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeCollector","type":"address"},{"indexed":false,"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"name":"NFTCollectionRoyaltyInfoChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"CONTEXT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SET_AUTHORIZER_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"quantity","type":"uint256[]"}],"name":"airdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"quantity","type":"uint256[]"}],"internalType":"struct AirdropRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct RequestSignature","name":"signature","type":"tuple"}],"name":"airdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"authorizer","outputs":[{"internalType":"address","name":"authorizerAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"internalType":"struct ClaimRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct RequestSignature","name":"signature","type":"tuple"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"baseUri","type":"string"},{"internalType":"string","name":"contractUri","type":"string"}],"internalType":"struct NFTCollectionInitializer","name":"data","type":"tuple"},{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"authorizer","type":"address"}],"internalType":"struct MoonpassInitializer","name":"moonpass","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"authorizerAddress","type":"address"}],"name":"setAuthorizer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"authorizerAddress","type":"address"}],"internalType":"struct SetAuthorizerRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct RequestSignature","name":"signature","type":"tuple"}],"name":"setAuthorizer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"uri","type":"string"}],"internalType":"struct SetBaseURIRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct RequestSignature","name":"signature","type":"tuple"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"uri","type":"string"}],"internalType":"struct SetContractURIRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct RequestSignature","name":"signature","type":"tuple"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feeCollector","type":"address"},{"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"name":"setRoyaltyInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"feeCollector","type":"address"},{"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"internalType":"struct SetRoyaltyInfoRequest","name":"request","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"internalType":"struct RequestSignature","name":"signature","type":"tuple"}],"name":"setRoyaltyInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040523060805234801561001457600080fd5b50608051613bad61003e60003960008181611d3401528181611d5d0152611edb0152613bad6000f3fe6080604052600436106102075760003560e01c8063672434821161011457806367243482146104cf5780636de6c80f146104ef5780636fe3e7d01461050f57806370a082311461052f578063715018a61461054f5780637ecebe00146105645780638456cb591461058457806384b0196e146105995780638da5cb5b146105c1578063938e3d7b146105d657806395d89b41146105f65780639f1e6aa31461060b578063a22cb4651461063f578063aad3ec961461065f578063ad3cb1cc1461067f578063b88d4fde146106b0578063c87b56dd146106c3578063d09edf31146106e3578063de05815d146106f8578063e8a3d48514610718578063e985e9c51461072d578063f2fde38b1461074d57600080fd5b806301ffc9a71461020c57806302fa7c4714610241578063058a628f1461026357806306fdde0314610283578063081812fc146102a5578063095ea7b3146102d25780631312ff4a146102e557806318160ddd146103275780631cb593651461033c57806323b872dd1461035c5780632a55205a1461036f5780632c3fe0b61461039d5780633f4ba83a146103bd57806342842e0e146103d25780634f1ef286146103e55780634fc92add146103f857806352d1902d1461041857806354fd4d501461042d57806355f804b31461045a57806357c197be1461047a5780635c975abb1461049a5780636352211e146104af575b600080fd5b34801561021857600080fd5b5061022c610227366004612ff6565b61076d565b60405190151581526020015b60405180910390f35b34801561024d57600080fd5b5061026161025c366004613041565b61078d565b005b34801561026f57600080fd5b5061026161027e366004613074565b6107c6565b34801561028f57600080fd5b506102986107fd565b60405161023891906130df565b3480156102b157600080fd5b506102c56102c03660046130f2565b610898565b604051610238919061310b565b6102616102e036600461311f565b6108e5565b3480156102f157600080fd5b506103197fd5be72381fa250230b48bcbd44617d993800a62a9e4ce1de0f18b2ba3757bf6b81565b604051908152602001610238565b34801561033357600080fd5b506103196108f1565b34801561034857600080fd5b50610261610357366004613173565b610911565b61026161036a36600461319f565b6109f4565b34801561037b57600080fd5b5061038f61038a3660046131db565b610be8565b6040516102389291906131fd565b3480156103a957600080fd5b506102616103b8366004613228565b610ca9565b3480156103c957600080fd5b50610261610d62565b6102616103e036600461319f565b610d97565b6102616103f33660046132ff565b610db2565b34801561040457600080fd5b50610261610413366004613173565b610dcd565b34801561042457600080fd5b50610319610e80565b34801561043957600080fd5b50610442610e9d565b6040516001600160401b039091168152602001610238565b34801561046657600080fd5b5061026161047536600461334c565b610eac565b34801561048657600080fd5b50610261610495366004613394565b610edf565b3480156104a657600080fd5b5061022c610fa5565b3480156104bb57600080fd5b506102c56104ca3660046130f2565b610fba565b3480156104db57600080fd5b506102616104ea36600461341d565b610fc5565b3480156104fb57600080fd5b5061026161050a366004613488565b611002565b34801561051b57600080fd5b5061026161052a366004613394565b611220565b34801561053b57600080fd5b5061031961054a366004613074565b6112e6565b34801561055b57600080fd5b5061026161134e565b34801561057057600080fd5b5061031961057f366004613074565b611362565b34801561059057600080fd5b5061026161138d565b3480156105a557600080fd5b506105ae6113bf565b60405161023897969594939291906134d2565b3480156105cd57600080fd5b506102c5611468565b3480156105e257600080fd5b506102616105f136600461334c565b611483565b34801561060257600080fd5b506102986114b6565b34801561061757600080fd5b506103197f08c0db72018bde0ea5215618bdbdfe278d6c1fae34ae3cfa2ef60ce15690617581565b34801561064b57600080fd5b5061026161065a366004613579565b6114ce565b34801561066b57600080fd5b5061026161067a36600461311f565b61154b565b34801561068b57600080fd5b50610298604051806040016040528060058152602001640352e302e360dc1b81525081565b6102616106be3660046135b0565b61157f565b3480156106cf57600080fd5b506102986106de3660046130f2565b6115c9565b3480156106ef57600080fd5b506102c561164d565b34801561070457600080fd5b50610261610713366004613617565b611658565b34801561072457600080fd5b50610298611717565b34801561073957600080fd5b5061022c61074836600461364c565b6117b8565b34801561075957600080fd5b50610261610768366004613074565b6117f5565b600061077882611830565b80610787575061078782611865565b92915050565b7fd4dd364b99254967de7b77fa79c0f7835d1d5ebdb779edee0c386bda7d2cc4826107b7816118b3565b6107c183836118bd565b505050565b7f5d69da2417578ce9128854ab56a119bb7974311cf5dd21f7e5f82f89d6f607a36107f0816118b3565b6107f982611916565b5050565b60606108076119a3565b600201805461081590613676565b80601f016020809104026020016040519081016040528092919081815260200182805461084190613676565b801561088e5780601f106108635761010080835404028352916020019161088e565b820191906000526020600020905b81548152906001019060200180831161087157829003601f168201915b5050505050905090565b60006108a3826119c7565b6108c0576040516333d1c03960e21b815260040160405180910390fd5b6108c86119a3565b60009283526006016020525060409020546001600160a01b031690565b6107f982826001611a10565b600060016108fd6119a3565b600101546109096119a3565b540303919050565b60007f1a5f47a3d7698ca42b65c48b76e6b598a73ad9b2dff6eced5612f02b0a83a2766109416020850185613074565b61095160408601602087016136aa565b61095a85611ac5565b6040805160208101959095526001600160a01b03909316928401929092526001600160601b03166060830152608082015260a00160405160208183030381529060405290506109c0600080516020613b588339815191526109bb8385611b2c565b611b60565b6109cf335b8360800135611b8b565b6107c16109df6020850185613074565b6109ef60408601602087016136aa565b6118bd565b60006109ff82611bbc565b9050836001600160a01b0316816001600160a01b031614610a325760405162a1148160e81b815260040160405180910390fd5b600080610a3e84611c69565b91509150610a638187610a4e3390565b6001600160a01b039081169116811491141790565b610a8e57610a7186336117b8565b610a8e57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610ab557604051633a954ecd60e21b815260040160405180910390fd5b610ac28686866001611c91565b8015610acd57600082555b610ad56119a3565b6001600160a01b0387166000908152600591909101602052604090208054600019019055610b016119a3565b6001600160a01b03861660009081526005919091016020526040902080546001019055610b3285600160e11b611c99565b610b3a6119a3565b60008681526004919091016020526040812091909155600160e11b84169003610bb05760018401610b696119a3565b600082815260049190910160205260408120549003610bae57610b8a6119a3565b548114610bae5783610b9a6119a3565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b0316600080516020613b3883398151915260405160405180910390a45b505050505050565b6000806000610bf5611cae565b60008681526001820160209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160601b03169183019190915291925090610c6e57506040805180820190915281546001600160a01b0381168252600160a01b90046001600160601b031660208201525b6020810151600090620f424090610c8e906001600160601b0316886136c5565b610c9891906136ea565b9151945090925050505b9250929050565b60007fd5be72381fa250230b48bcbd44617d993800a62a9e4ce1de0f18b2ba3757bf6b610cd96020850185613074565b610ce284611ac5565b604051602001610d0e939291909283526001600160a01b03919091166020830152604082015260600190565b6040516020818303038152906040529050610d4d7f5d69da2417578ce9128854ab56a119bb7974311cf5dd21f7e5f82f89d6f607a36109bb8385611b2c565b6107c1610d5d6020850185613074565b611916565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a610d8c816118b3565b610d94611cd2565b50565b6107c18383836040518060200160405280600081525061157f565b610dba611d29565b610dc382611dce565b6107f98282611e12565b60007f20d2cab3e0689eb2ea88b3c13f46a32bc2e198a515d587dd8b180c494021831e610dfd6020850185613074565b8460200135610e0b85611ac5565b604051602001610e1e949392919061370c565b6040516020818303038152906040529050610e5d7fbaddf15638485d1d7fff354c2f37c12e9656edf603fcc57ec3c4455c96c0c3ff6109bb8385611b2c565b610e66336109c5565b6107c1610e766020850185613074565b8460200135611ec6565b6000610e8a611ed0565b50600080516020613b1883398151915290565b6000610ea7611f19565b905090565b7f0be7dc2b6f1c4aa33bf833a508f2b20d047034d65c3c983b36058bc4f7d3080b610ed6816118b3565b6107f982611f32565b60007f16fec391a11b756f8577b95b1ed8603a4c85960a44085b63e28cc0b3c6f54e57610f0c8480613730565b610f1585611ac5565b604051602001610f289493929190613776565b6040516020818303038152906040529050610f55600080516020613b588339815191526109bb8385611b2c565b610f5e336109c5565b6107c1610f6b8480613730565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611f3292505050565b600080610fb0611f77565b5460ff1692915050565b600061078782611bbc565b7f3a5b873628a2c49bf313473942acc8932f6f84c76b74bf3db0e4d8b51277a623610fef816118b3565b610ffb85858585611f9b565b5050505050565b600061100c612017565b805490915060ff600160401b82041615906001600160401b03166000811580156110335750825b90506000826001600160401b0316600114801561104f5750303b155b90508115801561105d575080155b1561107b5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156110a557845460ff60401b1916600160401b1785555b6110ad61203b565b54610100900460ff166110cc576110c261203b565b5460ff16156110d0565b303b155b6111415760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604482015276081a5cc8185b1c9958591e481a5b9a5d1a585b1a5e9959604a1b60648201526084015b60405180910390fd5b600061114b61203b565b54610100900460ff16159050801561119757600161116761203b565b80549115156101000261ff0019909216919091179055600161118761203b565b805460ff19169115159190911790555b6111a1888861205f565b6111a9612156565b80156111d05760006111b961203b565b80549115156101000261ff00199092169190911790555b50831561121757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b60007f411f2ce55e5ee4345080b7a04216e1e81c45a71b5b8d50e0db3dc279f3cfb96361124d8480613730565b61125685611ac5565b6040516020016112699493929190613776565b6040516020818303038152906040529050611296600080516020613b588339815191526109bb8385611b2c565b61129f336109c5565b6107c16112ac8480613730565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061215e92505050565b60006001600160a01b03821661130f576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b0361131f6119a3565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b6113566121a6565b61136060006121d8565b565b60008061136d612234565b6001600160a01b0390931660009081526020939093525050604090205490565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6113b7816118b3565b610d94612258565b60006060806000806000606060006113d561229f565b80549091501580156113e957506001810154155b61142d5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606401611138565b6114356122c3565b61143d6122e0565b60408051600080825260208201909252600f60f81b9c939b5091995046985030975095509350915050565b6000806114736122fd565b546001600160a01b031692915050565b7f0be7dc2b6f1c4aa33bf833a508f2b20d047034d65c3c983b36058bc4f7d3080b6114ad816118b3565b6107f98261215e565b60606114c06119a3565b600301805461081590613676565b806114d76119a3565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b7f3a5b873628a2c49bf313473942acc8932f6f84c76b74bf3db0e4d8b51277a623611575816118b3565b6107c18383611ec6565b61158a8484846109f4565b6001600160a01b0383163b156115c3576115a684848484612321565b6115c3576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b60606115d4826119c7565b6115f157604051630a14c4b560e41b815260040160405180910390fd5b60006115fb61240d565b9050805160000361161b5760405180602001604052806000815250611646565b806116258461242a565b6040516020016116369291906137b6565b6040516020818303038152906040525b9392505050565b60008061147361246e565b60007f57b1196dab3e69442ff758f4c3893a398df0bdb82081994ac9a9f851540efb6c61168584806137e5565b61169260208701876137e5565b61169b87611ac5565b6040516020016116b09695949392919061382e565b60405160208183030381529060405290506116ef7fbaddf15638485d1d7fff354c2f37c12e9656edf603fcc57ec3c4455c96c0c3ff6109bb8385611b2c565b6116f8336109c5565b6107c161170584806137e5565b61171260208701876137e5565b611f9b565b60606000611723612492565b905080600101805461173490613676565b80601f016020809104026020016040519081016040528092919081815260200182805461176090613676565b80156117ad5780601f10611782576101008083540402835291602001916117ad565b820191906000526020600020905b81548152906001019060200180831161179057829003601f168201915b505050505091505090565b60006117c26119a3565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b6117fd6121a6565b6001600160a01b038116611827576000604051631e4fbdf760e01b8152600401611138919061310b565b610d94816121d8565b60006001600160e01b0319821663152a902d60e11b148061078757506301ffc9a760e01b6001600160e01b0319831614610787565b60006301ffc9a760e01b6001600160e01b03198316148061189657506380ac58cd60e01b6001600160e01b03198316145b806107875750506001600160e01b031916635b5e139f60e01b1490565b610d948133611b60565b6118c782826124b6565b604080516001600160a01b03841681526001600160601b03831660208201527f4b35521ca8c10d04be890c47dede4d5f75b49b8d56d4e2b3fd2614ff5b430cd191015b60405180910390a15050565b6119306001600160a01b038216637965db0b60e01b612565565b61194d57604051637ac7fa7d60e01b815260040160405180910390fd5b600061195761246e565b80546001600160a01b0319166001600160a01b0384161781556040519091507fd3b73458e8282b539a192287d7f3ddf05eb0ba05130cd0075ee05523f9ff51909061190a90849061310b565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b6000816001111580156119e157506119dd6119a3565b5482105b80156107875750600160e01b6119f56119a3565b60008481526004919091016020526040902054161592915050565b6000611a1b83610fba565b90508115611a5a57336001600160a01b03821614611a5a57611a3d81336117b8565b611a5a576040516367d9dca160e11b815260040160405180910390fd5b83611a636119a3565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b6000611ad082612581565b7f08c0db72018bde0ea5215618bdbdfe278d6c1fae34ae3cfa2ef60ce1569061753383606001358460800135604051602001611b0f949392919061370c565b604051602081830303815290604052805190602001209050919050565b6000611646611b3e60208401846138c1565b83602001358460400135611b5887805190602001206125a6565b9291906125d3565b611b6a8282612601565b6107f957808260405163e2517d3f60e01b81526004016111389291906131fd565b6000611b968361267e565b90508082146107c15782816040516301d4b62360e61b81526004016111389291906131fd565b600081600111611c5057611bce6119a3565b600083815260049190910160205260408120549150600160e01b82169003611c505780600003611c4b57611c006119a3565b548210611c2057604051636f96cda160e11b815260040160405180910390fd5b611c286119a3565b600019909201600081815260049390930160205260409092205490508015611c20575b919050565b604051636f96cda160e11b815260040160405180910390fd5b6000806000611c766119a3565b60009485526006016020525050604090912080549092909150565b6115c36126b1565b4260a01b176001600160a01b03919091161790565b7fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b0090565b611cda6126d7565b6000611ce4611f77565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051611d1e919061310b565b60405180910390a150565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480611db057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611da4600080516020613b18833981519152546001600160a01b031690565b6001600160a01b031614155b156113605760405163703e46dd60e11b815260040160405180910390fd5b6000611dd861164d565b6001600160a01b031603611de95750565b610d947f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36118b3565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611e6c575060408051601f3d908101601f19168201909252611e69918101906138e4565b60015b611e8b5781604051634c9c8ce360e01b8152600401611138919061310b565b600080516020613b188339815191528114611ebc57604051632a87526960e21b815260048101829052602401611138565b6107c183836126fc565b6107f98282612752565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146113605760405163703e46dd60e11b815260040160405180910390fd5b6000611f23612017565b546001600160401b0316919050565b6000611f3c612492565b905080611f498382613945565b506040517f3c4745519bc8888c6ab017bfe92d21c9f5fb8f22cd8f43efe15b8a5b1b16c41390600090a15050565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b82818114611fbc5760405163501b08a560e01b815260040160405180910390fd5b60005b81811015610be05761200f868683818110611fdc57611fdc613a04565b9050602002016020810190611ff19190613074565b85858481811061200357612003613a04565b90506020020135612752565b600101611fbf565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b7fee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85f90565b61206761276c565b61206f61203b565b54610100900460ff166120945760405162461bcd60e51b815260040161113890613a1a565b61209d81612791565b6121266120aa8380613730565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120ec925050506020850185613730565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061281692505050565b61212e612156565b61213661284d565b6121466112ac6060840184613730565b6107f9610f6b6040840184613730565b61136061276c565b6000612168612492565b9050600181016121788382613945565b506040517f2590abbd2f46049d58b92a5891e145fa757a2ebed8b7ee488044feaa43b27b3a90600090a15050565b336121af611468565b6001600160a01b031614611360573360405163118cdaa760e01b8152600401611138919061310b565b60006121e26122fd565b80546001600160a01b038481166001600160a01b031983168117845560405193945091169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb0090565b6122606126b1565b600061226a611f77565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611d113390565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10090565b606060006122cf61229f565b905080600201805461173490613676565b606060006122ec61229f565b905080600301805461173490613676565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930090565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612356903390899088908890600401613a6e565b6020604051808303816000875af1925050508015612391575060408051601f3d908101601f1916820190925261238e91810190613aab565b60015b6123ef573d8080156123bf576040519150601f19603f3d011682016040523d82523d6000602084013e6123c4565b606091505b5080516000036123e7576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b60606000612419612492565b905080600001805461173490613676565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806124445750819003601f19909101908152919050565b7fcf1e3c2eec56b7a457652c54121209bbbd2922d418d6ab903c014713a5d410e290565b7f4fe52371adf1fc5bb26ee736cbfc7fb9f2892e83072eda9f832b3d4a9428cb9990565b60006124c0611cae565b9050620f42406001600160601b03831681101561250257604051636f483d0960e01b81526001600160601b038416600482015260248101829052604401611138565b6001600160a01b03841661252c576000604051635b6cc80560e11b8152600401611138919061310b565b50604080518082019091526001600160a01b039093168084526001600160601b039092166020909301839052600160a01b909202179055565b60006125708361285d565b801561164657506116468383612890565b4281606001351015610d945760405163bb86e01760e01b815260040160405180910390fd5b60006107876125b361291a565b8360405161190160f01b8152600281019290925260228201526042902090565b6000806000806125e588888888612924565b9250925092506125f582826129e9565b50909695505050505050565b600061260b61164d565b604051632474521560e21b8152600481018590526001600160a01b03848116602483015291909116906391d1485490604401602060405180830381865afa15801561265a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116469190613ac8565b600080612689612234565b6001600160a01b03909316600090815260209390935250506040902080546001810190915590565b6126b9610fa5565b156113605760405163d93c066560e01b815260040160405180910390fd5b6126df610fa5565b61136057604051638dfc202b60e01b815260040160405180910390fd5b61270582612aa2565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561274a576107c18282612afe565b6107f9612b74565b61275a612b93565b6127648282612bc9565b6107f9612cec565b612774612cfd565b61136057604051631afcd79f60e31b815260040160405180910390fd5b61279961276c565b6127a1612d17565b6127e6604051806040016040528060088152602001676d6f6f6e7061737360c01b81525060405180604001604052806003815260200162312e3160e81b815250612d27565b6127fb6127f66020830183613074565b612d39565b612803612156565b610d94610d5d6040830160208401613074565b61281e61203b565b54610100900460ff166128435760405162461bcd60e51b815260040161113890613a1a565b6107f98282612d4a565b61285561276c565b611360612db6565b6000612870826301ffc9a760e01b612890565b80156107875750612889826001600160e01b0319612890565b1592915050565b6040516001600160e01b031982166024820152600090819060440160408051601f19818403018152919052602080820180516001600160e01b03166301ffc9a760e01b178152825192935060009283928392909183918a617530fa92503d91506000519050828015612903575060208210155b801561290f5750600081115b979650505050505050565b6000610ea7612dbe565b600080806fa2a8918ca85bafe22016d0b997e4df60600160ff1b0384111561295557506000915060039050826129df565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156129a9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129d5575060009250600191508290506129df565b9250600091508190505b9450945094915050565b60008260038111156129fd576129fd613ae5565b03612a06575050565b6001826003811115612a1a57612a1a613ae5565b03612a385760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115612a4c57612a4c613ae5565b03612a6d5760405163fce698f760e01b815260048101829052602401611138565b6003826003811115612a8157612a81613ae5565b036107f9576040516335e2f38360e21b815260048101829052602401611138565b806001600160a01b03163b600003612acf5780604051634c9c8ce360e01b8152600401611138919061310b565b600080516020613b1883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051612b1b9190613afb565b600060405180830381855af49150503d8060008114612b56576040519150601f19603f3d011682016040523d82523d6000602084013e612b5b565b606091505b5091509150612b6b858383612e32565b95945050505050565b34156113605760405163b398979f60e01b815260040160405180910390fd5b6000612b9d612e85565b805490915060011901612bc357604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6000612bd36119a3565b5490506000829003612bf85760405163b562e8dd60e01b815260040160405180910390fd5b612c056000848385611c91565b6001600160401b018202612c176119a3565b6001600160a01b0385166000908152600591909101602052604090208054919091019055612c4b836001841460e11b611c99565b612c536119a3565b600083815260049190910160205260408120919091556001600160a01b038416908383019083908390600080516020613b388339815191528180a4600183015b818114612cb95780836000600080516020613b38833981519152600080a4600101612c93565b5081600003612cda57604051622e076360e81b815260040160405180910390fd5b80612ce36119a3565b55506107c19050565b6000612cf6612e85565b6001905550565b6000612d07612017565b54600160401b900460ff16919050565b612d1f61276c565b611360612ea9565b612d2f61276c565b6107f98282612ec6565b612d4161276c565b610d9481612f07565b612d5261203b565b54610100900460ff16612d775760405162461bcd60e51b815260040161113890613a1a565b81612d806119a3565b60020190612d8e9082613945565b5080612d986119a3565b60030190612da69082613945565b506001612db16119a3565b555050565b612cec61276c565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f612de9612f0f565b612df1612f76565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b606082612e4757612e4282612fb7565b611646565b8151158015612e5e57506001600160a01b0384163b155b15612e7e5783604051639996b31560e01b8152600401611138919061310b565b5080611646565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0090565b612eb161276c565b6000612ebb611f77565b805460ff1916905550565b612ece61276c565b6000612ed861229f565b905060028101612ee88482613945565b5060038101612ef78382613945565b5060008082556001909101555050565b6117fd61276c565b600080612f1a61229f565b90506000612f266122c3565b805190915015612f3e57805160209091012092915050565b81548015612f4d579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b600080612f8161229f565b90506000612f8d6122e0565b805190915015612fa557805160209091012092915050565b60018201548015612f4d579392505050565b805115612fc75780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160e01b031981168114610d9457600080fd5b60006020828403121561300857600080fd5b813561164681612fe0565b80356001600160a01b0381168114611c4b57600080fd5b80356001600160601b0381168114611c4b57600080fd5b6000806040838503121561305457600080fd5b61305d83613013565b915061306b6020840161302a565b90509250929050565b60006020828403121561308657600080fd5b61164682613013565b60005b838110156130aa578181015183820152602001613092565b50506000910152565b600081518084526130cb81602086016020860161308f565b601f01601f19169290920160200192915050565b60208152600061164660208301846130b3565b60006020828403121561310457600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6000806040838503121561313257600080fd5b61313b83613013565b946020939093013593505050565b60006040828403121561315b57600080fd5b50919050565b600060a0828403121561315b57600080fd5b60008060e0838503121561318657600080fd5b6131908484613149565b915061306b8460408501613161565b6000806000606084860312156131b457600080fd5b6131bd84613013565b92506131cb60208501613013565b9150604084013590509250925092565b600080604083850312156131ee57600080fd5b50508035926020909101359150565b6001600160a01b03929092168252602082015260400190565b60006020828403121561315b57600080fd5b60008060c0838503121561323b57600080fd5b6132458484613216565b915061306b8460208501613161565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561328457613284613254565b604051601f8501601f19908116603f011681019082821181831017156132ac576132ac613254565b816040528093508581528686860111156132c557600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126132f057600080fd5b6116468383356020850161326a565b6000806040838503121561331257600080fd5b61331b83613013565b915060208301356001600160401b0381111561333657600080fd5b613342858286016132df565b9150509250929050565b60006020828403121561335e57600080fd5b81356001600160401b0381111561337457600080fd5b8201601f8101841361338557600080fd5b6124058482356020840161326a565b60008060c083850312156133a757600080fd5b82356001600160401b038111156133bd57600080fd5b6133c985828601613216565b92505061306b8460208501613161565b60008083601f8401126133eb57600080fd5b5081356001600160401b0381111561340257600080fd5b6020830191508360208260051b8501011115610ca257600080fd5b6000806000806040858703121561343357600080fd5b84356001600160401b038082111561344a57600080fd5b613456888389016133d9565b9096509450602087013591508082111561346f57600080fd5b5061347c878288016133d9565b95989497509550505050565b6000806060838503121561349b57600080fd5b82356001600160401b038111156134b157600080fd5b8301608081860312156134c357600080fd5b915061306b8460208501613149565b60ff60f81b881681526000602060e060208401526134f360e084018a6130b3565b8381036040850152613505818a6130b3565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b818110156135595783518352928401929184019160010161353d565b50909c9b505050505050505050505050565b8015158114610d9457600080fd5b6000806040838503121561358c57600080fd5b61359583613013565b915060208301356135a58161356b565b809150509250929050565b600080600080608085870312156135c657600080fd5b6135cf85613013565b93506135dd60208601613013565b92506040850135915060608501356001600160401b038111156135ff57600080fd5b61360b878288016132df565b91505092959194509250565b60008060c0838503121561362a57600080fd5b82356001600160401b0381111561364057600080fd5b6133c985828601613149565b6000806040838503121561365f57600080fd5b61366883613013565b915061306b60208401613013565b600181811c9082168061368a57607f821691505b60208210810361315b57634e487b7160e01b600052602260045260246000fd5b6000602082840312156136bc57600080fd5b6116468261302a565b808202811582820484141761078757634e487b7160e01b600052601160045260246000fd5b60008261370757634e487b7160e01b600052601260045260246000fd5b500490565b9384526001600160a01b039290921660208401526040830152606082015260800190565b6000808335601e1984360301811261374757600080fd5b8301803591506001600160401b0382111561376157600080fd5b602001915036819003821315610ca257600080fd5b848152606060208201528260608201528284608083013760006080848301015260006080601f19601f860116830101905082604083015295945050505050565b600083516137c881846020880161308f565b8351908301906137dc81836020880161308f565b01949350505050565b6000808335601e198436030181126137fc57600080fd5b8301803591506001600160401b0382111561381657600080fd5b6020019150600581901b3603821315610ca257600080fd5b86815260806020808301829052908201869052600090879060a08401835b89811015613878576001600160a01b0361386585613013565b168252928201929082019060010161384c565b5084810360408601528681526001600160fb1b0387111561389857600080fd5b8660051b9250828860208301376020838201019350505050826060830152979650505050505050565b6000602082840312156138d357600080fd5b813560ff8116811461164657600080fd5b6000602082840312156138f657600080fd5b5051919050565b601f8211156107c1576000816000526020600020601f850160051c810160208610156139265750805b601f850160051c820191505b81811015610be057828155600101613932565b81516001600160401b0381111561395e5761395e613254565b6139728161396c8454613676565b846138fd565b602080601f8311600181146139a7576000841561398f5750858301515b600019600386901b1c1916600185901b178555610be0565b600085815260208120601f198616915b828110156139d6578886015182559484019460019091019084016139b7565b50858210156139f45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613aa1908301846130b3565b9695505050505050565b600060208284031215613abd57600080fd5b815161164681612fe0565b600060208284031215613ada57600080fd5b81516116468161356b565b634e487b7160e01b600052602160045260246000fd5b60008251613b0d81846020870161308f565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbcddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6913d2a439797327ed40807d0cf050ade0697e465c8de8baf0d4d30d647314a7a2646970667358221220faf930b948254458fa24199e424e58c2052f096b31f4392ce37730c36c8cf7cd64736f6c63430008170033
Deployed Bytecode
0x6080604052600436106102075760003560e01c8063672434821161011457806367243482146104cf5780636de6c80f146104ef5780636fe3e7d01461050f57806370a082311461052f578063715018a61461054f5780637ecebe00146105645780638456cb591461058457806384b0196e146105995780638da5cb5b146105c1578063938e3d7b146105d657806395d89b41146105f65780639f1e6aa31461060b578063a22cb4651461063f578063aad3ec961461065f578063ad3cb1cc1461067f578063b88d4fde146106b0578063c87b56dd146106c3578063d09edf31146106e3578063de05815d146106f8578063e8a3d48514610718578063e985e9c51461072d578063f2fde38b1461074d57600080fd5b806301ffc9a71461020c57806302fa7c4714610241578063058a628f1461026357806306fdde0314610283578063081812fc146102a5578063095ea7b3146102d25780631312ff4a146102e557806318160ddd146103275780631cb593651461033c57806323b872dd1461035c5780632a55205a1461036f5780632c3fe0b61461039d5780633f4ba83a146103bd57806342842e0e146103d25780634f1ef286146103e55780634fc92add146103f857806352d1902d1461041857806354fd4d501461042d57806355f804b31461045a57806357c197be1461047a5780635c975abb1461049a5780636352211e146104af575b600080fd5b34801561021857600080fd5b5061022c610227366004612ff6565b61076d565b60405190151581526020015b60405180910390f35b34801561024d57600080fd5b5061026161025c366004613041565b61078d565b005b34801561026f57600080fd5b5061026161027e366004613074565b6107c6565b34801561028f57600080fd5b506102986107fd565b60405161023891906130df565b3480156102b157600080fd5b506102c56102c03660046130f2565b610898565b604051610238919061310b565b6102616102e036600461311f565b6108e5565b3480156102f157600080fd5b506103197fd5be72381fa250230b48bcbd44617d993800a62a9e4ce1de0f18b2ba3757bf6b81565b604051908152602001610238565b34801561033357600080fd5b506103196108f1565b34801561034857600080fd5b50610261610357366004613173565b610911565b61026161036a36600461319f565b6109f4565b34801561037b57600080fd5b5061038f61038a3660046131db565b610be8565b6040516102389291906131fd565b3480156103a957600080fd5b506102616103b8366004613228565b610ca9565b3480156103c957600080fd5b50610261610d62565b6102616103e036600461319f565b610d97565b6102616103f33660046132ff565b610db2565b34801561040457600080fd5b50610261610413366004613173565b610dcd565b34801561042457600080fd5b50610319610e80565b34801561043957600080fd5b50610442610e9d565b6040516001600160401b039091168152602001610238565b34801561046657600080fd5b5061026161047536600461334c565b610eac565b34801561048657600080fd5b50610261610495366004613394565b610edf565b3480156104a657600080fd5b5061022c610fa5565b3480156104bb57600080fd5b506102c56104ca3660046130f2565b610fba565b3480156104db57600080fd5b506102616104ea36600461341d565b610fc5565b3480156104fb57600080fd5b5061026161050a366004613488565b611002565b34801561051b57600080fd5b5061026161052a366004613394565b611220565b34801561053b57600080fd5b5061031961054a366004613074565b6112e6565b34801561055b57600080fd5b5061026161134e565b34801561057057600080fd5b5061031961057f366004613074565b611362565b34801561059057600080fd5b5061026161138d565b3480156105a557600080fd5b506105ae6113bf565b60405161023897969594939291906134d2565b3480156105cd57600080fd5b506102c5611468565b3480156105e257600080fd5b506102616105f136600461334c565b611483565b34801561060257600080fd5b506102986114b6565b34801561061757600080fd5b506103197f08c0db72018bde0ea5215618bdbdfe278d6c1fae34ae3cfa2ef60ce15690617581565b34801561064b57600080fd5b5061026161065a366004613579565b6114ce565b34801561066b57600080fd5b5061026161067a36600461311f565b61154b565b34801561068b57600080fd5b50610298604051806040016040528060058152602001640352e302e360dc1b81525081565b6102616106be3660046135b0565b61157f565b3480156106cf57600080fd5b506102986106de3660046130f2565b6115c9565b3480156106ef57600080fd5b506102c561164d565b34801561070457600080fd5b50610261610713366004613617565b611658565b34801561072457600080fd5b50610298611717565b34801561073957600080fd5b5061022c61074836600461364c565b6117b8565b34801561075957600080fd5b50610261610768366004613074565b6117f5565b600061077882611830565b80610787575061078782611865565b92915050565b7fd4dd364b99254967de7b77fa79c0f7835d1d5ebdb779edee0c386bda7d2cc4826107b7816118b3565b6107c183836118bd565b505050565b7f5d69da2417578ce9128854ab56a119bb7974311cf5dd21f7e5f82f89d6f607a36107f0816118b3565b6107f982611916565b5050565b60606108076119a3565b600201805461081590613676565b80601f016020809104026020016040519081016040528092919081815260200182805461084190613676565b801561088e5780601f106108635761010080835404028352916020019161088e565b820191906000526020600020905b81548152906001019060200180831161087157829003601f168201915b5050505050905090565b60006108a3826119c7565b6108c0576040516333d1c03960e21b815260040160405180910390fd5b6108c86119a3565b60009283526006016020525060409020546001600160a01b031690565b6107f982826001611a10565b600060016108fd6119a3565b600101546109096119a3565b540303919050565b60007f1a5f47a3d7698ca42b65c48b76e6b598a73ad9b2dff6eced5612f02b0a83a2766109416020850185613074565b61095160408601602087016136aa565b61095a85611ac5565b6040805160208101959095526001600160a01b03909316928401929092526001600160601b03166060830152608082015260a00160405160208183030381529060405290506109c0600080516020613b588339815191526109bb8385611b2c565b611b60565b6109cf335b8360800135611b8b565b6107c16109df6020850185613074565b6109ef60408601602087016136aa565b6118bd565b60006109ff82611bbc565b9050836001600160a01b0316816001600160a01b031614610a325760405162a1148160e81b815260040160405180910390fd5b600080610a3e84611c69565b91509150610a638187610a4e3390565b6001600160a01b039081169116811491141790565b610a8e57610a7186336117b8565b610a8e57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610ab557604051633a954ecd60e21b815260040160405180910390fd5b610ac28686866001611c91565b8015610acd57600082555b610ad56119a3565b6001600160a01b0387166000908152600591909101602052604090208054600019019055610b016119a3565b6001600160a01b03861660009081526005919091016020526040902080546001019055610b3285600160e11b611c99565b610b3a6119a3565b60008681526004919091016020526040812091909155600160e11b84169003610bb05760018401610b696119a3565b600082815260049190910160205260408120549003610bae57610b8a6119a3565b548114610bae5783610b9a6119a3565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b0316600080516020613b3883398151915260405160405180910390a45b505050505050565b6000806000610bf5611cae565b60008681526001820160209081526040918290208251808401909352546001600160a01b038116808452600160a01b9091046001600160601b03169183019190915291925090610c6e57506040805180820190915281546001600160a01b0381168252600160a01b90046001600160601b031660208201525b6020810151600090620f424090610c8e906001600160601b0316886136c5565b610c9891906136ea565b9151945090925050505b9250929050565b60007fd5be72381fa250230b48bcbd44617d993800a62a9e4ce1de0f18b2ba3757bf6b610cd96020850185613074565b610ce284611ac5565b604051602001610d0e939291909283526001600160a01b03919091166020830152604082015260600190565b6040516020818303038152906040529050610d4d7f5d69da2417578ce9128854ab56a119bb7974311cf5dd21f7e5f82f89d6f607a36109bb8385611b2c565b6107c1610d5d6020850185613074565b611916565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a610d8c816118b3565b610d94611cd2565b50565b6107c18383836040518060200160405280600081525061157f565b610dba611d29565b610dc382611dce565b6107f98282611e12565b60007f20d2cab3e0689eb2ea88b3c13f46a32bc2e198a515d587dd8b180c494021831e610dfd6020850185613074565b8460200135610e0b85611ac5565b604051602001610e1e949392919061370c565b6040516020818303038152906040529050610e5d7fbaddf15638485d1d7fff354c2f37c12e9656edf603fcc57ec3c4455c96c0c3ff6109bb8385611b2c565b610e66336109c5565b6107c1610e766020850185613074565b8460200135611ec6565b6000610e8a611ed0565b50600080516020613b1883398151915290565b6000610ea7611f19565b905090565b7f0be7dc2b6f1c4aa33bf833a508f2b20d047034d65c3c983b36058bc4f7d3080b610ed6816118b3565b6107f982611f32565b60007f16fec391a11b756f8577b95b1ed8603a4c85960a44085b63e28cc0b3c6f54e57610f0c8480613730565b610f1585611ac5565b604051602001610f289493929190613776565b6040516020818303038152906040529050610f55600080516020613b588339815191526109bb8385611b2c565b610f5e336109c5565b6107c1610f6b8480613730565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611f3292505050565b600080610fb0611f77565b5460ff1692915050565b600061078782611bbc565b7f3a5b873628a2c49bf313473942acc8932f6f84c76b74bf3db0e4d8b51277a623610fef816118b3565b610ffb85858585611f9b565b5050505050565b600061100c612017565b805490915060ff600160401b82041615906001600160401b03166000811580156110335750825b90506000826001600160401b0316600114801561104f5750303b155b90508115801561105d575080155b1561107b5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156110a557845460ff60401b1916600160401b1785555b6110ad61203b565b54610100900460ff166110cc576110c261203b565b5460ff16156110d0565b303b155b6111415760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604482015276081a5cc8185b1c9958591e481a5b9a5d1a585b1a5e9959604a1b60648201526084015b60405180910390fd5b600061114b61203b565b54610100900460ff16159050801561119757600161116761203b565b80549115156101000261ff0019909216919091179055600161118761203b565b805460ff19169115159190911790555b6111a1888861205f565b6111a9612156565b80156111d05760006111b961203b565b80549115156101000261ff00199092169190911790555b50831561121757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b60007f411f2ce55e5ee4345080b7a04216e1e81c45a71b5b8d50e0db3dc279f3cfb96361124d8480613730565b61125685611ac5565b6040516020016112699493929190613776565b6040516020818303038152906040529050611296600080516020613b588339815191526109bb8385611b2c565b61129f336109c5565b6107c16112ac8480613730565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061215e92505050565b60006001600160a01b03821661130f576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b0361131f6119a3565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b6113566121a6565b61136060006121d8565b565b60008061136d612234565b6001600160a01b0390931660009081526020939093525050604090205490565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6113b7816118b3565b610d94612258565b60006060806000806000606060006113d561229f565b80549091501580156113e957506001810154155b61142d5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606401611138565b6114356122c3565b61143d6122e0565b60408051600080825260208201909252600f60f81b9c939b5091995046985030975095509350915050565b6000806114736122fd565b546001600160a01b031692915050565b7f0be7dc2b6f1c4aa33bf833a508f2b20d047034d65c3c983b36058bc4f7d3080b6114ad816118b3565b6107f98261215e565b60606114c06119a3565b600301805461081590613676565b806114d76119a3565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b7f3a5b873628a2c49bf313473942acc8932f6f84c76b74bf3db0e4d8b51277a623611575816118b3565b6107c18383611ec6565b61158a8484846109f4565b6001600160a01b0383163b156115c3576115a684848484612321565b6115c3576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b60606115d4826119c7565b6115f157604051630a14c4b560e41b815260040160405180910390fd5b60006115fb61240d565b9050805160000361161b5760405180602001604052806000815250611646565b806116258461242a565b6040516020016116369291906137b6565b6040516020818303038152906040525b9392505050565b60008061147361246e565b60007f57b1196dab3e69442ff758f4c3893a398df0bdb82081994ac9a9f851540efb6c61168584806137e5565b61169260208701876137e5565b61169b87611ac5565b6040516020016116b09695949392919061382e565b60405160208183030381529060405290506116ef7fbaddf15638485d1d7fff354c2f37c12e9656edf603fcc57ec3c4455c96c0c3ff6109bb8385611b2c565b6116f8336109c5565b6107c161170584806137e5565b61171260208701876137e5565b611f9b565b60606000611723612492565b905080600101805461173490613676565b80601f016020809104026020016040519081016040528092919081815260200182805461176090613676565b80156117ad5780601f10611782576101008083540402835291602001916117ad565b820191906000526020600020905b81548152906001019060200180831161179057829003601f168201915b505050505091505090565b60006117c26119a3565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b6117fd6121a6565b6001600160a01b038116611827576000604051631e4fbdf760e01b8152600401611138919061310b565b610d94816121d8565b60006001600160e01b0319821663152a902d60e11b148061078757506301ffc9a760e01b6001600160e01b0319831614610787565b60006301ffc9a760e01b6001600160e01b03198316148061189657506380ac58cd60e01b6001600160e01b03198316145b806107875750506001600160e01b031916635b5e139f60e01b1490565b610d948133611b60565b6118c782826124b6565b604080516001600160a01b03841681526001600160601b03831660208201527f4b35521ca8c10d04be890c47dede4d5f75b49b8d56d4e2b3fd2614ff5b430cd191015b60405180910390a15050565b6119306001600160a01b038216637965db0b60e01b612565565b61194d57604051637ac7fa7d60e01b815260040160405180910390fd5b600061195761246e565b80546001600160a01b0319166001600160a01b0384161781556040519091507fd3b73458e8282b539a192287d7f3ddf05eb0ba05130cd0075ee05523f9ff51909061190a90849061310b565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b6000816001111580156119e157506119dd6119a3565b5482105b80156107875750600160e01b6119f56119a3565b60008481526004919091016020526040902054161592915050565b6000611a1b83610fba565b90508115611a5a57336001600160a01b03821614611a5a57611a3d81336117b8565b611a5a576040516367d9dca160e11b815260040160405180910390fd5b83611a636119a3565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b6000611ad082612581565b7f08c0db72018bde0ea5215618bdbdfe278d6c1fae34ae3cfa2ef60ce1569061753383606001358460800135604051602001611b0f949392919061370c565b604051602081830303815290604052805190602001209050919050565b6000611646611b3e60208401846138c1565b83602001358460400135611b5887805190602001206125a6565b9291906125d3565b611b6a8282612601565b6107f957808260405163e2517d3f60e01b81526004016111389291906131fd565b6000611b968361267e565b90508082146107c15782816040516301d4b62360e61b81526004016111389291906131fd565b600081600111611c5057611bce6119a3565b600083815260049190910160205260408120549150600160e01b82169003611c505780600003611c4b57611c006119a3565b548210611c2057604051636f96cda160e11b815260040160405180910390fd5b611c286119a3565b600019909201600081815260049390930160205260409092205490508015611c20575b919050565b604051636f96cda160e11b815260040160405180910390fd5b6000806000611c766119a3565b60009485526006016020525050604090912080549092909150565b6115c36126b1565b4260a01b176001600160a01b03919091161790565b7fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b0090565b611cda6126d7565b6000611ce4611f77565b805460ff1916815590507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051611d1e919061310b565b60405180910390a150565b306001600160a01b037f000000000000000000000000998448e2fc3431be7d070b6c6b53bf1db29ea359161480611db057507f000000000000000000000000998448e2fc3431be7d070b6c6b53bf1db29ea3596001600160a01b0316611da4600080516020613b18833981519152546001600160a01b031690565b6001600160a01b031614155b156113605760405163703e46dd60e11b815260040160405180910390fd5b6000611dd861164d565b6001600160a01b031603611de95750565b610d947f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e36118b3565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611e6c575060408051601f3d908101601f19168201909252611e69918101906138e4565b60015b611e8b5781604051634c9c8ce360e01b8152600401611138919061310b565b600080516020613b188339815191528114611ebc57604051632a87526960e21b815260048101829052602401611138565b6107c183836126fc565b6107f98282612752565b306001600160a01b037f000000000000000000000000998448e2fc3431be7d070b6c6b53bf1db29ea35916146113605760405163703e46dd60e11b815260040160405180910390fd5b6000611f23612017565b546001600160401b0316919050565b6000611f3c612492565b905080611f498382613945565b506040517f3c4745519bc8888c6ab017bfe92d21c9f5fb8f22cd8f43efe15b8a5b1b16c41390600090a15050565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330090565b82818114611fbc5760405163501b08a560e01b815260040160405180910390fd5b60005b81811015610be05761200f868683818110611fdc57611fdc613a04565b9050602002016020810190611ff19190613074565b85858481811061200357612003613a04565b90506020020135612752565b600101611fbf565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0090565b7fee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85f90565b61206761276c565b61206f61203b565b54610100900460ff166120945760405162461bcd60e51b815260040161113890613a1a565b61209d81612791565b6121266120aa8380613730565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120ec925050506020850185613730565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061281692505050565b61212e612156565b61213661284d565b6121466112ac6060840184613730565b6107f9610f6b6040840184613730565b61136061276c565b6000612168612492565b9050600181016121788382613945565b506040517f2590abbd2f46049d58b92a5891e145fa757a2ebed8b7ee488044feaa43b27b3a90600090a15050565b336121af611468565b6001600160a01b031614611360573360405163118cdaa760e01b8152600401611138919061310b565b60006121e26122fd565b80546001600160a01b038481166001600160a01b031983168117845560405193945091169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7f5ab42ced628888259c08ac98db1eb0cf702fc1501344311d8b100cd1bfe4bb0090565b6122606126b1565b600061226a611f77565b805460ff1916600117815590507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611d113390565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10090565b606060006122cf61229f565b905080600201805461173490613676565b606060006122ec61229f565b905080600301805461173490613676565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930090565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612356903390899088908890600401613a6e565b6020604051808303816000875af1925050508015612391575060408051601f3d908101601f1916820190925261238e91810190613aab565b60015b6123ef573d8080156123bf576040519150601f19603f3d011682016040523d82523d6000602084013e6123c4565b606091505b5080516000036123e7576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b60606000612419612492565b905080600001805461173490613676565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806124445750819003601f19909101908152919050565b7fcf1e3c2eec56b7a457652c54121209bbbd2922d418d6ab903c014713a5d410e290565b7f4fe52371adf1fc5bb26ee736cbfc7fb9f2892e83072eda9f832b3d4a9428cb9990565b60006124c0611cae565b9050620f42406001600160601b03831681101561250257604051636f483d0960e01b81526001600160601b038416600482015260248101829052604401611138565b6001600160a01b03841661252c576000604051635b6cc80560e11b8152600401611138919061310b565b50604080518082019091526001600160a01b039093168084526001600160601b039092166020909301839052600160a01b909202179055565b60006125708361285d565b801561164657506116468383612890565b4281606001351015610d945760405163bb86e01760e01b815260040160405180910390fd5b60006107876125b361291a565b8360405161190160f01b8152600281019290925260228201526042902090565b6000806000806125e588888888612924565b9250925092506125f582826129e9565b50909695505050505050565b600061260b61164d565b604051632474521560e21b8152600481018590526001600160a01b03848116602483015291909116906391d1485490604401602060405180830381865afa15801561265a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116469190613ac8565b600080612689612234565b6001600160a01b03909316600090815260209390935250506040902080546001810190915590565b6126b9610fa5565b156113605760405163d93c066560e01b815260040160405180910390fd5b6126df610fa5565b61136057604051638dfc202b60e01b815260040160405180910390fd5b61270582612aa2565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561274a576107c18282612afe565b6107f9612b74565b61275a612b93565b6127648282612bc9565b6107f9612cec565b612774612cfd565b61136057604051631afcd79f60e31b815260040160405180910390fd5b61279961276c565b6127a1612d17565b6127e6604051806040016040528060088152602001676d6f6f6e7061737360c01b81525060405180604001604052806003815260200162312e3160e81b815250612d27565b6127fb6127f66020830183613074565b612d39565b612803612156565b610d94610d5d6040830160208401613074565b61281e61203b565b54610100900460ff166128435760405162461bcd60e51b815260040161113890613a1a565b6107f98282612d4a565b61285561276c565b611360612db6565b6000612870826301ffc9a760e01b612890565b80156107875750612889826001600160e01b0319612890565b1592915050565b6040516001600160e01b031982166024820152600090819060440160408051601f19818403018152919052602080820180516001600160e01b03166301ffc9a760e01b178152825192935060009283928392909183918a617530fa92503d91506000519050828015612903575060208210155b801561290f5750600081115b979650505050505050565b6000610ea7612dbe565b600080806fa2a8918ca85bafe22016d0b997e4df60600160ff1b0384111561295557506000915060039050826129df565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156129a9573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129d5575060009250600191508290506129df565b9250600091508190505b9450945094915050565b60008260038111156129fd576129fd613ae5565b03612a06575050565b6001826003811115612a1a57612a1a613ae5565b03612a385760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115612a4c57612a4c613ae5565b03612a6d5760405163fce698f760e01b815260048101829052602401611138565b6003826003811115612a8157612a81613ae5565b036107f9576040516335e2f38360e21b815260048101829052602401611138565b806001600160a01b03163b600003612acf5780604051634c9c8ce360e01b8152600401611138919061310b565b600080516020613b1883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051612b1b9190613afb565b600060405180830381855af49150503d8060008114612b56576040519150601f19603f3d011682016040523d82523d6000602084013e612b5b565b606091505b5091509150612b6b858383612e32565b95945050505050565b34156113605760405163b398979f60e01b815260040160405180910390fd5b6000612b9d612e85565b805490915060011901612bc357604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b6000612bd36119a3565b5490506000829003612bf85760405163b562e8dd60e01b815260040160405180910390fd5b612c056000848385611c91565b6001600160401b018202612c176119a3565b6001600160a01b0385166000908152600591909101602052604090208054919091019055612c4b836001841460e11b611c99565b612c536119a3565b600083815260049190910160205260408120919091556001600160a01b038416908383019083908390600080516020613b388339815191528180a4600183015b818114612cb95780836000600080516020613b38833981519152600080a4600101612c93565b5081600003612cda57604051622e076360e81b815260040160405180910390fd5b80612ce36119a3565b55506107c19050565b6000612cf6612e85565b6001905550565b6000612d07612017565b54600160401b900460ff16919050565b612d1f61276c565b611360612ea9565b612d2f61276c565b6107f98282612ec6565b612d4161276c565b610d9481612f07565b612d5261203b565b54610100900460ff16612d775760405162461bcd60e51b815260040161113890613a1a565b81612d806119a3565b60020190612d8e9082613945565b5080612d986119a3565b60030190612da69082613945565b506001612db16119a3565b555050565b612cec61276c565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f612de9612f0f565b612df1612f76565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b606082612e4757612e4282612fb7565b611646565b8151158015612e5e57506001600160a01b0384163b155b15612e7e5783604051639996b31560e01b8152600401611138919061310b565b5080611646565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0090565b612eb161276c565b6000612ebb611f77565b805460ff1916905550565b612ece61276c565b6000612ed861229f565b905060028101612ee88482613945565b5060038101612ef78382613945565b5060008082556001909101555050565b6117fd61276c565b600080612f1a61229f565b90506000612f266122c3565b805190915015612f3e57805160209091012092915050565b81548015612f4d579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b600080612f8161229f565b90506000612f8d6122e0565b805190915015612fa557805160209091012092915050565b60018201548015612f4d579392505050565b805115612fc75780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160e01b031981168114610d9457600080fd5b60006020828403121561300857600080fd5b813561164681612fe0565b80356001600160a01b0381168114611c4b57600080fd5b80356001600160601b0381168114611c4b57600080fd5b6000806040838503121561305457600080fd5b61305d83613013565b915061306b6020840161302a565b90509250929050565b60006020828403121561308657600080fd5b61164682613013565b60005b838110156130aa578181015183820152602001613092565b50506000910152565b600081518084526130cb81602086016020860161308f565b601f01601f19169290920160200192915050565b60208152600061164660208301846130b3565b60006020828403121561310457600080fd5b5035919050565b6001600160a01b0391909116815260200190565b6000806040838503121561313257600080fd5b61313b83613013565b946020939093013593505050565b60006040828403121561315b57600080fd5b50919050565b600060a0828403121561315b57600080fd5b60008060e0838503121561318657600080fd5b6131908484613149565b915061306b8460408501613161565b6000806000606084860312156131b457600080fd5b6131bd84613013565b92506131cb60208501613013565b9150604084013590509250925092565b600080604083850312156131ee57600080fd5b50508035926020909101359150565b6001600160a01b03929092168252602082015260400190565b60006020828403121561315b57600080fd5b60008060c0838503121561323b57600080fd5b6132458484613216565b915061306b8460208501613161565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561328457613284613254565b604051601f8501601f19908116603f011681019082821181831017156132ac576132ac613254565b816040528093508581528686860111156132c557600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126132f057600080fd5b6116468383356020850161326a565b6000806040838503121561331257600080fd5b61331b83613013565b915060208301356001600160401b0381111561333657600080fd5b613342858286016132df565b9150509250929050565b60006020828403121561335e57600080fd5b81356001600160401b0381111561337457600080fd5b8201601f8101841361338557600080fd5b6124058482356020840161326a565b60008060c083850312156133a757600080fd5b82356001600160401b038111156133bd57600080fd5b6133c985828601613216565b92505061306b8460208501613161565b60008083601f8401126133eb57600080fd5b5081356001600160401b0381111561340257600080fd5b6020830191508360208260051b8501011115610ca257600080fd5b6000806000806040858703121561343357600080fd5b84356001600160401b038082111561344a57600080fd5b613456888389016133d9565b9096509450602087013591508082111561346f57600080fd5b5061347c878288016133d9565b95989497509550505050565b6000806060838503121561349b57600080fd5b82356001600160401b038111156134b157600080fd5b8301608081860312156134c357600080fd5b915061306b8460208501613149565b60ff60f81b881681526000602060e060208401526134f360e084018a6130b3565b8381036040850152613505818a6130b3565b606085018990526001600160a01b038816608086015260a0850187905284810360c08601528551808252602080880193509091019060005b818110156135595783518352928401929184019160010161353d565b50909c9b505050505050505050505050565b8015158114610d9457600080fd5b6000806040838503121561358c57600080fd5b61359583613013565b915060208301356135a58161356b565b809150509250929050565b600080600080608085870312156135c657600080fd5b6135cf85613013565b93506135dd60208601613013565b92506040850135915060608501356001600160401b038111156135ff57600080fd5b61360b878288016132df565b91505092959194509250565b60008060c0838503121561362a57600080fd5b82356001600160401b0381111561364057600080fd5b6133c985828601613149565b6000806040838503121561365f57600080fd5b61366883613013565b915061306b60208401613013565b600181811c9082168061368a57607f821691505b60208210810361315b57634e487b7160e01b600052602260045260246000fd5b6000602082840312156136bc57600080fd5b6116468261302a565b808202811582820484141761078757634e487b7160e01b600052601160045260246000fd5b60008261370757634e487b7160e01b600052601260045260246000fd5b500490565b9384526001600160a01b039290921660208401526040830152606082015260800190565b6000808335601e1984360301811261374757600080fd5b8301803591506001600160401b0382111561376157600080fd5b602001915036819003821315610ca257600080fd5b848152606060208201528260608201528284608083013760006080848301015260006080601f19601f860116830101905082604083015295945050505050565b600083516137c881846020880161308f565b8351908301906137dc81836020880161308f565b01949350505050565b6000808335601e198436030181126137fc57600080fd5b8301803591506001600160401b0382111561381657600080fd5b6020019150600581901b3603821315610ca257600080fd5b86815260806020808301829052908201869052600090879060a08401835b89811015613878576001600160a01b0361386585613013565b168252928201929082019060010161384c565b5084810360408601528681526001600160fb1b0387111561389857600080fd5b8660051b9250828860208301376020838201019350505050826060830152979650505050505050565b6000602082840312156138d357600080fd5b813560ff8116811461164657600080fd5b6000602082840312156138f657600080fd5b5051919050565b601f8211156107c1576000816000526020600020601f850160051c810160208610156139265750805b601f850160051c820191505b81811015610be057828155600101613932565b81516001600160401b0381111561395e5761395e613254565b6139728161396c8454613676565b846138fd565b602080601f8311600181146139a7576000841561398f5750858301515b600019600386901b1c1916600185901b178555610be0565b600085815260208120601f198616915b828110156139d6578886015182559484019460019091019084016139b7565b50858210156139f45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613aa1908301846130b3565b9695505050505050565b600060208284031215613abd57600080fd5b815161164681612fe0565b600060208284031215613ada57600080fd5b81516116468161356b565b634e487b7160e01b600052602160045260246000fd5b60008251613b0d81846020870161308f565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbcddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6913d2a439797327ed40807d0cf050ade0697e465c8de8baf0d4d30d647314a7a2646970667358221220faf930b948254458fa24199e424e58c2052f096b31f4392ce37730c36c8cf7cd64736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.