ERC-1155
Overview
Max Total Supply
70
Holders
29
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Source Code Verified (Exact Match)
Contract Name:
ERC1155NFT
Compiler Version
v0.8.27+commit.40a35a09
Optimization Enabled:
Yes with 10 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.26; /** ERC1155 Smart Contract */ import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol"; import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/interfaces/IERC2981.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "./PaymentSplitter.sol"; /// @custom:security-contact [email protected] contract ERC1155NFT is ERC1155, AccessControl, ERC1155Pausable, ERC1155Supply, PaymentSplitter, ReentrancyGuard { uint256 public price = 22e15; // The initial price to mint in WEI. uint256 public tokenBasedDiscount = 0; // Default commission percentage uint256 public defaultCommissionPercentage = 20; mapping(uint256 => uint256) public tokenMaxSupply; // 0 is openEnd mapping(uint256 => uint256) public perWalletMaxTokens; // 0 is openEnd bytes32 public merkleRoot; bytes32 public affiliateMerkleRoot; address public discountContract = 0x0000000000000000000000000000000000000000; bytes4 public discountOwnerFunctionSelector = bytes4(keccak256("ownerOf(uint256)")); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public constant WITHDRAW_ROLE = keccak256("WITHDRAW_ROLE"); bytes32 public constant SALES_ROLE = keccak256("SALES_ROLE"); bytes32 public constant CLAIM_ADMIN = keccak256("CLAIM_ADMIN"); uint256[] public saleIsActive; // Mapping for claimed token IDs (maps original token IDs to their claimed counterparts) mapping(uint256 => uint256) private _claimedTokenIds; struct SaleSchedule { uint256 start; uint256 end; } // Struct to hold keyword data struct KeywordData { address payoutAddress; uint256 commissionPercentage; uint256 split; } // Define a new struct type to hold the commission and payout address struct CommissionData { uint256 commission; uint256 discount; address payoutAddress; } // Mapping from keyword hash to data mapping(bytes32 => KeywordData) public keywordAffiliates; mapping(uint256 => SaleSchedule) private saleSchedules; // Mapping from payout address to balance mapping(address => uint256) public affiliateBalancesETH; // Variables to store the total affiliate balances uint256 public totalAffiliateBalanceETH; mapping(uint256 => bool) public saleMaxLock; bool public allowContractMints = false; bool[] private discountUsed; uint256 public reservedSupply; string private _contractURI; constructor(string memory uri_, address[] memory _payees, uint256[] memory _shares) ERC1155(uri_) PaymentSplitter(_payees, _shares) payable { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); _grantRole(ADMIN_ROLE, msg.sender); _grantRole(SALES_ROLE, msg.sender); } function setURI(string memory newuri) public onlyRole(ADMIN_ROLE) { _setURI(newuri); } /** * @dev Pauses all token transfers. * * See {Pausable} and {Pausable-_pause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function pause() public onlyRole(ADMIN_ROLE) { _pause(); } /** * @dev Unpauses all token transfers. * * See {Pausable} and {Pausable-_unpause}. * * Requirements: * * - the caller must have the `ADMIN_ROLE`. */ function unpause() public onlyRole(ADMIN_ROLE) { _unpause(); } function _mintCommon(address to, uint256 typeId, uint256 amount, uint256 discountTokenId, bytes32[] calldata proof, bytes memory data) internal view { // Create fixed-size memory arrays uint256[] memory types = new uint256[](1); uint256[] memory amounts = new uint256[](1); // Assign values types[0] = typeId; amounts[0] = amount; require(discountTokenId <= discountUsed.length, "Bad discount"); // Call _mintBatchCommon with the created arrays _mintBatchCommon(to, types, amounts, proof, data); } function _mintBatchCommon(address to, uint256[] memory types, uint256[] memory amounts, bytes32[] calldata proof, bytes memory /* data */) internal view returns (uint256) { require(msg.sender == tx.origin || allowContractMints, "No contracts!"); require((merkleRoot == 0 || _verify(_leaf(msg.sender), proof, merkleRoot)|| _verify(_leaf(to), proof, merkleRoot)), "Invalid proof"); uint256 typesLen = types.length; uint256 totalAmount = 0; for (uint256 i = 0; i < typesLen; ++i) { require(types[i] > 0, "Invalid ID"); require(checkSaleState(types[i]), "No sale"); require(_checkSaleSchedule(saleSchedules[types[i]]), "Wrong time"); require(tokenMaxSupply[types[i]] == 0 || totalSupply(types[i]) + amounts[i] <= tokenMaxSupply[types[i]], "Supply exhausted"); require(perWalletMaxTokens[types[i]] == 0 || balanceOf(to,types[i]) + amounts[i] <= perWalletMaxTokens[types[i]], "Reached per-wallet limit!"); totalAmount = totalAmount + amounts[i]; } return totalAmount; } /** /** * @notice Mint a new token * @param to The address to mint the token to * @param id The token ID to mint * @param amount The amount of the token to mint * @param discountTokenId The ID of the discount token, if any * @param keyword A keyword for special minting conditions * @param proof Merkle proof for whitelist verification * @param data Additional data with no specified format */ function mint(address to, uint256 id, uint256 amount, uint256 discountTokenId, string memory keyword, bytes32[] calldata proof, bytes memory data) public payable { _mintCommon(to, id, amount, discountTokenId, proof, data); // Calculate affiliate commission CommissionData memory commissionData = _calculateCommission(keyword, price, amount); require(_checkPrice(amount, discountTokenId, commissionData.discount), "Price"); affiliateBalancesETH[commissionData.payoutAddress] += commissionData.commission; totalAffiliateBalanceETH += commissionData.commission; // Mint the NFT super._mint(to, id, amount, data); } function _calculateCommission(string memory keyword, uint256 mintPrice, uint256 amount) private view returns (CommissionData memory) { if (bytes(keyword).length > 0 && !(bytes(keyword).length == 1 && bytes(keyword)[0] == 0x20)) { bytes32 keyHash = hashKeyword(keyword); // Get the commission and discount data CommissionData memory data = getCommissionData(keyHash); // Calculate the affiliate commission based on the returned commission percentage uint256 commission = (data.commission * mintPrice * amount) / 100; // Calculate the discount based on the returned discount percentage uint256 discount = (data.discount * mintPrice * amount) / 100; // Return the commission, discount, and payout address encapsulated in the CommissionData struct return CommissionData(commission, discount, data.payoutAddress); } // If the keyword is empty, return a struct with zero commission, zero discount, and the zero address return CommissionData(0, 0, address(0)); } function getCommissionData(bytes32 keywordHash) public view returns (CommissionData memory) { address payoutAddress = keywordAffiliates[keywordHash].payoutAddress; // Ensure there is a payout address, otherwise revert require(payoutAddress != address(0), "Keyword does not exist"); uint256 unsplitCommissionPercentage = keywordAffiliates[keywordHash].commissionPercentage; uint256 commissionPercentage; // If commission is not set, use a default value if (unsplitCommissionPercentage == 0) { commissionPercentage = defaultCommissionPercentage; } else { commissionPercentage = (unsplitCommissionPercentage * keywordAffiliates[keywordHash].split) / 100; } // Calculate discountPercentage correctly uint256 discountPercentage = (unsplitCommissionPercentage * (100 - keywordAffiliates[keywordHash].split)) / 100; // Return all relevant data return CommissionData(commissionPercentage, discountPercentage, payoutAddress); } function hashKeyword(string memory keyword) public pure returns (bytes32) { return keccak256(abi.encodePacked(keyword)); } /** * @notice Set the sale active status for specific token types * @param types An array of token types to update * @param tokenMaxSupplys An array of maximum supplies corresponding to each token ID * @param _globalLockAfterUpdate A boolean indicating whether to lock the global sale after this update */ function setSaleActive(uint256[] memory types, uint256[] memory tokenMaxSupplys, bool _globalLockAfterUpdate) external onlyRole(SALES_ROLE){ require(types.length == tokenMaxSupplys.length, "Array lengths must match"); saleIsActive = types; for (uint256 i = 0; i < types.length; i++) { uint256 tokenId = types[i]; uint256 limit = tokenMaxSupplys[i]; require(!saleMaxLock[tokenId] || tokenMaxSupply[tokenId] == limit, "saleMaxLock"); tokenMaxSupply[tokenId] = limit; if (!saleMaxLock[tokenId] && _globalLockAfterUpdate) { saleMaxLock[tokenId] = _globalLockAfterUpdate; } } } function setSaleSchedule(uint256 _id, uint256 _start, uint256 _end) external onlyRole(SALES_ROLE){ require(_id > 0, "Invalid token type ID"); saleSchedules[_id].start = _start; saleSchedules[_id].end = _end; } function flipAllowContractMintsState() external onlyRole(ADMIN_ROLE){ allowContractMints = !allowContractMints; } function mintReservedTokens(address to, uint256 id, uint256 amount, bytes memory data) external onlyRole(ADMIN_ROLE){ require(id > 0, "Invalid token type ID"); require(amount == 1 || hasRole(ADMIN_ROLE, _msgSender()), "> 1 only ADMIN_ROLE"); require(tokenMaxSupply[id] == 0 || totalSupply(id) + amount <= tokenMaxSupply[id], "Supply exhausted"); super._mint(to, id, amount, data); for (uint i = 0; i < amount; i++) { reservedSupply++; } } function withdraw() external onlyRole(WITHDRAW_ROLE) nonReentrant{ // Keep totalAffiliateBalanceETH for the Affiliates, preverably use RELEASE to obey paymentSplitter payable(msg.sender).transfer(address(this).balance - totalAffiliateBalanceETH); } function mintBatch(address to, uint256[] memory types, uint256[] memory amounts, uint256 discountTokenId, string memory keyword, bytes32[] calldata proof, bytes memory data) public payable { uint256 totalAmount = _mintBatchCommon(to, types, amounts, proof, data); CommissionData memory commissionData = _calculateCommission(keyword, price, totalAmount); require(_checkPrice(totalAmount,discountTokenId, commissionData.discount), "Price"); super._mintBatch(to, types, amounts, data); } // The following functions are overrides required by Solidity. function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal override(ERC1155, ERC1155Pausable, ERC1155Supply) { super._update(from, to, ids, values); } function supportsInterface(bytes4 interfaceId) public view override(ERC1155, AccessControl) returns (bool) { return super.supportsInterface(interfaceId); } function setMerkleRoot(bytes32 _merkleRoot,bool affiliate) external onlyRole(ADMIN_ROLE){ if (affiliate) { affiliateMerkleRoot = _merkleRoot; } else { merkleRoot = _merkleRoot; } } function setSaleMax(uint256 _id, uint32 _limit, bool _globalLockAfterUpdate) external onlyRole(SALES_ROLE){ require(saleMaxLock[_id] == false , "saleMaxLock"); require(_id > 0, "_id < 1"); saleMaxLock[_id] = _globalLockAfterUpdate; tokenMaxSupply[_id] = _limit; } function setPrice(uint256 _price) external onlyRole(SALES_ROLE){ price = _price; } function setWalletMax(uint256 _id, uint256 _walletLimit) external onlyRole(SALES_ROLE){ require(_id > 0, "Invalid token type ID"); perWalletMaxTokens[_id] = _walletLimit; } function setDiscountOwnerFunctionSelector(bytes4 _discountOwnerFunctionSelector) external onlyRole(SALES_ROLE){ discountOwnerFunctionSelector = _discountOwnerFunctionSelector; } function setContractURI(string memory _uri) external onlyRole(ADMIN_ROLE) { _contractURI = _uri; } function setClaimedTokenId(uint256 originalId, uint256 claimedId) external onlyRole(ADMIN_ROLE) { _claimedTokenIds[originalId] = claimedId; } function claim(uint256 tokenId, address owner, uint256 amount) external { // Check if owner owns enough of the token require(balanceOf(owner, tokenId) >= amount, "Insufficient balance to claim"); require(_claimedTokenIds[tokenId] != 0, "Claimed token ID not set"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender) || hasRole(CLAIM_ADMIN, _msgSender())); uint256 claimedTokenId = _claimedTokenIds[tokenId]; // Burn the original token _burn(owner, tokenId, amount); // Mint the claimed token _mint(owner, claimedTokenId, amount, ""); emit Claimed(owner, tokenId, claimedTokenId, amount); } /** * @dev Get the claimed token ID for a specific original token ID */ function getClaimedTokenId(uint256 tokenId) external view returns (uint256) { return _claimedTokenIds[tokenId]; } // Event to signal a claim event Claimed(address indexed account, uint256 originalTokenId, uint256 claimedTokenId, uint256 amount); function contractURI() public view returns (string memory) { return _contractURI; } function _leaf(address account) internal pure returns (bytes32) { return keccak256(abi.encodePacked(account)); } function _verify(bytes32 leaf, bytes32[] memory proof, bytes32 root) internal pure returns (bool) { return MerkleProof.verify(proof, root, leaf); } function _checkSaleSchedule(SaleSchedule memory s) internal view returns (bool) { if ( (s.start == 0 || s.start <= block.timestamp) && (s.end == 0 ||s.end >= block.timestamp) ) { return true; } return false; } function _checkPrice(uint256 amount, uint256 discountTokenId, uint256 keywordDiscount) internal returns (bool) { uint256 effectivePrice = price * amount; // Calculate the total price based on the amount require(effectivePrice >= keywordDiscount, "Keyword discount exceeds the price"); require(effectivePrice >= tokenBasedDiscount, "Token-based discount exceeds the price"); uint256 discountedPrice = effectivePrice; // Initialize discountedPrice with the effectivePrice // Check for discount using discountTokenId if (discountTokenId > 0 && discountTokenId <= discountUsed.length && amount == 1 && _walletHoldsUnusedDiscountToken(msg.sender, discountContract, discountTokenId)) { discountedPrice = effectivePrice - tokenBasedDiscount; // Apply token-based discount if (msg.value >= discountedPrice) { discountUsed[discountTokenId - 1] = true; return true; } } else if (keywordDiscount > 0) { discountedPrice = effectivePrice - keywordDiscount; if (msg.value >= discountedPrice) { return true; } } // If no discounts lead to a sufficient payment, return false if (msg.value >= effectivePrice) { return true; } return false; } function bytesToAddress(bytes memory bys) private pure returns (address addr) { assembly { addr := mload(add(bys, 32)) } } function _walletHoldsUnusedDiscountToken(address _wallet, address _contract, uint256 discountTokenId) internal returns (bool) { require(discountTokenId <= discountUsed.length || discountUsed[discountTokenId - 1] == false, "invalid discountTokenId"); (bool success, bytes memory owner) = _contract.call(abi.encodeWithSelector(discountOwnerFunctionSelector, discountTokenId)); require (success, "ownerOf fail"); require (bytesToAddress(owner) == _wallet, "discountToken: wrong owner"); return true; } function setDiscountContract(address _discountContract, uint256 _maxTokenId, uint256 _discount) external onlyRole(ADMIN_ROLE) { require(_discount >= 0, "Invalid discount percentage"); if (discountContract != _discountContract) { // reset all tokenId states to false discountUsed = new bool[](_maxTokenId); } discountContract = _discountContract; tokenBasedDiscount = _discount; } function checkSaleState(uint256 _id) internal view returns (bool){ for (uint256 i=0; i<saleIsActive.length; i++) { if (saleIsActive[i] == _id) { return true; } } return false; } function registerKeyword(string memory keyword, address payoutAddress, bool replace, bytes32[] calldata proof, uint256 split) public { // Calculate the hash of the keyword bytes32 keywordHash = keccak256(abi.encodePacked(keyword)); require(split <= 100 , "invalid split"); // Check if the keyword has already been registered require(keywordAffiliates[keywordHash].payoutAddress == address(0) || (replace && hasRole(ADMIN_ROLE, msg.sender)) || (replace && keywordAffiliates[keywordHash].payoutAddress == msg.sender) , "Keyword taken"); // Check proof to verify ownership require(hasRole(ADMIN_ROLE, msg.sender) || (affiliateMerkleRoot == 0 || _verify(_leaf(msg.sender), proof, affiliateMerkleRoot)|| _verify(_leaf(payoutAddress), proof, affiliateMerkleRoot)), "invalid merkle proof"); // Register the keyword with the payout address and default commission percentage if (payoutAddress == address(0)) { delete keywordAffiliates[keywordHash]; } else { keywordAffiliates[keywordHash] = KeywordData(payoutAddress, defaultCommissionPercentage, split); } } function setCommissionPercentage(string memory keyword, uint256 percentage) public onlyRole(SALES_ROLE) { require(percentage <= 100, ">100%"); bytes32 keywordHash = keccak256(abi.encodePacked(keyword)); keywordAffiliates[keywordHash].commissionPercentage = percentage; } function getCommissionPercentage(bytes32 keywordHash) public view returns (uint256) { uint256 percentage = keywordAffiliates[keywordHash].commissionPercentage; if (percentage == 0) { return defaultCommissionPercentage; } else { return percentage; } } // Protect totalAffiliateBalanceETH from PaymentSplitter function releasable(address account) public view override returns (uint256) { // Subtract affiliate funds from the total received uint256 totalReceived = address(this).balance - totalAffiliateBalanceETH + totalReleased(); return _pendingPayment(account, totalReceived, released(account)); } /** * @dev Internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) internal view override returns (uint256) { uint256 accountShares = shares(account); // Use the public getter uint256 totalSharesCount = totalShares(); // Use the public getter require(accountShares > 0, "Account has no shares"); return (totalReceived * accountShares) / totalSharesCount - alreadyReleased; } function releaseAffiliateFunds(address affiliate) public nonReentrant { uint256 balance; balance = affiliateBalancesETH[affiliate]; require(balance > 0, "No ETH"); require(totalAffiliateBalanceETH >= balance, "Insufficient total affiliate balance"); // Deducting individual affiliate balance affiliateBalancesETH[affiliate] = 0; // Deducting from total affiliate balance for ETH totalAffiliateBalanceETH -= balance; payable(affiliate).transfer(balance); } }
// 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.1.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC-165 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. This account bears the admin role (for the granted role). * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}. */ 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.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 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 ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-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 ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 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.1.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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. * * NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the * royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "./IERC1155.sol"; import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol"; import {ERC1155Utils} from "./utils/ERC1155Utils.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 ERC]. * * 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); ERC1155Utils.checkOnERC1155Received(operator, from, to, id, value, data); } else { ERC1155Utils.checkOnERC1155BatchReceived(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 ERC]. * * 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 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) { assembly ("memory-safe") { // 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.1.0) (token/ERC1155/extensions/ERC1155Pausable.sol) pragma solidity ^0.8.20; import {ERC1155} from "../ERC1155.sol"; import {Pausable} from "../../../utils/Pausable.sol"; /** * @dev ERC-1155 token with pausable token transfers, minting and burning. * * Useful for scenarios such as preventing trades until the end of an evaluation * period, or having an emergency switch for freezing all token transfers in the * event of a large bug. * * IMPORTANT: This contract does not include public pause and unpause functions. In * addition to inheriting this contract, you must define both functions, invoking the * {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate * access control, e.g. using {AccessControl} or {Ownable}. Not doing so will * make the contract pause mechanism of the contract unreachable, and thus unusable. */ abstract contract ERC1155Pausable is ERC1155, Pausable { /** * @dev See {ERC1155-_update}. * * Requirements: * * - the contract must not be paused. */ function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override whenNotPaused { super._update(from, to, ids, values); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/ERC1155Supply.sol) pragma solidity ^0.8.20; import {ERC1155} from "../ERC1155.sol"; import {Arrays} from "../../../utils/Arrays.sol"; /** * @dev Extension of ERC-1155 that adds tracking of total supply per id. * * Useful for scenarios where Fungible and Non-fungible tokens have to be * clearly identified. Note: While a totalSupply of 1 might mean the * corresponding is an NFT, there is no guarantees that no other token with the * same id are not going to be minted. * * NOTE: This contract implies a global limit of 2**256 - 1 to the number of tokens * that can be minted. * * CAUTION: This extension should not be added in an upgrade to an already deployed contract. */ abstract contract ERC1155Supply is ERC1155 { using Arrays for uint256[]; mapping(uint256 id => uint256) private _totalSupply; uint256 private _totalSupplyAll; /** * @dev Total value of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Total value of tokens. */ function totalSupply() public view virtual returns (uint256) { return _totalSupplyAll; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return totalSupply(id) > 0; } /** * @dev See {ERC1155-_update}. */ function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override { super._update(from, to, ids, values); if (from == address(0)) { uint256 totalMintValue = 0; for (uint256 i = 0; i < ids.length; ++i) { uint256 value = values.unsafeMemoryAccess(i); // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply[ids.unsafeMemoryAccess(i)] += value; totalMintValue += value; } // Overflow check required: The rest of the code assumes that totalSupplyAll never overflows _totalSupplyAll += totalMintValue; } if (to == address(0)) { uint256 totalBurnValue = 0; for (uint256 i = 0; i < ids.length; ++i) { uint256 value = values.unsafeMemoryAccess(i); unchecked { // Overflow not possible: values[i] <= balanceOf(from, ids[i]) <= totalSupply(ids[i]) _totalSupply[ids.unsafeMemoryAccess(i)] -= value; // Overflow not possible: sum_i(values[i]) <= sum_i(totalSupply(ids[i])) <= totalSupplyAll totalBurnValue += value; } } unchecked { // Overflow not possible: totalBurnValue = sum_i(values[i]) <= sum_i(totalSupply(ids[i])) <= totalSupplyAll _totalSupplyAll -= totalBurnValue; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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[ERC]. */ 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.1.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[ERC]. */ 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`. */ 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 zero address. */ 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.1.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 ERC-1155 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 ERC-1155 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.1.0) (token/ERC1155/utils/ERC1155Utils.sol) pragma solidity ^0.8.20; import {IERC1155Receiver} from "../IERC1155Receiver.sol"; import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol"; /** * @dev Library that provide common ERC-1155 utility functions. * * See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155]. * * _Available since v5.1._ */ library ERC1155Utils { /** * @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC1155Received( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) internal { 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 IERC1155Errors.ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC1155Receiver implementer revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC1155BatchReceived( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { 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 IERC1155Errors.ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC1155Receiver implementer revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. * * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being * set here. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Arrays.sol) // This file was procedurally generated from scripts/generate/templates/Arrays.js. pragma solidity ^0.8.20; import {Comparators} from "./Comparators.sol"; import {SlotDerivation} from "./SlotDerivation.sol"; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using SlotDerivation for bytes32; using StorageSlot for bytes32; /** * @dev Sort an array of uint256 (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( uint256[] memory array, function(uint256, uint256) pure returns (bool) comp ) internal pure returns (uint256[] memory) { _quickSort(_begin(array), _end(array), comp); return array; } /** * @dev Variant of {sort} that sorts an array of uint256 in increasing order. */ function sort(uint256[] memory array) internal pure returns (uint256[] memory) { sort(array, Comparators.lt); return array; } /** * @dev Sort an array of address (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( address[] memory array, function(address, address) pure returns (bool) comp ) internal pure returns (address[] memory) { sort(_castToUint256Array(array), _castToUint256Comp(comp)); return array; } /** * @dev Variant of {sort} that sorts an array of address in increasing order. */ function sort(address[] memory array) internal pure returns (address[] memory) { sort(_castToUint256Array(array), Comparators.lt); return array; } /** * @dev Sort an array of bytes32 (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( bytes32[] memory array, function(bytes32, bytes32) pure returns (bool) comp ) internal pure returns (bytes32[] memory) { sort(_castToUint256Array(array), _castToUint256Comp(comp)); return array; } /** * @dev Variant of {sort} that sorts an array of bytes32 in increasing order. */ function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) { sort(_castToUint256Array(array), Comparators.lt); return array; } /** * @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops * at end (exclusive). Sorting follows the `comp` comparator. * * Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls. * * IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should * be used only if the limits are within a memory array. */ function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure { unchecked { if (end - begin < 0x40) return; // Use first element as pivot uint256 pivot = _mload(begin); // Position where the pivot should be at the end of the loop uint256 pos = begin; for (uint256 it = begin + 0x20; it < end; it += 0x20) { if (comp(_mload(it), pivot)) { // If the value stored at the iterator's position comes before the pivot, we increment the // position of the pivot and move the value there. pos += 0x20; _swap(pos, it); } } _swap(begin, pos); // Swap pivot into place _quickSort(begin, pos, comp); // Sort the left side of the pivot _quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot } } /** * @dev Pointer to the memory location of the first element of `array`. */ function _begin(uint256[] memory array) private pure returns (uint256 ptr) { assembly ("memory-safe") { ptr := add(array, 0x20) } } /** * @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word * that comes just after the last element of the array. */ function _end(uint256[] memory array) private pure returns (uint256 ptr) { unchecked { return _begin(array) + array.length * 0x20; } } /** * @dev Load memory word (as a uint256) at location `ptr`. */ function _mload(uint256 ptr) private pure returns (uint256 value) { assembly { value := mload(ptr) } } /** * @dev Swaps the elements memory location `ptr1` and `ptr2`. */ function _swap(uint256 ptr1, uint256 ptr2) private pure { assembly { let value1 := mload(ptr1) let value2 := mload(ptr2) mstore(ptr1, value2) mstore(ptr2, value1) } } /// @dev Helper: low level cast address memory array to uint256 memory array function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) { assembly { output := input } } /// @dev Helper: low level cast bytes32 memory array to uint256 memory array function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) { assembly { output := input } } /// @dev Helper: low level cast address comp function to uint256 comp function function _castToUint256Comp( function(address, address) pure returns (bool) input ) private pure returns (function(uint256, uint256) pure returns (bool) output) { assembly { output := input } } /// @dev Helper: low level cast bytes32 comp function to uint256 comp function function _castToUint256Comp( function(bytes32, bytes32) pure returns (bool) input ) private pure returns (function(uint256, uint256) pure returns (bool) output) { assembly { output := input } } /** * @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). * * NOTE: The `array` is expected to be sorted in ascending order, and to * contain no repeated elements. * * IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks * support for repeated elements in the array. The {lowerBound} function should * be used instead. */ 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 Searches an `array` sorted in ascending order and returns the first * index that contains a value greater or equal than `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). * * See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound]. */ function lowerBound(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) { // this cannot overflow because mid < high unchecked { low = mid + 1; } } else { high = mid; } } return low; } /** * @dev Searches an `array` sorted in ascending order and returns the first * index that contains a value strictly greater than `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). * * See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound]. */ function upperBound(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 { // this cannot overflow because mid < high unchecked { low = mid + 1; } } } return low; } /** * @dev Same as {lowerBound}, but with an array in memory. */ function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure 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 (unsafeMemoryAccess(array, mid) < element) { // this cannot overflow because mid < high unchecked { low = mid + 1; } } else { high = mid; } } return low; } /** * @dev Same as {upperBound}, but with an array in memory. */ function upperBoundMemory(uint256[] memory array, uint256 element) internal pure 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 (unsafeMemoryAccess(array, mid) > element) { high = mid; } else { // this cannot overflow because mid < high unchecked { low = mid + 1; } } } 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; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).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; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).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; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).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(address[] memory arr, uint256 pos) internal pure returns (address 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(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 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(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(address[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(bytes32[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(uint256[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to compare values. * * _Available since v5.1._ */ library Comparators { function lt(uint256 a, uint256 b) internal pure returns (bool) { return a < b; } function gt(uint256 a, uint256 b) internal pure returns (bool) { return a > b; } }
// 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.1.0) (utils/cryptography/Hashes.sol) pragma solidity ^0.8.20; /** * @dev Library of standard hash functions. * * _Available since v5.1._ */ library Hashes { /** * @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs. * * NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. */ function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) { return a < b ? _efficientKeccak256(a, b) : _efficientKeccak256(b, a); } /** * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory. */ function _efficientKeccak256(bytes32 a, bytes32 b) private pure returns (bytes32 value) { assembly ("memory-safe") { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol) // This file was procedurally generated from scripts/generate/templates/MerkleProof.js. pragma solidity ^0.8.20; import {Hashes} from "./Hashes.sol"; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the Merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates Merkle trees that are safe * against this attack out of the box. * * IMPORTANT: Consider memory side-effects when using custom hashing functions * that access memory in an unsafe way. * * NOTE: This library supports proof verification for merkle trees built using * custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving * leaf inclusion in trees built using non-commutative hashing functions requires * additional logic that is not supported by this library. */ library MerkleProof { /** *@dev The multiproof provided is not valid. */ error MerkleProofInvalidMultiproof(); /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. * * This version handles proofs in memory with the default hashing function. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leaves & pre-images are assumed to be sorted. * * This version handles proofs in memory with the default hashing function. */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. * * This version handles proofs in memory with a custom hashing function. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bool) { return processProof(proof, leaf, hasher) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leaves & pre-images are assumed to be sorted. * * This version handles proofs in memory with a custom hashing function. */ function processProof( bytes32[] memory proof, bytes32 leaf, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = hasher(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. * * This version handles proofs in calldata with the default hashing function. */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leaves & pre-images are assumed to be sorted. * * This version handles proofs in calldata with the default hashing function. */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. * * This version handles proofs in calldata with a custom hashing function. */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bool) { return processProofCalldata(proof, leaf, hasher) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leaves & pre-images are assumed to be sorted. * * This version handles proofs in calldata with a custom hashing function. */ function processProofCalldata( bytes32[] calldata proof, bytes32 leaf, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = hasher(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * This version handles multiproofs in memory with the default hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. * * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. * The `leaves` must be validated independently. See {processMultiProof}. */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * This version handles multiproofs in memory with the default hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not * validating the leaves elsewhere. */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofFlagsLen = proofFlags.length; // Check proof validity. if (leavesLen + proof.length != proofFlagsLen + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](proofFlagsLen); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < proofFlagsLen; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = Hashes.commutativeKeccak256(a, b); } if (proofFlagsLen > 0) { if (proofPos != proof.length) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[proofFlagsLen - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * This version handles multiproofs in memory with a custom hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. * * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. * The `leaves` must be validated independently. See {processMultiProof}. */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bool) { return processMultiProof(proof, proofFlags, leaves, hasher) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * This version handles multiproofs in memory with a custom hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not * validating the leaves elsewhere. */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofFlagsLen = proofFlags.length; // Check proof validity. if (leavesLen + proof.length != proofFlagsLen + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](proofFlagsLen); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < proofFlagsLen; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = hasher(a, b); } if (proofFlagsLen > 0) { if (proofPos != proof.length) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[proofFlagsLen - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * This version handles multiproofs in calldata with the default hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. * * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. * The `leaves` must be validated independently. See {processMultiProofCalldata}. */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * This version handles multiproofs in calldata with the default hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not * validating the leaves elsewhere. */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofFlagsLen = proofFlags.length; // Check proof validity. if (leavesLen + proof.length != proofFlagsLen + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](proofFlagsLen); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < proofFlagsLen; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = Hashes.commutativeKeccak256(a, b); } if (proofFlagsLen > 0) { if (proofPos != proof.length) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[proofFlagsLen - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * This version handles multiproofs in calldata with a custom hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. * * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`. * The `leaves` must be validated independently. See {processMultiProofCalldata}. */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * This version handles multiproofs in calldata with a custom hashing function. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op, * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not * validating the leaves elsewhere. */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves, function(bytes32, bytes32) view returns (bytes32) hasher ) internal view returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofFlagsLen = proofFlags.length; // Check proof validity. if (leavesLen + proof.length != proofFlagsLen + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](proofFlagsLen); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < proofFlagsLen; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = hasher(a, b); } if (proofFlagsLen > 0) { if (proofPos != proof.length) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[proofFlagsLen - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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 ERC-165 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.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * 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[ERC 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.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { 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 success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { 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 success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(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. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * 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²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + 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²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. 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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. 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⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // 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²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, 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; } } /** * @dev 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) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @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; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @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; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @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.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/SlotDerivation.sol) // This file was procedurally generated from scripts/generate/templates/SlotDerivation.js. pragma solidity ^0.8.20; /** * @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots * corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by * the solidity language / compiler. * * See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.]. * * Example usage: * ```solidity * contract Example { * // Add the library methods * using StorageSlot for bytes32; * using SlotDerivation for bytes32; * * // Declare a namespace * string private constant _NAMESPACE = "<namespace>" // eg. OpenZeppelin.Slot * * function setValueInNamespace(uint256 key, address newValue) internal { * _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue; * } * * function getValueInNamespace(uint256 key) internal view returns (address) { * return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value; * } * } * ``` * * TIP: Consider using this library along with {StorageSlot}. * * NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking * upgrade safety will ignore the slots accessed through this library. * * _Available since v5.1._ */ library SlotDerivation { /** * @dev Derive an ERC-7201 slot from a string (namespace). */ function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) { assembly ("memory-safe") { mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1)) slot := and(keccak256(0x00, 0x20), not(0xff)) } } /** * @dev Add an offset to a slot to get the n-th element of a structure or an array. */ function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) { unchecked { return bytes32(uint256(slot) + pos); } } /** * @dev Derive the location of the first element in an array from the slot where the length is stored. */ function deriveArray(bytes32 slot) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, slot) result := keccak256(0x00, 0x20) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, and(key, shr(96, not(0)))) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, iszero(iszero(key))) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) let end := add(begin, length) let cache := mload(end) mstore(end, slot) result := keccak256(begin, add(length, 0x20)) mstore(end, cache) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) let end := add(begin, length) let cache := mload(end) mstore(end, slot) result := keccak256(begin, add(length, 0x20)) mstore(end, cache) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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 ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * 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; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 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) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { 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) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { 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) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (finance/PaymentSplitter.sol) pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; /** * @title PaymentSplitter * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware * that the Ether will be split in this way, since it is handled transparently by the contract. * * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim * an amount proportional to the percentage of total shares they were assigned. The distribution of shares is set at the * time of contract deployment and can't be updated thereafter. * * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} * function. * * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you * to run tests before sending real value to this contract. */ contract PaymentSplitter is Context { event PayeeAdded(address account, uint256 shares); event PaymentReleased(address to, uint256 amount); event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount); event PaymentReceived(address from, uint256 amount); uint256 private _totalShares; uint256 private _totalReleased; mapping(address => uint256) private _shares; mapping(address => uint256) private _released; address[] private _payees; mapping(IERC20 => uint256) private _erc20TotalReleased; mapping(IERC20 => mapping(address => uint256)) private _erc20Released; /** * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at * the matching position in the `shares` array. * * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no * duplicates in `payees`. */ constructor(address[] memory payees, uint256[] memory shares_) payable { require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch"); require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares_[i]); } } /** * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the * reliability of the events, and not the actual splitting of Ether. * * To learn more about this see the Solidity documentation for * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback * functions]. */ receive() external payable virtual { emit PaymentReceived(_msgSender(), msg.value); } /** * @dev Getter for the total shares held by payees. */ function totalShares() public view returns (uint256) { return _totalShares; } /** * @dev Getter for the total amount of Ether already released. */ function totalReleased() public view returns (uint256) { return _totalReleased; } /** * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20 * contract. */ function totalReleased(IERC20 token) public view returns (uint256) { return _erc20TotalReleased[token]; } /** * @dev Getter for the amount of shares held by an account. */ function shares(address account) public view returns (uint256) { return _shares[account]; } /** * @dev Getter for the amount of Ether already released to a payee. */ function released(address account) public view returns (uint256) { return _released[account]; } /** * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an * IERC20 contract. */ function released(IERC20 token, address account) public view returns (uint256) { return _erc20Released[token][account]; } /** * @dev Getter for the address of the payee number `index`. */ function payee(uint256 index) public view returns (address) { return _payees[index]; } /** * @dev Getter for the amount of payee's releasable Ether. */ function releasable(address account) public view virtual returns (uint256) { uint256 totalReceived = address(this).balance + totalReleased(); return _pendingPayment(account, totalReceived, released(account)); } /** * @dev Getter for the amount of payee's releasable `token` tokens. `token` should be the address of an * IERC20 contract. */ function releasable(IERC20 token, address account) public view virtual returns (uint256) { uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); return _pendingPayment(account, totalReceived, released(token, account)); } /** * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the * total shares and their previous withdrawals. */ function release(address payable account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 payment = releasable(account); require(payment != 0, "PaymentSplitter: account is not due payment"); // _totalReleased is the sum of all values in _released. // If "_totalReleased += payment" does not overflow, then "_released[account] += payment" cannot overflow. _totalReleased += payment; unchecked { _released[account] += payment; } Address.sendValue(account, payment); emit PaymentReleased(account, payment); } /** * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20 * contract. */ function release(IERC20 token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 payment = releasable(token, account); require(payment != 0, "PaymentSplitter: account is not due payment"); // _erc20TotalReleased[token] is the sum of all values in _erc20Released[token]. // If "_erc20TotalReleased[token] += payment" does not overflow, then "_erc20Released[token][account] += payment" // cannot overflow. _erc20TotalReleased[token] += payment; unchecked { _erc20Released[token][account] += payment; } SafeERC20.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); } /** * @dev internal logic for computing the pending payment of an `account` given the token historical balances and * already released amounts. */ function _pendingPayment( address account, uint256 totalReceived, uint256 alreadyReleased ) internal view virtual returns (uint256) { return (totalReceived * _shares[account]) / _totalShares - alreadyReleased; } /** * @dev Add a new payee to the contract. * @param account The address of the payee to add. * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { require(account != address(0), "PaymentSplitter: account is the zero address"); require(shares_ > 0, "PaymentSplitter: shares are 0"); require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; _totalShares = _totalShares + shares_; emit PayeeAdded(account, shares_); } }
{ "optimizer": { "enabled": true, "runs": 10 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"uri_","type":"string"},{"internalType":"address[]","name":"_payees","type":"address[]"},{"internalType":"uint256[]","name":"_shares","type":"uint256[]"}],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"originalTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimedTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20PaymentReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"PayeeAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PaymentReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PaymentReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CLAIM_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SALES_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAW_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"affiliateBalancesETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"affiliateMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowContractMints","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultCommissionPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"discountContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"discountOwnerFunctionSelector","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flipAllowContractMintsState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getClaimedTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"keywordHash","type":"bytes32"}],"name":"getCommissionData","outputs":[{"components":[{"internalType":"uint256","name":"commission","type":"uint256"},{"internalType":"uint256","name":"discount","type":"uint256"},{"internalType":"address","name":"payoutAddress","type":"address"}],"internalType":"struct ERC1155NFT.CommissionData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"keywordHash","type":"bytes32"}],"name":"getCommissionPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"keyword","type":"string"}],"name":"hashKeyword","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"keywordAffiliates","outputs":[{"internalType":"address","name":"payoutAddress","type":"address"},{"internalType":"uint256","name":"commissionPercentage","type":"uint256"},{"internalType":"uint256","name":"split","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"discountTokenId","type":"uint256"},{"internalType":"string","name":"keyword","type":"string"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"types","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"discountTokenId","type":"uint256"},{"internalType":"string","name":"keyword","type":"string"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mintBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mintReservedTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"payee","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"perWalletMaxTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"keyword","type":"string"},{"internalType":"address","name":"payoutAddress","type":"address"},{"internalType":"bool","name":"replace","type":"bool"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"split","type":"uint256"}],"name":"registerKeyword","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"releasable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"releasable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"account","type":"address"}],"name":"release","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"release","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"affiliate","type":"address"}],"name":"releaseAffiliateFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address","name":"account","type":"address"}],"name":"released","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"released","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reservedSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"saleIsActive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"saleMaxLock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"originalId","type":"uint256"},{"internalType":"uint256","name":"claimedId","type":"uint256"}],"name":"setClaimedTokenId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"keyword","type":"string"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"name":"setCommissionPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uri","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_discountContract","type":"address"},{"internalType":"uint256","name":"_maxTokenId","type":"uint256"},{"internalType":"uint256","name":"_discount","type":"uint256"}],"name":"setDiscountContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_discountOwnerFunctionSelector","type":"bytes4"}],"name":"setDiscountOwnerFunctionSelector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"bool","name":"affiliate","type":"bool"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"types","type":"uint256[]"},{"internalType":"uint256[]","name":"tokenMaxSupplys","type":"uint256[]"},{"internalType":"bool","name":"_globalLockAfterUpdate","type":"bool"}],"name":"setSaleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint32","name":"_limit","type":"uint32"},{"internalType":"bool","name":"_globalLockAfterUpdate","type":"bool"}],"name":"setSaleMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_start","type":"uint256"},{"internalType":"uint256","name":"_end","type":"uint256"}],"name":"setSaleSchedule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newuri","type":"string"}],"name":"setURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_walletLimit","type":"uint256"}],"name":"setWalletMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"shares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenBasedDiscount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenMaxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAffiliateBalanceETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"totalReleased","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalReleased","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040819052664e28e2290f0000600f5560006010556014601155601680546001600160c01b0319166331a9108f60a11b179055601e805460ff191690556154033881900390819083398101604081905261005a916105ea565b818184610066816101fb565b506004805460ff1916905580518251146100e25760405162461bcd60e51b815260206004820152603260248201527f5061796d656e7453706c69747465723a2070617965657320616e6420736861726044820152710cae640d8cadccee8d040dad2e6dac2e8c6d60731b60648201526084015b60405180910390fd5b60008251116101335760405162461bcd60e51b815260206004820152601a60248201527f5061796d656e7453706c69747465723a206e6f2070617965657300000000000060448201526064016100d9565b60005b825181101561018957610181838281518110610154576101546106ee565b602002602001015183838151811061016e5761016e6106ee565b602002602001015161020b60201b60201c565b600101610136565b50506001600e555061019c6000336103f1565b506101c77fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775336103f1565b506101f27fdeccffc5821b949817830292498e44ccb6097e4b74ff2f2db960723873324def336103f1565b5050505061086c565b6002610207828261078d565b5050565b6001600160a01b0382166102765760405162461bcd60e51b815260206004820152602c60248201527f5061796d656e7453706c69747465723a206163636f756e74206973207468652060448201526b7a65726f206164647265737360a01b60648201526084016100d9565b600081116102c65760405162461bcd60e51b815260206004820152601d60248201527f5061796d656e7453706c69747465723a2073686172657320617265203000000060448201526064016100d9565b6001600160a01b038216600090815260096020526040902054156103405760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e7420616c726561647960448201526a206861732073686172657360a81b60648201526084016100d9565b600b8054600181019091557f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90180546001600160a01b0319166001600160a01b03841690811790915560009081526009602052604090208190556007546103a890829061084b565b600755604080516001600160a01b0384168152602081018390527f40c340f65e17194d14ddddb073d3c9f888e3cb52b5aae0c6c7706b4fbc905fac910160405180910390a15050565b60008281526003602090815260408083206001600160a01b038516845290915281205460ff166104975760008381526003602090815260408083206001600160a01b03861684529091529020805460ff1916600117905561044f3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161049b565b5060005b92915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156104df576104df6104a1565b604052919050565b60006001600160401b03821115610500576105006104a1565b5060051b60200190565b600082601f83011261051b57600080fd5b815161052e610529826104e7565b6104b7565b8082825260208201915060208360051b86010192508583111561055057600080fd5b602085015b838110156105825780516001600160a01b038116811461057457600080fd5b835260209283019201610555565b5095945050505050565b600082601f83011261059d57600080fd5b81516105ab610529826104e7565b8082825260208201915060208360051b8601019250858311156105cd57600080fd5b602085015b838110156105825780518352602092830192016105d2565b6000806000606084860312156105ff57600080fd5b83516001600160401b0381111561061557600080fd5b8401601f8101861361062657600080fd5b80516001600160401b0381111561063f5761063f6104a1565b610652601f8201601f19166020016104b7565b81815287602083850101111561066757600080fd5b60005b828110156106865760208185018101518383018201520161066a565b50600060208383010152809550505050602084015160018060401b038111156106ae57600080fd5b6106ba8682870161050a565b604086015190935090506001600160401b038111156106d857600080fd5b6106e48682870161058c565b9150509250925092565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061071857607f821691505b60208210810361073857634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561078857806000526020600020601f840160051c810160208510156107655750805b601f840160051c820191505b818110156107855760008155600101610771565b50505b505050565b81516001600160401b038111156107a6576107a66104a1565b6107ba816107b48454610704565b8461073e565b6020601f8211600181146107ee57600083156107d65750848201515b600019600385901b1c1916600184901b178455610785565b600084815260208120601f198516915b8281101561081e57878501518255602094850194600190920191016107fe565b508482101561083c5786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b8082018082111561049b57634e487b7160e01b600052601160045260246000fd5b614b888061087b6000396000f3fe6080604052600436106103695760003560e01c806377e45a18116101c457806377e45a18146108c957806379a2e226146109035780638456cb59146109235780638b83209b1461093857806391b7f5ed1461095857806391d1485414610978578063938e3d7b1461099857806393c514c4146109b85780639852595c146109d8578063a035b1fe146109f8578063a217fddf14610a0e578063a22cb46514610a23578063a3f8eace14610a43578063a8f1c6d814610a63578063adbb2a6114610a83578063b558818114610a99578063b63ff1a014610aae578063bd85b03914610ac4578063c45ac05014610ae4578063c61adfea14610b04578063c62117c314610b24578063c7d07c6314610b44578063ce7c2ac214610b64578063d547741f14610b84578063d79779b214610ba4578063d96ba05f14610bc4578063de7d780f14610be6578063e02023a114610c06578063e1ba4e7714610c28578063e33b7de314610c48578063e8a3d48514610c5d578063e985e9c514610c72578063ea594d5114610c92578063ecb0108d14610cdd578063ee98523414610cfd578063f242432a14610d1f578063f4e042d514610d3f578063ff5bce2514610d5557600080fd5b80624221f0146103ae578062fdd58e146103ee57806301ffc9a71461040e57806302fe53051461043e57806308e70c98146104605780630e89341c1461048d578063104789c7146104ba57806318160ddd146104e757806319165587146104fc5780631d9d60cb1461051c578063248a9ca31461053c57806324d043e01461055c5780632c14302e1461057c5780632eb2c2d6146105a95780632eb4a7ab146105c95780632eb9020d146105df5780632f2ff15d146105f957806336568abe146106195780633a98ef39146106395780633a9f00f21461064e5780633acd4448146106615780633ccfd60b146106815780633f4ba83a14610696578063406072a9146106ab578063414cebe2146106cb57806344d19d2b146106eb578063471990621461070157806348b6eaef1461072157806348b750441461073757806349bceddb146107575780634e1273f4146107845780634f558e79146107b157806358c54426146107d15780635c975abb1461083c5780635ce695c6146108545780635e7375481461086757806375b238fc1461088757806375b49f8b146108a957600080fd5b366103a9577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be770333460405161039f929190613c78565b60405180910390a1005b600080fd5b3480156103ba57600080fd5b506103db6103c9366004613c91565b60126020526000908152604090205481565b6040519081526020015b60405180910390f35b3480156103fa57600080fd5b506103db610409366004613ccf565b610d85565b34801561041a57600080fd5b5061042e610429366004613d11565b610dad565b60405190151581526020016103e5565b34801561044a57600080fd5b5061045e610459366004613dea565b610db8565b005b34801561046c57600080fd5b506103db61047b366004613e1e565b601b6020526000908152604090205481565b34801561049957600080fd5b506104ad6104a8366004613c91565b610ddd565b6040516103e59190613e8b565b3480156104c657600080fd5b506016546104da906001600160a01b031681565b6040516103e59190613e9e565b3480156104f357600080fd5b506006546103db565b34801561050857600080fd5b5061045e610517366004613e1e565b610e71565b34801561052857600080fd5b506103db610537366004613dea565b610f58565b34801561054857600080fd5b506103db610557366004613c91565b610f88565b34801561056857600080fd5b5061045e610577366004613eb2565b610f9d565b34801561058857600080fd5b506103db610597366004613c91565b60009081526018602052604090205490565b3480156105b557600080fd5b5061045e6105c4366004613f77565b61104a565b3480156105d557600080fd5b506103db60145481565b3480156105eb57600080fd5b50601e5461042e9060ff1681565b34801561060557600080fd5b5061045e61061436600461402e565b6110a2565b34801561062557600080fd5b5061045e61063436600461402e565b6110c4565b34801561064557600080fd5b506007546103db565b61045e61065c3660046140a9565b6110fc565b34801561066d57600080fd5b5061045e61067c36600461417f565b6111ab565b34801561068d57600080fd5b5061045e611312565b3480156106a257600080fd5b5061045e61137b565b3480156106b757600080fd5b506103db6106c63660046141f6565b61139b565b3480156106d757600080fd5b5061045e6106e6366004613e1e565b6113c6565b3480156106f757600080fd5b506103db60205481565b34801561070d57600080fd5b5061045e61071c366004614224565b6114ef565b34801561072d57600080fd5b506103db601c5481565b34801561074357600080fd5b5061045e6107523660046141f6565b6115a5565b34801561076357600080fd5b506103db610772366004613c91565b60136020526000908152604090205481565b34801561079057600080fd5b506107a461079f366004614262565b6116b3565b6040516103e59190614367565b3480156107bd57600080fd5b5061042e6107cc366004613c91565b61177b565b3480156107dd57600080fd5b506108176107ec366004613c91565b6019602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b604080516001600160a01b0390941684526020840192909252908201526060016103e5565b34801561084857600080fd5b5060045460ff1661042e565b61045e61086236600461437a565b61178e565b34801561087357600080fd5b5061045e610882366004614411565b6117f4565b34801561089357600080fd5b506103db600080516020614b1383398151915281565b3480156108b557600080fd5b5061045e6108c4366004614449565b61196f565b3480156108d557600080fd5b506016546108ea90600160a01b900460e01b81565b6040516001600160e01b031990911681526020016103e5565b34801561090f57600080fd5b506103db61091e366004613c91565b611a03565b34801561092f57600080fd5b5061045e611a24565b34801561094457600080fd5b506104da610953366004613c91565b611a44565b34801561096457600080fd5b5061045e610973366004613c91565b611a74565b34801561098457600080fd5b5061042e61099336600461402e565b611a92565b3480156109a457600080fd5b5061045e6109b3366004613dea565b611abd565b3480156109c457600080fd5b506103db6109d3366004613c91565b611ae1565b3480156109e457600080fd5b506103db6109f3366004613e1e565b611b0a565b348015610a0457600080fd5b506103db600f5481565b348015610a1a57600080fd5b506103db600081565b348015610a2f57600080fd5b5061045e610a3e36600461448d565b611b25565b348015610a4f57600080fd5b506103db610a5e366004613e1e565b611b30565b348015610a6f57600080fd5b5061045e610a7e3660046144c2565b611b6f565b348015610a8f57600080fd5b506103db60155481565b348015610aa557600080fd5b5061045e611b9b565b348015610aba57600080fd5b506103db60105481565b348015610ad057600080fd5b506103db610adf366004613c91565b611bc8565b348015610af057600080fd5b506103db610aff3660046141f6565b611bda565b348015610b1057600080fd5b5061045e610b1f3660046144e5565b611c76565b348015610b3057600080fd5b5061045e610b3f366004614507565b611cc1565b348015610b5057600080fd5b5061045e610b5f366004613d11565b611d12565b348015610b7057600080fd5b506103db610b7f366004613e1e565b611d4f565b348015610b9057600080fd5b5061045e610b9f36600461402e565b611d6a565b348015610bb057600080fd5b506103db610bbf366004613e1e565b611d86565b348015610bd057600080fd5b506103db600080516020614ad383398151915281565b348015610bf257600080fd5b5061045e610c01366004614533565b611da1565b348015610c1257600080fd5b506103db600080516020614af383398151915281565b348015610c3457600080fd5b5061045e610c433660046144e5565b611ec9565b348015610c5457600080fd5b506008546103db565b348015610c6957600080fd5b506104ad611ef4565b348015610c7e57600080fd5b5061042e610c8d3660046141f6565b611f86565b348015610c9e57600080fd5b50610cb2610cad366004613c91565b611fb4565b604080518251815260208084015190820152918101516001600160a01b0316908201526060016103e5565b348015610ce957600080fd5b5061045e610cf8366004614595565b6120cd565b348015610d0957600080fd5b506103db600080516020614b3383398151915281565b348015610d2b57600080fd5b5061045e610d3a36600461462e565b612340565b348015610d4b57600080fd5b506103db60115481565b348015610d6157600080fd5b5061042e610d70366004613c91565b601d6020526000908152604090205460ff1681565b6000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b6000610da782612390565b600080516020614b13833981519152610dd0816123b5565b610dd9826123bf565b5050565b606060028054610dec9061468a565b80601f0160208091040260200160405190810160405280929190818152602001828054610e189061468a565b8015610e655780601f10610e3a57610100808354040283529160200191610e65565b820191906000526020600020905b815481529060010190602001808311610e4857829003601f168201915b50505050509050919050565b6001600160a01b038116600090815260096020526040902054610eaf5760405162461bcd60e51b8152600401610ea6906146be565b60405180910390fd5b6000610eba82611b30565b905080600003610edc5760405162461bcd60e51b8152600401610ea690614704565b8060086000828254610eee9190614765565b90915550506001600160a01b0382166000908152600a60205260409020805482019055610f1b82826123cb565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b0568282604051610f4c929190613c78565b60405180910390a15050565b600081604051602001610f6b9190614778565b604051602081830303815290604052805190602001209050919050565b60009081526003602052604090206001015490565b600080516020614b13833981519152610fb5816123b5565b6016546001600160a01b0385811691161461102257826001600160401b03811115610fe257610fe2613d2e565b60405190808252806020026020018201604052801561100b578160200160208202803683370190505b50805161102091601f91602090910190613b59565b505b50601680546001600160a01b0319166001600160a01b03949094169390931790925550601055565b336001600160a01b038616811480159061106b57506110698682611f86565b155b1561108d57808660405163711bec9160e11b8152600401610ea6929190614794565b61109a8686868686612469565b505050505050565b6110ab82610f88565b6110b4816123b5565b6110be83836124c9565b50505050565b6001600160a01b03811633146110ed5760405163334bd91960e11b815260040160405180910390fd5b6110f7828261255d565b505050565b61110b888888888787876125ca565b600061111a85600f548961269d565b905061112b878783602001516127c1565b6111475760405162461bcd60e51b8152600401610ea6906147ae565b80516040808301516001600160a01b03166000908152601b6020529081208054909190611175908490614765565b90915550508051601c805460009061118e908490614765565b909155506111a0905089898985612981565b505050505050505050565b600080516020614b338339815191526111c3816123b5565b825184511461120f5760405162461bcd60e51b8152602060048201526018602482015277082e4e4c2f240d8cadccee8d0e640daeae6e840dac2e8c6d60431b6044820152606401610ea6565b8351611222906017906020870190613bfe565b5060005b845181101561130b576000858281518110611243576112436147cd565b602002602001015190506000858381518110611261576112616147cd565b6020908102919091018101516000848152601d90925260409091205490915060ff16158061129c575060008281526012602052604090205481145b6112b85760405162461bcd60e51b8152600401610ea6906147e3565b6000828152601260209081526040808320849055601d90915290205460ff161580156112e15750845b15611301576000828152601d60205260409020805460ff19168615151790555b5050600101611226565b5050505050565b600080516020614af383398151915261132a816123b5565b6113326129ca565b601c5433906108fc906113459047614808565b6040518115909202916000818181858888f1935050505015801561136d573d6000803e3d6000fd5b506113786001600e55565b50565b600080516020614b13833981519152611393816123b5565b6113786129f4565b6001600160a01b039182166000908152600d6020908152604080832093909416825291909152205490565b6113ce6129ca565b6001600160a01b0381166000908152601b60205260409020548061141d5760405162461bcd60e51b815260206004820152600660248201526509cde408aa8960d31b6044820152606401610ea6565b80601c54101561147b5760405162461bcd60e51b8152602060048201526024808201527f496e73756666696369656e7420746f74616c20616666696c696174652062616c604482015263616e636560e01b6064820152608401610ea6565b6001600160a01b0382166000908152601b60205260408120819055601c80548392906114a8908490614808565b90915550506040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156114e3573d6000803e3d6000fd5b50506113786001600e55565b600080516020614b33833981519152611507816123b5565b6000848152601d602052604090205460ff16156115365760405162461bcd60e51b8152600401610ea6906147e3565b600084116115705760405162461bcd60e51b81526020600482015260076024820152665f6964203c203160c81b6044820152606401610ea6565b506000928352601d60209081526040808520805460ff1916931515939093179092556012905290912063ffffffff9091169055565b6001600160a01b0381166000908152600960205260409020546115da5760405162461bcd60e51b8152600401610ea6906146be565b60006115e68383611bda565b9050806000036116085760405162461bcd60e51b8152600401610ea690614704565b6001600160a01b0383166000908152600c602052604081208054839290611630908490614765565b90915550506001600160a01b038084166000908152600d6020908152604080832093861683529290522080548201905561166b838383612a40565b826001600160a01b03167f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a83836040516116a6929190613c78565b60405180910390a2505050565b606081518351146116e45781518351604051635b05999160e01b815260048101929092526024820152604401610ea6565b600083516001600160401b038111156116ff576116ff613d2e565b604051908082528060200260200182016040528015611728578160200160208202803683370190505b50905060005b84518110156117735761174e6117448683612a98565b6104098684612a98565b828281518110611760576117606147cd565b602090810291909101015260010161172e565b509392505050565b60008061178783611bc8565b1192915050565b600061179e898989878787612aa6565b905060006117af86600f548461269d565b90506117c0828883602001516127c1565b6117dc5760405162461bcd60e51b8152600401610ea6906147ae565b6117e88a8a8a86612ed6565b50505050505050505050565b806117ff8385610d85565b101561184d5760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e742062616c616e636520746f20636c61696d0000006044820152606401610ea6565b60008381526018602052604081205490036118a55760405162461bcd60e51b815260206004820152601860248201527710db185a5b5959081d1bdad95b881251081b9bdd081cd95d60421b6044820152606401610ea6565b336001600160a01b03831614806118c157506118c18233611f86565b806118df57506118df600080516020614ad383398151915233611a92565b6118e857600080fd5b600083815260186020526040902054611902838584612f0e565b61191d83828460405180602001604052806000815250612981565b60408051858152602081018390529081018390526001600160a01b038416907f9cdcf2f7714cca3508c7f0110b04a90a80a3a8dd0e35de99689db74d28c5383e9060600160405180910390a250505050565b600080516020614b33833981519152611987816123b5565b60648211156119c05760405162461bcd60e51b81526020600482015260056024820152643e3130302560d81b6044820152606401610ea6565b6000836040516020016119d39190614778565b60408051601f19818403018152918152815160209283012060009081526019909252902060010192909255505050565b60178181548110611a1357600080fd5b600091825260209091200154905081565b600080516020614b13833981519152611a3c816123b5565b611378612f65565b6000600b8281548110611a5957611a596147cd565b6000918252602090912001546001600160a01b031692915050565b600080516020614b33833981519152611a8c816123b5565b50600f55565b60009182526003602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020614b13833981519152611ad5816123b5565b60216110f78382614862565b600081815260196020526040812060010154808203610da7575050601154919050565b50919050565b6001600160a01b03166000908152600a602052604090205490565b610dd9338383612fa2565b600080611b3c60085490565b601c54611b499047614808565b611b539190614765565b9050611b688382611b6386611b0a565b613038565b9392505050565b600080516020614b13833981519152611b87816123b5565b8115611b94575050601555565b5050601455565b600080516020614b13833981519152611bb3816123b5565b50601e805460ff19811660ff90911615179055565b60009081526005602052604090205490565b600080611be684611d86565b6040516370a0823160e01b81526001600160a01b038616906370a0823190611c12903090600401613e9e565b602060405180830381865afa158015611c2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c539190614920565b611c5d9190614765565b9050611c6e8382611b63878761139b565b949350505050565b600080516020614b33833981519152611c8e816123b5565b60008311611cae5760405162461bcd60e51b8152600401610ea690614939565b5060009182526013602052604090912055565b600080516020614b33833981519152611cd9816123b5565b60008411611cf95760405162461bcd60e51b8152600401610ea690614939565b506000928352601a602052604090922090815560010155565b600080516020614b33833981519152611d2a816123b5565b506016805460e09290921c600160a01b0263ffffffff60a01b19909216919091179055565b6001600160a01b031660009081526009602052604090205490565b611d7382610f88565b611d7c816123b5565b6110be838361255d565b6001600160a01b03166000908152600c602052604090205490565b600080516020614b13833981519152611db9816123b5565b60008411611dd95760405162461bcd60e51b8152600401610ea690614939565b8260011480611dfb5750611dfb600080516020614b1383398151915233611a92565b611e3d5760405162461bcd60e51b81526020600482015260136024820152723e2031206f6e6c792041444d494e5f524f4c4560681b6044820152606401610ea6565b6000848152601260205260409020541580611e79575060008481526012602052604090205483611e6c86611bc8565b611e769190614765565b11155b611e955760405162461bcd60e51b8152600401610ea690614968565b611ea185858585612981565b60005b8381101561109a5760208054906000611ebc83614992565b9091555050600101611ea4565b600080516020614b13833981519152611ee1816123b5565b5060009182526018602052604090912055565b606060218054611f039061468a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f2f9061468a565b8015611f7c5780601f10611f5157610100808354040283529160200191611f7c565b820191906000526020600020905b815481529060010190602001808311611f5f57829003601f168201915b5050505050905090565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b611fbc613c39565b6000828152601960205260409020546001600160a01b03168061201a5760405162461bcd60e51b815260206004820152601660248201527512d95e5ddbdc9908191bd95cc81b9bdd08195e1a5cdd60521b6044820152606401610ea6565b6000838152601960205260408120600101549081810361203d5750601154612069565b60008581526019602052604090206002015460649061205c90846149ab565b61206691906149c2565b90505b6000858152601960205260408120600201546064906120889082614808565b61209290856149ab565b61209c91906149c2565b90506040518060600160405280838152602001828152602001856001600160a01b0316815250945050505050919050565b6000866040516020016120e09190614778565b60405160208183030381529060405280519060200120905060648211156121395760405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081cdc1b1a5d609a1b6044820152606401610ea6565b6000818152601960205260409020546001600160a01b0316158061217857508480156121785750612178600080516020614b1383398151915233611a92565b806121a157508480156121a157506000818152601960205260409020546001600160a01b031633145b6121dd5760405162461bcd60e51b815260206004820152600d60248201526c25b2bcbbb7b932103a30b5b2b760991b6044820152606401610ea6565b6121f5600080516020614b1383398151915233611a92565b806122605750601554158061224e575061224e612211336130c5565b8585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060155491506130e79050565b806122605750612260612211876130c5565b6122a35760405162461bcd60e51b815260206004820152601460248201527334b73b30b634b21036b2b935b63290383937b7b360611b6044820152606401610ea6565b6001600160a01b0386166122dd57600081815260196020526040812080546001600160a01b03191681556001810182905560020155612337565b604080516060810182526001600160a01b038881168252601154602080840191825283850187815260008781526019909252949020925183546001600160a01b031916921691909117825551600182015590516002909101555b50505050505050565b336001600160a01b0386168114801590612361575061235f8682611f86565b155b1561238357808660405163711bec9160e11b8152600401610ea6929190614794565b61109a86868686866130f4565b60006001600160e01b03198216637965db0b60e01b1480610da75750610da782613165565b61137881336131b5565b6002610dd98282614862565b804710156123f55760405163cf47918160e01b815247600482015260248101829052604401610ea6565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612442576040519150601f19603f3d011682016040523d82523d6000602084013e612447565b606091505b50509050806110f75760405163d6bda27560e01b815260040160405180910390fd5b6001600160a01b038416612493576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6001600160a01b0385166124bc576000604051626a0d4560e21b8152600401610ea69190613e9e565b61130b85858585856131e0565b60006124d58383611a92565b6125555760008381526003602090815260408083206001600160a01b03861684529091529020805460ff1916600117905561250d3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610da7565b506000610da7565b60006125698383611a92565b156125555760008381526003602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610da7565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090508782600081518110612623576126236147cd565b6020026020010181815250508681600081518110612643576126436147cd565b6020908102919091010152601f5486111561268f5760405162461bcd60e51b815260206004820152600c60248201526b10985908191a5cd8dbdd5b9d60a21b6044820152606401610ea6565b6117e8898383888888612aa6565b6126a5613c39565b600084511180156126e95750835160011480156126e75750836000815181106126d0576126d06147cd565b6020910101516001600160f81b031916600160fd1b145b155b156127915760006126f985610f58565b9050600061270682611fb4565b9050600060648587846000015161271d91906149ab565b61272791906149ab565b61273191906149c2565b9050600060648688856020015161274891906149ab565b61275291906149ab565b61275c91906149c2565b9050604051806060016040528083815260200182815260200184604001516001600160a01b0316815250945050505050611b68565b6040518060600160405280600081526020016000815260200160006001600160a01b031681525090509392505050565b60008084600f546127d291906149ab565b90508281101561282f5760405162461bcd60e51b815260206004820152602260248201527f4b6579776f726420646973636f756e7420657863656564732074686520707269604482015261636560f01b6064820152608401610ea6565b6010548110156128905760405162461bcd60e51b815260206004820152602660248201527f546f6b656e2d626173656420646973636f756e7420657863656564732074686560448201526520707269636560d01b6064820152608401610ea6565b8084158015906128a25750601f548511155b80156128ae5750856001145b80156128cd57506016546128cd9033906001600160a01b031687613245565b1561293f576010546128df9083614808565b905080341061293a576001601f6128f68288614808565b81548110612906576129066147cd565b90600052602060002090602091828204019190066101000a81548160ff021916908315150217905550600192505050611b68565b612963565b83156129635761294f8483614808565b905080341061296357600192505050611b68565b81341061297557600192505050611b68565b50600095945050505050565b6001600160a01b0384166129ab576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6000806129b88585613439565b9150915061109a6000878484876131e0565b6002600e54036129ed57604051633ee5aeb560e01b815260040160405180910390fd5b6002600e55565b6129fc613461565b6004805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612a369190613e9e565b60405180910390a1565b6110f783846001600160a01b031663a9059cbb8585604051602401612a66929190613c78565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613486565b602090810291909101015190565b600033321480612ab85750601e5460ff165b612af45760405162461bcd60e51b815260206004820152600d60248201526c4e6f20636f6e7472616374732160981b6044820152606401610ea6565b6014541580612b475750612b47612b0a336130c5565b8585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060145491506130e79050565b80612b595750612b59612b0a886130c5565b612b955760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610ea6565b85516000805b82811015612ec9576000898281518110612bb757612bb76147cd565b602002602001015111612bf95760405162461bcd60e51b815260206004820152600a602482015269125b9d985b1a5908125160b21b6044820152606401610ea6565b612c1b898281518110612c0e57612c0e6147cd565b60200260200101516134ee565b612c515760405162461bcd60e51b81526020600482015260076024820152664e6f2073616c6560c81b6044820152606401610ea6565b612ca4601a60008b8481518110612c6a57612c6a6147cd565b602002602001015181526020019081526020016000206040518060400160405290816000820154815260200160018201548152505061353a565b612cdd5760405162461bcd60e51b815260206004820152600a60248201526957726f6e672074696d6560b01b6044820152606401610ea6565b601260008a8381518110612cf357612cf36147cd565b602002602001015181526020019081526020016000205460001480612d895750601260008a8381518110612d2957612d296147cd565b6020026020010151815260200190815260200160002054888281518110612d5257612d526147cd565b6020026020010151612d7c8b8481518110612d6f57612d6f6147cd565b6020026020010151611bc8565b612d869190614765565b11155b612da55760405162461bcd60e51b8152600401610ea690614968565b601360008a8381518110612dbb57612dbb6147cd565b602002602001015181526020019081526020016000205460001480612e525750601360008a8381518110612df157612df16147cd565b6020026020010151815260200190815260200160002054888281518110612e1a57612e1a6147cd565b6020026020010151612e458c8c8581518110612e3857612e386147cd565b6020026020010151610d85565b612e4f9190614765565b11155b612e9a5760405162461bcd60e51b815260206004820152601960248201527852656163686564207065722d77616c6c6574206c696d69742160381b6044820152606401610ea6565b878181518110612eac57612eac6147cd565b602002602001015182612ebf9190614765565b9150600101612b9b565b5098975050505050505050565b6001600160a01b038416612f00576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6110be6000858585856131e0565b6001600160a01b038316612f37576000604051626a0d4560e21b8152600401610ea69190613e9e565b600080612f448484613439565b9150915061130b8560008484604051806020016040528060008152506131e0565b612f6d61357d565b6004805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a293390565b6001600160a01b038216612fcb57600060405162ced3e160e81b8152600401610ea69190613e9e565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60008061304485611d4f565b9050600061305160075490565b90506000821161309b5760405162461bcd60e51b81526020600482015260156024820152744163636f756e7420686173206e6f2073686172657360581b6044820152606401610ea6565b83816130a784886149ab565b6130b191906149c2565b6130bb9190614808565b9695505050505050565b6040516001600160601b0319606083901b166020820152600090603401610f6b565b6000611c6e8383866135a1565b6001600160a01b03841661311e576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6001600160a01b038516613147576000604051626a0d4560e21b8152600401610ea69190613e9e565b6000806131548585613439565b9150915061233787878484876131e0565b60006001600160e01b03198216636cdb3d1360e11b148061319657506001600160e01b031982166303a24d0760e21b145b80610da757506301ffc9a760e01b6001600160e01b0319831614610da7565b6131bf8282611a92565b610dd957808260405163e2517d3f60e01b8152600401610ea6929190613c78565b6131ec858585856135b7565b6001600160a01b0384161561130b57825133906001036132375760006132128582612a98565b905060006132208582612a98565b90506132308389898585896135c3565b505061109a565b61109a8187878787876136d5565b601f54600090821115806132935750601f613261600184614808565b81548110613271576132716147cd565b60009182526020918290209181049091015460ff601f9092166101000a900416155b6132d95760405162461bcd60e51b81526020600482015260176024820152761a5b9d985b1a5908191a5cd8dbdd5b9d151bdad95b9259604a1b6044820152606401610ea6565b6016546040516024810184905260009182916001600160a01b03871691600160a01b900460e01b9060440160408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516133429190614778565b6000604051808303816000865af19150503d806000811461337f576040519150601f19603f3d011682016040523d82523d6000602084013e613384565b606091505b5091509150816133c55760405162461bcd60e51b815260206004820152600c60248201526b1bdddb995c93d98819985a5b60a21b6044820152606401610ea6565b856001600160a01b03166133da826020015190565b6001600160a01b03161461342d5760405162461bcd60e51b815260206004820152601a6024820152793234b9b1b7bab73a2a37b5b2b71d103bb937b7339037bbb732b960311b6044820152606401610ea6565b50600195945050505050565b6040805160018082526020820194909452808201938452606081019290925260808201905291565b60045460ff1661348457604051638dfc202b60e01b815260040160405180910390fd5b565b600080602060008451602086016000885af1806134a9576040513d6000823e3d81fd5b50506000513d915081156134c15780600114156134ce565b6001600160a01b0384163b155b156110be5783604051635274afe760e01b8152600401610ea69190613e9e565b6000805b601754811015613531578260178281548110613510576135106147cd565b9060005260206000200154036135295750600192915050565b6001016134f2565b50600092915050565b8051600090158061354c575081514210155b8015613568575060208201511580613568575042826020015110155b1561357557506001919050565b506000919050565b60045460ff16156134845760405163d93c066560e01b815260040160405180910390fd5b6000826135ae85846137b5565b14949350505050565b6110be848484846137f0565b6001600160a01b0384163b1561109a5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061360790899089908890889088906004016149e4565b6020604051808303816000875af1925050508015613642575060408051601f3d908101601f1916820190925261363f91810190614a29565b60015b6136a2573d808015613670576040519150601f19603f3d011682016040523d82523d6000602084013e613675565b606091505b50805160000361369a5784604051632bfa23e760e11b8152600401610ea69190613e9e565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b146123375784604051632bfa23e760e11b8152600401610ea69190613e9e565b6001600160a01b0384163b1561109a5760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906137199089908990889088908890600401614a46565b6020604051808303816000875af1925050508015613754575060408051601f3d908101601f1916820190925261375191810190614a29565b60015b613782573d808015613670576040519150601f19603f3d011682016040523d82523d6000602084013e613675565b6001600160e01b0319811663bc197c8160e01b146123375784604051632bfa23e760e11b8152600401610ea69190613e9e565b600081815b8451811015611773576137e6828683815181106137d9576137d96147cd565b60200260200101516138f4565b91506001016137ba565b6137fc84848484613920565b6001600160a01b038416613886576000805b835181101561386c5760006138238483612a98565b905080600560006138348886612a98565b815260200190815260200160002060008282546138519190614765565b9091555061386190508184614765565b92505060010161380e565b50806006600082825461387f9190614765565b9091555050505b6001600160a01b0383166110be576000805b83518110156138e35760006138ad8483612a98565b905080600560006138be8886612a98565b8152602081019190915260400160002080549190910390559190910190600101613898565b506006805491909103905550505050565b6000818310613910576000828152602084905260409020611b68565b5060009182526020526040902090565b61392861357d565b6110be84848484805182511461395e5781518151604051635b05999160e01b815260048101929092526024820152604401610ea6565b3360005b8351811015613a6e5760006139778583612a98565b905060006139858584612a98565b90506001600160a01b03881615613a1f576000828152602081815260408083206001600160a01b038c168452909152902054818110156139f8576040516303dee4c560e01b81526001600160a01b038a166004820152602481018290526044810183905260648101849052608401610ea6565b6000838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615613a64576000828152602081815260408083206001600160a01b038b16845290915281208054839290613a5e908490614765565b90915550505b5050600101613962565b508251600103613afb576000613a848482612a98565b90506000613a928482612a98565b9050856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051613aec929190918252602082015260400190565b60405180910390a4505061130b565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613b4a929190614aa4565b60405180910390a45050505050565b82805482825590600052602060002090601f01602090048101928215613bee5791602002820160005b83821115613bbf57835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302613b82565b8015613bec5782816101000a81549060ff0219169055600101602081600001049283019260010302613bbf565b505b50613bfa929150613c63565b5090565b828054828255906000526020600020908101928215613bee579160200282015b82811115613bee578251825591602001919060010190613c1e565b6040518060600160405280600081526020016000815260200160006001600160a01b031681525090565b5b80821115613bfa5760008155600101613c64565b6001600160a01b03929092168252602082015260400190565b600060208284031215613ca357600080fd5b5035919050565b6001600160a01b038116811461137857600080fd5b8035613cca81613caa565b919050565b60008060408385031215613ce257600080fd5b8235613ced81613caa565b946020939093013593505050565b6001600160e01b03198116811461137857600080fd5b600060208284031215613d2357600080fd5b8135611b6881613cfb565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613d6c57613d6c613d2e565b604052919050565b600082601f830112613d8557600080fd5b8135602083016000806001600160401b03841115613da557613da5613d2e565b50601f8301601f1916602001613dba81613d44565b915050828152858383011115613dcf57600080fd5b82826020830137600092810160200192909252509392505050565b600060208284031215613dfc57600080fd5b81356001600160401b03811115613e1257600080fd5b611c6e84828501613d74565b600060208284031215613e3057600080fd5b8135611b6881613caa565b60005b83811015613e56578181015183820152602001613e3e565b50506000910152565b60008151808452613e77816020860160208601613e3b565b601f01601f19169290920160200192915050565b602081526000611b686020830184613e5f565b6001600160a01b0391909116815260200190565b600080600060608486031215613ec757600080fd5b8335613ed281613caa565b95602085013595506040909401359392505050565b60006001600160401b03821115613f0057613f00613d2e565b5060051b60200190565b600082601f830112613f1b57600080fd5b8135613f2e613f2982613ee7565b613d44565b8082825260208201915060208360051b860101925085831115613f5057600080fd5b602085015b83811015613f6d578035835260209283019201613f55565b5095945050505050565b600080600080600060a08688031215613f8f57600080fd5b8535613f9a81613caa565b94506020860135613faa81613caa565b935060408601356001600160401b03811115613fc557600080fd5b613fd188828901613f0a565b93505060608601356001600160401b03811115613fed57600080fd5b613ff988828901613f0a565b92505060808601356001600160401b0381111561401557600080fd5b61402188828901613d74565b9150509295509295909350565b6000806040838503121561404157600080fd5b82359150602083013561405381613caa565b809150509250929050565b60008083601f84011261407057600080fd5b5081356001600160401b0381111561408757600080fd5b6020830191508360208260051b85010111156140a257600080fd5b9250929050565b60008060008060008060008060e0898b0312156140c557600080fd5b88356140d081613caa565b975060208901359650604089013595506060890135945060808901356001600160401b0381111561410057600080fd5b61410c8b828c01613d74565b94505060a08901356001600160401b0381111561412857600080fd5b6141348b828c0161405e565b90945092505060c08901356001600160401b0381111561415357600080fd5b61415f8b828c01613d74565b9150509295985092959890939650565b80358015158114613cca57600080fd5b60008060006060848603121561419457600080fd5b83356001600160401b038111156141aa57600080fd5b6141b686828701613f0a565b93505060208401356001600160401b038111156141d257600080fd5b6141de86828701613f0a565b9250506141ed6040850161416f565b90509250925092565b6000806040838503121561420957600080fd5b823561421481613caa565b9150602083013561405381613caa565b60008060006060848603121561423957600080fd5b83359250602084013563ffffffff8116811461425457600080fd5b91506141ed6040850161416f565b6000806040838503121561427557600080fd5b82356001600160401b0381111561428b57600080fd5b8301601f8101851361429c57600080fd5b80356142aa613f2982613ee7565b8082825260208201915060208360051b8501019250878311156142cc57600080fd5b6020840193505b828410156142f75783356142e681613caa565b8252602093840193909101906142d3565b945050505060208301356001600160401b0381111561431557600080fd5b61432185828601613f0a565b9150509250929050565b600081518084526020840193506020830160005b8281101561435d57815186526020958601959091019060010161433f565b5093949350505050565b602081526000611b68602083018461432b565b60008060008060008060008060e0898b03121561439657600080fd5b61439f89613cbf565b975060208901356001600160401b038111156143ba57600080fd5b6143c68b828c01613f0a565b97505060408901356001600160401b038111156143e257600080fd5b6143ee8b828c01613f0a565b9650506060890135945060808901356001600160401b0381111561410057600080fd5b60008060006060848603121561442657600080fd5b83359250602084013561443881613caa565b929592945050506040919091013590565b6000806040838503121561445c57600080fd5b82356001600160401b0381111561447257600080fd5b61447e85828601613d74565b95602094909401359450505050565b600080604083850312156144a057600080fd5b82356144ab81613caa565b91506144b96020840161416f565b90509250929050565b600080604083850312156144d557600080fd5b823591506144b96020840161416f565b600080604083850312156144f857600080fd5b50508035926020909101359150565b60008060006060848603121561451c57600080fd5b505081359360208301359350604090920135919050565b6000806000806080858703121561454957600080fd5b843561455481613caa565b9350602085013592506040850135915060608501356001600160401b0381111561457d57600080fd5b61458987828801613d74565b91505092959194509250565b60008060008060008060a087890312156145ae57600080fd5b86356001600160401b038111156145c457600080fd5b6145d089828a01613d74565b96505060208701356145e181613caa565b94506145ef6040880161416f565b935060608701356001600160401b0381111561460a57600080fd5b61461689828a0161405e565b979a9699509497949695608090950135949350505050565b600080600080600060a0868803121561464657600080fd5b853561465181613caa565b9450602086013561466181613caa565b9350604086013592506060860135915060808601356001600160401b0381111561401557600080fd5b600181811c9082168061469e57607f821691505b602082108103611b0457634e487b7160e01b600052602260045260246000fd5b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610da757610da761474f565b6000825161478a818460208701613e3b565b9190910192915050565b6001600160a01b0392831681529116602082015260400190565b602080825260059082015264507269636560d81b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6020808252600b908201526a73616c654d61784c6f636b60a81b604082015260600190565b81810381811115610da757610da761474f565b601f8211156110f757806000526020600020601f840160051c810160208510156148425750805b601f840160051c820191505b8181101561130b576000815560010161484e565b81516001600160401b0381111561487b5761487b613d2e565b61488f81614889845461468a565b8461481b565b6020601f8211600181146148c357600083156148ab5750848201515b600019600385901b1c1916600184901b17845561130b565b600084815260208120601f198516915b828110156148f357878501518255602094850194600190920191016148d3565b50848210156149115786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b60006020828403121561493257600080fd5b5051919050565b602080825260159082015274125b9d985b1a59081d1bdad95b881d1e5c19481251605a1b604082015260600190565b60208082526010908201526f14dd5c1c1b1e48195e1a185d5cdd195960821b604082015260600190565b6000600182016149a4576149a461474f565b5060010190565b8082028115828204841417610da757610da761474f565b6000826149df57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090614a1e90830184613e5f565b979650505050505050565b600060208284031215614a3b57600080fd5b8151611b6881613cfb565b6001600160a01b0386811682528516602082015260a060408201819052600090614a729083018661432b565b8281036060840152614a84818661432b565b90508281036080840152614a988185613e5f565b98975050505050505050565b604081526000614ab7604083018561432b565b8281036020840152614ac9818561432b565b9594505050505056fedfba9a3606cffcfda39d36eb9952d33729f3db2d78aee4695e084cd2295afeb65d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108eca49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775deccffc5821b949817830292498e44ccb6097e4b74ff2f2db960723873324defa264697066735822122084e146f636b72e0ce698f2b0839b02272f627ff627788e21fc3dc8ee5c316b2764736f6c634300081b0033000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000003f697066733a2f2f516d6266763247786a585468554e6d753961597255464e6d684b576b5077784448754c76324456614871515746372f7b69647d2e6a736f6e000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000ba8317f0da687b85b86bb3ba5ab48619df2921b50000000000000000000000000bce18970a171d93f015e8278359fc5021166f2e000000000000000000000000cbd1bdda4cf44c05dea8deee537ab3a01a1ae6e4000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000a
Deployed Bytecode
0x6080604052600436106103695760003560e01c806377e45a18116101c457806377e45a18146108c957806379a2e226146109035780638456cb59146109235780638b83209b1461093857806391b7f5ed1461095857806391d1485414610978578063938e3d7b1461099857806393c514c4146109b85780639852595c146109d8578063a035b1fe146109f8578063a217fddf14610a0e578063a22cb46514610a23578063a3f8eace14610a43578063a8f1c6d814610a63578063adbb2a6114610a83578063b558818114610a99578063b63ff1a014610aae578063bd85b03914610ac4578063c45ac05014610ae4578063c61adfea14610b04578063c62117c314610b24578063c7d07c6314610b44578063ce7c2ac214610b64578063d547741f14610b84578063d79779b214610ba4578063d96ba05f14610bc4578063de7d780f14610be6578063e02023a114610c06578063e1ba4e7714610c28578063e33b7de314610c48578063e8a3d48514610c5d578063e985e9c514610c72578063ea594d5114610c92578063ecb0108d14610cdd578063ee98523414610cfd578063f242432a14610d1f578063f4e042d514610d3f578063ff5bce2514610d5557600080fd5b80624221f0146103ae578062fdd58e146103ee57806301ffc9a71461040e57806302fe53051461043e57806308e70c98146104605780630e89341c1461048d578063104789c7146104ba57806318160ddd146104e757806319165587146104fc5780631d9d60cb1461051c578063248a9ca31461053c57806324d043e01461055c5780632c14302e1461057c5780632eb2c2d6146105a95780632eb4a7ab146105c95780632eb9020d146105df5780632f2ff15d146105f957806336568abe146106195780633a98ef39146106395780633a9f00f21461064e5780633acd4448146106615780633ccfd60b146106815780633f4ba83a14610696578063406072a9146106ab578063414cebe2146106cb57806344d19d2b146106eb578063471990621461070157806348b6eaef1461072157806348b750441461073757806349bceddb146107575780634e1273f4146107845780634f558e79146107b157806358c54426146107d15780635c975abb1461083c5780635ce695c6146108545780635e7375481461086757806375b238fc1461088757806375b49f8b146108a957600080fd5b366103a9577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be770333460405161039f929190613c78565b60405180910390a1005b600080fd5b3480156103ba57600080fd5b506103db6103c9366004613c91565b60126020526000908152604090205481565b6040519081526020015b60405180910390f35b3480156103fa57600080fd5b506103db610409366004613ccf565b610d85565b34801561041a57600080fd5b5061042e610429366004613d11565b610dad565b60405190151581526020016103e5565b34801561044a57600080fd5b5061045e610459366004613dea565b610db8565b005b34801561046c57600080fd5b506103db61047b366004613e1e565b601b6020526000908152604090205481565b34801561049957600080fd5b506104ad6104a8366004613c91565b610ddd565b6040516103e59190613e8b565b3480156104c657600080fd5b506016546104da906001600160a01b031681565b6040516103e59190613e9e565b3480156104f357600080fd5b506006546103db565b34801561050857600080fd5b5061045e610517366004613e1e565b610e71565b34801561052857600080fd5b506103db610537366004613dea565b610f58565b34801561054857600080fd5b506103db610557366004613c91565b610f88565b34801561056857600080fd5b5061045e610577366004613eb2565b610f9d565b34801561058857600080fd5b506103db610597366004613c91565b60009081526018602052604090205490565b3480156105b557600080fd5b5061045e6105c4366004613f77565b61104a565b3480156105d557600080fd5b506103db60145481565b3480156105eb57600080fd5b50601e5461042e9060ff1681565b34801561060557600080fd5b5061045e61061436600461402e565b6110a2565b34801561062557600080fd5b5061045e61063436600461402e565b6110c4565b34801561064557600080fd5b506007546103db565b61045e61065c3660046140a9565b6110fc565b34801561066d57600080fd5b5061045e61067c36600461417f565b6111ab565b34801561068d57600080fd5b5061045e611312565b3480156106a257600080fd5b5061045e61137b565b3480156106b757600080fd5b506103db6106c63660046141f6565b61139b565b3480156106d757600080fd5b5061045e6106e6366004613e1e565b6113c6565b3480156106f757600080fd5b506103db60205481565b34801561070d57600080fd5b5061045e61071c366004614224565b6114ef565b34801561072d57600080fd5b506103db601c5481565b34801561074357600080fd5b5061045e6107523660046141f6565b6115a5565b34801561076357600080fd5b506103db610772366004613c91565b60136020526000908152604090205481565b34801561079057600080fd5b506107a461079f366004614262565b6116b3565b6040516103e59190614367565b3480156107bd57600080fd5b5061042e6107cc366004613c91565b61177b565b3480156107dd57600080fd5b506108176107ec366004613c91565b6019602052600090815260409020805460018201546002909201546001600160a01b03909116919083565b604080516001600160a01b0390941684526020840192909252908201526060016103e5565b34801561084857600080fd5b5060045460ff1661042e565b61045e61086236600461437a565b61178e565b34801561087357600080fd5b5061045e610882366004614411565b6117f4565b34801561089357600080fd5b506103db600080516020614b1383398151915281565b3480156108b557600080fd5b5061045e6108c4366004614449565b61196f565b3480156108d557600080fd5b506016546108ea90600160a01b900460e01b81565b6040516001600160e01b031990911681526020016103e5565b34801561090f57600080fd5b506103db61091e366004613c91565b611a03565b34801561092f57600080fd5b5061045e611a24565b34801561094457600080fd5b506104da610953366004613c91565b611a44565b34801561096457600080fd5b5061045e610973366004613c91565b611a74565b34801561098457600080fd5b5061042e61099336600461402e565b611a92565b3480156109a457600080fd5b5061045e6109b3366004613dea565b611abd565b3480156109c457600080fd5b506103db6109d3366004613c91565b611ae1565b3480156109e457600080fd5b506103db6109f3366004613e1e565b611b0a565b348015610a0457600080fd5b506103db600f5481565b348015610a1a57600080fd5b506103db600081565b348015610a2f57600080fd5b5061045e610a3e36600461448d565b611b25565b348015610a4f57600080fd5b506103db610a5e366004613e1e565b611b30565b348015610a6f57600080fd5b5061045e610a7e3660046144c2565b611b6f565b348015610a8f57600080fd5b506103db60155481565b348015610aa557600080fd5b5061045e611b9b565b348015610aba57600080fd5b506103db60105481565b348015610ad057600080fd5b506103db610adf366004613c91565b611bc8565b348015610af057600080fd5b506103db610aff3660046141f6565b611bda565b348015610b1057600080fd5b5061045e610b1f3660046144e5565b611c76565b348015610b3057600080fd5b5061045e610b3f366004614507565b611cc1565b348015610b5057600080fd5b5061045e610b5f366004613d11565b611d12565b348015610b7057600080fd5b506103db610b7f366004613e1e565b611d4f565b348015610b9057600080fd5b5061045e610b9f36600461402e565b611d6a565b348015610bb057600080fd5b506103db610bbf366004613e1e565b611d86565b348015610bd057600080fd5b506103db600080516020614ad383398151915281565b348015610bf257600080fd5b5061045e610c01366004614533565b611da1565b348015610c1257600080fd5b506103db600080516020614af383398151915281565b348015610c3457600080fd5b5061045e610c433660046144e5565b611ec9565b348015610c5457600080fd5b506008546103db565b348015610c6957600080fd5b506104ad611ef4565b348015610c7e57600080fd5b5061042e610c8d3660046141f6565b611f86565b348015610c9e57600080fd5b50610cb2610cad366004613c91565b611fb4565b604080518251815260208084015190820152918101516001600160a01b0316908201526060016103e5565b348015610ce957600080fd5b5061045e610cf8366004614595565b6120cd565b348015610d0957600080fd5b506103db600080516020614b3383398151915281565b348015610d2b57600080fd5b5061045e610d3a36600461462e565b612340565b348015610d4b57600080fd5b506103db60115481565b348015610d6157600080fd5b5061042e610d70366004613c91565b601d6020526000908152604090205460ff1681565b6000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b6000610da782612390565b600080516020614b13833981519152610dd0816123b5565b610dd9826123bf565b5050565b606060028054610dec9061468a565b80601f0160208091040260200160405190810160405280929190818152602001828054610e189061468a565b8015610e655780601f10610e3a57610100808354040283529160200191610e65565b820191906000526020600020905b815481529060010190602001808311610e4857829003601f168201915b50505050509050919050565b6001600160a01b038116600090815260096020526040902054610eaf5760405162461bcd60e51b8152600401610ea6906146be565b60405180910390fd5b6000610eba82611b30565b905080600003610edc5760405162461bcd60e51b8152600401610ea690614704565b8060086000828254610eee9190614765565b90915550506001600160a01b0382166000908152600a60205260409020805482019055610f1b82826123cb565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b0568282604051610f4c929190613c78565b60405180910390a15050565b600081604051602001610f6b9190614778565b604051602081830303815290604052805190602001209050919050565b60009081526003602052604090206001015490565b600080516020614b13833981519152610fb5816123b5565b6016546001600160a01b0385811691161461102257826001600160401b03811115610fe257610fe2613d2e565b60405190808252806020026020018201604052801561100b578160200160208202803683370190505b50805161102091601f91602090910190613b59565b505b50601680546001600160a01b0319166001600160a01b03949094169390931790925550601055565b336001600160a01b038616811480159061106b57506110698682611f86565b155b1561108d57808660405163711bec9160e11b8152600401610ea6929190614794565b61109a8686868686612469565b505050505050565b6110ab82610f88565b6110b4816123b5565b6110be83836124c9565b50505050565b6001600160a01b03811633146110ed5760405163334bd91960e11b815260040160405180910390fd5b6110f7828261255d565b505050565b61110b888888888787876125ca565b600061111a85600f548961269d565b905061112b878783602001516127c1565b6111475760405162461bcd60e51b8152600401610ea6906147ae565b80516040808301516001600160a01b03166000908152601b6020529081208054909190611175908490614765565b90915550508051601c805460009061118e908490614765565b909155506111a0905089898985612981565b505050505050505050565b600080516020614b338339815191526111c3816123b5565b825184511461120f5760405162461bcd60e51b8152602060048201526018602482015277082e4e4c2f240d8cadccee8d0e640daeae6e840dac2e8c6d60431b6044820152606401610ea6565b8351611222906017906020870190613bfe565b5060005b845181101561130b576000858281518110611243576112436147cd565b602002602001015190506000858381518110611261576112616147cd565b6020908102919091018101516000848152601d90925260409091205490915060ff16158061129c575060008281526012602052604090205481145b6112b85760405162461bcd60e51b8152600401610ea6906147e3565b6000828152601260209081526040808320849055601d90915290205460ff161580156112e15750845b15611301576000828152601d60205260409020805460ff19168615151790555b5050600101611226565b5050505050565b600080516020614af383398151915261132a816123b5565b6113326129ca565b601c5433906108fc906113459047614808565b6040518115909202916000818181858888f1935050505015801561136d573d6000803e3d6000fd5b506113786001600e55565b50565b600080516020614b13833981519152611393816123b5565b6113786129f4565b6001600160a01b039182166000908152600d6020908152604080832093909416825291909152205490565b6113ce6129ca565b6001600160a01b0381166000908152601b60205260409020548061141d5760405162461bcd60e51b815260206004820152600660248201526509cde408aa8960d31b6044820152606401610ea6565b80601c54101561147b5760405162461bcd60e51b8152602060048201526024808201527f496e73756666696369656e7420746f74616c20616666696c696174652062616c604482015263616e636560e01b6064820152608401610ea6565b6001600160a01b0382166000908152601b60205260408120819055601c80548392906114a8908490614808565b90915550506040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156114e3573d6000803e3d6000fd5b50506113786001600e55565b600080516020614b33833981519152611507816123b5565b6000848152601d602052604090205460ff16156115365760405162461bcd60e51b8152600401610ea6906147e3565b600084116115705760405162461bcd60e51b81526020600482015260076024820152665f6964203c203160c81b6044820152606401610ea6565b506000928352601d60209081526040808520805460ff1916931515939093179092556012905290912063ffffffff9091169055565b6001600160a01b0381166000908152600960205260409020546115da5760405162461bcd60e51b8152600401610ea6906146be565b60006115e68383611bda565b9050806000036116085760405162461bcd60e51b8152600401610ea690614704565b6001600160a01b0383166000908152600c602052604081208054839290611630908490614765565b90915550506001600160a01b038084166000908152600d6020908152604080832093861683529290522080548201905561166b838383612a40565b826001600160a01b03167f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a83836040516116a6929190613c78565b60405180910390a2505050565b606081518351146116e45781518351604051635b05999160e01b815260048101929092526024820152604401610ea6565b600083516001600160401b038111156116ff576116ff613d2e565b604051908082528060200260200182016040528015611728578160200160208202803683370190505b50905060005b84518110156117735761174e6117448683612a98565b6104098684612a98565b828281518110611760576117606147cd565b602090810291909101015260010161172e565b509392505050565b60008061178783611bc8565b1192915050565b600061179e898989878787612aa6565b905060006117af86600f548461269d565b90506117c0828883602001516127c1565b6117dc5760405162461bcd60e51b8152600401610ea6906147ae565b6117e88a8a8a86612ed6565b50505050505050505050565b806117ff8385610d85565b101561184d5760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e742062616c616e636520746f20636c61696d0000006044820152606401610ea6565b60008381526018602052604081205490036118a55760405162461bcd60e51b815260206004820152601860248201527710db185a5b5959081d1bdad95b881251081b9bdd081cd95d60421b6044820152606401610ea6565b336001600160a01b03831614806118c157506118c18233611f86565b806118df57506118df600080516020614ad383398151915233611a92565b6118e857600080fd5b600083815260186020526040902054611902838584612f0e565b61191d83828460405180602001604052806000815250612981565b60408051858152602081018390529081018390526001600160a01b038416907f9cdcf2f7714cca3508c7f0110b04a90a80a3a8dd0e35de99689db74d28c5383e9060600160405180910390a250505050565b600080516020614b33833981519152611987816123b5565b60648211156119c05760405162461bcd60e51b81526020600482015260056024820152643e3130302560d81b6044820152606401610ea6565b6000836040516020016119d39190614778565b60408051601f19818403018152918152815160209283012060009081526019909252902060010192909255505050565b60178181548110611a1357600080fd5b600091825260209091200154905081565b600080516020614b13833981519152611a3c816123b5565b611378612f65565b6000600b8281548110611a5957611a596147cd565b6000918252602090912001546001600160a01b031692915050565b600080516020614b33833981519152611a8c816123b5565b50600f55565b60009182526003602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020614b13833981519152611ad5816123b5565b60216110f78382614862565b600081815260196020526040812060010154808203610da7575050601154919050565b50919050565b6001600160a01b03166000908152600a602052604090205490565b610dd9338383612fa2565b600080611b3c60085490565b601c54611b499047614808565b611b539190614765565b9050611b688382611b6386611b0a565b613038565b9392505050565b600080516020614b13833981519152611b87816123b5565b8115611b94575050601555565b5050601455565b600080516020614b13833981519152611bb3816123b5565b50601e805460ff19811660ff90911615179055565b60009081526005602052604090205490565b600080611be684611d86565b6040516370a0823160e01b81526001600160a01b038616906370a0823190611c12903090600401613e9e565b602060405180830381865afa158015611c2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c539190614920565b611c5d9190614765565b9050611c6e8382611b63878761139b565b949350505050565b600080516020614b33833981519152611c8e816123b5565b60008311611cae5760405162461bcd60e51b8152600401610ea690614939565b5060009182526013602052604090912055565b600080516020614b33833981519152611cd9816123b5565b60008411611cf95760405162461bcd60e51b8152600401610ea690614939565b506000928352601a602052604090922090815560010155565b600080516020614b33833981519152611d2a816123b5565b506016805460e09290921c600160a01b0263ffffffff60a01b19909216919091179055565b6001600160a01b031660009081526009602052604090205490565b611d7382610f88565b611d7c816123b5565b6110be838361255d565b6001600160a01b03166000908152600c602052604090205490565b600080516020614b13833981519152611db9816123b5565b60008411611dd95760405162461bcd60e51b8152600401610ea690614939565b8260011480611dfb5750611dfb600080516020614b1383398151915233611a92565b611e3d5760405162461bcd60e51b81526020600482015260136024820152723e2031206f6e6c792041444d494e5f524f4c4560681b6044820152606401610ea6565b6000848152601260205260409020541580611e79575060008481526012602052604090205483611e6c86611bc8565b611e769190614765565b11155b611e955760405162461bcd60e51b8152600401610ea690614968565b611ea185858585612981565b60005b8381101561109a5760208054906000611ebc83614992565b9091555050600101611ea4565b600080516020614b13833981519152611ee1816123b5565b5060009182526018602052604090912055565b606060218054611f039061468a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f2f9061468a565b8015611f7c5780601f10611f5157610100808354040283529160200191611f7c565b820191906000526020600020905b815481529060010190602001808311611f5f57829003601f168201915b5050505050905090565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b611fbc613c39565b6000828152601960205260409020546001600160a01b03168061201a5760405162461bcd60e51b815260206004820152601660248201527512d95e5ddbdc9908191bd95cc81b9bdd08195e1a5cdd60521b6044820152606401610ea6565b6000838152601960205260408120600101549081810361203d5750601154612069565b60008581526019602052604090206002015460649061205c90846149ab565b61206691906149c2565b90505b6000858152601960205260408120600201546064906120889082614808565b61209290856149ab565b61209c91906149c2565b90506040518060600160405280838152602001828152602001856001600160a01b0316815250945050505050919050565b6000866040516020016120e09190614778565b60405160208183030381529060405280519060200120905060648211156121395760405162461bcd60e51b815260206004820152600d60248201526c1a5b9d985b1a59081cdc1b1a5d609a1b6044820152606401610ea6565b6000818152601960205260409020546001600160a01b0316158061217857508480156121785750612178600080516020614b1383398151915233611a92565b806121a157508480156121a157506000818152601960205260409020546001600160a01b031633145b6121dd5760405162461bcd60e51b815260206004820152600d60248201526c25b2bcbbb7b932103a30b5b2b760991b6044820152606401610ea6565b6121f5600080516020614b1383398151915233611a92565b806122605750601554158061224e575061224e612211336130c5565b8585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060155491506130e79050565b806122605750612260612211876130c5565b6122a35760405162461bcd60e51b815260206004820152601460248201527334b73b30b634b21036b2b935b63290383937b7b360611b6044820152606401610ea6565b6001600160a01b0386166122dd57600081815260196020526040812080546001600160a01b03191681556001810182905560020155612337565b604080516060810182526001600160a01b038881168252601154602080840191825283850187815260008781526019909252949020925183546001600160a01b031916921691909117825551600182015590516002909101555b50505050505050565b336001600160a01b0386168114801590612361575061235f8682611f86565b155b1561238357808660405163711bec9160e11b8152600401610ea6929190614794565b61109a86868686866130f4565b60006001600160e01b03198216637965db0b60e01b1480610da75750610da782613165565b61137881336131b5565b6002610dd98282614862565b804710156123f55760405163cf47918160e01b815247600482015260248101829052604401610ea6565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612442576040519150601f19603f3d011682016040523d82523d6000602084013e612447565b606091505b50509050806110f75760405163d6bda27560e01b815260040160405180910390fd5b6001600160a01b038416612493576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6001600160a01b0385166124bc576000604051626a0d4560e21b8152600401610ea69190613e9e565b61130b85858585856131e0565b60006124d58383611a92565b6125555760008381526003602090815260408083206001600160a01b03861684529091529020805460ff1916600117905561250d3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610da7565b506000610da7565b60006125698383611a92565b156125555760008381526003602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610da7565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090508782600081518110612623576126236147cd565b6020026020010181815250508681600081518110612643576126436147cd565b6020908102919091010152601f5486111561268f5760405162461bcd60e51b815260206004820152600c60248201526b10985908191a5cd8dbdd5b9d60a21b6044820152606401610ea6565b6117e8898383888888612aa6565b6126a5613c39565b600084511180156126e95750835160011480156126e75750836000815181106126d0576126d06147cd565b6020910101516001600160f81b031916600160fd1b145b155b156127915760006126f985610f58565b9050600061270682611fb4565b9050600060648587846000015161271d91906149ab565b61272791906149ab565b61273191906149c2565b9050600060648688856020015161274891906149ab565b61275291906149ab565b61275c91906149c2565b9050604051806060016040528083815260200182815260200184604001516001600160a01b0316815250945050505050611b68565b6040518060600160405280600081526020016000815260200160006001600160a01b031681525090509392505050565b60008084600f546127d291906149ab565b90508281101561282f5760405162461bcd60e51b815260206004820152602260248201527f4b6579776f726420646973636f756e7420657863656564732074686520707269604482015261636560f01b6064820152608401610ea6565b6010548110156128905760405162461bcd60e51b815260206004820152602660248201527f546f6b656e2d626173656420646973636f756e7420657863656564732074686560448201526520707269636560d01b6064820152608401610ea6565b8084158015906128a25750601f548511155b80156128ae5750856001145b80156128cd57506016546128cd9033906001600160a01b031687613245565b1561293f576010546128df9083614808565b905080341061293a576001601f6128f68288614808565b81548110612906576129066147cd565b90600052602060002090602091828204019190066101000a81548160ff021916908315150217905550600192505050611b68565b612963565b83156129635761294f8483614808565b905080341061296357600192505050611b68565b81341061297557600192505050611b68565b50600095945050505050565b6001600160a01b0384166129ab576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6000806129b88585613439565b9150915061109a6000878484876131e0565b6002600e54036129ed57604051633ee5aeb560e01b815260040160405180910390fd5b6002600e55565b6129fc613461565b6004805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051612a369190613e9e565b60405180910390a1565b6110f783846001600160a01b031663a9059cbb8585604051602401612a66929190613c78565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050613486565b602090810291909101015190565b600033321480612ab85750601e5460ff165b612af45760405162461bcd60e51b815260206004820152600d60248201526c4e6f20636f6e7472616374732160981b6044820152606401610ea6565b6014541580612b475750612b47612b0a336130c5565b8585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060145491506130e79050565b80612b595750612b59612b0a886130c5565b612b955760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610ea6565b85516000805b82811015612ec9576000898281518110612bb757612bb76147cd565b602002602001015111612bf95760405162461bcd60e51b815260206004820152600a602482015269125b9d985b1a5908125160b21b6044820152606401610ea6565b612c1b898281518110612c0e57612c0e6147cd565b60200260200101516134ee565b612c515760405162461bcd60e51b81526020600482015260076024820152664e6f2073616c6560c81b6044820152606401610ea6565b612ca4601a60008b8481518110612c6a57612c6a6147cd565b602002602001015181526020019081526020016000206040518060400160405290816000820154815260200160018201548152505061353a565b612cdd5760405162461bcd60e51b815260206004820152600a60248201526957726f6e672074696d6560b01b6044820152606401610ea6565b601260008a8381518110612cf357612cf36147cd565b602002602001015181526020019081526020016000205460001480612d895750601260008a8381518110612d2957612d296147cd565b6020026020010151815260200190815260200160002054888281518110612d5257612d526147cd565b6020026020010151612d7c8b8481518110612d6f57612d6f6147cd565b6020026020010151611bc8565b612d869190614765565b11155b612da55760405162461bcd60e51b8152600401610ea690614968565b601360008a8381518110612dbb57612dbb6147cd565b602002602001015181526020019081526020016000205460001480612e525750601360008a8381518110612df157612df16147cd565b6020026020010151815260200190815260200160002054888281518110612e1a57612e1a6147cd565b6020026020010151612e458c8c8581518110612e3857612e386147cd565b6020026020010151610d85565b612e4f9190614765565b11155b612e9a5760405162461bcd60e51b815260206004820152601960248201527852656163686564207065722d77616c6c6574206c696d69742160381b6044820152606401610ea6565b878181518110612eac57612eac6147cd565b602002602001015182612ebf9190614765565b9150600101612b9b565b5098975050505050505050565b6001600160a01b038416612f00576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6110be6000858585856131e0565b6001600160a01b038316612f37576000604051626a0d4560e21b8152600401610ea69190613e9e565b600080612f448484613439565b9150915061130b8560008484604051806020016040528060008152506131e0565b612f6d61357d565b6004805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612a293390565b6001600160a01b038216612fcb57600060405162ced3e160e81b8152600401610ea69190613e9e565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60008061304485611d4f565b9050600061305160075490565b90506000821161309b5760405162461bcd60e51b81526020600482015260156024820152744163636f756e7420686173206e6f2073686172657360581b6044820152606401610ea6565b83816130a784886149ab565b6130b191906149c2565b6130bb9190614808565b9695505050505050565b6040516001600160601b0319606083901b166020820152600090603401610f6b565b6000611c6e8383866135a1565b6001600160a01b03841661311e576000604051632bfa23e760e11b8152600401610ea69190613e9e565b6001600160a01b038516613147576000604051626a0d4560e21b8152600401610ea69190613e9e565b6000806131548585613439565b9150915061233787878484876131e0565b60006001600160e01b03198216636cdb3d1360e11b148061319657506001600160e01b031982166303a24d0760e21b145b80610da757506301ffc9a760e01b6001600160e01b0319831614610da7565b6131bf8282611a92565b610dd957808260405163e2517d3f60e01b8152600401610ea6929190613c78565b6131ec858585856135b7565b6001600160a01b0384161561130b57825133906001036132375760006132128582612a98565b905060006132208582612a98565b90506132308389898585896135c3565b505061109a565b61109a8187878787876136d5565b601f54600090821115806132935750601f613261600184614808565b81548110613271576132716147cd565b60009182526020918290209181049091015460ff601f9092166101000a900416155b6132d95760405162461bcd60e51b81526020600482015260176024820152761a5b9d985b1a5908191a5cd8dbdd5b9d151bdad95b9259604a1b6044820152606401610ea6565b6016546040516024810184905260009182916001600160a01b03871691600160a01b900460e01b9060440160408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516133429190614778565b6000604051808303816000865af19150503d806000811461337f576040519150601f19603f3d011682016040523d82523d6000602084013e613384565b606091505b5091509150816133c55760405162461bcd60e51b815260206004820152600c60248201526b1bdddb995c93d98819985a5b60a21b6044820152606401610ea6565b856001600160a01b03166133da826020015190565b6001600160a01b03161461342d5760405162461bcd60e51b815260206004820152601a6024820152793234b9b1b7bab73a2a37b5b2b71d103bb937b7339037bbb732b960311b6044820152606401610ea6565b50600195945050505050565b6040805160018082526020820194909452808201938452606081019290925260808201905291565b60045460ff1661348457604051638dfc202b60e01b815260040160405180910390fd5b565b600080602060008451602086016000885af1806134a9576040513d6000823e3d81fd5b50506000513d915081156134c15780600114156134ce565b6001600160a01b0384163b155b156110be5783604051635274afe760e01b8152600401610ea69190613e9e565b6000805b601754811015613531578260178281548110613510576135106147cd565b9060005260206000200154036135295750600192915050565b6001016134f2565b50600092915050565b8051600090158061354c575081514210155b8015613568575060208201511580613568575042826020015110155b1561357557506001919050565b506000919050565b60045460ff16156134845760405163d93c066560e01b815260040160405180910390fd5b6000826135ae85846137b5565b14949350505050565b6110be848484846137f0565b6001600160a01b0384163b1561109a5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061360790899089908890889088906004016149e4565b6020604051808303816000875af1925050508015613642575060408051601f3d908101601f1916820190925261363f91810190614a29565b60015b6136a2573d808015613670576040519150601f19603f3d011682016040523d82523d6000602084013e613675565b606091505b50805160000361369a5784604051632bfa23e760e11b8152600401610ea69190613e9e565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b146123375784604051632bfa23e760e11b8152600401610ea69190613e9e565b6001600160a01b0384163b1561109a5760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906137199089908990889088908890600401614a46565b6020604051808303816000875af1925050508015613754575060408051601f3d908101601f1916820190925261375191810190614a29565b60015b613782573d808015613670576040519150601f19603f3d011682016040523d82523d6000602084013e613675565b6001600160e01b0319811663bc197c8160e01b146123375784604051632bfa23e760e11b8152600401610ea69190613e9e565b600081815b8451811015611773576137e6828683815181106137d9576137d96147cd565b60200260200101516138f4565b91506001016137ba565b6137fc84848484613920565b6001600160a01b038416613886576000805b835181101561386c5760006138238483612a98565b905080600560006138348886612a98565b815260200190815260200160002060008282546138519190614765565b9091555061386190508184614765565b92505060010161380e565b50806006600082825461387f9190614765565b9091555050505b6001600160a01b0383166110be576000805b83518110156138e35760006138ad8483612a98565b905080600560006138be8886612a98565b8152602081019190915260400160002080549190910390559190910190600101613898565b506006805491909103905550505050565b6000818310613910576000828152602084905260409020611b68565b5060009182526020526040902090565b61392861357d565b6110be84848484805182511461395e5781518151604051635b05999160e01b815260048101929092526024820152604401610ea6565b3360005b8351811015613a6e5760006139778583612a98565b905060006139858584612a98565b90506001600160a01b03881615613a1f576000828152602081815260408083206001600160a01b038c168452909152902054818110156139f8576040516303dee4c560e01b81526001600160a01b038a166004820152602481018290526044810183905260648101849052608401610ea6565b6000838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615613a64576000828152602081815260408083206001600160a01b038b16845290915281208054839290613a5e908490614765565b90915550505b5050600101613962565b508251600103613afb576000613a848482612a98565b90506000613a928482612a98565b9050856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051613aec929190918252602082015260400190565b60405180910390a4505061130b565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051613b4a929190614aa4565b60405180910390a45050505050565b82805482825590600052602060002090601f01602090048101928215613bee5791602002820160005b83821115613bbf57835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302613b82565b8015613bec5782816101000a81549060ff0219169055600101602081600001049283019260010302613bbf565b505b50613bfa929150613c63565b5090565b828054828255906000526020600020908101928215613bee579160200282015b82811115613bee578251825591602001919060010190613c1e565b6040518060600160405280600081526020016000815260200160006001600160a01b031681525090565b5b80821115613bfa5760008155600101613c64565b6001600160a01b03929092168252602082015260400190565b600060208284031215613ca357600080fd5b5035919050565b6001600160a01b038116811461137857600080fd5b8035613cca81613caa565b919050565b60008060408385031215613ce257600080fd5b8235613ced81613caa565b946020939093013593505050565b6001600160e01b03198116811461137857600080fd5b600060208284031215613d2357600080fd5b8135611b6881613cfb565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613d6c57613d6c613d2e565b604052919050565b600082601f830112613d8557600080fd5b8135602083016000806001600160401b03841115613da557613da5613d2e565b50601f8301601f1916602001613dba81613d44565b915050828152858383011115613dcf57600080fd5b82826020830137600092810160200192909252509392505050565b600060208284031215613dfc57600080fd5b81356001600160401b03811115613e1257600080fd5b611c6e84828501613d74565b600060208284031215613e3057600080fd5b8135611b6881613caa565b60005b83811015613e56578181015183820152602001613e3e565b50506000910152565b60008151808452613e77816020860160208601613e3b565b601f01601f19169290920160200192915050565b602081526000611b686020830184613e5f565b6001600160a01b0391909116815260200190565b600080600060608486031215613ec757600080fd5b8335613ed281613caa565b95602085013595506040909401359392505050565b60006001600160401b03821115613f0057613f00613d2e565b5060051b60200190565b600082601f830112613f1b57600080fd5b8135613f2e613f2982613ee7565b613d44565b8082825260208201915060208360051b860101925085831115613f5057600080fd5b602085015b83811015613f6d578035835260209283019201613f55565b5095945050505050565b600080600080600060a08688031215613f8f57600080fd5b8535613f9a81613caa565b94506020860135613faa81613caa565b935060408601356001600160401b03811115613fc557600080fd5b613fd188828901613f0a565b93505060608601356001600160401b03811115613fed57600080fd5b613ff988828901613f0a565b92505060808601356001600160401b0381111561401557600080fd5b61402188828901613d74565b9150509295509295909350565b6000806040838503121561404157600080fd5b82359150602083013561405381613caa565b809150509250929050565b60008083601f84011261407057600080fd5b5081356001600160401b0381111561408757600080fd5b6020830191508360208260051b85010111156140a257600080fd5b9250929050565b60008060008060008060008060e0898b0312156140c557600080fd5b88356140d081613caa565b975060208901359650604089013595506060890135945060808901356001600160401b0381111561410057600080fd5b61410c8b828c01613d74565b94505060a08901356001600160401b0381111561412857600080fd5b6141348b828c0161405e565b90945092505060c08901356001600160401b0381111561415357600080fd5b61415f8b828c01613d74565b9150509295985092959890939650565b80358015158114613cca57600080fd5b60008060006060848603121561419457600080fd5b83356001600160401b038111156141aa57600080fd5b6141b686828701613f0a565b93505060208401356001600160401b038111156141d257600080fd5b6141de86828701613f0a565b9250506141ed6040850161416f565b90509250925092565b6000806040838503121561420957600080fd5b823561421481613caa565b9150602083013561405381613caa565b60008060006060848603121561423957600080fd5b83359250602084013563ffffffff8116811461425457600080fd5b91506141ed6040850161416f565b6000806040838503121561427557600080fd5b82356001600160401b0381111561428b57600080fd5b8301601f8101851361429c57600080fd5b80356142aa613f2982613ee7565b8082825260208201915060208360051b8501019250878311156142cc57600080fd5b6020840193505b828410156142f75783356142e681613caa565b8252602093840193909101906142d3565b945050505060208301356001600160401b0381111561431557600080fd5b61432185828601613f0a565b9150509250929050565b600081518084526020840193506020830160005b8281101561435d57815186526020958601959091019060010161433f565b5093949350505050565b602081526000611b68602083018461432b565b60008060008060008060008060e0898b03121561439657600080fd5b61439f89613cbf565b975060208901356001600160401b038111156143ba57600080fd5b6143c68b828c01613f0a565b97505060408901356001600160401b038111156143e257600080fd5b6143ee8b828c01613f0a565b9650506060890135945060808901356001600160401b0381111561410057600080fd5b60008060006060848603121561442657600080fd5b83359250602084013561443881613caa565b929592945050506040919091013590565b6000806040838503121561445c57600080fd5b82356001600160401b0381111561447257600080fd5b61447e85828601613d74565b95602094909401359450505050565b600080604083850312156144a057600080fd5b82356144ab81613caa565b91506144b96020840161416f565b90509250929050565b600080604083850312156144d557600080fd5b823591506144b96020840161416f565b600080604083850312156144f857600080fd5b50508035926020909101359150565b60008060006060848603121561451c57600080fd5b505081359360208301359350604090920135919050565b6000806000806080858703121561454957600080fd5b843561455481613caa565b9350602085013592506040850135915060608501356001600160401b0381111561457d57600080fd5b61458987828801613d74565b91505092959194509250565b60008060008060008060a087890312156145ae57600080fd5b86356001600160401b038111156145c457600080fd5b6145d089828a01613d74565b96505060208701356145e181613caa565b94506145ef6040880161416f565b935060608701356001600160401b0381111561460a57600080fd5b61461689828a0161405e565b979a9699509497949695608090950135949350505050565b600080600080600060a0868803121561464657600080fd5b853561465181613caa565b9450602086013561466181613caa565b9350604086013592506060860135915060808601356001600160401b0381111561401557600080fd5b600181811c9082168061469e57607f821691505b602082108103611b0457634e487b7160e01b600052602260045260246000fd5b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610da757610da761474f565b6000825161478a818460208701613e3b565b9190910192915050565b6001600160a01b0392831681529116602082015260400190565b602080825260059082015264507269636560d81b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6020808252600b908201526a73616c654d61784c6f636b60a81b604082015260600190565b81810381811115610da757610da761474f565b601f8211156110f757806000526020600020601f840160051c810160208510156148425750805b601f840160051c820191505b8181101561130b576000815560010161484e565b81516001600160401b0381111561487b5761487b613d2e565b61488f81614889845461468a565b8461481b565b6020601f8211600181146148c357600083156148ab5750848201515b600019600385901b1c1916600184901b17845561130b565b600084815260208120601f198516915b828110156148f357878501518255602094850194600190920191016148d3565b50848210156149115786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b60006020828403121561493257600080fd5b5051919050565b602080825260159082015274125b9d985b1a59081d1bdad95b881d1e5c19481251605a1b604082015260600190565b60208082526010908201526f14dd5c1c1b1e48195e1a185d5cdd195960821b604082015260600190565b6000600182016149a4576149a461474f565b5060010190565b8082028115828204841417610da757610da761474f565b6000826149df57634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090614a1e90830184613e5f565b979650505050505050565b600060208284031215614a3b57600080fd5b8151611b6881613cfb565b6001600160a01b0386811682528516602082015260a060408201819052600090614a729083018661432b565b8281036060840152614a84818661432b565b90508281036080840152614a988185613e5f565b98975050505050505050565b604081526000614ab7604083018561432b565b8281036020840152614ac9818561432b565b9594505050505056fedfba9a3606cffcfda39d36eb9952d33729f3db2d78aee4695e084cd2295afeb65d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108eca49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775deccffc5821b949817830292498e44ccb6097e4b74ff2f2db960723873324defa264697066735822122084e146f636b72e0ce698f2b0839b02272f627ff627788e21fc3dc8ee5c316b2764736f6c634300081b0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000003f697066733a2f2f516d6266763247786a585468554e6d753961597255464e6d684b576b5077784448754c76324456614871515746372f7b69647d2e6a736f6e000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000ba8317f0da687b85b86bb3ba5ab48619df2921b50000000000000000000000000bce18970a171d93f015e8278359fc5021166f2e000000000000000000000000cbd1bdda4cf44c05dea8deee537ab3a01a1ae6e4000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000a
-----Decoded View---------------
Arg [0] : uri_ (string): ipfs://Qmbfv2GxjXThUNmu9aYrUFNmhKWkPwxDHuLv2DVaHqQWF7/{id}.json
Arg [1] : _payees (address[]): 0xbA8317F0DA687b85b86Bb3Ba5ab48619df2921b5,0x0BCe18970A171D93F015E8278359Fc5021166F2E,0xcbD1bdDA4cf44C05deA8deeE537ab3a01a1aE6E4
Arg [2] : _shares (uint256[]): 70,20,10
-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [3] : 000000000000000000000000000000000000000000000000000000000000003f
Arg [4] : 697066733a2f2f516d6266763247786a585468554e6d753961597255464e6d68
Arg [5] : 4b576b5077784448754c76324456614871515746372f7b69647d2e6a736f6e00
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [7] : 000000000000000000000000ba8317f0da687b85b86bb3ba5ab48619df2921b5
Arg [8] : 0000000000000000000000000bce18970a171d93f015e8278359fc5021166f2e
Arg [9] : 000000000000000000000000cbd1bdda4cf44c05dea8deee537ab3a01a1ae6e4
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000046
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000014
Arg [13] : 000000000000000000000000000000000000000000000000000000000000000a
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.