Overview
APE Balance
0 APE
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 4767044 | 25 hrs ago | IN | 0 APE | 0.06022166 |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
PickMint1155
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol"; import {Payable} from "./../libraries/Payable.sol"; import {SupplyControl1155} from "./../libraries/SupplyControl1155.sol"; import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import {DTOs} from "./../libraries/dtos.sol"; contract PickMint1155 is Payable, SupplyControl1155, LimitPerWallet, SignatureProtected { string public constant contractType = "PICK-MINTER-1155"; string public constant version = "1.0.0"; IERC1155Mintable public erc1155Contract; bool private _isInitialized; function init( address owner, address signerAddress, address feeRecipient, uint256[] memory availableTokens, DTOs.Recipient[] memory recipients, address erc1155Address ) external { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(owner); initSupplyControl(availableTokens); initSignatureProtected(signerAddress); initPayable(feeRecipient, recipients); erc1155Contract = IERC1155Mintable(erc1155Address); _isInitialized = true; } function mint( uint256[] memory _ids, uint256[] memory _amounts, uint256 _maxPerWallet, uint256 _pricePerToken, uint256 _feePerToken, bytes calldata _signature ) external payable { validateSignature( abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken), _signature ); uint256 _amount; for (uint256 i; i < _ids.length; i++) { require( _ids[i] < availableTokens.length, "Invalid ID to be minted" ); uint _available = availableTokens[_ids[i]]; if (_available < _amounts[i]) { _amounts[i] = _available; } availableTokens[_ids[i]] -= _amounts[i]; _amount += _amounts[i]; } require( _amount > 0, "None of the selected tokens to mint are available" ); uint256 _availableAmount = getAvailableForWallet( _amount, _maxPerWallet ); require( _availableAmount >= _amount, "Not enough tokens available to mint for your wallet" ); checkSentEther(_amount, _pricePerToken, _feePerToken); erc1155Contract.mint(msg.sender, _ids, _amounts); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// 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) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// 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) (proxy/Clones.sol) pragma solidity ^0.8.20; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. */ library Clones { /** * @dev A clone instance deployment failed. */ error ERC1167FailedCreateClone(); /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create(0, 0x09, 0x37) } if (instance == address(0)) { revert ERC1167FailedCreateClone(); } } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create2(0, 0x09, 0x37, salt) } if (instance == address(0)) { revert ERC1167FailedCreateClone(); } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(add(ptr, 0x38), deployer) mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff) mstore(add(ptr, 0x14), implementation) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73) mstore(add(ptr, 0x58), salt) mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37)) predicted := keccak256(add(ptr, 0x43), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt ) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/common/ERC2981.sol) pragma solidity ^0.8.20; import {IERC2981} from "../../interfaces/IERC2981.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information. * * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the * fee is specified in basis points by default. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported. */ abstract contract ERC2981 is IERC2981, ERC165 { struct RoyaltyInfo { address receiver; uint96 royaltyFraction; } RoyaltyInfo private _defaultRoyaltyInfo; mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo; /** * @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); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId); } /** * @inheritdoc IERC2981 */ function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual returns (address, uint256) { RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId]; if (royalty.receiver == address(0)) { royalty = _defaultRoyaltyInfo; } uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator(); return (royalty.receiver, royaltyAmount); } /** * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an * override. */ function _feeDenominator() internal pure virtual returns (uint96) { return 10000; } /** * @dev Sets the royalty information that all ids in this contract will default to. * * Requirements: * * - `receiver` cannot be the zero address. * - `feeNumerator` cannot be greater than the fee denominator. */ function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual { 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 { 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 { 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 { delete _tokenRoyaltyInfo[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "./IERC1155.sol"; import {IERC1155Receiver} from "./IERC1155Receiver.sol"; import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol"; import {Context} from "../../utils/Context.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {Arrays} from "../../utils/Arrays.sol"; import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 */ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; mapping(uint256 id => mapping(address account => uint256)) private _balances; mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256 /* id */) public view virtual returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual returns (uint256[] memory) { if (accounts.length != ids.length) { revert ERC1155InvalidArrayLength(ids.length, accounts.length); } uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i)); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeTransferFrom(from, to, id, value, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeBatchTransferFrom(from, to, ids, values, data); } /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` * (or `to`) is the zero address. * * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. * - `ids` and `values` must have the same length. * * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead. */ function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual { if (ids.length != values.length) { revert ERC1155InvalidArrayLength(ids.length, values.length); } address operator = _msgSender(); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids.unsafeMemoryAccess(i); uint256 value = values.unsafeMemoryAccess(i); if (from != address(0)) { uint256 fromBalance = _balances[id][from]; if (fromBalance < value) { revert ERC1155InsufficientBalance(from, fromBalance, value, id); } unchecked { // Overflow not possible: value <= fromBalance _balances[id][from] = fromBalance - value; } } if (to != address(0)) { _balances[id][to] += value; } } if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); emit TransferSingle(operator, from, to, id, value); } else { emit TransferBatch(operator, from, to, ids, values); } } /** * @dev Version of {_update} that performs the token acceptance check by calling * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it * contains code (eg. is a smart contract at the moment of execution). * * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any * update to the contract state after this function would break the check-effect-interaction pattern. Consider * overriding {_update} instead. */ function _updateWithAcceptanceCheck( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal virtual { _update(from, to, ids, values); if (to != address(0)) { address operator = _msgSender(); if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data); } else { _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data); } } } /** * @dev Transfers a `value` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. * - `ids` and `values` must have the same length. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the values in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `values` must have the same length. * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev Destroys a `value` amount of tokens of type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. */ function _burn(address from, uint256 id, uint256 value) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. * - `ids` and `values` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC1155InvalidOperator(address(0)); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address * if it contains code at the moment of execution. */ function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address * if it contains code at the moment of execution. */ function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Creates an array in memory with only one value for each of the elements provided. */ function _asSingletonArrays( uint256 element1, uint256 element2 ) private pure returns (uint256[] memory array1, uint256[] memory array2) { /// @solidity memory-safe-assembly assembly { // Load the free memory pointer array1 := mload(0x40) // Set array length to 1 mstore(array1, 1) // Store the single element at the next word after the length (where content starts) mstore(add(array1, 0x20), element1) // Repeat for next array locating it right after the first array array2 := add(array1, 0x40) mstore(array2, 1) mstore(add(array2, 0x20), element2) // Update the free memory pointer by pointing after the second array mstore(0x40, add(array2, 0x40)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "./IERC721.sol"; import {IERC721Receiver} from "./IERC721Receiver.sol"; import {IERC721Metadata} from "./extensions/IERC721Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {Strings} from "../../utils/Strings.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors { using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; mapping(uint256 tokenId => address) private _owners; mapping(address owner => uint256) private _balances; mapping(uint256 tokenId => address) private _tokenApprovals; mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual returns (uint256) { if (owner == address(0)) { revert ERC721InvalidOwner(address(0)); } return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual returns (address) { return _requireOwned(tokenId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual returns (string memory) { _requireOwned(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual { _approve(to, tokenId, _msgSender()); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual returns (address) { _requireOwned(tokenId); return _getApproved(tokenId); } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here. address previousOwner = _update(to, tokenId, _msgSender()); if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual { transferFrom(from, to, tokenId); _checkOnERC721Received(from, to, tokenId, data); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist * * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the * core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted. */ function _getApproved(uint256 tokenId) internal view virtual returns (address) { return _tokenApprovals[tokenId]; } /** * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in * particular (ignoring whether it is owned by `owner`). * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) { return spender != address(0) && (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender); } /** * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner. * Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets * the `spender` for the specific `tokenId`. * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual { if (!_isAuthorized(owner, spender, tokenId)) { if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } else { revert ERC721InsufficientApproval(spender, tokenId); } } } /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that * a uint256 would ever overflow from increments when these increments are bounded to uint128 values. * * WARNING: Increasing an account's balance using this function tends to be paired with an override of the * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership * remain consistent with one another. */ function _increaseBalance(address account, uint128 value) internal virtual { unchecked { _balances[account] += value; } } /** * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update. * * The `auth` argument is optional. If the value passed is non 0, then this function will check that * `auth` is either the owner of the token, or approved to operate on the token (by the owner). * * Emits a {Transfer} event. * * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}. */ function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) { address from = _ownerOf(tokenId); // Perform (optional) operator check if (auth != address(0)) { _checkAuthorized(from, auth, tokenId); } // Execute the update if (from != address(0)) { // Clear approval. No need to re-authorize or emit the Approval event _approve(address(0), tokenId, address(0), false); unchecked { _balances[from] -= 1; } } if (to != address(0)) { unchecked { _balances[to] += 1; } } _owners[tokenId] = to; emit Transfer(from, to, tokenId); return from; } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner != address(0)) { revert ERC721InvalidSender(address(0)); } } /** * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); _checkOnERC721Received(address(0), to, tokenId, data); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal { address previousOwner = _update(address(0), tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } else if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients * are aware of the ERC721 standard to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is like {safeTransferFrom} in the sense that it invokes * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `tokenId` token must exist and be owned by `from`. * - `to` cannot be the zero address. * - `from` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId) internal { _safeTransfer(from, to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); _checkOnERC721Received(from, to, tokenId, data); } /** * @dev Approve `to` to operate on `tokenId` * * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is * either the owner of the token, or approved to operate on all tokens held by this owner. * * Emits an {Approval} event. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address to, uint256 tokenId, address auth) internal { _approve(to, tokenId, auth, true); } /** * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not * emitted in the context of transfers. */ function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual { // Avoid reading the owner unless necessary if (emitEvent || auth != address(0)) { address owner = _requireOwned(tokenId); // We do not use _isAuthorized because single-token approvals should not be able to call approve if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) { revert ERC721InvalidApprover(auth); } if (emitEvent) { emit Approval(owner, to, tokenId); } } _tokenApprovals[tokenId] = to; } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Requirements: * - operator can't be the address zero. * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC721InvalidOperator(operator); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned). * Returns the owner. * * Overrides to ownership logic should be done to {_ownerOf}. */ function _requireOwned(uint256 tokenId) internal view returns (address) { address owner = _ownerOf(tokenId); if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } return owner; } /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the * recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private { if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { if (retval != IERC721Receiver.onERC721Received.selector) { revert ERC721InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { revert ERC721InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using StorageSlot for bytes32; /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in ascending order, and to contain no * repeated elements. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getUint256Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// 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 // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @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/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 // 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); } } }
// 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 // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {DTOs} from "./../libraries/dtos.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; interface IERC1155 { function init( address owner, uint96 royalty, string memory name, string memory symbol, bool transferLocked, address metadataResolver ) external; function addMinter(address minter) external; function transferOwnership(address owner) external; function owner() external returns (address); } interface IMinter { function init( address owner, address signerAddress, address feeRecipient, uint256[] memory availableTokens, DTOs.Recipient[] memory recipients, address erc1155Address ) external; } interface IMetadataResolver { function setBaseURI(address _address, string memory _baseURI) external; } contract ERC1155ProxyFactory is Ownable, SignatureProtected { address public paymentRecipient; address public erc1155Address; mapping(string => address) allowedMinters; string public metadataBaseUrl; IMetadataResolver public metadataResolver; event NewContract( string indexed iuuid, string uuid, address token, address minter, uint256[] extras ); constructor( address _erc1155Address, string memory _metadataBaseUrl, address _metadataResolverAddress, address _signerAddress, address _paymentRecipient ) { paymentRecipient = _paymentRecipient; erc1155Address = _erc1155Address; metadataBaseUrl = _metadataBaseUrl; metadataResolver = IMetadataResolver(_metadataResolverAddress); initSignatureProtected(_signerAddress); } // Only Owner function setERC721Address(address _erc1155Address) external onlyOwner { erc1155Address = _erc1155Address; } function addAllowedMinter( string memory _type, address _address ) external onlyOwner { allowedMinters[_type] = _address; } function removeAllowedMinter(string memory _type) external onlyOwner { delete allowedMinters[_type]; } function getAllowedMinterByKind( string memory kind ) public view returns (address) { require( allowedMinters[kind] != address(0), "No contract found for the given kind" ); return allowedMinters[kind]; } function setMetadataResolverAddress( address _metadataResolverAddress ) external onlyOwner { metadataResolver = IMetadataResolver(_metadataResolverAddress); } function setMetadataBaseUrl( string memory _metadataBaseUrl ) external onlyOwner { metadataBaseUrl = _metadataBaseUrl; } function setPaymentRecipient(address _paymentRecipient) external onlyOwner { paymentRecipient = _paymentRecipient; } // Public function create( DTOs.Create1155ContractDto calldata _createDto ) external payable { validateSignature( abi.encodePacked( keccak256(abi.encodePacked(_createDto.uuid)), _createDto.paymentAmount, _createDto.extras ), _createDto.signature ); handlePayment(_createDto.paymentAmount); address cloneErc1155Address = Clones.clone(erc1155Address); IERC1155 erc1155 = IERC1155(cloneErc1155Address); erc1155.init( _createDto.owner, _createDto.royaltyPercentage, _createDto.name, _createDto.symbol, _createDto.transferLocked, address(metadataResolver) ); address cloneMinterAddress = Clones.clone( getAllowedMinterByKind(_createDto.minterKind) ); IMinter minter = IMinter(cloneMinterAddress); minter.init( _createDto.owner, _createDto.signer, paymentRecipient, _createDto.availableTokens, _createDto.recipients, cloneErc1155Address ); erc1155.addMinter(cloneMinterAddress); erc1155.transferOwnership(_createDto.owner); metadataResolver.setBaseURI( cloneErc1155Address, string(abi.encodePacked(metadataBaseUrl, _createDto.uuid, "/")) ); emit NewContract( _createDto.uuid, _createDto.uuid, cloneErc1155Address, cloneMinterAddress, _createDto.extras ); } function handlePayment(uint256 paymentAmount) internal { if (paymentAmount == 0) { return; } require( msg.value >= paymentAmount, "The payment amount has not been satisfied" ); (bool success, ) = address(paymentRecipient).call{value: msg.value}(""); require(success, "Payable: Transfer failed"); } function encodeBytes32String( string memory source ) private pure returns (bytes32 result) { bytes memory tempBytes = bytes(source); if (tempBytes.length == 0) { return 0x0; } assembly { result := mload(add(tempBytes, 32)) } } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {DTOs} from "./../libraries/dtos.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; interface IERC721 { function init( address owner, uint96 royalty, string memory name, string memory symbol, bool transferLocked, address metadataResolver ) external; function addMinter(address minter) external; function transferOwnership(address owner) external; function owner() external returns (address); } interface IMinter { function init( address owner, uint256 maxSupply, address signerAddress, address feeRecipient, DTOs.Recipient[] memory recipients, address erc721Address ) external; } interface IMetadataResolver { function setBaseURI(address _address, string memory _baseURI) external; } contract ERC721ProxyFactory is Ownable, SignatureProtected { address public paymentRecipient; address public erc721Address; mapping(string => address) allowedMinters; string public metadataBaseUrl; IMetadataResolver public metadataResolver; event NewContract( string indexed iuuid, string uuid, address token, address minter, uint256[] extras ); constructor( address _erc721Address, string memory _metadataBaseUrl, address _metadataResolverAddress, address _signerAddress, address _paymentRecipient ) { paymentRecipient = _paymentRecipient; erc721Address = _erc721Address; metadataBaseUrl = _metadataBaseUrl; metadataResolver = IMetadataResolver(_metadataResolverAddress); initSignatureProtected(_signerAddress); } // Only Owner function setERC721Address(address _erc721Address) external onlyOwner { erc721Address = _erc721Address; } function addAllowedMinter( string memory _type, address _address ) external onlyOwner { allowedMinters[_type] = _address; } function removeAllowedMinter(string memory _type) external onlyOwner { delete allowedMinters[_type]; } function getAllowedMinterByKind( string memory kind ) public view returns (address) { require( allowedMinters[kind] != address(0), "No contract found for the given kind" ); return allowedMinters[kind]; } function setMetadataResolverAddress( address _metadataResolverAddress ) external onlyOwner { metadataResolver = IMetadataResolver(_metadataResolverAddress); } function setMetadataBaseUrl( string memory _metadataBaseUrl ) external onlyOwner { metadataBaseUrl = _metadataBaseUrl; } function setPaymentRecipient(address _paymentRecipient) external onlyOwner { paymentRecipient = _paymentRecipient; } // Public function create( DTOs.Create721ContractDto calldata _createDto ) external payable { validateSignature( abi.encodePacked( keccak256(abi.encodePacked(_createDto.uuid)), _createDto.paymentAmount, _createDto.extras ), _createDto.signature ); handlePayment(_createDto.paymentAmount); address cloneErc721Address = Clones.clone(erc721Address); IERC721 erc721 = IERC721(cloneErc721Address); erc721.init( _createDto.owner, _createDto.royaltyPercentage, _createDto.name, _createDto.symbol, _createDto.transferLocked, address(metadataResolver) ); address cloneMinterAddress = Clones.clone( getAllowedMinterByKind(_createDto.minterKind) ); IMinter minter = IMinter(cloneMinterAddress); minter.init( _createDto.owner, _createDto.maxSupply, _createDto.signer, paymentRecipient, _createDto.recipients, cloneErc721Address ); erc721.addMinter(cloneMinterAddress); erc721.transferOwnership(_createDto.owner); metadataResolver.setBaseURI( cloneErc721Address, string(abi.encodePacked(metadataBaseUrl, _createDto.uuid, "/")) ); emit NewContract( _createDto.uuid, _createDto.uuid, cloneErc721Address, cloneMinterAddress, _createDto.extras ); } function handlePayment(uint256 paymentAmount) internal { if (paymentAmount == 0) { return; } require( msg.value >= paymentAmount, "The payment amount has not been satisfied" ); (bool success, ) = address(paymentRecipient).call{value: msg.value}(""); require(success, "Payable: Transfer failed"); } function encodeBytes32String( string memory source ) private pure returns (bytes32 result) { bytes memory tempBytes = bytes(source); if (tempBytes.length == 0) { return 0x0; } assembly { result := mload(add(tempBytes, 32)) } } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; interface IERC1155Mintable { function mint( address _to, uint256[] memory _ids, uint256[] memory _values ) external; function totalMinted() external returns (uint256); }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; interface IERC721Mintable { function mint(address _to, uint256[] memory _ids) external; function totalMinted() external returns (uint256); function exists(uint256 _tokenId) external view returns (bool); }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; interface IMetadataResolver { function getTokenURI( address _address, uint256 _tokenId ) external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library DTOs { struct Recipient { address addr; uint256 percentage; } struct Create721ContractDto { address owner; string uuid; string name; string symbol; bool transferLocked; uint96 royaltyPercentage; uint256 maxSupply; address signer; Recipient[] recipients; uint256 paymentAmount; string minterKind; uint256[] extras; bytes signature; } struct Create1155ContractDto { address owner; string uuid; string name; string symbol; bool transferLocked; uint96 royaltyPercentage; uint256[] availableTokens; address signer; Recipient[] recipients; uint256 paymentAmount; string minterKind; uint256[] extras; bytes signature; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; abstract contract LimitPerWallet { mapping(address => uint256) public mintsPerWallet; /** * @dev Checks if the given wallet address can mint more tokens. * If the desired amount to be minted exceeds the amount of tokens left allowed to be minted by the given address * it will return the maximum amount of tokens that address can mint. * * If the given address can not mint more tokens it will revert the transaction. */ function getAvailableForWallet( uint256 _amount, uint256 _maxPerWallet ) internal returns (uint256) { // If maxPerWallet is 0 it means that there is no limit per wallet. if (_maxPerWallet == 0) { return _amount; } if (mintsPerWallet[msg.sender] + _amount > _maxPerWallet) { _amount = _maxPerWallet - mintsPerWallet[msg.sender]; } require( _amount > 0, "LimitPerWallet: The caller address can not mint more tokens" ); mintsPerWallet[msg.sender] += _amount; return _amount; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; abstract contract Lockable is Ownable { bool public isMintLocked; bool public isBurnLocked; bool public isMetadataLocked; modifier mintIsNotLocked() { require(isMintLocked == false, "Lockable: mint is locked"); _; } modifier burnIsNotLocked() { require(isBurnLocked == false, "Lockable: burn is locked"); _; } modifier metadataIsNotLocked() { require(isMetadataLocked == false, "Lockable: metadata is locked"); _; } function lockMint() external onlyOwner { isMintLocked = true; } function lockBurn() external onlyOwner { isBurnLocked = true; } function lockMetadata() external onlyOwner { isMetadataLocked = true; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {DTOs} from "./../libraries/dtos.sol"; abstract contract Payable { address public feeRecipient; uint256 private _totalEarnings; modifier onlyRecipient() { bool isRecipient = false; for (uint256 i = 0; i < recipients.length; i++) { if (recipients[i].addr == msg.sender) { isRecipient = true; break; } } require( isRecipient, "Payable: The caller is not an allowed withdrawer" ); _; } uint256 constant BASIS_POINTS = 10000; DTOs.Recipient[] public recipients; function initPayable( address _feeRecipient, DTOs.Recipient[] memory _recipients ) internal { feeRecipient = _feeRecipient; for (uint256 i = 0; i < _recipients.length; i++) { recipients.push(_recipients[i]); } } function checkSentEther( uint256 _amount, uint256 _pricePerToken, uint256 _feePerToken ) internal { uint totalPrice = _amount * _pricePerToken; uint totalFee = _amount * _feePerToken; uint total = totalPrice + totalFee; require( msg.value >= total, "Payable: Not enough Ether provided to mint" ); if (msg.value > total) { payable(msg.sender).transfer(msg.value - total); } if (totalFee > 0) { (bool success, ) = address(feeRecipient).call{value: totalFee}(""); require(success, "Payable: Transfer failed"); } } function withdraw() external onlyRecipient { uint256 totalBalance = address(this).balance; _totalEarnings += totalBalance; for (uint256 i; i < recipients.length; i++) { (bool success, ) = address(recipients[i].addr).call{ value: mulScale( totalBalance, recipients[i].percentage, BASIS_POINTS ) }(""); require(success, "Payable: Transfer failed"); } } function totalEarnings() external view returns (uint256) { return _totalEarnings + address(this).balance; } function mulScale( uint256 x, uint256 y, uint256 scale ) internal pure returns (uint256) { uint256 a = x / scale; uint256 b = x % scale; uint256 c = y / scale; uint256 d = y % scale; return a * c * scale + a * d + b * c + (b * d) / scale; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; abstract contract ProtectedMintBurn is Ownable { event AddMinter(address _minter); event RemoveMinter(address _minter); event AddBurner(address _minter); event RemoveBurner(address _minter); mapping(address => bool) public allowedMinter; mapping(address => bool) public allowedBurner; constructor() { allowedMinter[msg.sender] = true; } modifier onlyMinter() { require( allowedMinter[msg.sender], "ProtectedMintBurn: caller is not a minter" ); _; } modifier onlyBurner() { require( allowedBurner[msg.sender], "ProtectedMintBurn: caller is not a burner" ); _; } function addMinter(address _minter) external onlyOwner { allowedMinter[_minter] = true; emit AddMinter(_minter); } function removeMinter(address _minter) external onlyOwner { allowedMinter[_minter] = false; emit RemoveMinter(_minter); } function addBurner(address _burner) external onlyOwner { allowedBurner[_burner] = true; emit AddBurner(_burner); } function removeBurner(address _burner) external onlyOwner { allowedBurner[_burner] = false; emit RemoveBurner(_burner); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; abstract contract RandomGenerator { /** * @dev Generates a pseudo-random number. */ function getRandomNumber( uint256 _upper, uint256 _variable // This value should change in between calls to this function within the same block to avoid generating the same number. ) internal view returns (uint256) { uint256 random = uint256( keccak256( abi.encodePacked( _variable, blockhash(block.number - 1), block.coinbase, block.prevrandao, msg.sender ) ) ); return (random % _upper); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; abstract contract SignatureProtected is Ownable { address public signerAddress; constructor() Ownable(msg.sender) {} function initSignatureProtected(address _signerAddress) internal { signerAddress = _signerAddress; } function setSignerAddress(address _signerAddress) external onlyOwner { signerAddress = _signerAddress; } function validateSignature( bytes memory packedParams, bytes calldata signature ) internal view { require( ECDSA.recover(generateHash(packedParams), signature) == signerAddress, "SignatureProtected: Invalid signature for the caller" ); } function generateHash( bytes memory packedParams ) private view returns (bytes32) { bytes32 _hash = keccak256( bytes.concat( abi.encodePacked(address(this), msg.sender), packedParams ) ); bytes memory result = abi.encodePacked( "\x19Ethereum Signed Message:\n32", _hash ); return keccak256(result); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; abstract contract SupplyControl { uint256 public maxSupply; function initSupplyControl(uint256 _maxSupply) internal { maxSupply = _maxSupply; } /** * @dev Checks if there are tokens left to be minted. * If there are not enough tokens for the given amount to mint, it will return whatever is left. * * If there are no tokens left to be minted it will revert the transaction. */ function _getAvailableTokens( uint256 _amountToMint, uint256 _totalMinted ) internal view returns (uint256) { uint256 availableTokens = maxSupply - _totalMinted; require(availableTokens > 0, "SupplyControl: No tokens left to mint"); if (availableTokens < _amountToMint) { return availableTokens; } return _amountToMint; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; abstract contract SupplyControl1155 { uint256[] internal availableTokens; uint256 public maxSupply; function initSupplyControl(uint256[] memory _availableTokens) internal { availableTokens = _availableTokens; for (uint256 i; i < _availableTokens.length; i++) { maxSupply += _availableTokens[i]; } } /** * @dev Checks if there are tokens left to be minted. * If there are not enough tokens for the given amount to mint, it will return whatever is left. * * If there are no tokens left to be minted it will revert the transaction. */ function _getAvailableTokens( uint256 _amountToMint ) internal view returns (uint256) { uint256 _availableTokens = getAvailableTokens(); require(_availableTokens > 0, "SupplyControl: No tokens left to mint"); if (_availableTokens < _amountToMint) { return _availableTokens; } return _amountToMint; } function getAvailableTokens() public view returns (uint256) { uint256 _availableTokens; for (uint256 i; i < availableTokens.length; i++) { _availableTokens += availableTokens[i]; } return _availableTokens; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import {IMetadataResolver} from "./../interfaces/IMetadataResolver.sol"; contract MetadataBaseUrl is Ownable, IMetadataResolver { using Strings for uint256; mapping(address => bool) public allowedSetters; mapping(address => string) public baseURI; constructor() Ownable(msg.sender) { allowedSetters[msg.sender] = true; } function addAllowedSetter(address _allowedSetter) external onlyOwner { allowedSetters[_allowedSetter] = true; } function removeAllowedSetter(address _allowedSetter) external onlyOwner { allowedSetters[_allowedSetter] = false; } function setBaseURI(address _address, string memory _baseURI) external { require( allowedSetters[msg.sender], "MetadataBaseUrl: Caller not allowed" ); baseURI[_address] = _baseURI; } function getTokenURI( address _address, uint256 _tokenId ) external view returns (string memory) { return string(abi.encodePacked(baseURI[_address], _tokenId.toString())); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol"; import {Payable} from "./../libraries/Payable.sol"; import {SupplyControl} from "./../libraries/SupplyControl.sol"; import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import {DTOs} from "./../libraries/dtos.sol"; contract PickMint721 is Payable, SupplyControl, LimitPerWallet, SignatureProtected { string public constant contractType = "PICK-MINTER-721"; string public constant version = "1.0.0"; IERC721Mintable public erc721Contract; bool private _isInitialized; function init( address owner, uint256 maxSupply, address signerAddress, address feeRecipient, DTOs.Recipient[] memory recipients, address erc721Address ) external { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(owner); initSupplyControl(maxSupply); initSignatureProtected(signerAddress); initPayable(feeRecipient, recipients); erc721Contract = IERC721Mintable(erc721Address); _isInitialized = true; } function mint( uint256[] memory _ids, uint256 _maxPerWallet, uint256 _pricePerToken, uint256 _feePerToken, bytes calldata _signature ) external payable { validateSignature( abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken), _signature ); uint256 _amount; for (uint256 i; i < _ids.length; i++) { require(_ids[i] < maxSupply, "Invalid ID to be minted"); if (!erc721Contract.exists(_ids[i])) { _amount++; } } uint256 _availableAmount = getAvailableForWallet( _amount, _maxPerWallet ); require( _availableAmount >= _amount, "Not enough tokens available to mint for your wallet" ); checkSentEther(_amount, _pricePerToken, _feePerToken); uint256[] memory idsToMint = new uint256[](_amount); uint256 c; for (uint256 i; i < _ids.length; i++) { if (erc721Contract.exists(_ids[i])) { continue; } idsToMint[c] = _ids[i]; c++; } erc721Contract.mint(msg.sender, idsToMint); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol"; import {Payable} from "./../libraries/Payable.sol"; import {SupplyControl1155} from "./../libraries/SupplyControl1155.sol"; import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import {DTOs} from "./../libraries/dtos.sol"; import {RandomGenerator} from "./../libraries/RandomGenerator.sol"; contract RandomMint1155 is Payable, SupplyControl1155, LimitPerWallet, SignatureProtected, RandomGenerator { string public constant contractType = "RANDOM-MINTER-1155"; string public constant version = "1.0.0"; IERC1155Mintable public erc1155Contract; bool private _isInitialized; function init( address owner, address signerAddress, address feeRecipient, uint256[] memory availableTokens, DTOs.Recipient[] memory recipients, address erc1155Address ) external { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(owner); initSupplyControl(availableTokens); initSignatureProtected(signerAddress); initPayable(feeRecipient, recipients); erc1155Contract = IERC1155Mintable(erc1155Address); _isInitialized = true; } function mint( uint256 _amount, uint256 _maxPerWallet, uint256 _pricePerToken, uint256 _feePerToken, bytes calldata _signature ) external payable { validateSignature( abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken), _signature ); _amount = _getAvailableTokens(_amount); _amount = getAvailableForWallet(_amount, _maxPerWallet); checkSentEther(_amount, _pricePerToken, _feePerToken); uint256[] memory amountsPerToken = new uint256[]( availableTokens.length ); uint256 diffCount = 0; for (uint256 i; i < _amount; i++) { uint256 tokenId = getRandomTokenId(i); if (amountsPerToken[tokenId] == 0) { diffCount++; } amountsPerToken[tokenId]++; } uint256[] memory ids = new uint256[](diffCount); uint256[] memory amounts = new uint256[](diffCount); uint256 found = 0; for (uint256 i; i < amountsPerToken.length; i++) { if (amountsPerToken[i] == 0) { continue; } ids[found] = i; amounts[found] = amountsPerToken[i]; found++; } erc1155Contract.mint(msg.sender, ids, amounts); } function getRandomTokenId( uint256 _randomVariable ) internal returns (uint256) { uint256 random = getRandomNumber(getAvailableTokens(), _randomVariable); uint256 total; for (uint256 i; i < availableTokens.length; i++) { total += availableTokens[i]; if (random < total) { availableTokens[i]--; return i; } } revert("Invalid random value generated"); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol"; import {Payable} from "./../libraries/Payable.sol"; import {SupplyControl} from "./../libraries/SupplyControl.sol"; import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import {DTOs} from "./../libraries/dtos.sol"; import {RandomGenerator} from "./../libraries/RandomGenerator.sol"; contract RandomMint721 is Payable, SupplyControl, LimitPerWallet, SignatureProtected, RandomGenerator { mapping(uint256 => uint256) private tokenMatrix; string public constant contractType = "RANDOM-MINTER-721"; string public constant version = "1.0.0"; IERC721Mintable public erc721Contract; bool private _isInitialized; function init( address owner, uint256 maxSupply, address signerAddress, address feeRecipient, DTOs.Recipient[] memory recipients, address erc721Address ) external { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(owner); initSupplyControl(maxSupply); initSignatureProtected(signerAddress); initPayable(feeRecipient, recipients); erc721Contract = IERC721Mintable(erc721Address); _isInitialized = true; } function mint( uint256 _amount, uint256 _maxPerWallet, uint256 _pricePerToken, uint256 _feePerToken, bytes calldata _signature ) external payable { validateSignature( abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken), _signature ); uint256 totalMinted = erc721Contract.totalMinted(); _amount = _getAvailableTokens(_amount, totalMinted); _amount = getAvailableForWallet(_amount, _maxPerWallet); checkSentEther(_amount, _pricePerToken, _feePerToken); uint256[] memory ids = new uint256[](_amount); for (uint256 i; i < ids.length; i++) { ids[i] = getTokenToBeMinted(totalMinted + i, maxSupply); } erc721Contract.mint(msg.sender, ids); } function getAvailableTokens() public view returns (uint256) { (bool success, bytes memory totalSupply) = address(erc721Contract) .staticcall(abi.encodeWithSignature("totalMinted()")); require(success, "Call to totalSupply failed"); return maxSupply - abi.decode(totalSupply, (uint256)); } /** * @dev Returns a random available token to be minted */ function getTokenToBeMinted( uint256 _totalSupply, uint256 _maxSupply ) internal returns (uint256) { uint256 maxIndex = _maxSupply - _totalSupply; uint256 random = getRandomNumber(maxIndex, _totalSupply); uint256 tokenId = tokenMatrix[random]; if (tokenMatrix[random] == 0) { tokenId = random; } tokenMatrix[maxIndex - 1] == 0 ? tokenMatrix[random] = maxIndex - 1 : tokenMatrix[random] = tokenMatrix[maxIndex - 1]; return tokenId; } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol"; import {Payable} from "./../libraries/Payable.sol"; import {SupplyControl} from "./../libraries/SupplyControl.sol"; import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol"; import {SignatureProtected} from "./../libraries/SignatureProtected.sol"; import {DTOs} from "./../libraries/dtos.sol"; contract SequentialMint721 is Payable, SupplyControl, LimitPerWallet, SignatureProtected { string public constant contractType = "SEQUENTIAL-MINTER-721"; string public constant version = "1.0.0"; IERC721Mintable public erc721Contract; bool private _isInitialized; function init( address owner, uint256 maxSupply, address signerAddress, address feeRecipient, DTOs.Recipient[] memory recipients, address erc721Address ) external { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(owner); initSupplyControl(maxSupply); initSignatureProtected(signerAddress); initPayable(feeRecipient, recipients); erc721Contract = IERC721Mintable(erc721Address); _isInitialized = true; } function mint( uint256 _amount, uint256 _maxPerWallet, uint256 _pricePerToken, uint256 _feePerToken, bytes calldata _signature ) external payable { validateSignature( abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken), _signature ); uint256 totalMinted = erc721Contract.totalMinted(); _amount = _getAvailableTokens(_amount, totalMinted); _amount = getAvailableForWallet(_amount, _maxPerWallet); checkSentEther(_amount, _pricePerToken, _feePerToken); uint256[] memory ids = new uint256[](_amount); for (uint256 i; i < ids.length; i++) { ids[i] = totalMinted + i; } erc721Contract.mint(msg.sender, ids); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol"; import {Lockable} from "./../libraries/Lockable.sol"; import {ProtectedMintBurn} from "./../libraries/ProtectedMintBurn.sol"; import {IMetadataResolver} from "./../interfaces/IMetadataResolver.sol"; import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; contract Base1155 is ERC1155, ERC2981, Ownable, Lockable, ProtectedMintBurn, IERC1155Mintable { event TransferLocked(bool isTransferLocked); string public constant contractType = "ERC-1155"; string public constant version = "1.0.0"; IMetadataResolver public metadataResolver; uint256 public totalMinted; uint256 public totalBurned; bool public transferLocked; string private _name; string private _symbol; bool private _isInitialized; struct BatchMint { address addr; uint256[] ids; uint256[] values; } constructor() ERC1155("") Ownable(msg.sender) {} function init( address owner, uint96 royalty, string memory __name, string memory __symbol, bool _transferLocked, address _metadataResolver ) public { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(msg.sender); _setDefaultRoyalty(owner, royalty); _name = __name; _symbol = __symbol; transferLocked = _transferLocked; metadataResolver = IMetadataResolver(_metadataResolver); _isInitialized = true; } // Only Minter function mint( address _to, uint256[] memory _ids, uint256[] memory _values ) external onlyMinter mintIsNotLocked { _mintBatch(_to, _ids, _values, ""); uint256 _totalMinted; for (uint256 i; i < _values.length; i++) { _totalMinted += _values[i]; } totalMinted += _totalMinted; } function batchMint( BatchMint[] memory bm ) external onlyMinter mintIsNotLocked { uint256 _totalMinted; for (uint256 i; i < bm.length; i++) { _mintBatch(bm[i].addr, bm[i].ids, bm[i].values, ""); for (uint256 f; f < bm[i].values.length; f++) { _totalMinted += bm[i].values[f]; } } totalMinted += _totalMinted; } // Only Burner function burn( address _from, uint256[] memory _ids, uint256[] memory _values ) external onlyBurner burnIsNotLocked { _burnBatch(_from, _ids, _values); uint256 _totalBurned; for (uint256 i; i < _values.length; i++) { _totalBurned += _values[i]; } totalBurned += _totalBurned; } // Only owner function setDefaultRoyalty( address _receiver, uint96 _feeNumerator ) external onlyOwner { _setDefaultRoyalty(_receiver, _feeNumerator); } function setTokenRoyalty( uint256 _tokenId, address _receiver, uint96 _feeNumerator ) external onlyOwner { _setTokenRoyalty(_tokenId, _receiver, _feeNumerator); } function setMetadataResolver( address _metadataResolverAddress ) external onlyOwner metadataIsNotLocked { metadataResolver = IMetadataResolver(_metadataResolverAddress); } function setTransferLocked(bool _transferLocked) external onlyOwner { transferLocked = _transferLocked; emit TransferLocked(_transferLocked); } // Public function name() public view virtual returns (string memory) { return _name; } function symbol() public view virtual returns (string memory) { return _symbol; } function uri( uint256 _tokenId ) public view virtual override returns (string memory) { return metadataResolver.getTokenURI(address(this), _tokenId); } function totalSupply() public view returns (uint256) { return totalMinted - totalBurned; } function supportsInterface( bytes4 _interfaceId ) public view virtual override(ERC1155, ERC2981) returns (bool) { return super.supportsInterface(_interfaceId); } function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override { // Check that either the token is being minted // or that the transfer is unlocked require( from == address(0) || !transferLocked, "The token can not be transferred at this time." ); return super._update(from, to, ids, values); } }
// SPDX-License-Identifier: MIT // @author: Buildtree - Powered by NFT Studios pragma solidity ^0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol"; import {Lockable} from "./../libraries/Lockable.sol"; import {ProtectedMintBurn} from "./../libraries/ProtectedMintBurn.sol"; import {IMetadataResolver} from "./../interfaces/IMetadataResolver.sol"; import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; contract Base721 is ERC721, ERC2981, Ownable, Lockable, ProtectedMintBurn, IERC721Mintable { event TransferLocked(bool isTransferLocked); string public constant contractType = "ERC-721"; string public constant version = "1.0.0"; IMetadataResolver public metadataResolver; uint256 public totalMinted; uint256 public totalBurned; bool public transferLocked; string private _name; string private _symbol; bool private _isInitialized; constructor() ERC721("", "") Ownable(msg.sender) {} function init( address owner, uint96 royalty, string memory __name, string memory __symbol, bool _transferLocked, address _metadataResolver ) public { require(_isInitialized == false, "Contract already initialized."); _transferOwnership(msg.sender); _setDefaultRoyalty(owner, royalty); _name = __name; _symbol = __symbol; transferLocked = _transferLocked; metadataResolver = IMetadataResolver(_metadataResolver); _isInitialized = true; } // Only Minter function mint( address _to, uint256[] memory _ids ) external onlyMinter mintIsNotLocked { for (uint i; i < _ids.length; i++) { _safeMint(_to, _ids[i]); } totalMinted += _ids.length; } function batchMint( address[] memory _addresses, uint256[] memory _ids ) external onlyMinter mintIsNotLocked { for (uint i; i < _ids.length; i++) { _safeMint(_addresses[i], _ids[i]); } totalMinted += _ids.length; } // Only Burner function burn(uint256[] memory _ids) external onlyBurner burnIsNotLocked { for (uint i; i < _ids.length; i++) { _burn(_ids[i]); } totalBurned += _ids.length; } // Only owner function setDefaultRoyalty( address _receiver, uint96 _feeNumerator ) external onlyOwner { _setDefaultRoyalty(_receiver, _feeNumerator); } function setTokenRoyalty( uint256 _tokenId, address _receiver, uint96 _feeNumerator ) external onlyOwner { _setTokenRoyalty(_tokenId, _receiver, _feeNumerator); } function setMetadataResolver( address _metadataResolverAddress ) external onlyOwner metadataIsNotLocked { metadataResolver = IMetadataResolver(_metadataResolverAddress); } function setTransferLocked(bool _transferLocked) external onlyOwner { transferLocked = _transferLocked; emit TransferLocked(_transferLocked); } // Public function name() public view virtual override returns (string memory) { return _name; } function symbol() public view virtual override returns (string memory) { return _symbol; } function tokenURI( uint256 _tokenId ) public view virtual override returns (string memory) { require(_ownerOf(_tokenId) != address(0), "Token does not exists"); return metadataResolver.getTokenURI(address(this), _tokenId); } function totalSupply() public view returns (uint256) { return totalMinted - totalBurned; } function exists(uint256 _tokenId) external view returns (bool) { return _ownerOf(_tokenId) != address(0); } function supportsInterface( bytes4 _interfaceId ) public view virtual override(ERC721, ERC2981) returns (bool) { return super.supportsInterface(_interfaceId); } function _update( address to, uint256 tokenId, address auth ) internal virtual override returns (address) { address from = _ownerOf(tokenId); // Check that either the token is being minted // or that the transfer is unlocked require( from == address(0) || !transferLocked, "The token can not be transferred at this time." ); return super._update(to, tokenId, auth); } }
{ "evmVersion": "paris", "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"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":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"contractType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc1155Contract","outputs":[{"internalType":"contract IERC1155Mintable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"signerAddress","type":"address"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"uint256[]","name":"availableTokens","type":"uint256[]"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"internalType":"struct DTOs.Recipient[]","name":"recipients","type":"tuple[]"},{"internalType":"address","name":"erc1155Address","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"},{"internalType":"uint256","name":"_maxPerWallet","type":"uint256"},{"internalType":"uint256","name":"_pricePerToken","type":"uint256"},{"internalType":"uint256","name":"_feePerToken","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mintsPerWallet","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":"","type":"uint256"}],"name":"recipients","outputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signerAddress","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalEarnings","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5033600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603620000885760006040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016200007f9190620001ab565b60405180910390fd5b6200009981620000a060201b60201c565b50620001c8565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001938262000166565b9050919050565b620001a58162000186565b82525050565b6000602082019050620001c260008301846200019a565b92915050565b61297d80620001d86000396000f3fe6080604052600436106100fe5760003560e01c806370238eb211610095578063cb2ef6f711610064578063cb2ef6f7146102de578063d1bc76a114610309578063d5abeb0114610347578063e35568cb14610372578063f2fde38b1461039d576100fe565b806370238eb214610255578063715018a6146102715780637a564970146102885780638da5cb5b146102b3576100fe565b806346904840116100d157806346904840146101975780634d0df5fc146101c257806354fd4d50146101ff5780635b7633d01461022a576100fe565b8063046dc16614610103578063128a3abf1461012c5780632df3eba4146101555780633ccfd60b14610180575b600080fd5b34801561010f57600080fd5b5061012a60048036038101906101259190611881565b6103c6565b005b34801561013857600080fd5b50610153600480360381019061014e9190611b55565b610412565b005b34801561016157600080fd5b5061016a6104f1565b6040516101779190611c29565b60405180910390f35b34801561018c57600080fd5b50610195610506565b005b3480156101a357600080fd5b506101ac610749565b6040516101b99190611c53565b60405180910390f35b3480156101ce57600080fd5b506101e960048036038101906101e49190611881565b61076d565b6040516101f69190611c29565b60405180910390f35b34801561020b57600080fd5b50610214610785565b6040516102219190611ced565b60405180910390f35b34801561023657600080fd5b5061023f6107be565b60405161024c9190611c53565b60405180910390f35b61026f600480360381019061026a9190611d6a565b6107e4565b005b34801561027d57600080fd5b50610286610adb565b005b34801561029457600080fd5b5061029d610aef565b6040516102aa9190611eb0565b60405180910390f35b3480156102bf57600080fd5b506102c8610b15565b6040516102d59190611c53565b60405180910390f35b3480156102ea57600080fd5b506102f3610b3f565b6040516103009190611ced565b60405180910390f35b34801561031557600080fd5b50610330600480360381019061032b9190611ecb565b610b78565b60405161033e929190611ef8565b60405180910390f35b34801561035357600080fd5b5061035c610bcc565b6040516103699190611c29565b60405180910390f35b34801561037e57600080fd5b50610387610bd2565b6040516103949190611c29565b60405180910390f35b3480156103a957600080fd5b506103c460048036038101906103bf9190611881565b610c26565b005b6103ce610cac565b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60001515600860149054906101000a900460ff16151514610468576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045f90611f6d565b60405180910390fd5b61047186610d33565b61047a83610df9565b61048385610e60565b61048d8483610ea4565b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600860146101000a81548160ff021916908315150217905550505050505050565b6000476001546105019190611fbc565b905090565b6000805b6002805490508110156105a5573373ffffffffffffffffffffffffffffffffffffffff166002828154811061054257610541611ff0565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff160361059857600191506105a5565b808060010191505061050a565b50806105e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105dd90612091565b60405180910390fd5b600047905080600160008282546105fd9190611fbc565b9250508190555060005b6002805490508110156107445760006002828154811061062a57610629611ff0565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166106a4846002858154811061068a57610689611ff0565b5b906000526020600020906002020160010154612710610f9b565b6040516106b0906120e2565b60006040518083038185875af1925050503d80600081146106ed576040519150601f19603f3d011682016040523d82523d6000602084013e6106f2565b606091505b5050905080610736576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072d90612143565b60405180910390fd5b508080600101915050610607565b505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60056020528060005260406000206000915090505481565b6040518060400160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6108128585856040516020016107fc93929190612184565b604051602081830303815290604052838361104d565b6000805b885181101561099f5760038054905089828151811061083857610837611ff0565b5b602002602001015110610880576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108779061220d565b60405180910390fd5b600060038a838151811061089757610896611ff0565b5b6020026020010151815481106108b0576108af611ff0565b5b906000526020600020015490508882815181106108d0576108cf611ff0565b5b602002602001015181101561090057808983815181106108f3576108f2611ff0565b5b6020026020010181815250505b88828151811061091357610912611ff0565b5b602002602001015160038b84815181106109305761092f611ff0565b5b60200260200101518154811061094957610948611ff0565b5b906000526020600020016000828254610962919061222d565b9250508190555088828151811061097c5761097b611ff0565b5b60200260200101518361098f9190611fbc565b9250508080600101915050610816565b50600081116109e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109da906122d3565b60405180910390fd5b60006109ef8288611137565b905081811015610a34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2b90612365565b60405180910390fd5b610a3f82878761128b565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639727756a338b8b6040518463ffffffff1660e01b8152600401610a9e93929190612443565b600060405180830381600087803b158015610ab857600080fd5b505af1158015610acc573d6000803e3d6000fd5b50505050505050505050505050565b610ae3610cac565b610aed6000610d33565b565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6040518060400160405280601081526020017f5049434b2d4d494e5445522d313135350000000000000000000000000000000081525081565b60028181548110610b8857600080fd5b90600052602060002090600202016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154905082565b60045481565b60008060005b600380549050811015610c1e5760038181548110610bf957610bf8611ff0565b5b906000526020600020015482610c0f9190611fbc565b91508080600101915050610bd8565b508091505090565b610c2e610cac565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610ca05760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610c979190611c53565b60405180910390fd5b610ca981610d33565b50565b610cb4611439565b73ffffffffffffffffffffffffffffffffffffffff16610cd2610b15565b73ffffffffffffffffffffffffffffffffffffffff1614610d3157610cf5611439565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610d289190611c53565b60405180910390fd5b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8060039080519060200190610e0f9291906117a5565b5060005b8151811015610e5c57818181518110610e2f57610e2e611ff0565b5b602002602001015160046000828254610e489190611fbc565b925050819055508080600101915050610e13565b5050565b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b8151811015610f96576002828281518110610f0557610f04611ff0565b5b6020026020010151908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015550508080600101915050610ee7565b505050565b6000808285610faa91906124b7565b905060008386610fba91906124e8565b905060008486610fca91906124b7565b905060008587610fda91906124e8565b9050858184610fe99190612519565b610ff391906124b7565b8284610fff9190612519565b828661100b9190612519565b8885886110189190612519565b6110229190612519565b61102c9190611fbc565b6110369190611fbc565b6110409190611fbc565b9450505050509392505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166110dc61109285611441565b84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506114c5565b73ffffffffffffffffffffffffffffffffffffffff1614611132576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611129906125cd565b60405180910390fd5b505050565b600080820361114857829050611285565b8183600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111949190611fbc565b11156111e857600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826111e5919061222d565b92505b6000831161122b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112229061265f565b60405180910390fd5b82600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461127a9190611fbc565b925050819055508290505b92915050565b600082846112999190612519565b9050600082856112a99190612519565b9050600081836112b99190611fbc565b9050803410156112fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f5906126f1565b60405180910390fd5b80341115611359573373ffffffffffffffffffffffffffffffffffffffff166108fc823461132c919061222d565b9081150290604051600060405180830381858888f19350505050158015611357573d6000803e3d6000fd5b505b60008211156114315760008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16836040516113a9906120e2565b60006040518083038185875af1925050503d80600081146113e6576040519150601f19603f3d011682016040523d82523d6000602084013e6113eb565b606091505b505090508061142f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142690612143565b60405180910390fd5b505b505050505050565b600033905090565b6000803033604051602001611457929190612759565b604051602081830303815290604052836040516020016114789291906127c1565b6040516020818303038152906040528051906020012090506000816040516020016114a39190612867565b6040516020818303038152906040529050808051906020012092505050919050565b6000806000806114d586866114f1565b9250925092506114e5828261154d565b82935050505092915050565b600080600060418451036115365760008060006020870151925060408701519150606087015160001a9050611528888285856116b1565b955095509550505050611546565b60006002855160001b9250925092505b9250925092565b600060038111156115615761156061288d565b5b8260038111156115745761157361288d565b5b03156116ad576001600381111561158e5761158d61288d565b5b8260038111156115a1576115a061288d565b5b036115d8576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600260038111156115ec576115eb61288d565b5b8260038111156115ff576115fe61288d565b5b03611644578060001c6040517ffce698f700000000000000000000000000000000000000000000000000000000815260040161163b9190611c29565b60405180910390fd5b6003808111156116575761165661288d565b5b82600381111561166a5761166961288d565b5b036116ac57806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016116a391906128cb565b60405180910390fd5b5b5050565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c11156116f157600060038592509250925061179b565b6000600188888888604051600081526020016040526040516117169493929190612902565b6020604051602081039080840390855afa158015611738573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361178c57600060016000801b9350935093505061179b565b8060008060001b935093509350505b9450945094915050565b8280548282559060005260206000209081019282156117e1579160200282015b828111156117e05782518255916020019190600101906117c5565b5b5090506117ee91906117f2565b5090565b5b8082111561180b5760008160009055506001016117f3565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061184e82611823565b9050919050565b61185e81611843565b811461186957600080fd5b50565b60008135905061187b81611855565b92915050565b60006020828403121561189757611896611819565b5b60006118a58482850161186c565b91505092915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6118fc826118b3565b810181811067ffffffffffffffff8211171561191b5761191a6118c4565b5b80604052505050565b600061192e61180f565b905061193a82826118f3565b919050565b600067ffffffffffffffff82111561195a576119596118c4565b5b602082029050602081019050919050565b600080fd5b6000819050919050565b61198381611970565b811461198e57600080fd5b50565b6000813590506119a08161197a565b92915050565b60006119b96119b48461193f565b611924565b905080838252602082019050602084028301858111156119dc576119db61196b565b5b835b81811015611a0557806119f18882611991565b8452602084019350506020810190506119de565b5050509392505050565b600082601f830112611a2457611a236118ae565b5b8135611a348482602086016119a6565b91505092915050565b600067ffffffffffffffff821115611a5857611a576118c4565b5b602082029050602081019050919050565b600080fd5b600060408284031215611a8457611a83611a69565b5b611a8e6040611924565b90506000611a9e8482850161186c565b6000830152506020611ab284828501611991565b60208301525092915050565b6000611ad1611acc84611a3d565b611924565b90508083825260208201905060408402830185811115611af457611af361196b565b5b835b81811015611b1d5780611b098882611a6e565b845260208401935050604081019050611af6565b5050509392505050565b600082601f830112611b3c57611b3b6118ae565b5b8135611b4c848260208601611abe565b91505092915050565b60008060008060008060c08789031215611b7257611b71611819565b5b6000611b8089828a0161186c565b9650506020611b9189828a0161186c565b9550506040611ba289828a0161186c565b945050606087013567ffffffffffffffff811115611bc357611bc261181e565b5b611bcf89828a01611a0f565b935050608087013567ffffffffffffffff811115611bf057611bef61181e565b5b611bfc89828a01611b27565b92505060a0611c0d89828a0161186c565b9150509295509295509295565b611c2381611970565b82525050565b6000602082019050611c3e6000830184611c1a565b92915050565b611c4d81611843565b82525050565b6000602082019050611c686000830184611c44565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611ca8578082015181840152602081019050611c8d565b60008484015250505050565b6000611cbf82611c6e565b611cc98185611c79565b9350611cd9818560208601611c8a565b611ce2816118b3565b840191505092915050565b60006020820190508181036000830152611d078184611cb4565b905092915050565b600080fd5b60008083601f840112611d2a57611d296118ae565b5b8235905067ffffffffffffffff811115611d4757611d46611d0f565b5b602083019150836001820283011115611d6357611d6261196b565b5b9250929050565b600080600080600080600060c0888a031215611d8957611d88611819565b5b600088013567ffffffffffffffff811115611da757611da661181e565b5b611db38a828b01611a0f565b975050602088013567ffffffffffffffff811115611dd457611dd361181e565b5b611de08a828b01611a0f565b9650506040611df18a828b01611991565b9550506060611e028a828b01611991565b9450506080611e138a828b01611991565b93505060a088013567ffffffffffffffff811115611e3457611e3361181e565b5b611e408a828b01611d14565b925092505092959891949750929550565b6000819050919050565b6000611e76611e71611e6c84611823565b611e51565b611823565b9050919050565b6000611e8882611e5b565b9050919050565b6000611e9a82611e7d565b9050919050565b611eaa81611e8f565b82525050565b6000602082019050611ec56000830184611ea1565b92915050565b600060208284031215611ee157611ee0611819565b5b6000611eef84828501611991565b91505092915050565b6000604082019050611f0d6000830185611c44565b611f1a6020830184611c1a565b9392505050565b7f436f6e747261637420616c726561647920696e697469616c697a65642e000000600082015250565b6000611f57601d83611c79565b9150611f6282611f21565b602082019050919050565b60006020820190508181036000830152611f8681611f4a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611fc782611970565b9150611fd283611970565b9250828201905080821115611fea57611fe9611f8d565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f50617961626c653a205468652063616c6c6572206973206e6f7420616e20616c60008201527f6c6f776564207769746864726177657200000000000000000000000000000000602082015250565b600061207b603083611c79565b91506120868261201f565b604082019050919050565b600060208201905081810360008301526120aa8161206e565b9050919050565b600081905092915050565b50565b60006120cc6000836120b1565b91506120d7826120bc565b600082019050919050565b60006120ed826120bf565b9150819050919050565b7f50617961626c653a205472616e73666572206661696c65640000000000000000600082015250565b600061212d601883611c79565b9150612138826120f7565b602082019050919050565b6000602082019050818103600083015261215c81612120565b9050919050565b6000819050919050565b61217e61217982611970565b612163565b82525050565b6000612190828661216d565b6020820191506121a0828561216d565b6020820191506121b0828461216d565b602082019150819050949350505050565b7f496e76616c696420494420746f206265206d696e746564000000000000000000600082015250565b60006121f7601783611c79565b9150612202826121c1565b602082019050919050565b60006020820190508181036000830152612226816121ea565b9050919050565b600061223882611970565b915061224383611970565b925082820390508181111561225b5761225a611f8d565b5b92915050565b7f4e6f6e65206f66207468652073656c656374656420746f6b656e7320746f206d60008201527f696e742061726520617661696c61626c65000000000000000000000000000000602082015250565b60006122bd603183611c79565b91506122c882612261565b604082019050919050565b600060208201905081810360008301526122ec816122b0565b9050919050565b7f4e6f7420656e6f75676820746f6b656e7320617661696c61626c6520746f206d60008201527f696e7420666f7220796f75722077616c6c657400000000000000000000000000602082015250565b600061234f603383611c79565b915061235a826122f3565b604082019050919050565b6000602082019050818103600083015261237e81612342565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6123ba81611970565b82525050565b60006123cc83836123b1565b60208301905092915050565b6000602082019050919050565b60006123f082612385565b6123fa8185612390565b9350612405836123a1565b8060005b8381101561243657815161241d88826123c0565b9750612428836123d8565b925050600181019050612409565b5085935050505092915050565b60006060820190506124586000830186611c44565b818103602083015261246a81856123e5565b9050818103604083015261247e81846123e5565b9050949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006124c282611970565b91506124cd83611970565b9250826124dd576124dc612488565b5b828204905092915050565b60006124f382611970565b91506124fe83611970565b92508261250e5761250d612488565b5b828206905092915050565b600061252482611970565b915061252f83611970565b925082820261253d81611970565b9150828204841483151761255457612553611f8d565b5b5092915050565b7f5369676e617475726550726f7465637465643a20496e76616c6964207369676e60008201527f617475726520666f72207468652063616c6c6572000000000000000000000000602082015250565b60006125b7603483611c79565b91506125c28261255b565b604082019050919050565b600060208201905081810360008301526125e6816125aa565b9050919050565b7f4c696d697450657257616c6c65743a205468652063616c6c657220616464726560008201527f73732063616e206e6f74206d696e74206d6f726520746f6b656e730000000000602082015250565b6000612649603b83611c79565b9150612654826125ed565b604082019050919050565b600060208201905081810360008301526126788161263c565b9050919050565b7f50617961626c653a204e6f7420656e6f7567682045746865722070726f76696460008201527f656420746f206d696e7400000000000000000000000000000000000000000000602082015250565b60006126db602a83611c79565b91506126e68261267f565b604082019050919050565b6000602082019050818103600083015261270a816126ce565b9050919050565b60008160601b9050919050565b600061272982612711565b9050919050565b600061273b8261271e565b9050919050565b61275361274e82611843565b612730565b82525050565b60006127658285612742565b6014820191506127758284612742565b6014820191508190509392505050565b600081519050919050565b600061279b82612785565b6127a581856120b1565b93506127b5818560208601611c8a565b80840191505092915050565b60006127cd8285612790565b91506127d98284612790565b91508190509392505050565b600081905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b6000612826601c836127e5565b9150612831826127f0565b601c82019050919050565b6000819050919050565b6000819050919050565b61286161285c8261283c565b612846565b82525050565b600061287282612819565b915061287e8284612850565b60208201915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6128c58161283c565b82525050565b60006020820190506128e060008301846128bc565b92915050565b600060ff82169050919050565b6128fc816128e6565b82525050565b600060808201905061291760008301876128bc565b61292460208301866128f3565b61293160408301856128bc565b61293e60608301846128bc565b9594505050505056fea26469706673582212208b78def0f320042ae8b9f5138210c00890503e7c5d1fe0b16bdd40fbaaf335ea64736f6c63430008180033
Deployed Bytecode
0x6080604052600436106100fe5760003560e01c806370238eb211610095578063cb2ef6f711610064578063cb2ef6f7146102de578063d1bc76a114610309578063d5abeb0114610347578063e35568cb14610372578063f2fde38b1461039d576100fe565b806370238eb214610255578063715018a6146102715780637a564970146102885780638da5cb5b146102b3576100fe565b806346904840116100d157806346904840146101975780634d0df5fc146101c257806354fd4d50146101ff5780635b7633d01461022a576100fe565b8063046dc16614610103578063128a3abf1461012c5780632df3eba4146101555780633ccfd60b14610180575b600080fd5b34801561010f57600080fd5b5061012a60048036038101906101259190611881565b6103c6565b005b34801561013857600080fd5b50610153600480360381019061014e9190611b55565b610412565b005b34801561016157600080fd5b5061016a6104f1565b6040516101779190611c29565b60405180910390f35b34801561018c57600080fd5b50610195610506565b005b3480156101a357600080fd5b506101ac610749565b6040516101b99190611c53565b60405180910390f35b3480156101ce57600080fd5b506101e960048036038101906101e49190611881565b61076d565b6040516101f69190611c29565b60405180910390f35b34801561020b57600080fd5b50610214610785565b6040516102219190611ced565b60405180910390f35b34801561023657600080fd5b5061023f6107be565b60405161024c9190611c53565b60405180910390f35b61026f600480360381019061026a9190611d6a565b6107e4565b005b34801561027d57600080fd5b50610286610adb565b005b34801561029457600080fd5b5061029d610aef565b6040516102aa9190611eb0565b60405180910390f35b3480156102bf57600080fd5b506102c8610b15565b6040516102d59190611c53565b60405180910390f35b3480156102ea57600080fd5b506102f3610b3f565b6040516103009190611ced565b60405180910390f35b34801561031557600080fd5b50610330600480360381019061032b9190611ecb565b610b78565b60405161033e929190611ef8565b60405180910390f35b34801561035357600080fd5b5061035c610bcc565b6040516103699190611c29565b60405180910390f35b34801561037e57600080fd5b50610387610bd2565b6040516103949190611c29565b60405180910390f35b3480156103a957600080fd5b506103c460048036038101906103bf9190611881565b610c26565b005b6103ce610cac565b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60001515600860149054906101000a900460ff16151514610468576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045f90611f6d565b60405180910390fd5b61047186610d33565b61047a83610df9565b61048385610e60565b61048d8483610ea4565b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600860146101000a81548160ff021916908315150217905550505050505050565b6000476001546105019190611fbc565b905090565b6000805b6002805490508110156105a5573373ffffffffffffffffffffffffffffffffffffffff166002828154811061054257610541611ff0565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff160361059857600191506105a5565b808060010191505061050a565b50806105e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105dd90612091565b60405180910390fd5b600047905080600160008282546105fd9190611fbc565b9250508190555060005b6002805490508110156107445760006002828154811061062a57610629611ff0565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166106a4846002858154811061068a57610689611ff0565b5b906000526020600020906002020160010154612710610f9b565b6040516106b0906120e2565b60006040518083038185875af1925050503d80600081146106ed576040519150601f19603f3d011682016040523d82523d6000602084013e6106f2565b606091505b5050905080610736576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161072d90612143565b60405180910390fd5b508080600101915050610607565b505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60056020528060005260406000206000915090505481565b6040518060400160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6108128585856040516020016107fc93929190612184565b604051602081830303815290604052838361104d565b6000805b885181101561099f5760038054905089828151811061083857610837611ff0565b5b602002602001015110610880576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108779061220d565b60405180910390fd5b600060038a838151811061089757610896611ff0565b5b6020026020010151815481106108b0576108af611ff0565b5b906000526020600020015490508882815181106108d0576108cf611ff0565b5b602002602001015181101561090057808983815181106108f3576108f2611ff0565b5b6020026020010181815250505b88828151811061091357610912611ff0565b5b602002602001015160038b84815181106109305761092f611ff0565b5b60200260200101518154811061094957610948611ff0565b5b906000526020600020016000828254610962919061222d565b9250508190555088828151811061097c5761097b611ff0565b5b60200260200101518361098f9190611fbc565b9250508080600101915050610816565b50600081116109e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109da906122d3565b60405180910390fd5b60006109ef8288611137565b905081811015610a34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2b90612365565b60405180910390fd5b610a3f82878761128b565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639727756a338b8b6040518463ffffffff1660e01b8152600401610a9e93929190612443565b600060405180830381600087803b158015610ab857600080fd5b505af1158015610acc573d6000803e3d6000fd5b50505050505050505050505050565b610ae3610cac565b610aed6000610d33565b565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6040518060400160405280601081526020017f5049434b2d4d494e5445522d313135350000000000000000000000000000000081525081565b60028181548110610b8857600080fd5b90600052602060002090600202016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154905082565b60045481565b60008060005b600380549050811015610c1e5760038181548110610bf957610bf8611ff0565b5b906000526020600020015482610c0f9190611fbc565b91508080600101915050610bd8565b508091505090565b610c2e610cac565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610ca05760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610c979190611c53565b60405180910390fd5b610ca981610d33565b50565b610cb4611439565b73ffffffffffffffffffffffffffffffffffffffff16610cd2610b15565b73ffffffffffffffffffffffffffffffffffffffff1614610d3157610cf5611439565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610d289190611c53565b60405180910390fd5b565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8060039080519060200190610e0f9291906117a5565b5060005b8151811015610e5c57818181518110610e2f57610e2e611ff0565b5b602002602001015160046000828254610e489190611fbc565b925050819055508080600101915050610e13565b5050565b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b8151811015610f96576002828281518110610f0557610f04611ff0565b5b6020026020010151908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015550508080600101915050610ee7565b505050565b6000808285610faa91906124b7565b905060008386610fba91906124e8565b905060008486610fca91906124b7565b905060008587610fda91906124e8565b9050858184610fe99190612519565b610ff391906124b7565b8284610fff9190612519565b828661100b9190612519565b8885886110189190612519565b6110229190612519565b61102c9190611fbc565b6110369190611fbc565b6110409190611fbc565b9450505050509392505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166110dc61109285611441565b84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506114c5565b73ffffffffffffffffffffffffffffffffffffffff1614611132576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611129906125cd565b60405180910390fd5b505050565b600080820361114857829050611285565b8183600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111949190611fbc565b11156111e857600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826111e5919061222d565b92505b6000831161122b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112229061265f565b60405180910390fd5b82600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461127a9190611fbc565b925050819055508290505b92915050565b600082846112999190612519565b9050600082856112a99190612519565b9050600081836112b99190611fbc565b9050803410156112fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112f5906126f1565b60405180910390fd5b80341115611359573373ffffffffffffffffffffffffffffffffffffffff166108fc823461132c919061222d565b9081150290604051600060405180830381858888f19350505050158015611357573d6000803e3d6000fd5b505b60008211156114315760008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16836040516113a9906120e2565b60006040518083038185875af1925050503d80600081146113e6576040519150601f19603f3d011682016040523d82523d6000602084013e6113eb565b606091505b505090508061142f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161142690612143565b60405180910390fd5b505b505050505050565b600033905090565b6000803033604051602001611457929190612759565b604051602081830303815290604052836040516020016114789291906127c1565b6040516020818303038152906040528051906020012090506000816040516020016114a39190612867565b6040516020818303038152906040529050808051906020012092505050919050565b6000806000806114d586866114f1565b9250925092506114e5828261154d565b82935050505092915050565b600080600060418451036115365760008060006020870151925060408701519150606087015160001a9050611528888285856116b1565b955095509550505050611546565b60006002855160001b9250925092505b9250925092565b600060038111156115615761156061288d565b5b8260038111156115745761157361288d565b5b03156116ad576001600381111561158e5761158d61288d565b5b8260038111156115a1576115a061288d565b5b036115d8576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600260038111156115ec576115eb61288d565b5b8260038111156115ff576115fe61288d565b5b03611644578060001c6040517ffce698f700000000000000000000000000000000000000000000000000000000815260040161163b9190611c29565b60405180910390fd5b6003808111156116575761165661288d565b5b82600381111561166a5761166961288d565b5b036116ac57806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016116a391906128cb565b60405180910390fd5b5b5050565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c11156116f157600060038592509250925061179b565b6000600188888888604051600081526020016040526040516117169493929190612902565b6020604051602081039080840390855afa158015611738573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361178c57600060016000801b9350935093505061179b565b8060008060001b935093509350505b9450945094915050565b8280548282559060005260206000209081019282156117e1579160200282015b828111156117e05782518255916020019190600101906117c5565b5b5090506117ee91906117f2565b5090565b5b8082111561180b5760008160009055506001016117f3565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061184e82611823565b9050919050565b61185e81611843565b811461186957600080fd5b50565b60008135905061187b81611855565b92915050565b60006020828403121561189757611896611819565b5b60006118a58482850161186c565b91505092915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6118fc826118b3565b810181811067ffffffffffffffff8211171561191b5761191a6118c4565b5b80604052505050565b600061192e61180f565b905061193a82826118f3565b919050565b600067ffffffffffffffff82111561195a576119596118c4565b5b602082029050602081019050919050565b600080fd5b6000819050919050565b61198381611970565b811461198e57600080fd5b50565b6000813590506119a08161197a565b92915050565b60006119b96119b48461193f565b611924565b905080838252602082019050602084028301858111156119dc576119db61196b565b5b835b81811015611a0557806119f18882611991565b8452602084019350506020810190506119de565b5050509392505050565b600082601f830112611a2457611a236118ae565b5b8135611a348482602086016119a6565b91505092915050565b600067ffffffffffffffff821115611a5857611a576118c4565b5b602082029050602081019050919050565b600080fd5b600060408284031215611a8457611a83611a69565b5b611a8e6040611924565b90506000611a9e8482850161186c565b6000830152506020611ab284828501611991565b60208301525092915050565b6000611ad1611acc84611a3d565b611924565b90508083825260208201905060408402830185811115611af457611af361196b565b5b835b81811015611b1d5780611b098882611a6e565b845260208401935050604081019050611af6565b5050509392505050565b600082601f830112611b3c57611b3b6118ae565b5b8135611b4c848260208601611abe565b91505092915050565b60008060008060008060c08789031215611b7257611b71611819565b5b6000611b8089828a0161186c565b9650506020611b9189828a0161186c565b9550506040611ba289828a0161186c565b945050606087013567ffffffffffffffff811115611bc357611bc261181e565b5b611bcf89828a01611a0f565b935050608087013567ffffffffffffffff811115611bf057611bef61181e565b5b611bfc89828a01611b27565b92505060a0611c0d89828a0161186c565b9150509295509295509295565b611c2381611970565b82525050565b6000602082019050611c3e6000830184611c1a565b92915050565b611c4d81611843565b82525050565b6000602082019050611c686000830184611c44565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611ca8578082015181840152602081019050611c8d565b60008484015250505050565b6000611cbf82611c6e565b611cc98185611c79565b9350611cd9818560208601611c8a565b611ce2816118b3565b840191505092915050565b60006020820190508181036000830152611d078184611cb4565b905092915050565b600080fd5b60008083601f840112611d2a57611d296118ae565b5b8235905067ffffffffffffffff811115611d4757611d46611d0f565b5b602083019150836001820283011115611d6357611d6261196b565b5b9250929050565b600080600080600080600060c0888a031215611d8957611d88611819565b5b600088013567ffffffffffffffff811115611da757611da661181e565b5b611db38a828b01611a0f565b975050602088013567ffffffffffffffff811115611dd457611dd361181e565b5b611de08a828b01611a0f565b9650506040611df18a828b01611991565b9550506060611e028a828b01611991565b9450506080611e138a828b01611991565b93505060a088013567ffffffffffffffff811115611e3457611e3361181e565b5b611e408a828b01611d14565b925092505092959891949750929550565b6000819050919050565b6000611e76611e71611e6c84611823565b611e51565b611823565b9050919050565b6000611e8882611e5b565b9050919050565b6000611e9a82611e7d565b9050919050565b611eaa81611e8f565b82525050565b6000602082019050611ec56000830184611ea1565b92915050565b600060208284031215611ee157611ee0611819565b5b6000611eef84828501611991565b91505092915050565b6000604082019050611f0d6000830185611c44565b611f1a6020830184611c1a565b9392505050565b7f436f6e747261637420616c726561647920696e697469616c697a65642e000000600082015250565b6000611f57601d83611c79565b9150611f6282611f21565b602082019050919050565b60006020820190508181036000830152611f8681611f4a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611fc782611970565b9150611fd283611970565b9250828201905080821115611fea57611fe9611f8d565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f50617961626c653a205468652063616c6c6572206973206e6f7420616e20616c60008201527f6c6f776564207769746864726177657200000000000000000000000000000000602082015250565b600061207b603083611c79565b91506120868261201f565b604082019050919050565b600060208201905081810360008301526120aa8161206e565b9050919050565b600081905092915050565b50565b60006120cc6000836120b1565b91506120d7826120bc565b600082019050919050565b60006120ed826120bf565b9150819050919050565b7f50617961626c653a205472616e73666572206661696c65640000000000000000600082015250565b600061212d601883611c79565b9150612138826120f7565b602082019050919050565b6000602082019050818103600083015261215c81612120565b9050919050565b6000819050919050565b61217e61217982611970565b612163565b82525050565b6000612190828661216d565b6020820191506121a0828561216d565b6020820191506121b0828461216d565b602082019150819050949350505050565b7f496e76616c696420494420746f206265206d696e746564000000000000000000600082015250565b60006121f7601783611c79565b9150612202826121c1565b602082019050919050565b60006020820190508181036000830152612226816121ea565b9050919050565b600061223882611970565b915061224383611970565b925082820390508181111561225b5761225a611f8d565b5b92915050565b7f4e6f6e65206f66207468652073656c656374656420746f6b656e7320746f206d60008201527f696e742061726520617661696c61626c65000000000000000000000000000000602082015250565b60006122bd603183611c79565b91506122c882612261565b604082019050919050565b600060208201905081810360008301526122ec816122b0565b9050919050565b7f4e6f7420656e6f75676820746f6b656e7320617661696c61626c6520746f206d60008201527f696e7420666f7220796f75722077616c6c657400000000000000000000000000602082015250565b600061234f603383611c79565b915061235a826122f3565b604082019050919050565b6000602082019050818103600083015261237e81612342565b9050919050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6123ba81611970565b82525050565b60006123cc83836123b1565b60208301905092915050565b6000602082019050919050565b60006123f082612385565b6123fa8185612390565b9350612405836123a1565b8060005b8381101561243657815161241d88826123c0565b9750612428836123d8565b925050600181019050612409565b5085935050505092915050565b60006060820190506124586000830186611c44565b818103602083015261246a81856123e5565b9050818103604083015261247e81846123e5565b9050949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006124c282611970565b91506124cd83611970565b9250826124dd576124dc612488565b5b828204905092915050565b60006124f382611970565b91506124fe83611970565b92508261250e5761250d612488565b5b828206905092915050565b600061252482611970565b915061252f83611970565b925082820261253d81611970565b9150828204841483151761255457612553611f8d565b5b5092915050565b7f5369676e617475726550726f7465637465643a20496e76616c6964207369676e60008201527f617475726520666f72207468652063616c6c6572000000000000000000000000602082015250565b60006125b7603483611c79565b91506125c28261255b565b604082019050919050565b600060208201905081810360008301526125e6816125aa565b9050919050565b7f4c696d697450657257616c6c65743a205468652063616c6c657220616464726560008201527f73732063616e206e6f74206d696e74206d6f726520746f6b656e730000000000602082015250565b6000612649603b83611c79565b9150612654826125ed565b604082019050919050565b600060208201905081810360008301526126788161263c565b9050919050565b7f50617961626c653a204e6f7420656e6f7567682045746865722070726f76696460008201527f656420746f206d696e7400000000000000000000000000000000000000000000602082015250565b60006126db602a83611c79565b91506126e68261267f565b604082019050919050565b6000602082019050818103600083015261270a816126ce565b9050919050565b60008160601b9050919050565b600061272982612711565b9050919050565b600061273b8261271e565b9050919050565b61275361274e82611843565b612730565b82525050565b60006127658285612742565b6014820191506127758284612742565b6014820191508190509392505050565b600081519050919050565b600061279b82612785565b6127a581856120b1565b93506127b5818560208601611c8a565b80840191505092915050565b60006127cd8285612790565b91506127d98284612790565b91508190509392505050565b600081905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b6000612826601c836127e5565b9150612831826127f0565b601c82019050919050565b6000819050919050565b6000819050919050565b61286161285c8261283c565b612846565b82525050565b600061287282612819565b915061287e8284612850565b60208201915081905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6128c58161283c565b82525050565b60006020820190506128e060008301846128bc565b92915050565b600060ff82169050919050565b6128fc816128e6565b82525050565b600060808201905061291760008301876128bc565b61292460208301866128f3565b61293160408301856128bc565b61293e60608301846128bc565b9594505050505056fea26469706673582212208b78def0f320042ae8b9f5138210c00890503e7c5d1fe0b16bdd40fbaaf335ea64736f6c63430008180033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ 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.