ERC-20
Overview
Max Total Supply
6,969 PLT
Holders
2,173
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
3.033333333 PLTValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Source Code Verified (Exact Match)
Contract Name:
Palette
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 10000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /// @dev Core abstracts of Palette. import { ERC404U16 } from "./404/ERC404U16.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; /// @dev Helper libraries to ensure seamless integration. import { LibPalette } from "./libraries/Palette.Lib.sol"; import { MerkleProofLib } from "solady/src/utils/MerkleProofLib.sol"; import { SafeTransferLib } from "solady/src/utils/SafeTransferLib.sol"; import { LibString } from "solady/src/utils/LibString.sol"; /// @dev Reference interfaces for consumption. import { PaletteRenderer } from "./interfaces/PaletteRenderer.sol"; /** * @title Palette: 🟦🟪🟨🟥 * @notice An experimental ERC404 token with phased airdrop claims that combines * the best of ERC20 and ERC721 into a single contract. * @author artist: cfw (@iamcfw) * @author art dev: orbism (@ArtofOrb) * @author contract dev: nftchance (@nftchance | [email protected]) */ contract Palette is ERC404U16, Ownable { using LibString for uint256; using MerkleProofLib for bytes32[]; /// @dev The maximum total of ERC20 tokens that can exist. /// @dev Each ERC721 is an underlying definition of 10 ** 18 ERC20 tokens. uint256 public constant MAX_TOTAL_SUPPLY = 6969 * 10 ** 18; /// @dev Amount of creator owned liquidity. uint256 public constant SUPPLY_RETAINED = 2869 * 10 ** 18; /// @dev The URL to the metadata for the tokenURI. string public baseTokenURI; /// @dev Slot for contract render. PaletteRenderer public renderer; /// @dev State var to control the first and only state change of trading. /// @dev Once started, trading cannot be stopped. bool public tradingStarted; /// @dev Control over the active airdrop phases. mapping(uint256 => LibPalette.Phase) public phases; /// @dev Track the amounts that have been claimed by each address. mapping(uint256 => mapping(address => uint256)) phaseToAddressToClaimed; /** * @dev Modifier to check if a phase is still open. * @param $phaseIndex The index of the phase to check. */ modifier onlyOpenPhase(uint256 $phaseIndex) { uint32 end = phases[$phaseIndex].endTime; /// @dev Make sure the phase is still open. if (end > 0) { if (end < block.timestamp) { revert LibPalette.PhaseClosed(); } } _; } /** * @dev Modifier to check if a phase is active. * @param $phaseIndex The index of the phase to check. */ modifier onlyActivePhase(uint256 $phaseIndex) { /// @dev Pull the phase out of storage. LibPalette.Phase storage phase = phases[$phaseIndex]; /// @dev Make sure the phase has started. if (block.timestamp < phase.startTime) revert LibPalette.PhasePending(); /// @dev Make sure the phase is still open. if (phase.endTime < block.timestamp) revert LibPalette.PhaseClosed(); /// @dev Make sure the phase has a valid merkle root. if (phase.merkleRoot == 0) revert LibPalette.PhaseInvalid(); _; } /** * @dev Modifier to check if a proof and amount being claimed is valid. * @param $phaseIndex The index of the phase to check. * @param $proof The merkle proof to validate the mint. * @param $claimer The address that is claiming the mint. * @param $amount The amount that was allocated to the caller. * @param $price The price of minting a token. * @param $claim The amount that the caller is claiming. * @param $payment The amount that the caller is paying. */ modifier onlyValidClaim( uint256 $phaseIndex, bytes32[] calldata $proof, address $claimer, uint256 $amount, uint256 $price, uint256 $claim, uint256 $payment ) { /// @dev Prevent the max supply from being exceeded. if (MAX_TOTAL_SUPPLY < totalSupply + $claim) { revert LibPalette.SupplyInsufficient(); } /// @dev Verify the proof and calculate the amount that remains claimable. (bool proven, uint256 claimable) = prove($phaseIndex, $proof, $claimer, $amount, $price); /// @dev Prevent an address from providing an invalid proof. if (proven == false) { revert LibPalette.ProofInvalid(); } /// @dev Prevent an address from claiming more than they are allocated. if ($claim > claimable) { revert LibPalette.ProofInsufficient(); } /// @dev Prevent an address from claiming an insanely small piece. if($claim < 10 ** 6) { revert LibPalette.ClaimInsufficient(); } /// @dev Ensure the caller has paid the correct amount. if ($payment < price($claim, $price)) { revert LibPalette.ValueInsufficient(); } /// @dev Update the amount that has been claimed by the address. phaseToAddressToClaimed[$phaseIndex][$claimer] += $claim; _; } /** * @dev Modifier to check if trading is ready. * @param $from The address to transfer from. */ modifier onlyTrading(address $from) { /// @dev Check if trading has been enabled yet. if (tradingStarted == false) { /// @dev Exempt mints as well as transfers from the owner. if ($from != address(0) && $from != owner()) { revert LibPalette.TokenLoading(); } } _; } /// @dev Initialize Palette. constructor( address $owner, string memory $baseTokenURI, string memory $name, string memory $symbol, uint8 $decimals ) ERC404U16($name, $symbol, $decimals) Ownable($owner) { /// @dev Set the base token URI. baseTokenURI = $baseTokenURI; /// @dev Set the owner as 721 exempt to avoid gas consumption. _setERC721TransferExempt($owner, true); /// @dev Mint the initial supply to the owner that will be used /// to seed the liquidity pool. _mintERC20($owner, SUPPLY_RETAINED); } /** * @notice Allow the owner to set a new airdrop phase with a new merkle root. * @dev Allows you to set `startBlock` in the past so that no RPC nodes or frontends * error in response to a delayed or cached response. If a phase is set, it is * good to go until it is closed. * @param $phaseIndex The index of the phase to set. * @param $phase The phase to set. */ function setPhase( uint256 $phaseIndex, LibPalette.Phase memory $phase ) public onlyOwner onlyOpenPhase($phaseIndex) { /// @dev Prevent the initialization of an invalid phase. if ($phase.merkleRoot == 0) revert LibPalette.PhaseInvalid(); /// @dev Write the phase into record. phases[$phaseIndex] = $phase; } /** * @notice Allow the owner to close a phase. * @dev Once a phase is closed, it cannot be reopened. By default, when the `endBlock` * time is reached, the phase will automatically be closed however it can be * manually closed by the owner early if desired. * @param $phaseIndex The index of the phase to close. */ function closePhase(uint256 $phaseIndex) public onlyOwner onlyOpenPhase($phaseIndex) { /// @dev Close the phase preventing any future mints. We look /// back one block so that no one can mint in the same block /// that it is closed. phases[$phaseIndex].endTime = uint32(block.timestamp - 1); } /** * @notice Allow users to mint a piece of the airdrop. * @dev This function is only available during the active phase and will mint * the user the declared amount of their allocation in the phase. * @param $phaseIndex The index of the phase to mint from. * @param $proof The merkle proof to validate the mint. * @param $amount The amount that was allocated to the caller. * @param $price The price of minting a token. * @param $claim The amount that the caller is claiming. */ function mint( uint256 $phaseIndex, bytes32[] calldata $proof, uint256 $amount, uint256 $price, uint256 $claim ) public payable onlyActivePhase($phaseIndex) onlyValidClaim( $phaseIndex, $proof, msg.sender, $amount, $price, $claim, msg.value ) { /// @dev Mint an amount of the ERC20 to the caller. _mintERC20(msg.sender, $claim); } /** * @notice Allow the owner to set the ERC721 transfer exempt status. * @dev This function is only available to the owner and enables the ability * to prevent NFT conversion for specific addresses. * @dev This is used for the liquidity pool as well as a few other instances. * @param $account The account to set the ERC721 transfer exempt status of. * @param $value The value to set the ERC721 transfer exempt status to. */ function setERC721TransferExempt( address $account, bool $value ) public onlyOwner { /// @dev Control the fractionalization whitelist. _setERC721TransferExempt($account, $value); } /** * @notice Allow the owner to set the base token URI. * @dev This function is only available to the owner and enables the ability * to set the base token URI for the tokenURI. * @param $uri The URI to set as the base token URI. */ function setBaseTokenURI(string memory $uri) public onlyOwner { baseTokenURI = $uri; } /** * @notice Allow the owner to set the renderer for the tokenURI. * @dev This function is only available to the owner and enables the ability * to set the renderer for the tokenURI. * @param $renderer The address of the renderer to set. */ function setRenderer(address $renderer) public onlyOwner { /// @dev Set the renderer for the tokenURI. renderer = PaletteRenderer($renderer); /// @dev Disconnect the Renderer from this contract. if (address(renderer) != address(0)) { renderer.disconnect(); } } /** * @notice Allow the owner to set the trading status and bypass the max * supply check removing the need to wait until the max supply is * reached before trading can begin. */ function setTradingStarted() public onlyOwner { tradingStarted = true; } /** * @notice Allow the owner to withdraw the contract balance. */ function withdraw() public onlyOwner { SafeTransferLib.safeTransferETH(owner(), address(this).balance); } /** * @notice Calculate and return the price of a mint. * @param $amount The amount of the ERC20 to calculate the price of. * @param $pricePerToken The price of minting a token. * @return $price The price of the mint. */ function price( uint256 $amount, uint256 $pricePerToken ) public view returns (uint256 $price) { /// @dev Calculate the price of the mint. $price = ($amount * $pricePerToken) / units; } /** * @notice Return the active phase. * @dev This is just a function that can be read offchain to easily determine * the active phase without having to store more state. * @dev An uninformed cap of 60 phases is set to prevent gas exhaustion. There is * no reason for having chosen this amount beyond it being extremely unlikely * that we would ever need more than 60 phases while still allowing extreme * granularity. * @return $phaseIndex The index of the active phase. * @return $phase The active phase. */ function active() public view returns (uint256 $phaseIndex, LibPalette.Phase memory $phase) { /// @dev Loop through the phase mapping and find the active phase. for (uint256 i; i < 60; i++) { /// @dev Make sure the phase is actually active. if ( phases[i].startTime < block.timestamp && phases[i].endTime > block.timestamp ) { return (i, phases[i]); } } /// @dev Serve the maximum value as a flag that no phase is active. return (type(uint256).max, $phase); } /** * @notice Return the active status of a specific phase. * @param $phaseIndex The index of the phase to check. * @return $active The active status of the phase. */ function active(uint256 $phaseIndex) public view returns (bool $active) { $active = phases[$phaseIndex].startTime < block.timestamp && phases[$phaseIndex].endTime > block.timestamp; } /** * @notice Pure function to access internally and externally enabling the * ability to verify a proof onchain and offchain before use. * @param $phaseIndex The index of the phase to verify. * @param $proof The merkle proof to validate the mint. * @param $claimer The address that is claiming the mint. * @param $amount The amount that was allocated to the caller. * @param $price The price of minting a token. */ function prove( uint256 $phaseIndex, bytes32[] calldata $proof, address $claimer, uint256 $amount, uint256 $price ) public view returns (bool $proven, uint256 $claimable) { /// @dev Verify the proof provided is a valid leaf in the merkle tree. $proven = $proof.verifyCalldata( phases[$phaseIndex].merkleRoot, keccak256(abi.encode($claimer, $amount, $price)) ); /// @dev Calculate the amount that remains claimable. if ($proven) { $claimable = $amount - phaseToAddressToClaimed[$phaseIndex][$claimer]; } } /** * @notice ERC721 metadata for tokenURI to return image. * @param $id The id of the token to return the image for. * @return $uri The URI of the token to return the image for. */ function tokenURI(uint256 $id) public view override returns (string memory) { /// @dev Make sure the token has an owner (ie: it exists). if (_getOwnerOf($id) == address(0)) revert LibPalette.TokenInvalid(); /// @dev The token ID without the encoding shift. uint256 tokenId = $id - (1 << 255); /// @dev If the renderer has been initialized, use the renderer. if (address(renderer) != address(0)) { return renderer.render($id); } /// @dev If the static metadata has not yet been initialized, use the prereveal. bytes memory uriBytes = bytes(baseTokenURI); uint256 length = uriBytes.length; if (length > 0 && uriBytes[length - 1] != 0x2F) { return baseTokenURI; } /// @dev When the renderer has not yet been initialized, use the static. return string.concat(baseTokenURI, tokenId.toString()); } /** * @notice ERC20 trading prevention until the time is ready. * @param $from The address to transfer from. * @param $to The address to transfer to. * @param $value The amount to transfer. */ function _transferERC20( address $from, address $to, uint256 $value ) internal override onlyTrading($from) { super._transferERC20($from, $to, $value); } /** * @notice ERC721 trading prevention until the time is ready. * @dev Realistically this should never be hit, but it is here just * to handle edge-cases where the ERC721 is being transferred * before the ERC20 is ready to be traded. * @param $from The address to transfer from. * @param $to The address to transfer to. * @param $id The id to transfer. */ function _transferERC721( address $from, address $to, uint256 $id ) internal override onlyTrading($from) { super._transferERC721($from, $to, $id); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IERC721Receiver } from "@openzeppelin/contracts/interfaces/IERC721Receiver.sol"; import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol"; import { IERC404 } from "./interfaces/IERC404.sol"; import { PackedDoubleEndedQueue } from "./lib/PackedDoubleEndedQueue.sol"; import { ERC721Events } from "./lib/ERC721Events.sol"; import { ERC20Events } from "./lib/ERC20Events.sol"; /// @dev This is an optimized ERC404 implementation designed to support smaller collections, /// with id's up to a maximum of 65535. abstract contract ERC404U16 is IERC404 { using PackedDoubleEndedQueue for PackedDoubleEndedQueue.Uint16Deque; /// @dev The queue of ERC-721 tokens stored in the contract. PackedDoubleEndedQueue.Uint16Deque private _storedERC721Ids; /// @dev Token name string public name; /// @dev Token symbol string public symbol; /// @dev Decimals for ERC-20 representation uint8 public immutable decimals; /// @dev Units for ERC-20 representation uint256 public immutable units; /// @dev Total supply in ERC-20 representation uint256 public totalSupply; /// @dev Current mint counter which also represents the highest /// minted id, monotonically increasing to ensure accurate ownership uint256 public minted; /// @dev Initial chain id for EIP-2612 support uint256 internal immutable _INITIAL_CHAIN_ID; /// @dev Initial domain separator for EIP-2612 support bytes32 internal immutable _INITIAL_DOMAIN_SEPARATOR; /// @dev Balance of user in ERC-20 representation mapping(address => uint256) public balanceOf; /// @dev Allowance of user in ERC-20 representation mapping(address => mapping(address => uint256)) public allowance; /// @dev Approval in ERC-721 representaion mapping(uint256 => address) public getApproved; /// @dev Approval for all in ERC-721 representation mapping(address => mapping(address => bool)) public isApprovedForAll; /// @dev Packed representation of ownerOf and owned indices mapping(uint256 => uint256) internal _ownedData; /// @dev Array of owned ids in ERC-721 representation mapping(address => uint16[]) internal _owned; /// @dev Addresses that are exempt from ERC-721 transfer, typically for gas savings (pairs, routers, etc) mapping(address => bool) internal _erc721TransferExempt; /// @dev EIP-2612 nonces mapping(address => uint256) public nonces; /// @dev Address bitmask for packed ownership data uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; /// @dev Owned index bitmask for packed ownership data uint256 private constant _BITMASK_OWNED_INDEX = ((1 << 96) - 1) << 160; /// @dev Constant for token id encoding uint256 public constant ID_ENCODING_PREFIX = 1 << 255; constructor(string memory name_, string memory symbol_, uint8 decimals_) { name = name_; symbol = symbol_; if (decimals_ < 18) { revert DecimalsTooLow(); } decimals = decimals_; units = 10 ** decimals; // EIP-2612 initialization _INITIAL_CHAIN_ID = block.chainid; _INITIAL_DOMAIN_SEPARATOR = _computeDomainSeparator(); } /// @notice Function to find owner of a given ERC-721 token function ownerOf(uint256 id_) public view virtual returns (address erc721Owner) { erc721Owner = _getOwnerOf(id_); // If the id_ is beyond the range of minted tokens, is 0, or the token is not owned by anyone, revert. if (id_ <= ID_ENCODING_PREFIX || erc721Owner == address(0)) { revert NotFound(); } } function owned(address owner_) public view virtual returns (uint256[] memory) { uint256[] memory ownedAsU256 = new uint256[](_owned[owner_].length); for (uint256 i = 0; i < _owned[owner_].length;) { ownedAsU256[i] = ID_ENCODING_PREFIX + _owned[owner_][i]; unchecked { ++i; } } return ownedAsU256; } function erc721BalanceOf(address owner_) public view virtual returns (uint256) { return _owned[owner_].length; } function erc20BalanceOf(address owner_) public view virtual returns (uint256) { return balanceOf[owner_]; } function erc20TotalSupply() public view virtual returns (uint256) { return totalSupply; } function erc721TotalSupply() public view virtual returns (uint256) { return minted; } function getERC721QueueLength() public view virtual returns (uint256) { return _storedERC721Ids.length(); } function getERC721TokensInQueue( uint256 start_, uint256 count_ ) public view virtual returns (uint256[] memory) { uint256[] memory tokensInQueue = new uint256[](count_); for (uint256 i = start_; i < start_ + count_;) { tokensInQueue[i - start_] = ID_ENCODING_PREFIX + _storedERC721Ids.at(i); unchecked { ++i; } } return tokensInQueue; } /// @notice tokenURI must be implemented by child contract function tokenURI(uint256 id_) public view virtual returns (string memory); /// @notice Function for token approvals /// @dev This function assumes the operator is attempting to approve an ERC-721 /// if valueOrId is less than the minted count. Unlike setApprovalForAll, /// spender_ must be allowed to be 0x0 so that approval can be revoked. function approve( address spender_, uint256 valueOrId_ ) public virtual returns (bool) { // The ERC-721 tokens are 1-indexed, so 0 is not a valid id and indicates that // operator is attempting to set the ERC-20 allowance to 0. if (valueOrId_ > ID_ENCODING_PREFIX && valueOrId_ != type(uint256).max) { erc721Approve(spender_, valueOrId_); } else { return erc20Approve(spender_, valueOrId_); } return true; } function erc721Approve(address spender_, uint256 id_) public virtual { // Intention is to approve as ERC-721 token (id). address erc721Owner = _getOwnerOf(id_); if ( msg.sender != erc721Owner && !isApprovedForAll[erc721Owner][msg.sender] ) { revert Unauthorized(); } getApproved[id_] = spender_; emit ERC721Events.Approval(erc721Owner, spender_, id_); } /// @dev Providing type(uint256).max for approval value results in an /// unlimited approval that is not deducted from on transfers. function erc20Approve( address spender_, uint256 value_ ) public virtual returns (bool) { // Prevent granting 0x0 an ERC-20 allowance. if (spender_ == address(0)) { revert InvalidSpender(); } // Intention is to approve as ERC-20 token (value). allowance[msg.sender][spender_] = value_; emit ERC20Events.Approval(msg.sender, spender_, value_); return true; } /// @notice Function for ERC-721 approvals function setApprovalForAll( address operator_, bool approved_ ) public virtual { // Prevent approvals to 0x0. if (operator_ == address(0)) { revert InvalidOperator(); } isApprovedForAll[msg.sender][operator_] = approved_; emit ERC721Events.ApprovalForAll(msg.sender, operator_, approved_); } /// @notice Function for mixed transfers from an operator that may be different than 'from'. /// @dev This function assumes the operator is attempting to transfer an ERC-721 /// if valueOrId is less than or equal to current max id. function transferFrom( address from_, address to_, uint256 valueOrId_ ) public virtual returns (bool) { if (valueOrId_ > ID_ENCODING_PREFIX) { erc721TransferFrom(from_, to_, valueOrId_); } else { // Intention is to transfer as ERC-20 token (value). return erc20TransferFrom(from_, to_, valueOrId_); } return true; } /// @notice Function for ERC-721 transfers from. /// @dev This function is recommended for ERC721 transfers function erc721TransferFrom( address from_, address to_, uint256 id_ ) public virtual { // Prevent transferring tokens from 0x0. if (from_ == address(0)) { revert InvalidSender(); } // Prevent burning tokens to 0x0. if (to_ == address(0)) { revert InvalidRecipient(); } if (from_ != _getOwnerOf(id_)) { revert Unauthorized(); } // Check that the operator is either the sender or approved for the transfer. if ( msg.sender != from_ && !isApprovedForAll[from_][msg.sender] && msg.sender != getApproved[id_] ) { revert Unauthorized(); } if (erc721TransferExempt(to_)) { revert RecipientIsERC721TransferExempt(); } // Transfer 1 * units ERC-20 and 1 ERC-721 token. // ERC-721 transfer exemptions handled above. Can't make it to this point if either is transfer exempt. _transferERC20(from_, to_, units); _transferERC721(from_, to_, id_); } /// @notice Function for ERC-20 transfers from. /// @dev This function is recommended for ERC20 transfers function erc20TransferFrom( address from_, address to_, uint256 value_ ) public virtual returns (bool) { // Prevent transferring tokens from 0x0. if (from_ == address(0)) { revert InvalidSender(); } // Prevent burning tokens to 0x0. if (to_ == address(0)) { revert InvalidRecipient(); } // Intention is to transfer as ERC-20 token (value). uint256 allowed = allowance[from_][msg.sender]; // Check that the operator has sufficient allowance. if (allowed != type(uint256).max) { allowance[from_][msg.sender] = allowed - value_; } // Transferring ERC-20s directly requires the _transfer function. // Handles ERC-721 exemptions internally. return _transferERC20WithERC721(from_, to_, value_); } /// @notice Function for ERC-20 transfers. /// @dev This function assumes the operator is attempting to transfer as ERC-20 /// given this function is only supported on the ERC-20 interface. /// Treats even small amounts that are valid ERC-721 ids as ERC-20s. function transfer( address to_, uint256 value_ ) public virtual returns (bool) { // Prevent burning tokens to 0x0. if (to_ == address(0)) { revert InvalidRecipient(); } // Transferring ERC-20s directly requires the _transfer function. // Handles ERC-721 exemptions internally. return _transferERC20WithERC721(msg.sender, to_, value_); } /// @notice Function for ERC-721 transfers with contract support. /// This function only supports moving valid ERC-721 ids, as it does not exist on the ERC-20 /// spec and will revert otherwise. function safeTransferFrom( address from_, address to_, uint256 id_ ) public virtual { safeTransferFrom(from_, to_, id_, ""); } /// @notice Function for ERC-721 transfers with contract support and callback data. /// This function only supports moving valid ERC-721 ids, as it does not exist on the /// ERC-20 spec and will revert otherwise. function safeTransferFrom( address from_, address to_, uint256 id_, bytes memory data_ ) public virtual { if (id_ <= ID_ENCODING_PREFIX) { revert InvalidTokenId(); } transferFrom(from_, to_, id_); if ( to_.code.length != 0 && IERC721Receiver(to_).onERC721Received( msg.sender, from_, id_, data_ ) != IERC721Receiver.onERC721Received.selector ) { revert UnsafeRecipient(); } } /// @notice Function for EIP-2612 permits /// @dev Providing type(uint256).max for permit value results in an /// unlimited approval that is not deducted from on transfers. function permit( address owner_, address spender_, uint256 value_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_ ) public virtual { if (deadline_ < block.timestamp) { revert PermitDeadlineExpired(); } if (value_ > ID_ENCODING_PREFIX && value_ != type(uint256).max) { revert InvalidApproval(); } if (spender_ == address(0)) { revert InvalidSpender(); } unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner_, spender_, value_, nonces[owner_]++, deadline_ ) ) ) ), v_, r_, s_ ); if (recoveredAddress == address(0) || recoveredAddress != owner_) { revert InvalidSigner(); } allowance[recoveredAddress][spender_] = value_; } emit ERC20Events.Approval(owner_, spender_, value_); } /// @notice Returns domain initial domain separator, or recomputes if chain id is not equal to initial chain id function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == _INITIAL_CHAIN_ID ? _INITIAL_DOMAIN_SEPARATOR : _computeDomainSeparator(); } function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC404).interfaceId || interfaceId == type(IERC165).interfaceId; } /// @notice Function for self-exemption function setSelfERC721TransferExempt(bool state_) public virtual { _setERC721TransferExempt(msg.sender, state_); } /// @notice Function to check if address is transfer exempt function erc721TransferExempt(address target_) public view virtual returns (bool) { return target_ == address(0) || _erc721TransferExempt[target_]; } /// @notice Internal function to compute domain separator for EIP-2612 permits function _computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /// @notice This is the lowest level ERC-20 transfer function, which /// should be used for both normal ERC-20 transfers as well as minting. /// Note that this function allows transfers to and from 0x0. function _transferERC20( address from_, address to_, uint256 value_ ) internal virtual { // Minting is a special case for which we should not check the balance of // the sender, and we should increase the total supply. if (from_ == address(0)) { totalSupply += value_; } else { // Deduct value from sender's balance. balanceOf[from_] -= value_; } // Update the recipient's balance. // Can be unchecked because on mint, adding to totalSupply is checked, and on transfer balance deduction is checked. unchecked { balanceOf[to_] += value_; } emit ERC20Events.Transfer(from_, to_, value_); } /// @notice Consolidated record keeping function for transferring ERC-721s. /// @dev Assign the token to the new owner, and remove from the old owner. /// Note that this function allows transfers to and from 0x0. /// Does not handle ERC-721 exemptions. function _transferERC721( address from_, address to_, uint256 id_ ) internal virtual { // If this is not a mint, handle record keeping for transfer from previous owner. if (from_ != address(0)) { // On transfer of an NFT, any previous approval is reset. delete getApproved[id_]; uint256 updatedId = ID_ENCODING_PREFIX + _owned[from_][_owned[from_].length - 1]; if (updatedId != id_) { uint256 updatedIndex = _getOwnedIndex(id_); // update _owned for sender _owned[from_][updatedIndex] = uint16(updatedId); // update index for the moved id _setOwnedIndex(updatedId, updatedIndex); } // pop _owned[from_].pop(); } // Check if this is a burn. if (to_ != address(0)) { // If not a burn, update the owner of the token to the new owner. // Update owner of the token to the new owner. _setOwnerOf(id_, to_); // Push token onto the new owner's stack. _owned[to_].push(uint16(id_)); // Update index for new owner's stack. _setOwnedIndex(id_, _owned[to_].length - 1); } else { // If this is a burn, reset the owner of the token to 0x0 by deleting the token from _ownedData. delete _ownedData[id_]; } emit ERC721Events.Transfer(from_, to_, id_); } /// @notice Internal function for ERC-20 transfers. Also handles any ERC-721 transfers that may be required. // Handles ERC-721 exemptions. function _transferERC20WithERC721( address from_, address to_, uint256 value_ ) internal virtual returns (bool) { uint256 erc20BalanceOfSenderBefore = erc20BalanceOf(from_); uint256 erc20BalanceOfReceiverBefore = erc20BalanceOf(to_); _transferERC20(from_, to_, value_); // Preload for gas savings on branches bool isFromERC721TransferExempt = erc721TransferExempt(from_); bool isToERC721TransferExempt = erc721TransferExempt(to_); // Skip _withdrawAndStoreERC721 and/or _retrieveOrMintERC721 for ERC-721 transfer exempt addresses // 1) to save gas // 2) because ERC-721 transfer exempt addresses won't always have/need ERC-721s corresponding to their ERC20s. if (isFromERC721TransferExempt && isToERC721TransferExempt) { // Case 1) Both sender and recipient are ERC-721 transfer exempt. No ERC-721s need to be transferred. // NOOP. } else if (isFromERC721TransferExempt) { // Case 2) The sender is ERC-721 transfer exempt, but the recipient is not. Contract should not attempt // to transfer ERC-721s from the sender, but the recipient should receive ERC-721s // from the bank/minted for any whole number increase in their balance. // Only cares about whole number increments. uint256 tokensToRetrieveOrMint = (balanceOf[to_] / units) - (erc20BalanceOfReceiverBefore / units); for (uint256 i = 0; i < tokensToRetrieveOrMint;) { _retrieveOrMintERC721(to_); unchecked { ++i; } } } else if (isToERC721TransferExempt) { // Case 3) The sender is not ERC-721 transfer exempt, but the recipient is. Contract should attempt // to withdraw and store ERC-721s from the sender, but the recipient should not // receive ERC-721s from the bank/minted. // Only cares about whole number increments. uint256 tokensToWithdrawAndStore = ( erc20BalanceOfSenderBefore / units ) - (balanceOf[from_] / units); for (uint256 i = 0; i < tokensToWithdrawAndStore;) { _withdrawAndStoreERC721(from_); unchecked { ++i; } } } else { // Case 4) Neither the sender nor the recipient are ERC-721 transfer exempt. // Strategy: // 1. First deal with the whole tokens. These are easy and will just be transferred. // 2. Look at the fractional part of the value: // a) If it causes the sender to lose a whole token that was represented by an NFT due to a // fractional part being transferred, withdraw and store an additional NFT from the sender. // b) If it causes the receiver to gain a whole new token that should be represented by an NFT // due to receiving a fractional part that completes a whole token, retrieve or mint an NFT to the recevier. // Whole tokens worth of ERC-20s get transferred as ERC-721s without any burning/minting. uint256 nftsToTransfer = value_ / units; for (uint256 i = 0; i < nftsToTransfer;) { // Pop from sender's ERC-721 stack and transfer them (LIFO) uint256 indexOfLastToken = _owned[from_].length - 1; uint256 tokenId = ID_ENCODING_PREFIX + _owned[from_][indexOfLastToken]; _transferERC721(from_, to_, tokenId); unchecked { ++i; } } // If the sender's transaction changes their holding from a fractional to a non-fractional // amount (or vice versa), adjust ERC-721s. // // Check if the send causes the sender to lose a whole token that was represented by an ERC-721 // due to a fractional part being transferred. if ( erc20BalanceOfSenderBefore / units - erc20BalanceOf(from_) / units > nftsToTransfer ) { _withdrawAndStoreERC721(from_); } if ( erc20BalanceOf(to_) / units - erc20BalanceOfReceiverBefore / units > nftsToTransfer ) { _retrieveOrMintERC721(to_); } } return true; } /// @notice Internal function for ERC20 minting /// @dev This function will allow minting of new ERC20s. /// If mintCorrespondingERC721s_ is true, and the recipient is not ERC-721 exempt, it will /// also mint the corresponding ERC721s. /// Handles ERC-721 exemptions. function _mintERC20(address to_, uint256 value_) internal virtual { /// You cannot mint to the zero address (you can't mint and immediately burn in the same transfer). if (to_ == address(0)) { revert InvalidRecipient(); } if (totalSupply + value_ > ID_ENCODING_PREFIX) { revert MintLimitReached(); } _transferERC20WithERC721(address(0), to_, value_); } /// @notice Internal function for ERC-721 minting and retrieval from the bank. /// @dev This function will allow minting of new ERC-721s up to the total fractional supply. It will /// first try to pull from the bank, and if the bank is empty, it will mint a new token. /// Does not handle ERC-721 exemptions. function _retrieveOrMintERC721(address to_) internal virtual { if (to_ == address(0)) { revert InvalidRecipient(); } uint256 id; if (!_storedERC721Ids.empty()) { // If there are any tokens in the bank, use those first. // Pop off the end of the queue (FIFO). id = ID_ENCODING_PREFIX + _storedERC721Ids.popBack(); } else { // Otherwise, mint a new token, should not be able to go over the total fractional supply. ++minted; // Reserve max uint256 for approvals if (minted == type(uint256).max) { revert MintLimitReached(); } id = ID_ENCODING_PREFIX + minted; } address erc721Owner = _getOwnerOf(id); // The token should not already belong to anyone besides 0x0 or this contract. // If it does, something is wrong, as this should never happen. if (erc721Owner != address(0)) { revert AlreadyExists(); } // Transfer the token to the recipient, either transferring from the contract's bank or minting. // Does not handle ERC-721 exemptions. _transferERC721(erc721Owner, to_, id); } /// @notice Internal function for ERC-721 deposits to bank (this contract). /// @dev This function will allow depositing of ERC-721s to the bank, which can be retrieved by future minters. // Does not handle ERC-721 exemptions. function _withdrawAndStoreERC721(address from_) internal virtual { if (from_ == address(0)) { revert InvalidSender(); } // Retrieve the latest token added to the owner's stack (LIFO). uint256 id = ID_ENCODING_PREFIX + _owned[from_][_owned[from_].length - 1]; // Transfer to 0x0. // Does not handle ERC-721 exemptions. _transferERC721(from_, address(0), id); // Record the token in the contract's bank queue. _storedERC721Ids.pushFront(uint16(id)); } /// @notice Initialization function to set pairs / etc, saving gas by avoiding mint / burn on unnecessary targets function _setERC721TransferExempt( address target_, bool state_ ) internal virtual { if (target_ == address(0)) { revert InvalidExemption(); } // Adjust the ERC721 balances of the target to respect exemption rules. // Despite this logic, it is still recommended practice to exempt prior to the target // having an active balance. if (state_) { _clearERC721Balance(target_); } else { _reinstateERC721Balance(target_); } _erc721TransferExempt[target_] = state_; } /// @notice Function to reinstate balance on exemption removal function _reinstateERC721Balance(address target_) private { uint256 expectedERC721Balance = erc20BalanceOf(target_) / units; uint256 actualERC721Balance = erc721BalanceOf(target_); for (uint256 i = 0; i < expectedERC721Balance - actualERC721Balance;) { // Transfer ERC721 balance in from pool _retrieveOrMintERC721(target_); unchecked { ++i; } } } /// @notice Function to clear balance on exemption inclusion function _clearERC721Balance(address target_) private { uint256 erc721Balance = erc721BalanceOf(target_); for (uint256 i = 0; i < erc721Balance;) { // Transfer out ERC721 balance _withdrawAndStoreERC721(target_); unchecked { ++i; } } } function _getOwnerOf(uint256 id_) internal view virtual returns (address ownerOf_) { uint256 data = _ownedData[id_]; assembly { ownerOf_ := and(data, _BITMASK_ADDRESS) } } function _setOwnerOf(uint256 id_, address owner_) internal virtual { uint256 data = _ownedData[id_]; assembly { data := add(and(data, _BITMASK_OWNED_INDEX), and(owner_, _BITMASK_ADDRESS)) } _ownedData[id_] = data; } function _getOwnedIndex(uint256 id_) internal view virtual returns (uint256 ownedIndex_) { uint256 data = _ownedData[id_]; assembly { ownedIndex_ := shr(160, data) } } function _setOwnedIndex(uint256 id_, uint256 index_) internal virtual { uint256 data = _ownedData[id_]; if (index_ > _BITMASK_OWNED_INDEX >> 160) { revert OwnedIndexOverflow(); } assembly { data := add( and(data, _BITMASK_ADDRESS), and(shl(160, index_), _BITMASK_OWNED_INDEX) ) } _ownedData[id_] = data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; library LibPalette { /// @dev Object defintion of a airdrop phase. struct Phase { bytes32 merkleRoot; uint32 startTime; uint32 endTime; } /// @dev A phase has not opened yet. error PhasePending(); /// @dev A phase has closed. error PhaseClosed(); /// @dev A phase is overlapping with another. error PhaseOverlapping(); /// @dev The phase does not exist. error PhaseInvalid(); /// @dev The proof provided is invalid. error ProofInvalid(); /// @dev The proof used is claiming more tokens than allocated. error ProofInsufficient(); /// @dev Too few tokens are being claimed. error ClaimInsufficient(); /// @dev The allocation being minted does not have enough /// value provided with it. error ValueInsufficient(); /// @dev The max supply will be exceeded. error SupplyInsufficient(); /// @dev The token does not exist. error TokenInvalid(); /// @dev The token is not ready to be traded. error TokenLoading(); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Gas optimized verification of proof of inclusion for a leaf in a Merkle tree. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol) library MerkleProofLib { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* MERKLE PROOF VERIFICATION OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`. function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool isValid) { /// @solidity memory-safe-assembly assembly { if mload(proof) { // Initialize `offset` to the offset of `proof` elements in memory. let offset := add(proof, 0x20) // Left shift by 5 is equivalent to multiplying by 0x20. let end := add(offset, shl(5, mload(proof))) // Iterate over proof elements to compute root hash. for {} 1 {} { // Slot of `leaf` in scratch space. // If the condition is true: 0x20, otherwise: 0x00. let scratch := shl(5, gt(leaf, mload(offset))) // Store elements to hash contiguously in scratch space. // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes. mstore(scratch, leaf) mstore(xor(scratch, 0x20), mload(offset)) // Reuse `leaf` to store the hash to reduce stack operations. leaf := keccak256(0x00, 0x40) offset := add(offset, 0x20) if iszero(lt(offset, end)) { break } } } isValid := eq(leaf, root) } } /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`. function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool isValid) { /// @solidity memory-safe-assembly assembly { if proof.length { // Left shift by 5 is equivalent to multiplying by 0x20. let end := add(proof.offset, shl(5, proof.length)) // Initialize `offset` to the offset of `proof` in the calldata. let offset := proof.offset // Iterate over proof elements to compute root hash. for {} 1 {} { // Slot of `leaf` in scratch space. // If the condition is true: 0x20, otherwise: 0x00. let scratch := shl(5, gt(leaf, calldataload(offset))) // Store elements to hash contiguously in scratch space. // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes. mstore(scratch, leaf) mstore(xor(scratch, 0x20), calldataload(offset)) // Reuse `leaf` to store the hash to reduce stack operations. leaf := keccak256(0x00, 0x40) offset := add(offset, 0x20) if iszero(lt(offset, end)) { break } } } isValid := eq(leaf, root) } } /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`, /// given `proof` and `flags`. /// /// Note: /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length` /// will always return false. /// - The sum of the lengths of `proof` and `leaves` must never overflow. /// - Any non-zero word in the `flags` array is treated as true. /// - The memory offset of `proof` must be non-zero /// (i.e. `proof` is not pointing to the scratch space). function verifyMultiProof( bytes32[] memory proof, bytes32 root, bytes32[] memory leaves, bool[] memory flags ) internal pure returns (bool isValid) { // Rebuilds the root by consuming and producing values on a queue. // The queue starts with the `leaves` array, and goes into a `hashes` array. // After the process, the last element on the queue is verified // to be equal to the `root`. // // The `flags` array denotes whether the sibling // should be popped from the queue (`flag == true`), or // should be popped from the `proof` (`flag == false`). /// @solidity memory-safe-assembly assembly { // Cache the lengths of the arrays. let leavesLength := mload(leaves) let proofLength := mload(proof) let flagsLength := mload(flags) // Advance the pointers of the arrays to point to the data. leaves := add(0x20, leaves) proof := add(0x20, proof) flags := add(0x20, flags) // If the number of flags is correct. for {} eq(add(leavesLength, proofLength), add(flagsLength, 1)) {} { // For the case where `proof.length + leaves.length == 1`. if iszero(flagsLength) { // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`. isValid := eq(mload(xor(leaves, mul(xor(proof, leaves), proofLength))), root) break } // The required final proof offset if `flagsLength` is not zero, otherwise zero. let proofEnd := add(proof, shl(5, proofLength)) // We can use the free memory space for the queue. // We don't need to allocate, since the queue is temporary. let hashesFront := mload(0x40) // Copy the leaves into the hashes. // Sometimes, a little memory expansion costs less than branching. // Should cost less, even with a high free memory offset of 0x7d00. leavesLength := shl(5, leavesLength) for { let i := 0 } iszero(eq(i, leavesLength)) { i := add(i, 0x20) } { mstore(add(hashesFront, i), mload(add(leaves, i))) } // Compute the back of the hashes. let hashesBack := add(hashesFront, leavesLength) // This is the end of the memory for the queue. // We recycle `flagsLength` to save on stack variables (sometimes save gas). flagsLength := add(hashesBack, shl(5, flagsLength)) for {} 1 {} { // Pop from `hashes`. let a := mload(hashesFront) // Pop from `hashes`. let b := mload(add(hashesFront, 0x20)) hashesFront := add(hashesFront, 0x40) // If the flag is false, load the next proof, // else, pops from the queue. if iszero(mload(flags)) { // Loads the next proof. b := mload(proof) proof := add(proof, 0x20) // Unpop from `hashes`. hashesFront := sub(hashesFront, 0x20) } // Advance to the next flag. flags := add(flags, 0x20) // Slot of `a` in scratch space. // If the condition is true: 0x20, otherwise: 0x00. let scratch := shl(5, gt(a, b)) // Hash the scratch space and push the result onto the queue. mstore(scratch, a) mstore(xor(scratch, 0x20), b) mstore(hashesBack, keccak256(0x00, 0x40)) hashesBack := add(hashesBack, 0x20) if iszero(lt(hashesBack, flagsLength)) { break } } isValid := and( // Checks if the last value in the queue is same as the root. eq(mload(sub(hashesBack, 0x20)), root), // And whether all the proofs are used, if required. eq(proofEnd, proof) ) break } } } /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`, /// given `proof` and `flags`. /// /// Note: /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length` /// will always return false. /// - Any non-zero word in the `flags` array is treated as true. /// - The calldata offset of `proof` must be non-zero /// (i.e. `proof` is from a regular Solidity function with a 4-byte selector). function verifyMultiProofCalldata( bytes32[] calldata proof, bytes32 root, bytes32[] calldata leaves, bool[] calldata flags ) internal pure returns (bool isValid) { // Rebuilds the root by consuming and producing values on a queue. // The queue starts with the `leaves` array, and goes into a `hashes` array. // After the process, the last element on the queue is verified // to be equal to the `root`. // // The `flags` array denotes whether the sibling // should be popped from the queue (`flag == true`), or // should be popped from the `proof` (`flag == false`). /// @solidity memory-safe-assembly assembly { // If the number of flags is correct. for {} eq(add(leaves.length, proof.length), add(flags.length, 1)) {} { // For the case where `proof.length + leaves.length == 1`. if iszero(flags.length) { // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`. // forgefmt: disable-next-item isValid := eq( calldataload( xor(leaves.offset, mul(xor(proof.offset, leaves.offset), proof.length)) ), root ) break } // The required final proof offset if `flagsLength` is not zero, otherwise zero. let proofEnd := add(proof.offset, shl(5, proof.length)) // We can use the free memory space for the queue. // We don't need to allocate, since the queue is temporary. let hashesFront := mload(0x40) // Copy the leaves into the hashes. // Sometimes, a little memory expansion costs less than branching. // Should cost less, even with a high free memory offset of 0x7d00. calldatacopy(hashesFront, leaves.offset, shl(5, leaves.length)) // Compute the back of the hashes. let hashesBack := add(hashesFront, shl(5, leaves.length)) // This is the end of the memory for the queue. // We recycle `flagsLength` to save on stack variables (sometimes save gas). flags.length := add(hashesBack, shl(5, flags.length)) // We don't need to make a copy of `proof.offset` or `flags.offset`, // as they are pass-by-value (this trick may not always save gas). for {} 1 {} { // Pop from `hashes`. let a := mload(hashesFront) // Pop from `hashes`. let b := mload(add(hashesFront, 0x20)) hashesFront := add(hashesFront, 0x40) // If the flag is false, load the next proof, // else, pops from the queue. if iszero(calldataload(flags.offset)) { // Loads the next proof. b := calldataload(proof.offset) proof.offset := add(proof.offset, 0x20) // Unpop from `hashes`. hashesFront := sub(hashesFront, 0x20) } // Advance to the next flag offset. flags.offset := add(flags.offset, 0x20) // Slot of `a` in scratch space. // If the condition is true: 0x20, otherwise: 0x00. let scratch := shl(5, gt(a, b)) // Hash the scratch space and push the result onto the queue. mstore(scratch, a) mstore(xor(scratch, 0x20), b) mstore(hashesBack, keccak256(0x00, 0x40)) hashesBack := add(hashesBack, 0x20) if iszero(lt(hashesBack, flags.length)) { break } } isValid := and( // Checks if the last value in the queue is same as the root. eq(mload(sub(hashesBack, 0x20)), root), // And whether all the proofs are used, if required. eq(proofEnd, proof.offset) ) break } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EMPTY CALLDATA HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns an empty calldata bytes32 array. function emptyProof() internal pure returns (bytes32[] calldata proof) { /// @solidity memory-safe-assembly assembly { proof.length := 0 } } /// @dev Returns an empty calldata bytes32 array. function emptyLeaves() internal pure returns (bytes32[] calldata leaves) { /// @solidity memory-safe-assembly assembly { leaves.length := 0 } } /// @dev Returns an empty calldata bool array. function emptyFlags() internal pure returns (bool[] calldata flags) { /// @solidity memory-safe-assembly assembly { flags.length := 0 } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// /// @dev Note: /// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection. /// - For ERC20s, this implementation won't check that a token has code, /// responsibility is delegated to the caller. library SafeTransferLib { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ETH transfer has failed. error ETHTransferFailed(); /// @dev The ERC20 `transferFrom` has failed. error TransferFromFailed(); /// @dev The ERC20 `transfer` has failed. error TransferFailed(); /// @dev The ERC20 `approve` has failed. error ApproveFailed(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes. uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300; /// @dev Suggested gas stipend for contract receiving ETH to perform a few /// storage reads and writes, but low enough to prevent griefing. uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ETH OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants. // // The regular variants: // - Forwards all remaining gas to the target. // - Reverts if the target reverts. // - Reverts if the current contract has insufficient balance. // // The force variants: // - Forwards with an optional gas stipend // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases). // - If the target reverts, or if the gas stipend is exhausted, // creates a temporary contract to force send the ETH via `SELFDESTRUCT`. // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758. // - Reverts if the current contract has insufficient balance. // // The try variants: // - Forwards with a mandatory gas stipend. // - Instead of reverting, returns whether the transfer succeeded. /// @dev Sends `amount` (in wei) ETH to `to`. function safeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } } } /// @dev Sends all the ETH in the current contract to `to`. function safeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { // Transfer all the ETH and check if it succeeded or not. if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } } } /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`. function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal { /// @solidity memory-safe-assembly assembly { if lt(selfbalance(), amount) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`. function forceSafeTransferAllETH(address to, uint256 gasStipend) internal { /// @solidity memory-safe-assembly assembly { if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`. function forceSafeTransferETH(address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { if lt(selfbalance(), amount) { mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`. revert(0x1c, 0x04) } if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`. function forceSafeTransferAllETH(address to) internal { /// @solidity memory-safe-assembly assembly { // forgefmt: disable-next-item if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) { mstore(0x00, to) // Store the address in scratch space. mstore8(0x0b, 0x73) // Opcode `PUSH20`. mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`. if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation. } } } /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`. function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00) } } /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`. function trySafeTransferAllETH(address to, uint256 gasStipend) internal returns (bool success) { /// @solidity memory-safe-assembly assembly { success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC20 OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Sends `amount` of ERC20 `token` from `from` to `to`. /// Reverts upon failure. /// /// The `from` account must have at least `amount` approved for /// the current contract to manage. function safeTransferFrom(address token, address from, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x60, amount) // Store the `amount` argument. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends all of ERC20 `token` from `from` to `to`. /// Reverts upon failure. /// /// The `from` account must have their entire balance approved for /// the current contract to manage. function safeTransferAllFrom(address token, address from, address to) internal returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Cache the free memory pointer. mstore(0x40, to) // Store the `to` argument. mstore(0x2c, shl(96, from)) // Store the `from` argument. mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`. // Read the balance, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`. amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20) ) ) { mstore(0x00, 0x7939f424) // `TransferFromFailed()`. revert(0x1c, 0x04) } mstore(0x60, 0) // Restore the zero slot to zero. mstore(0x40, m) // Restore the free memory pointer. } } /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`. /// Reverts upon failure. function safeTransfer(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sends all of ERC20 `token` from the current contract to `to`. /// Reverts upon failure. function safeTransferAll(address token, address to) internal returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`. mstore(0x20, address()) // Store the address of the current contract. // Read the balance, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x14, to) // Store the `to` argument. amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it. mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`. // Perform the transfer, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x90b8ec18) // `TransferFailed()`. revert(0x1c, 0x04) } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract. /// Reverts upon failure. function safeApprove(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. // Perform the approval, reverting upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`. revert(0x1c, 0x04) } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract. /// If the initial attempt to approve fails, attempts to reset the approved amount to zero, /// then retries the approval again (some tokens, e.g. USDT, requires this). /// Reverts upon failure. function safeApproveWithRetry(address token, address to, uint256 amount) internal { /// @solidity memory-safe-assembly assembly { mstore(0x14, to) // Store the `to` argument. mstore(0x34, amount) // Store the `amount` argument. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. // Perform the approval, retrying upon failure. if iszero( and( // The arguments of `and` are evaluated from right to left. or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x34, 0) // Store 0 for the `amount`. mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`. pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval. mstore(0x34, amount) // Store back the original `amount`. // Retry the approval, reverting upon failure. if iszero( and( or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing. call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20) ) ) { mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`. revert(0x1c, 0x04) } } mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten. } } /// @dev Returns the amount of ERC20 `token` owned by `account`. /// Returns zero if the `token` does not exist. function balanceOf(address token, address account) internal view returns (uint256 amount) { /// @solidity memory-safe-assembly assembly { mstore(0x14, account) // Store the `account` argument. mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`. amount := mul( mload(0x20), and( // The arguments of `and` are evaluated from right to left. gt(returndatasize(), 0x1f), // At least 32 bytes returned. staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20) ) ) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Library for converting numbers into strings and other string operations. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol) /// /// @dev Note: /// For performance and bytecode compactness, most of the string operations are restricted to /// byte strings (7-bit ASCII), except where otherwise specified. /// Usage of byte string operations on charsets with runes spanning two or more bytes /// can lead to undefined behavior. library LibString { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The length of the output is too small to contain all the hex digits. error HexLengthInsufficient(); /// @dev The length of the string is more than 32 bytes. error TooBigForSmallString(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The constant returned when the `search` is not found in the string. uint256 internal constant NOT_FOUND = type(uint256).max; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* DECIMAL OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the base 10 decimal representation of `value`. function toString(uint256 value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. str := add(mload(0x40), 0x80) // Update the free memory pointer to allocate. mstore(0x40, add(str, 0x20)) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str let w := not(0) // Tsk. // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let temp := value } 1 {} { str := add(str, w) // `sub(str, 1)`. // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } /// @dev Returns the base 10 decimal representation of `value`. function toString(int256 value) internal pure returns (string memory str) { if (value >= 0) { return toString(uint256(value)); } unchecked { str = toString(~uint256(value) + 1); } /// @solidity memory-safe-assembly assembly { // We still have some spare memory space on the left, // as we have allocated 3 words (96 bytes) for up to 78 digits. let length := mload(str) // Load the string length. mstore(str, 0x2d) // Store the '-' character. str := sub(str, 1) // Move back the string pointer by a byte. mstore(str, add(length, 1)) // Update the string length. } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HEXADECIMAL OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the hexadecimal representation of `value`, /// left-padded to an input length of `length` bytes. /// The output is prefixed with "0x" encoded using 2 hexadecimal digits per byte, /// giving a total length of `length * 2 + 2` bytes. /// Reverts if `length` is too small for the output to contain all the digits. function toHexString(uint256 value, uint256 length) internal pure returns (string memory str) { str = toHexStringNoPrefix(value, length); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`, /// left-padded to an input length of `length` bytes. /// The output is prefixed with "0x" encoded using 2 hexadecimal digits per byte, /// giving a total length of `length * 2` bytes. /// Reverts if `length` is too small for the output to contain all the digits. function toHexStringNoPrefix(uint256 value, uint256 length) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { // We need 0x20 bytes for the trailing zeros padding, `length * 2` bytes // for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length. // We add 0x20 to the total and round down to a multiple of 0x20. // (0x20 + 0x20 + 0x02 + 0x20) = 0x62. str := add(mload(0x40), and(add(shl(1, length), 0x42), not(0x1f))) // Allocate the memory. mstore(0x40, add(str, 0x20)) // Zeroize the slot after the string. mstore(str, 0) // Cache the end to calculate the length later. let end := str // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let start := sub(str, add(length, length)) let w := not(1) // Tsk. let temp := value // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for {} 1 {} { str := add(str, w) // `sub(str, 2)`. mstore8(add(str, 1), mload(and(temp, 15))) mstore8(str, mload(and(shr(4, temp), 15))) temp := shr(8, temp) if iszero(xor(str, start)) { break } } if temp { mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`. revert(0x1c, 0x04) } // Compute the string's length. let strLength := sub(end, str) // Move the pointer and write the length. str := sub(str, 0x20) mstore(str, strLength) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte. /// As address are 20 bytes long, the output will left-padded to have /// a length of `20 * 2 + 2` bytes. function toHexString(uint256 value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x". /// The output excludes leading "0" from the `toHexString` output. /// `0x00: "0x0", 0x01: "0x1", 0x12: "0x12", 0x123: "0x123"`. function toMinimalHexString(uint256 value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present. let strLength := add(mload(str), 2) // Compute the length. mstore(add(str, o), 0x3078) // Write the "0x" prefix, accounting for leading zero. str := sub(add(str, o), 2) // Move the pointer, accounting for leading zero. mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero. } } /// @dev Returns the hexadecimal representation of `value`. /// The output excludes leading "0" from the `toHexStringNoPrefix` output. /// `0x00: "0", 0x01: "1", 0x12: "12", 0x123: "123"`. function toMinimalHexStringNoPrefix(uint256 value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present. let strLength := mload(str) // Get the length. str := add(str, o) // Move the pointer, accounting for leading zero. mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is encoded using 2 hexadecimal digits per byte. /// As address are 20 bytes long, the output will left-padded to have /// a length of `20 * 2` bytes. function toHexStringNoPrefix(uint256 value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, // 0x02 bytes for the prefix, and 0x40 bytes for the digits. // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0. str := add(mload(0x40), 0x80) // Allocate the memory. mstore(0x40, add(str, 0x20)) // Zeroize the slot after the string. mstore(str, 0) // Cache the end to calculate the length later. let end := str // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let w := not(1) // Tsk. // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let temp := value } 1 {} { str := add(str, w) // `sub(str, 2)`. mstore8(add(str, 1), mload(and(temp, 15))) mstore8(str, mload(and(shr(4, temp), 15))) temp := shr(8, temp) if iszero(temp) { break } } // Compute the string's length. let strLength := sub(end, str) // Move the pointer and write the length. str := sub(str, 0x20) mstore(str, strLength) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x", encoded using 2 hexadecimal digits per byte, /// and the alphabets are capitalized conditionally according to /// https://eips.ethereum.org/EIPS/eip-55 function toHexStringChecksummed(address value) internal pure returns (string memory str) { str = toHexString(value); /// @solidity memory-safe-assembly assembly { let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...` let o := add(str, 0x22) let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... ` let t := shl(240, 136) // `0b10001000 << 240` for { let i := 0 } 1 {} { mstore(add(i, i), mul(t, byte(i, hashed))) i := add(i, 1) if eq(i, 20) { break } } mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask))))) o := add(o, 0x20) mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask))))) } } /// @dev Returns the hexadecimal representation of `value`. /// The output is prefixed with "0x" and encoded using 2 hexadecimal digits per byte. function toHexString(address value) internal pure returns (string memory str) { str = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hexadecimal representation of `value`. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(address value) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { str := mload(0x40) // Allocate the memory. // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, // 0x02 bytes for the prefix, and 0x28 bytes for the digits. // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80. mstore(0x40, add(str, 0x80)) // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) str := add(str, 2) mstore(str, 40) let o := add(str, 0x20) mstore(add(o, 40), 0) value := shl(96, value) // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. for { let i := 0 } 1 {} { let p := add(o, add(i, i)) let temp := byte(i, value) mstore8(add(p, 1), mload(and(temp, 15))) mstore8(p, mload(shr(4, temp))) i := add(i, 1) if eq(i, 20) { break } } } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexString(bytes memory raw) internal pure returns (string memory str) { str = toHexStringNoPrefix(raw); /// @solidity memory-safe-assembly assembly { let strLength := add(mload(str), 2) // Compute the length. mstore(str, 0x3078) // Write the "0x" prefix. str := sub(str, 2) // Move the pointer. mstore(str, strLength) // Write the length. } } /// @dev Returns the hex encoded string from the raw bytes. /// The output is encoded using 2 hexadecimal digits per byte. function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) { /// @solidity memory-safe-assembly assembly { let length := mload(raw) str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix. mstore(str, add(length, length)) // Store the length of the output. // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let o := add(str, 0x20) let end := add(raw, length) for {} iszero(eq(raw, end)) {} { raw := add(raw, 1) mstore8(add(o, 1), mload(and(mload(raw), 15))) mstore8(o, mload(and(shr(4, mload(raw)), 15))) o := add(o, 2) } mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate the memory. } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* RUNE STRING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the number of UTF characters in the string. function runeCount(string memory s) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { if mload(s) { mstore(0x00, div(not(0), 255)) mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506) let o := add(s, 0x20) let end := add(o, mload(s)) for { result := 1 } 1 { result := add(result, 1) } { o := add(o, byte(0, mload(shr(250, mload(o))))) if iszero(lt(o, end)) { break } } } } } /// @dev Returns if this string is a 7-bit ASCII string. /// (i.e. all characters codes are in [0..127]) function is7BitASCII(string memory s) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { let mask := shl(7, div(not(0), 255)) result := 1 let n := mload(s) if n { let o := add(s, 0x20) let end := add(o, n) let last := mload(end) mstore(end, 0) for {} 1 {} { if and(mask, mload(o)) { result := 0 break } o := add(o, 0x20) if iszero(lt(o, end)) { break } } mstore(end, last) } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* BYTE STRING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // For performance and bytecode compactness, byte string operations are restricted // to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets. // Usage of byte string operations on charsets with runes spanning two or more bytes // can lead to undefined behavior. /// @dev Returns `subject` all occurrences of `search` replaced with `replacement`. function replace(string memory subject, string memory search, string memory replacement) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let subjectLength := mload(subject) let searchLength := mload(search) let replacementLength := mload(replacement) subject := add(subject, 0x20) search := add(search, 0x20) replacement := add(replacement, 0x20) result := add(mload(0x40), 0x20) let subjectEnd := add(subject, subjectLength) if iszero(gt(searchLength, subjectLength)) { let subjectSearchEnd := add(sub(subjectEnd, searchLength), 1) let h := 0 if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) } let m := shl(3, sub(0x20, and(searchLength, 0x1f))) let s := mload(search) for {} 1 {} { let t := mload(subject) // Whether the first `searchLength % 32` bytes of // `subject` and `search` matches. if iszero(shr(m, xor(t, s))) { if h { if iszero(eq(keccak256(subject, searchLength), h)) { mstore(result, t) result := add(result, 1) subject := add(subject, 1) if iszero(lt(subject, subjectSearchEnd)) { break } continue } } // Copy the `replacement` one word at a time. for { let o := 0 } 1 {} { mstore(add(result, o), mload(add(replacement, o))) o := add(o, 0x20) if iszero(lt(o, replacementLength)) { break } } result := add(result, replacementLength) subject := add(subject, searchLength) if searchLength { if iszero(lt(subject, subjectSearchEnd)) { break } continue } } mstore(result, t) result := add(result, 1) subject := add(subject, 1) if iszero(lt(subject, subjectSearchEnd)) { break } } } let resultRemainder := result result := add(mload(0x40), 0x20) let k := add(sub(resultRemainder, result), sub(subjectEnd, subject)) // Copy the rest of the string one word at a time. for {} lt(subject, subjectEnd) {} { mstore(resultRemainder, mload(subject)) resultRemainder := add(resultRemainder, 0x20) subject := add(subject, 0x20) } result := sub(result, 0x20) let last := add(add(result, 0x20), k) // Zeroize the slot after the string. mstore(last, 0) mstore(0x40, add(last, 0x20)) // Allocate the memory. mstore(result, k) // Store the length. } } /// @dev Returns the byte index of the first location of `search` in `subject`, /// searching from left to right, starting from `from`. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found. function indexOf(string memory subject, string memory search, uint256 from) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { for { let subjectLength := mload(subject) } 1 {} { if iszero(mload(search)) { if iszero(gt(from, subjectLength)) { result := from break } result := subjectLength break } let searchLength := mload(search) let subjectStart := add(subject, 0x20) result := not(0) // Initialize to `NOT_FOUND`. subject := add(subjectStart, from) let end := add(sub(add(subjectStart, subjectLength), searchLength), 1) let m := shl(3, sub(0x20, and(searchLength, 0x1f))) let s := mload(add(search, 0x20)) if iszero(and(lt(subject, end), lt(from, subjectLength))) { break } if iszero(lt(searchLength, 0x20)) { for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} { if iszero(shr(m, xor(mload(subject), s))) { if eq(keccak256(subject, searchLength), h) { result := sub(subject, subjectStart) break } } subject := add(subject, 1) if iszero(lt(subject, end)) { break } } break } for {} 1 {} { if iszero(shr(m, xor(mload(subject), s))) { result := sub(subject, subjectStart) break } subject := add(subject, 1) if iszero(lt(subject, end)) { break } } break } } } /// @dev Returns the byte index of the first location of `search` in `subject`, /// searching from left to right. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found. function indexOf(string memory subject, string memory search) internal pure returns (uint256 result) { result = indexOf(subject, search, 0); } /// @dev Returns the byte index of the first location of `search` in `subject`, /// searching from right to left, starting from `from`. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found. function lastIndexOf(string memory subject, string memory search, uint256 from) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { for {} 1 {} { result := not(0) // Initialize to `NOT_FOUND`. let searchLength := mload(search) if gt(searchLength, mload(subject)) { break } let w := result let fromMax := sub(mload(subject), searchLength) if iszero(gt(fromMax, from)) { from := fromMax } let end := add(add(subject, 0x20), w) subject := add(add(subject, 0x20), from) if iszero(gt(subject, end)) { break } // As this function is not too often used, // we shall simply use keccak256 for smaller bytecode size. for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} { if eq(keccak256(subject, searchLength), h) { result := sub(subject, add(end, 1)) break } subject := add(subject, w) // `sub(subject, 1)`. if iszero(gt(subject, end)) { break } } break } } } /// @dev Returns the byte index of the first location of `search` in `subject`, /// searching from right to left. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found. function lastIndexOf(string memory subject, string memory search) internal pure returns (uint256 result) { result = lastIndexOf(subject, search, uint256(int256(-1))); } /// @dev Returns true if `search` is found in `subject`, false otherwise. function contains(string memory subject, string memory search) internal pure returns (bool) { return indexOf(subject, search) != NOT_FOUND; } /// @dev Returns whether `subject` starts with `search`. function startsWith(string memory subject, string memory search) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { let searchLength := mload(search) // Just using keccak256 directly is actually cheaper. // forgefmt: disable-next-item result := and( iszero(gt(searchLength, mload(subject))), eq( keccak256(add(subject, 0x20), searchLength), keccak256(add(search, 0x20), searchLength) ) ) } } /// @dev Returns whether `subject` ends with `search`. function endsWith(string memory subject, string memory search) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { let searchLength := mload(search) let subjectLength := mload(subject) // Whether `search` is not longer than `subject`. let withinRange := iszero(gt(searchLength, subjectLength)) // Just using keccak256 directly is actually cheaper. // forgefmt: disable-next-item result := and( withinRange, eq( keccak256( // `subject + 0x20 + max(subjectLength - searchLength, 0)`. add(add(subject, 0x20), mul(withinRange, sub(subjectLength, searchLength))), searchLength ), keccak256(add(search, 0x20), searchLength) ) ) } } /// @dev Returns `subject` repeated `times`. function repeat(string memory subject, uint256 times) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let subjectLength := mload(subject) if iszero(or(iszero(times), iszero(subjectLength))) { subject := add(subject, 0x20) result := mload(0x40) let output := add(result, 0x20) for {} 1 {} { // Copy the `subject` one word at a time. for { let o := 0 } 1 {} { mstore(add(output, o), mload(add(subject, o))) o := add(o, 0x20) if iszero(lt(o, subjectLength)) { break } } output := add(output, subjectLength) times := sub(times, 1) if iszero(times) { break } } mstore(output, 0) // Zeroize the slot after the string. let resultLength := sub(output, add(result, 0x20)) mstore(result, resultLength) // Store the length. // Allocate the memory. mstore(0x40, add(result, add(resultLength, 0x20))) } } } /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive). /// `start` and `end` are byte offsets. function slice(string memory subject, uint256 start, uint256 end) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let subjectLength := mload(subject) if iszero(gt(subjectLength, end)) { end := subjectLength } if iszero(gt(subjectLength, start)) { start := subjectLength } if lt(start, end) { result := mload(0x40) let resultLength := sub(end, start) mstore(result, resultLength) subject := add(subject, start) let w := not(0x1f) // Copy the `subject` one word at a time, backwards. for { let o := and(add(resultLength, 0x1f), w) } 1 {} { mstore(add(result, o), mload(add(subject, o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } // Zeroize the slot after the string. mstore(add(add(result, 0x20), resultLength), 0) // Allocate memory for the length and the bytes, // rounded up to a multiple of 32. mstore(0x40, add(result, and(add(resultLength, 0x3f), w))) } } } /// @dev Returns a copy of `subject` sliced from `start` to the end of the string. /// `start` is a byte offset. function slice(string memory subject, uint256 start) internal pure returns (string memory result) { result = slice(subject, start, uint256(int256(-1))); } /// @dev Returns all the indices of `search` in `subject`. /// The indices are byte offsets. function indicesOf(string memory subject, string memory search) internal pure returns (uint256[] memory result) { /// @solidity memory-safe-assembly assembly { let subjectLength := mload(subject) let searchLength := mload(search) if iszero(gt(searchLength, subjectLength)) { subject := add(subject, 0x20) search := add(search, 0x20) result := add(mload(0x40), 0x20) let subjectStart := subject let subjectSearchEnd := add(sub(add(subject, subjectLength), searchLength), 1) let h := 0 if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) } let m := shl(3, sub(0x20, and(searchLength, 0x1f))) let s := mload(search) for {} 1 {} { let t := mload(subject) // Whether the first `searchLength % 32` bytes of // `subject` and `search` matches. if iszero(shr(m, xor(t, s))) { if h { if iszero(eq(keccak256(subject, searchLength), h)) { subject := add(subject, 1) if iszero(lt(subject, subjectSearchEnd)) { break } continue } } // Append to `result`. mstore(result, sub(subject, subjectStart)) result := add(result, 0x20) // Advance `subject` by `searchLength`. subject := add(subject, searchLength) if searchLength { if iszero(lt(subject, subjectSearchEnd)) { break } continue } } subject := add(subject, 1) if iszero(lt(subject, subjectSearchEnd)) { break } } let resultEnd := result // Assign `result` to the free memory pointer. result := mload(0x40) // Store the length of `result`. mstore(result, shr(5, sub(resultEnd, add(result, 0x20)))) // Allocate memory for result. // We allocate one more word, so this array can be recycled for {split}. mstore(0x40, add(resultEnd, 0x20)) } } } /// @dev Returns a arrays of strings based on the `delimiter` inside of the `subject` string. function split(string memory subject, string memory delimiter) internal pure returns (string[] memory result) { uint256[] memory indices = indicesOf(subject, delimiter); /// @solidity memory-safe-assembly assembly { let w := not(0x1f) let indexPtr := add(indices, 0x20) let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1))) mstore(add(indicesEnd, w), mload(subject)) mstore(indices, add(mload(indices), 1)) let prevIndex := 0 for {} 1 {} { let index := mload(indexPtr) mstore(indexPtr, 0x60) if iszero(eq(index, prevIndex)) { let element := mload(0x40) let elementLength := sub(index, prevIndex) mstore(element, elementLength) // Copy the `subject` one word at a time, backwards. for { let o := and(add(elementLength, 0x1f), w) } 1 {} { mstore(add(element, o), mload(add(add(subject, prevIndex), o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } // Zeroize the slot after the string. mstore(add(add(element, 0x20), elementLength), 0) // Allocate memory for the length and the bytes, // rounded up to a multiple of 32. mstore(0x40, add(element, and(add(elementLength, 0x3f), w))) // Store the `element` into the array. mstore(indexPtr, element) } prevIndex := add(index, mload(delimiter)) indexPtr := add(indexPtr, 0x20) if iszero(lt(indexPtr, indicesEnd)) { break } } result := indices if iszero(mload(delimiter)) { result := add(indices, 0x20) mstore(result, sub(mload(indices), 2)) } } } /// @dev Returns a concatenated string of `a` and `b`. /// Cheaper than `string.concat()` and does not de-align the free memory pointer. function concat(string memory a, string memory b) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let w := not(0x1f) result := mload(0x40) let aLength := mload(a) // Copy `a` one word at a time, backwards. for { let o := and(add(aLength, 0x20), w) } 1 {} { mstore(add(result, o), mload(add(a, o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } let bLength := mload(b) let output := add(result, aLength) // Copy `b` one word at a time, backwards. for { let o := and(add(bLength, 0x20), w) } 1 {} { mstore(add(output, o), mload(add(b, o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } let totalLength := add(aLength, bLength) let last := add(add(result, 0x20), totalLength) // Zeroize the slot after the string. mstore(last, 0) // Stores the length. mstore(result, totalLength) // Allocate memory for the length and the bytes, // rounded up to a multiple of 32. mstore(0x40, and(add(last, 0x1f), w)) } } /// @dev Returns a copy of the string in either lowercase or UPPERCASE. /// WARNING! This function is only compatible with 7-bit ASCII strings. function toCase(string memory subject, bool toUpper) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let length := mload(subject) if length { result := add(mload(0x40), 0x20) subject := add(subject, 1) let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff) let w := not(0) for { let o := length } 1 {} { o := add(o, w) let b := and(0xff, mload(add(subject, o))) mstore8(add(result, o), xor(b, and(shr(b, flags), 0x20))) if iszero(o) { break } } result := mload(0x40) mstore(result, length) // Store the length. let last := add(add(result, 0x20), length) mstore(last, 0) // Zeroize the slot after the string. mstore(0x40, add(last, 0x20)) // Allocate the memory. } } } /// @dev Returns a string from a small bytes32 string. /// `s` must be null-terminated, or behavior will be undefined. function fromSmallString(bytes32 s) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) let n := 0 for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\0'. mstore(result, n) let o := add(result, 0x20) mstore(o, s) mstore(add(o, n), 0) mstore(0x40, add(result, 0x40)) } } /// @dev Returns the small string, with all bytes after the first null byte zeroized. function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\0'. mstore(0x00, s) mstore(result, 0x00) result := mload(0x00) } } /// @dev Returns the string as a normalized null-terminated small string. function toSmallString(string memory s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { result := mload(s) if iszero(lt(result, 33)) { mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`. revert(0x1c, 0x04) } result := shl(shl(3, sub(32, result)), mload(add(s, result))) } } /// @dev Returns a lowercased copy of the string. /// WARNING! This function is only compatible with 7-bit ASCII strings. function lower(string memory subject) internal pure returns (string memory result) { result = toCase(subject, false); } /// @dev Returns an UPPERCASED copy of the string. /// WARNING! This function is only compatible with 7-bit ASCII strings. function upper(string memory subject) internal pure returns (string memory result) { result = toCase(subject, true); } /// @dev Escapes the string to be used within HTML tags. function escapeHTML(string memory s) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let end := add(s, mload(s)) result := add(mload(0x40), 0x20) // Store the bytes of the packed offsets and strides into the scratch space. // `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6. mstore(0x1f, 0x900094) mstore(0x08, 0xc0000000a6ab) // Store ""&'<>" into the scratch space. mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b)) for {} iszero(eq(s, end)) {} { s := add(s, 1) let c := and(mload(s), 0xff) // Not in `["\"","'","&","<",">"]`. if iszero(and(shl(c, 1), 0x500000c400000000)) { mstore8(result, c) result := add(result, 1) continue } let t := shr(248, mload(c)) mstore(result, mload(and(t, 0x1f))) result := add(result, shr(5, t)) } let last := result mstore(last, 0) // Zeroize the slot after the string. result := mload(0x40) mstore(result, sub(last, add(result, 0x20))) // Store the length. mstore(0x40, add(last, 0x20)) // Allocate the memory. } } /// @dev Escapes the string to be used within double-quotes in a JSON. /// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes. function escapeJSON(string memory s, bool addDoubleQuotes) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let end := add(s, mload(s)) result := add(mload(0x40), 0x20) if addDoubleQuotes { mstore8(result, 34) result := add(1, result) } // Store "\\u0000" in scratch space. // Store "0123456789abcdef" in scratch space. // Also, store `{0x08:"b", 0x09:"t", 0x0a:"n", 0x0c:"f", 0x0d:"r"}`. // into the scratch space. mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672) // Bitmask for detecting `["\"","\\"]`. let e := or(shl(0x22, 1), shl(0x5c, 1)) for {} iszero(eq(s, end)) {} { s := add(s, 1) let c := and(mload(s), 0xff) if iszero(lt(c, 0x20)) { if iszero(and(shl(c, 1), e)) { // Not in `["\"","\\"]`. mstore8(result, c) result := add(result, 1) continue } mstore8(result, 0x5c) // "\\". mstore8(add(result, 1), c) result := add(result, 2) continue } if iszero(and(shl(c, 1), 0x3700)) { // Not in `["\b","\t","\n","\f","\d"]`. mstore8(0x1d, mload(shr(4, c))) // Hex value. mstore8(0x1e, mload(and(c, 15))) // Hex value. mstore(result, mload(0x19)) // "\\u00XX". result := add(result, 6) continue } mstore8(result, 0x5c) // "\\". mstore8(add(result, 1), mload(add(c, 8))) result := add(result, 2) } if addDoubleQuotes { mstore8(result, 34) result := add(1, result) } let last := result mstore(last, 0) // Zeroize the slot after the string. result := mload(0x40) mstore(result, sub(last, add(result, 0x20))) // Store the length. mstore(0x40, add(last, 0x20)) // Allocate the memory. } } /// @dev Escapes the string to be used within double-quotes in a JSON. function escapeJSON(string memory s) internal pure returns (string memory result) { result = escapeJSON(s, false); } /// @dev Returns whether `a` equals `b`. function eq(string memory a, string memory b) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b))) } } /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string. function eqs(string memory a, bytes32 b) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { // These should be evaluated on compile time, as far as possible. let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`. let x := not(or(m, or(b, add(m, and(b, m))))) let r := shl(7, iszero(iszero(shr(128, x)))) r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x)))))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(r, shl(3, lt(0xff, shr(r, x)))) // forgefmt: disable-next-item result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))), xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20))))) } } /// @dev Packs a single string with its length into a single word. /// Returns `bytes32(0)` if the length is zero or greater than 31. function packOne(string memory a) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { // We don't need to zero right pad the string, // since this is our own custom non-standard packing scheme. result := mul( // Load the length and the bytes. mload(add(a, 0x1f)), // `length != 0 && length < 32`. Abuses underflow. // Assumes that the length is valid and within the block gas limit. lt(sub(mload(a), 1), 0x1f) ) } } /// @dev Unpacks a string packed using {packOne}. /// Returns the empty string if `packed` is `bytes32(0)`. /// If `packed` is not an output of {packOne}, the output behavior is undefined. function unpackOne(bytes32 packed) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { // Grab the free memory pointer. result := mload(0x40) // Allocate 2 words (1 for the length, 1 for the bytes). mstore(0x40, add(result, 0x40)) // Zeroize the length slot. mstore(result, 0) // Store the length and bytes. mstore(add(result, 0x1f), packed) // Right pad with zeroes. mstore(add(add(result, 0x20), mload(result)), 0) } } /// @dev Packs two strings with their lengths into a single word. /// Returns `bytes32(0)` if combined length is zero or greater than 30. function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { let aLength := mload(a) // We don't need to zero right pad the strings, // since this is our own custom non-standard packing scheme. result := mul( // Load the length and the bytes of `a` and `b`. or( shl(shl(3, sub(0x1f, aLength)), mload(add(a, aLength))), mload(sub(add(b, 0x1e), aLength)) ), // `totalLength != 0 && totalLength < 31`. Abuses underflow. // Assumes that the lengths are valid and within the block gas limit. lt(sub(add(aLength, mload(b)), 1), 0x1e) ) } } /// @dev Unpacks strings packed using {packTwo}. /// Returns the empty strings if `packed` is `bytes32(0)`. /// If `packed` is not an output of {packTwo}, the output behavior is undefined. function unpackTwo(bytes32 packed) internal pure returns (string memory resultA, string memory resultB) { /// @solidity memory-safe-assembly assembly { // Grab the free memory pointer. resultA := mload(0x40) resultB := add(resultA, 0x40) // Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words. mstore(0x40, add(resultB, 0x40)) // Zeroize the length slots. mstore(resultA, 0) mstore(resultB, 0) // Store the lengths and bytes. mstore(add(resultA, 0x1f), packed) mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA)))) // Right pad with zeroes. mstore(add(add(resultA, 0x20), mload(resultA)), 0) mstore(add(add(resultB, 0x20), mload(resultB)), 0) } } /// @dev Directly returns `a` without copying. function directReturn(string memory a) internal pure { assembly { // Assumes that the string does not start from the scratch space. let retStart := sub(a, 0x20) let retSize := add(mload(a), 0x40) // Right pad with zeroes. Just in case the string is produced // by a method that doesn't zero right pad. mstore(add(retStart, retSize), 0) // Store the return offset. mstore(retStart, 0x20) // End the transaction, returning the string. return(retStart, retSize) } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; interface PaletteRenderer { function disconnect() external view; function render(uint256 $id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721Receiver.sol) pragma solidity ^0.8.20; import {IERC721Receiver} from "../token/ERC721/IERC721Receiver.sol";
// 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 pragma solidity ^0.8.20; import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol"; interface IERC404 is IERC165 { error NotFound(); error InvalidTokenId(); error AlreadyExists(); error InvalidRecipient(); error InvalidSender(); error InvalidSpender(); error InvalidOperator(); error UnsafeRecipient(); error RecipientIsERC721TransferExempt(); error Unauthorized(); error InsufficientAllowance(); error DecimalsTooLow(); error PermitDeadlineExpired(); error InvalidSigner(); error InvalidApproval(); error OwnedIndexOverflow(); error MintLimitReached(); error InvalidExemption(); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function erc20TotalSupply() external view returns (uint256); function erc721TotalSupply() external view returns (uint256); function balanceOf(address owner_) external view returns (uint256); function erc721BalanceOf(address owner_) external view returns (uint256); function erc20BalanceOf(address owner_) external view returns (uint256); function erc721TransferExempt(address account_) external view returns (bool); function isApprovedForAll( address owner_, address operator_ ) external view returns (bool); function allowance( address owner_, address spender_ ) external view returns (uint256); function owned(address owner_) external view returns (uint256[] memory); function ownerOf(uint256 id_) external view returns (address erc721Owner); function tokenURI(uint256 id_) external view returns (string memory); function approve( address spender_, uint256 valueOrId_ ) external returns (bool); function erc20Approve( address spender_, uint256 value_ ) external returns (bool); function erc721Approve(address spender_, uint256 id_) external; function setApprovalForAll(address operator_, bool approved_) external; function transferFrom( address from_, address to_, uint256 valueOrId_ ) external returns (bool); function erc20TransferFrom( address from_, address to_, uint256 value_ ) external returns (bool); function erc721TransferFrom( address from_, address to_, uint256 id_ ) external; function transfer(address to_, uint256 amount_) external returns (bool); function getERC721QueueLength() external view returns (uint256); function getERC721TokensInQueue( uint256 start_, uint256 count_ ) external view returns (uint256[] memory); function setSelfERC721TransferExempt(bool state_) external; function safeTransferFrom( address from_, address to_, uint256 id_ ) external; function safeTransferFrom( address from_, address to_, uint256 id_, bytes calldata data_ ) external; function DOMAIN_SEPARATOR() external view returns (bytes32); function permit( address owner_, address spender_, uint256 value_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_ ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/DoubleEndedQueue.sol) // Modified by Pandora Labs to support native packed operations pragma solidity ^0.8.20; /** * @dev A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of * the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and * FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes {clear}, given that * the existing queue contents are left in storage. * * The struct is called `Uint16Deque`. And is designed for packed uint16 values, though this approach can be * extrapolated to different implementations. This data structure can only be used in storage, and not in memory. * * ```solidity * PackedDoubleEndedQueue.Uint16Deque queue; * ``` */ library PackedDoubleEndedQueue { uint128 constant SLOT_MASK = (1 << 64) - 1; uint128 constant INDEX_MASK = SLOT_MASK << 64; uint256 constant SLOT_DATA_MASK = (1 << 16) - 1; /** * @dev An operation (e.g. {front}) couldn't be completed due to the queue being empty. */ error QueueEmpty(); /** * @dev A push operation couldn't be completed due to the queue being full. */ error QueueFull(); /** * @dev An operation (e.g. {at}) couldn't be completed due to an index being out of bounds. */ error QueueOutOfBounds(); /** * @dev Invalid slot. */ error InvalidSlot(); /** * @dev Indices and slots are 64 bits to fit within a single storage slot. * * Struct members have an underscore prefix indicating that they are "private" and should not be read or written to * directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and * lead to unexpected behavior. * * The first item is at data[begin] and the last item is at data[end - 1]. This range can wrap around. */ struct Uint16Deque { uint64 _beginIndex; uint64 _beginSlot; uint64 _endIndex; uint64 _endSlot; mapping(uint64 index => uint256) _data; } /** * @dev Removes the item at the end of the queue and returns it. * * Reverts with {QueueEmpty} if the queue is empty. */ function popBack(Uint16Deque storage deque) internal returns (uint16 value) { unchecked { uint64 backIndex = deque._endIndex; uint64 backSlot = deque._endSlot; if (backIndex == deque._beginIndex && backSlot == deque._beginSlot) { revert QueueEmpty(); } if (backSlot == 0) { --backIndex; backSlot = 15; } else { --backSlot; } uint256 data = deque._data[backIndex]; value = _getEntry(data, backSlot); deque._data[backIndex] = _setData(data, backSlot, 0); deque._endIndex = backIndex; deque._endSlot = backSlot; } } /** * @dev Inserts an item at the beginning of the queue. * * Reverts with {QueueFull} if the queue is full. */ function pushFront(Uint16Deque storage deque, uint16 value_) internal { unchecked { uint64 frontIndex = deque._beginIndex; uint64 frontSlot = deque._beginSlot; if (frontSlot == 0) { --frontIndex; frontSlot = 15; } else { --frontSlot; } if (frontIndex == deque._endIndex) revert QueueFull(); deque._data[frontIndex] = _setData(deque._data[frontIndex], frontSlot, value_); deque._beginIndex = frontIndex; deque._beginSlot = frontSlot; } } /** * @dev Return the item at a position in the queue given by `index`, with the first item at 0 and last item at * `length(deque) - 1`. * * Reverts with `QueueOutOfBounds` if the index is out of bounds. */ function at( Uint16Deque storage deque, uint256 index_ ) internal view returns (uint16 value) { if (index_ >= length(deque) * 16) revert QueueOutOfBounds(); unchecked { return _getEntry( deque._data[deque._beginIndex + uint64(deque._beginSlot + (index_ % 16)) / 16 + uint64(index_ / 16)], uint64(((deque._beginSlot + index_) % 16)) ); } } /** * @dev Returns the number of items in the queue. */ function length(Uint16Deque storage deque) internal view returns (uint256) { unchecked { return (16 - deque._beginSlot) + deque._endSlot + deque._endIndex * 16 - deque._beginIndex * 16 - 16; } } /** * @dev Returns true if the queue is empty. */ function empty(Uint16Deque storage deque) internal view returns (bool) { return deque._endSlot == deque._beginSlot && deque._endIndex == deque._beginIndex; } function _setData( uint256 data_, uint64 slot_, uint16 value ) private pure returns (uint256) { return (data_ & (~_getSlotMask(slot_))) + (uint256(value) << (16 * slot_)); } function _getEntry( uint256 data, uint64 slot_ ) private pure returns (uint16) { return uint16((data & _getSlotMask(slot_)) >> (16 * slot_)); } function _getSlotMask(uint64 slot_) private pure returns (uint256) { return SLOT_DATA_MASK << (slot_ * 16); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; library ERC721Events { event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); event Approval( address indexed owner, address indexed spender, uint256 indexed id ); event Transfer( address indexed from, address indexed to, uint256 indexed id ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; library ERC20Events { event Approval( address indexed owner, address indexed spender, uint256 value ); event Transfer(address indexed from, address indexed to, uint256 amount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "murky/=lib/murky/src/", "solady/=node_modules/solady/", "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "openzeppelin-contracts/=lib/murky/lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"$owner","type":"address"},{"internalType":"string","name":"$baseTokenURI","type":"string"},{"internalType":"string","name":"$name","type":"string"},{"internalType":"string","name":"$symbol","type":"string"},{"internalType":"uint8","name":"$decimals","type":"uint8"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyExists","type":"error"},{"inputs":[],"name":"ClaimInsufficient","type":"error"},{"inputs":[],"name":"DecimalsTooLow","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InvalidApproval","type":"error"},{"inputs":[],"name":"InvalidExemption","type":"error"},{"inputs":[],"name":"InvalidOperator","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidSigner","type":"error"},{"inputs":[],"name":"InvalidSpender","type":"error"},{"inputs":[],"name":"InvalidTokenId","type":"error"},{"inputs":[],"name":"MintLimitReached","type":"error"},{"inputs":[],"name":"NotFound","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"OwnedIndexOverflow","type":"error"},{"inputs":[],"name":"PermitDeadlineExpired","type":"error"},{"inputs":[],"name":"PhaseClosed","type":"error"},{"inputs":[],"name":"PhaseInvalid","type":"error"},{"inputs":[],"name":"PhasePending","type":"error"},{"inputs":[],"name":"ProofInsufficient","type":"error"},{"inputs":[],"name":"ProofInvalid","type":"error"},{"inputs":[],"name":"QueueEmpty","type":"error"},{"inputs":[],"name":"QueueFull","type":"error"},{"inputs":[],"name":"QueueOutOfBounds","type":"error"},{"inputs":[],"name":"RecipientIsERC721TransferExempt","type":"error"},{"inputs":[],"name":"SupplyInsufficient","type":"error"},{"inputs":[],"name":"TokenInvalid","type":"error"},{"inputs":[],"name":"TokenLoading","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnsafeRecipient","type":"error"},{"inputs":[],"name":"ValueInsufficient","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ID_ENCODING_PREFIX","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TOTAL_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SUPPLY_RETAINED","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"active","outputs":[{"internalType":"uint256","name":"$phaseIndex","type":"uint256"},{"components":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"uint32","name":"startTime","type":"uint32"},{"internalType":"uint32","name":"endTime","type":"uint32"}],"internalType":"struct LibPalette.Phase","name":"$phase","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"$phaseIndex","type":"uint256"}],"name":"active","outputs":[{"internalType":"bool","name":"$active","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseTokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"$phaseIndex","type":"uint256"}],"name":"closePhase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"erc20Approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"erc20BalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc20TotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"erc20TransferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"erc721Approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"erc721BalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc721TotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target_","type":"address"}],"name":"erc721TransferExempt","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"erc721TransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getERC721QueueLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start_","type":"uint256"},{"internalType":"uint256","name":"count_","type":"uint256"}],"name":"getERC721TokensInQueue","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"$phaseIndex","type":"uint256"},{"internalType":"bytes32[]","name":"$proof","type":"bytes32[]"},{"internalType":"uint256","name":"$amount","type":"uint256"},{"internalType":"uint256","name":"$price","type":"uint256"},{"internalType":"uint256","name":"$claim","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"minted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"owned","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"erc721Owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"},{"internalType":"uint256","name":"deadline_","type":"uint256"},{"internalType":"uint8","name":"v_","type":"uint8"},{"internalType":"bytes32","name":"r_","type":"bytes32"},{"internalType":"bytes32","name":"s_","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"phases","outputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"uint32","name":"startTime","type":"uint32"},{"internalType":"uint32","name":"endTime","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"$amount","type":"uint256"},{"internalType":"uint256","name":"$pricePerToken","type":"uint256"}],"name":"price","outputs":[{"internalType":"uint256","name":"$price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"$phaseIndex","type":"uint256"},{"internalType":"bytes32[]","name":"$proof","type":"bytes32[]"},{"internalType":"address","name":"$claimer","type":"address"},{"internalType":"uint256","name":"$amount","type":"uint256"},{"internalType":"uint256","name":"$price","type":"uint256"}],"name":"prove","outputs":[{"internalType":"bool","name":"$proven","type":"bool"},{"internalType":"uint256","name":"$claimable","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renderer","outputs":[{"internalType":"contract PaletteRenderer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator_","type":"address"},{"internalType":"bool","name":"approved_","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"$uri","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"$account","type":"address"},{"internalType":"bool","name":"$value","type":"bool"}],"name":"setERC721TransferExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"$phaseIndex","type":"uint256"},{"components":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"uint32","name":"startTime","type":"uint32"},{"internalType":"uint32","name":"endTime","type":"uint32"}],"internalType":"struct LibPalette.Phase","name":"$phase","type":"tuple"}],"name":"setPhase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"$renderer","type":"address"}],"name":"setRenderer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"state_","type":"bool"}],"name":"setSelfERC721TransferExempt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setTradingStarted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"$id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingStarted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"units","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101006040523480156200001257600080fd5b50604051620058f7380380620058f783398101604081905262000035916200105f565b848383836002620000478482620011bd565b506003620000568382620011bd565b5060128160ff1610156200007d576040516398790fd560e01b815260040160405180910390fd5b60ff811660808190526200009390600a6200139c565b60a0524660c052620000a462000121565b60e0525050506001600160a01b038116620000d957604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000e481620001bd565b50600f620000f38582620011bd565b50620001018560016200020f565b6200011685689b875f8b62f3b4000062000285565b5050505050620014f7565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6002604051620001559190620013b4565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b600e80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216620002375760405163a41e3d3f60e01b815260040160405180910390fd5b80156200024f576200024982620002f5565b6200025a565b6200025a826200032d565b6001600160a01b03919091166000908152600c60205260409020805460ff1916911515919091179055565b6001600160a01b038216620002ad57604051634e46966960e11b815260040160405180910390fd5b600160ff1b81600454620002c2919062001432565b1115620002e25760405163303b682f60e01b815260040160405180910390fd5b620002f060008383620003b6565b505050565b6001600160a01b0381166000908152600b6020526040812054905b81811015620002f057620003248362000684565b60010162000310565b60a05160009062000353836001600160a01b031660009081526006602052604090205490565b6200035f919062001448565b9050600062000383836001600160a01b03166000908152600b602052604090205490565b905060005b6200039482846200146b565b811015620003b057620003a78462000738565b60010162000388565b50505050565b6001600160a01b03838116600090815260066020526040808220549285168252812054909190620003e98686866200082e565b6000620003f6876200089a565b9050600062000405876200089a565b9050818015620004125750805b620006765781156200048e57600060a0518462000430919062001448565b60a0516001600160a01b038a1660009081526006602052604090205462000458919062001448565b6200046491906200146b565b905060005b8181101562000486576200047d8962000738565b60010162000469565b505062000676565b8015620004fb5760a0516001600160a01b0389166000908152600660205260408120549091620004be9162001448565b60a051620004cd908762001448565b620004d991906200146b565b905060005b818110156200048657620004f28a62000684565b600101620004de565b600060a051876200050d919062001448565b905060005b81811015620005be576001600160a01b038a166000908152600b602052604081205462000542906001906200146b565b6001600160a01b038c166000908152600b60205260408120805492935090918390811062000574576200057462001481565b60009182526020909120601082040154620005a491600f166002026101000a900461ffff16600160ff1b62001432565b9050620005b38c8c83620008d1565b505060010162000512565b5060a0518190620005e48b6001600160a01b031660009081526006602052604090205490565b620005f0919062001448565b60a051620005ff908862001448565b6200060b91906200146b565b11156200061d576200061d8962000684565b8060a051856200062e919062001448565b60a0516001600160a01b038b1660009081526006602052604090205462000656919062001448565b6200066291906200146b565b11156200067457620006748862000738565b505b506001979650505050505050565b6001600160a01b038116620006ac57604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b0381166000908152600b602052604081208054620006d4906001906200146b565b81548110620006e757620006e762001481565b600091825260209091206010820401546200071791600f166002026101000a900461ffff16600160ff1b62001432565b90506200072782600083620008d1565b620007346000826200093d565b5050565b6001600160a01b0381166200076057604051634e46966960e11b815260040160405180910390fd5b60006200076d8162000a14565b6200079a576200077e600062000a5c565b620007929061ffff16600160ff1b62001432565b9050620007e9565b600560008154620007ab9062001497565b90915550600554600101620007d35760405163303b682f60e01b815260040160405180910390fd5b600554620007e690600160ff1b62001432565b90505b6000818152600a60205260409020546001600160a01b03168015620008215760405163119b4fd360e11b815260040160405180910390fd5b620002f0818484620008d1565b6010548390600160a01b900460ff1615156000036200088d576001600160a01b038116158015906200086e5750600e546001600160a01b03828116911614155b156200088d57604051630fb2141b60e41b815260040160405180910390fd5b620003b084848462000b74565b60006001600160a01b0382161580620008cb57506001600160a01b0382166000908152600c602052604090205460ff165b92915050565b6010548390600160a01b900460ff16151560000362000930576001600160a01b03811615801590620009115750600e546001600160a01b03828116911614155b156200093057604051630fb2141b60e41b815260040160405180910390fd5b620003b084848462000c26565b81546001600160401b03808216916801000000000000000090041660008190036200096f575060001901600f62000974565b600019015b83546001600160401b03600160801b909104811690831603620009aa57604051638acb5f2760e01b815260040160405180910390fd5b6001600160401b0382166000908152600185016020526040902054620009d290828562000e95565b6001600160401b03928316600081815260018701602052604090209190915584546001600160801b031916176801000000000000000091909216021790915550565b8054600090600160c01b81046001600160401b039081166801000000000000000090920416148015620008cb575050546001600160401b03808216600160801b909204161490565b80546000906001600160401b03600160801b8204811691600160c01b8104821691168214801562000aa5575083546001600160401b038281166801000000000000000090920416145b1562000ac4576040516375e52f4f60e01b815260040160405180910390fd5b806001600160401b031660000362000ae3575060001901600f62000ae8565b600019015b6001600160401b038216600090815260018501602052604090205462000b0f818362000edc565b935062000b1f8183600062000e95565b6001600160401b03938416600081815260018801602052604090209190915585546001600160801b0316600160801b9091026001600160c01b031617600160c01b929093169190910291909117909255919050565b6001600160a01b03831662000ba357806004600082825462000b97919062001432565b9091555062000bd39050565b6001600160a01b0383166000908152600660205260408120805483929062000bcd9084906200146b565b90915550505b6001600160a01b0380831660008181526006602052604090819020805485019055519091851690600080516020620058d78339815191529062000c199085815260200190565b60405180910390a3505050565b6001600160a01b0383161562000da457600081815260086020908152604080832080546001600160a01b03191690556001600160a01b0386168352600b9091528120805462000c78906001906200146b565b8154811062000c8b5762000c8b62001481565b6000918252602090912060108204015462000cbb91600f166002026101000a900461ffff16600160ff1b62001432565b905081811462000d4c576000828152600a602052604081205460a01c6001600160a01b0386166000908152600b60205260409020805491925083918390811062000d095762000d0962001481565b90600052602060002090601091828204019190066002026101000a81548161ffff021916908361ffff16021790555062000d4a828262000f0b60201b60201c565b505b6001600160a01b0384166000908152600b6020526040902080548062000d765762000d76620014b3565b600082815260209020601060001990920191820401805461ffff6002600f8516026101000a02191690559055505b6001600160a01b0382161562000e50576000818152600a6020526040902080546001600160a01b0319166001600160a01b0384160190556001600160a01b0382166000818152600b60209081526040822080546001808201835582855292842060108204018054600f9092166002026101000a61ffff818102199093169288160291909117905592909152905462000e4a91839162000e4491906200146b565b62000f0b565b62000e60565b6000818152600a60205260408120555b80826001600160a01b0316846001600160a01b0316600080516020620058d783398151915260405160405180910390a4505050565b600062000ea4836010620014c9565b6001600160401b03168261ffff16901b62000ec58462000f7360201b60201c565b19851662000ed4919062001432565b949350505050565b600062000eeb826010620014c9565b6001600160401b031662000eff8362000f73565b8416901c905092915050565b6000828152600a60205260409020546001600160601b0382111562000f4357604051633f2cd0e360e21b815260040160405180910390fd5b6000928352600a60205260409092206001600160a01b039290921660a09190911b6001600160a01b031916019055565b600062000f82826010620014c9565b6001600160401b031661ffff901b9050919050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011262000fbf57600080fd5b81516001600160401b038082111562000fdc5762000fdc62000f97565b604051601f8301601f19908116603f0116810190828211818310171562001007576200100762000f97565b81604052838152602092508660208588010111156200102557600080fd5b600091505b838210156200104957858201830151818301840152908201906200102a565b6000602085830101528094505050505092915050565b600080600080600060a086880312156200107857600080fd5b85516001600160a01b03811681146200109057600080fd5b60208701519095506001600160401b0380821115620010ae57600080fd5b620010bc89838a0162000fad565b95506040880151915080821115620010d357600080fd5b620010e189838a0162000fad565b94506060880151915080821115620010f857600080fd5b50620011078882890162000fad565b925050608086015160ff811681146200111f57600080fd5b809150509295509295909350565b600181811c908216806200114257607f821691505b6020821081036200116357634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002f0576000816000526020600020601f850160051c81016020861015620011945750805b601f850160051c820191505b81811015620011b557828155600101620011a0565b505050505050565b81516001600160401b03811115620011d957620011d962000f97565b620011f181620011ea84546200112d565b8462001169565b602080601f831160018114620012295760008415620012105750858301515b600019600386901b1c1916600185901b178555620011b5565b600085815260208120601f198616915b828110156200125a5788860151825594840194600190910190840162001239565b5085821015620012795787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620012e0578160001904821115620012c457620012c462001289565b80851615620012d257918102915b93841c9390800290620012a4565b509250929050565b600082620012f957506001620008cb565b816200130857506000620008cb565b81600181146200132157600281146200132c576200134c565b6001915050620008cb565b60ff84111562001340576200134062001289565b50506001821b620008cb565b5060208310610133831016604e8410600b841016171562001371575081810a620008cb565b6200137d83836200129f565b806000190482111562001394576200139462001289565b029392505050565b6000620013ad60ff841683620012e8565b9392505050565b6000808354620013c4816200112d565b60018281168015620013df5760018114620013f55762001426565b60ff198416875282151583028701945062001426565b8760005260208060002060005b858110156200141d5781548a82015290840190820162001402565b50505082870194505b50929695505050505050565b80820180821115620008cb57620008cb62001289565b6000826200146657634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115620008cb57620008cb62001289565b634e487b7160e01b600052603260045260246000fd5b600060018201620014ac57620014ac62001289565b5060010190565b634e487b7160e01b600052603160045260246000fd5b6001600160401b03818116838216028082169190828114620014ef57620014ef62001289565b505092915050565b60805160a05160c05160e0516143526200158560003960006111db015260006111ab0152600081816108dc015281816112460152818161222f01528181612877015281816128bb015281816129340152818161295e015281816129b201528181612a8101528181612ace01528181612b1201528181612b390152612ef8015260006105e501526143526000f3fe6080604052600436106103765760003560e01c80637342152f116101d1578063b65d8a0811610102578063d96ca0b9116100a0578063e985e9c51161006f578063e985e9c514610b1a578063e9d1845e14610b55578063f2fde38b14610b75578063f780bc1a14610b9557600080fd5b8063d96ca0b914610a82578063dd62ed3e14610aa2578063dd63769914610ada578063dfabc03314610afa57600080fd5b8063c6e672b9116100dc578063c6e672b914610a0d578063c87b56dd14610a2d578063d505accf14610a4d578063d547cfb714610a6d57600080fd5b8063b65d8a08146109a1578063b88d4fde146109d8578063c5ab3ba6146109f857600080fd5b806394040aec1161016f578063a22cb46511610149578063a22cb465146108fe578063a9059cbb1461091e578063b1ab93171461093e578063b3f9ea341461096b57600080fd5b806394040aec1461089857806395d89b41146108b5578063976a8435146108ca57600080fd5b806389fb4c66116101ab57806389fb4c66146108255780638a696e501461083a5780638ada6b0f1461085a5780638da5cb5b1461087a57600080fd5b80637342152f146107b85780637ecebe00146107d85780638033d5811461080557600080fd5b806333039d3d116102ab57806356d3163d116102495780636352211e116102235780636352211e1461073e5780636e8f624b1461075e57806370a0823114610776578063715018a6146107a357600080fd5b806356d3163d146106d75780635b4f472a146106f75780635e66f7141461072957600080fd5b806342842e0e1161028557806342842e0e14610661578063487a2395146106815780634d966072146106a15780634f02c420146106c157600080fd5b806333039d3d146106195780633644e515146106375780633ccfd60b1461064c57600080fd5b806309f0ef651161031857806323dbf19f116102f257806323dbf19f146105365780632e37eef61461054b57806330176e13146105b3578063313ce567146105d357600080fd5b806309f0ef65146104e057806318160ddd1461050057806323b872dd1461051657600080fd5b806306fdde031161035457806306fdde031461043b578063081812fc1461045d578063095ea7b3146104ab57806309674eb0146104cb57600080fd5b806301ffc9a71461037b57806302519da3146103b057806302fb0c5e146103f4575b600080fd5b34801561038757600080fd5b5061039b610396366004613905565b610bb5565b60405190151581526020015b60405180910390f35b3480156103bc57600080fd5b506103e66103cb366004613939565b6001600160a01b031660009081526006602052604090205490565b6040519081526020016103a7565b34801561040057600080fd5b50610409610c4e565b60408051928352815160208085019190915282015163ffffffff908116848301529101511660608201526080016103a7565b34801561044757600080fd5b50610450610d22565b6040516103a791906139a4565b34801561046957600080fd5b506104936104783660046139b7565b6008602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103a7565b3480156104b757600080fd5b5061039b6104c63660046139d0565b610db0565b3480156104d757600080fd5b506103e6610df5565b3480156104ec57600080fd5b5061039b6104fb366004613939565b610e8a565b34801561050c57600080fd5b506103e660045481565b34801561052257600080fd5b5061039b6105313660046139fa565b610ebc565b610549610544366004613a82565b610ef7565b005b34801561055757600080fd5b506105916105663660046139b7565b6011602052600090815260409020805460019091015463ffffffff8082169164010000000090041683565b6040805193845263ffffffff92831660208501529116908201526060016103a7565b3480156105bf57600080fd5b506105496105ce366004613bae565b61118f565b3480156105df57600080fd5b506106077f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016103a7565b34801561062557600080fd5b506103e6690179ca4da0a7d144000081565b34801561064357600080fd5b506103e66111a7565b34801561065857600080fd5b506105496111fd565b34801561066d57600080fd5b5061054961067c3660046139fa565b611222565b34801561068d57600080fd5b506103e661069c366004613bf7565b611242565b3480156106ad57600080fd5b5061039b6106bc3660046139d0565b611279565b3480156106cd57600080fd5b506103e660055481565b3480156106e357600080fd5b506105496106f2366004613939565b61131f565b34801561070357600080fd5b5060105461039b9074010000000000000000000000000000000000000000900460ff1681565b34801561073557600080fd5b506105496113cc565b34801561074a57600080fd5b506104936107593660046139b7565b611415565b34801561076a57600080fd5b506103e6600160ff1b81565b34801561078257600080fd5b506103e6610791366004613939565b60066020526000908152604090205481565b3480156107af57600080fd5b50610549611483565b3480156107c457600080fd5b506105496107d33660046139b7565b611495565b3480156107e457600080fd5b506103e66107f3366004613939565b600d6020526000908152604090205481565b34801561081157600080fd5b5061039b6108203660046139b7565b611563565b34801561083157600080fd5b506004546103e6565b34801561084657600080fd5b50610549610855366004613c29565b6115ad565b34801561086657600080fd5b50601054610493906001600160a01b031681565b34801561088657600080fd5b50600e546001600160a01b0316610493565b3480156108a457600080fd5b506103e6689b875f8b62f3b4000081565b3480156108c157600080fd5b506104506115b7565b3480156108d657600080fd5b506103e67f000000000000000000000000000000000000000000000000000000000000000081565b34801561090a57600080fd5b50610549610919366004613c44565b6115c4565b34801561092a57600080fd5b5061039b6109393660046139d0565b61168e565b34801561094a57600080fd5b5061095e610959366004613939565b6116db565b6040516103a79190613c77565b34801561097757600080fd5b506103e6610986366004613939565b6001600160a01b03166000908152600b602052604090205490565b3480156109ad57600080fd5b506109c16109bc366004613cbb565b6117e3565b6040805192151583526020830191909152016103a7565b3480156109e457600080fd5b506105496109f3366004613d2b565b61187e565b348015610a0457600080fd5b506005546103e6565b348015610a1957600080fd5b50610549610a28366004613c44565b6119cd565b348015610a3957600080fd5b50610450610a483660046139b7565b6119df565b348015610a5957600080fd5b50610549610a68366004613da7565b611cb1565b348015610a7957600080fd5b50610450611f7f565b348015610a8e57600080fd5b5061039b610a9d3660046139fa565b611f8c565b348015610aae57600080fd5b506103e6610abd366004613e1a565b600760209081526000928352604080842090915290825290205481565b348015610ae657600080fd5b50610549610af53660046139fa565b61207e565b348015610b0657600080fd5b50610549610b153660046139d0565b61225e565b348015610b2657600080fd5b5061039b610b35366004613e1a565b600960209081526000928352604080842090915290825290205460ff1681565b348015610b6157600080fd5b50610549610b70366004613e58565b612355565b348015610b8157600080fd5b50610549610b90366004613939565b612466565b348015610ba157600080fd5b5061095e610bb0366004613bf7565b6124bf565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fcaf91ff5000000000000000000000000000000000000000000000000000000001480610c4857507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b6040805160608101825260008082526020820181905291810182905260005b603c811015610d18576000818152601160205260409020600101544263ffffffff909116108015610cbd57506000818152601160205260409020600101544264010000000090910463ffffffff16115b15610d105760008181526011602090815260409182902082516060810184528154815260019091015463ffffffff8082169383019390935264010000000090049091169181019190915290939092509050565b600101610c6d565b5060001991509091565b60028054610d2f90613edf565b80601f0160208091040260200160405190810160405280929190818152602001828054610d5b90613edf565b8015610da85780601f10610d7d57610100808354040283529160200191610da8565b820191906000526020600020905b815481529060010190602001808311610d8b57829003601f168201915b505050505081565b6000600160ff1b82118015610dc757506000198214155b15610ddb57610dd6838361225e565b610dec565b610de58383611279565b9050610c48565b50600192915050565b6000610e856000547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff067ffffffffffffffff8083166010908102680100000000000000008504831682037801000000000000000000000000000000000000000000000000860484160170010000000000000000000000000000000090950483169091029390930192909203011690565b905090565b60006001600160a01b0382161580610c485750506001600160a01b03166000908152600c602052604090205460ff1690565b6000600160ff1b821115610eda57610ed584848461207e565b610eec565b610ee5848484611f8c565b9050610ef0565b5060015b9392505050565b6000868152601160205260409020600181015487919063ffffffff16421015610f4c576040517f352f847400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018101544264010000000090910463ffffffff161015610f99576040517fc75933e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8054600003610fd4576040517f4d45de8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b878787338888883481600454610fea9190613f61565b690179ca4da0a7d1440000101561102d576040517f1d0a391c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008061103e8a8a8a8a8a8a6117e3565b909250905081151560000361107f576040517f7fcdd1f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808411156110b9576040517ff1cd97ea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620f42408410156110f6576040517fa15f405c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111008486611242565b831015611139576040517f383abece00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008a81526012602090815260408083206001600160a01b038b1684529091528120805486929061116b908490613f61565b9091555061117b9050338e61256e565b505050505050505050505050505050505050565b611197612605565b600f6111a38282613fc4565b5050565b60007f000000000000000000000000000000000000000000000000000000000000000046146111d857610e8561264b565b507f000000000000000000000000000000000000000000000000000000000000000090565b611205612605565b61122061121a600e546001600160a01b031690565b476126e5565b565b61123d8383836040518060200160405280600081525061187e565b505050565b60007f000000000000000000000000000000000000000000000000000000000000000061126f8385614084565b610ef091906140ca565b60006001600160a01b0383166112bb576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350600192915050565b611327612605565b601080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155156113c957601060009054906101000a90046001600160a01b03166001600160a01b031663d9374bff6040518163ffffffff1660e01b815260040160006040518083038186803b1580156113b057600080fd5b505afa1580156113c4573d6000803e3d6000fd5b505050505b50565b6113d4612605565b601080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b6000818152600a60205260409020546001600160a01b0316600160ff1b8211158061144757506001600160a01b038116155b1561147e576040517fc5723b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b61148b612605565b6112206000612701565b61149d612605565b6000818152601160205260409020600101548190640100000000900463ffffffff16801561150557428163ffffffff161015611505576040517fc75933e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611510600142614105565b600093845260116020526040909320600101805463ffffffff94909416640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff909416939093179092555050565b6000818152601160205260408120600101544263ffffffff909116108015610c485750506000908152601160205260409020600101544264010000000090910463ffffffff161190565b6113c9338261276b565b60038054610d2f90613edf565b6001600160a01b038216611604576040517fccea9e6f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526009602090815260408083206001600160a01b0387168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b0383166116d0576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ef0338484612811565b6001600160a01b0381166000908152600b60205260408120546060919067ffffffffffffffff81111561171057611710613ae8565b604051908082528060200260200182016040528015611739578160200160208202803683370190505b50905060005b6001600160a01b0384166000908152600b60205260409020548110156117dc576001600160a01b0384166000908152600b6020526040902080548290811061178957611789614118565b600091825260209091206010820401546117b791600f166002026101000a900461ffff16600160ff1b613f61565b8282815181106117c9576117c9614118565b602090810291909101015260010161173f565b5092915050565b60008681526011602090815260408083205481516001600160a01b03881681850152808301879052606080820187905283518083039091018152608090910190925281519190920120829161183b9189918991612baa565b915081156118735760008881526012602090815260408083206001600160a01b03891684529091529020546118709085614105565b90505b965096945050505050565b600160ff1b82116118bb576040517f3f6cc76800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6118c6848484610ebc565b506001600160a01b0383163b1580159061199057506040517f150b7a0200000000000000000000000000000000000000000000000000000000808252906001600160a01b0385169063150b7a0290611928903390899088908890600401614147565b6020604051808303816000875af1158015611947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196b9190614183565b7fffffffff000000000000000000000000000000000000000000000000000000001614155b156119c7576040517f3da6393100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b6119d5612605565b6111a3828261276b565b6000818152600a60205260409020546060906001600160a01b0316611a30576040517fab9713c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611a40600160ff1b84614105565b6010549091506001600160a01b031615611ade576010546040517fc321118c000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b039091169063c321118c90602401600060405180830381865afa158015611ab6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ef091908101906141a0565b6000600f8054611aed90613edf565b80601f0160208091040260200160405190810160405280929190818152602001828054611b1990613edf565b8015611b665780601f10611b3b57610100808354040283529160200191611b66565b820191906000526020600020905b815481529060010190602001808311611b4957829003601f168201915b505083519394505050811580159150611be2575081611b86600183614105565b81518110611b9657611b96614118565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f2f0000000000000000000000000000000000000000000000000000000000000014155b15611c7c57600f8054611bf490613edf565b80601f0160208091040260200160405190810160405280929190818152602001828054611c2090613edf565b8015611c6d5780601f10611c4257610100808354040283529160200191611c6d565b820191906000526020600020905b815481529060010190602001808311611c5057829003601f168201915b50505050509350505050919050565b600f611c8784612be4565b604051602001611c9892919061429f565b6040516020818303038152906040529350505050919050565b42841015611ceb576040517f05787bdf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160ff1b85118015611d0057506000198514155b15611d37576040517f1f3e0de800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038616611d77576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006001611d836111a7565b6001600160a01b038a81166000818152600d602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e0830190915280519201919091207f19010000000000000000000000000000000000000000000000000000000000006101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015611eaa573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580611edf5750876001600160a01b0316816001600160a01b031614155b15611f16576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0390811660009081526007602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b600f8054610d2f90613edf565b60006001600160a01b038416611fce576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03831661200e576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0384166000908152600760209081526040808320338452909152902054600019811461206a576120458382614105565b6001600160a01b03861660009081526007602090815260408083203384529091529020555b612075858585612811565b95945050505050565b6001600160a01b0383166120be576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166120fe576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600a60205260409020546001600160a01b03848116911614612151576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336001600160a01b0384161480159061218e57506001600160a01b038316600090815260096020908152604080832033845290915290205460ff16155b80156121b157506000818152600860205260409020546001600160a01b03163314155b156121e8576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121f182610e8a565b15612228576040517f5ce7539700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61225383837f0000000000000000000000000000000000000000000000000000000000000000612c28565b61123d838383612cb9565b6000818152600a60205260409020546001600160a01b03163381148015906122aa57506001600160a01b038116600090815260096020908152604080832033845290915290205460ff16155b156122e1576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526008602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b61235d612605565b6000828152601160205260409020600101548290640100000000900463ffffffff1680156123c557428163ffffffff1610156123c5576040517fc75933e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8251600003612400576040517f4d45de8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600091825260116020908152604092839020825181559082015160019091018054939092015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000909416911617919091179055565b61246e612605565b6001600160a01b0381166124b6576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b6113c981612701565b606060008267ffffffffffffffff8111156124dc576124dc613ae8565b604051908082528060200260200182016040528015612505578160200160208202803683370190505b509050835b6125148486613f61565b81101561256657612526600082612d4a565b6125389061ffff16600160ff1b613f61565b826125438784614105565b8151811061255357612553614118565b602090810291909101015260010161250a565b509392505050565b6001600160a01b0382166125ae576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160ff1b816004546125c19190613f61565b11156125f9576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61123d60008383612811565b600e546001600160a01b03163314611220576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016124ad565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600260405161267d91906142c4565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60003860003884865af16111a35763b12d13eb6000526004601cfd5b600e80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166127ab576040517fa41e3d3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80156127bf576127ba82612ea5565b6127c8565b6127c882612ed9565b6001600160a01b03919091166000908152600c6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6001600160a01b03838116600090815260066020526040808220549285168252812054909190612842868686612c28565b600061284d87610e8a565b9050600061285a87610e8a565b90508180156128665750805b612b9c57811561290f57600061289c7f0000000000000000000000000000000000000000000000000000000000000000856140ca565b6001600160a01b0389166000908152600660205260409020546128e0907f0000000000000000000000000000000000000000000000000000000000000000906140ca565b6128ea9190614105565b905060005b818110156129085761290089612f67565b6001016128ef565b5050612b9c565b80156129ab576001600160a01b038816600090815260066020526040812054612959907f0000000000000000000000000000000000000000000000000000000000000000906140ca565b6129837f0000000000000000000000000000000000000000000000000000000000000000876140ca565b61298d9190614105565b905060005b81811015612908576129a38a613098565b600101612992565b60006129d77f0000000000000000000000000000000000000000000000000000000000000000886140ca565b905060005b81811015612a7d576001600160a01b038a166000908152600b6020526040812054612a0990600190614105565b6001600160a01b038c166000908152600b602052604081208054929350909183908110612a3857612a38614118565b60009182526020909120601082040154612a6691600f166002026101000a900461ffff16600160ff1b613f61565b9050612a738c8c83612cb9565b50506001016129dc565b50807f0000000000000000000000000000000000000000000000000000000000000000612abf8b6001600160a01b031660009081526006602052604090205490565b612ac991906140ca565b612af37f0000000000000000000000000000000000000000000000000000000000000000886140ca565b612afd9190614105565b1115612b0c57612b0c89613098565b80612b377f0000000000000000000000000000000000000000000000000000000000000000866140ca565b7f0000000000000000000000000000000000000000000000000000000000000000612b778b6001600160a01b031660009081526006602052604090205490565b612b8191906140ca565b612b8b9190614105565b1115612b9a57612b9a88612f67565b505b506001979650505050505050565b60008315612bdc578360051b8501855b803580851160051b94855260209485185260406000209301818110612bba5750505b501492915050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a900480612bff575050819003601f19909101908152919050565b601054839074010000000000000000000000000000000000000000900460ff161515600003612cae576001600160a01b03811615801590612c775750600e546001600160a01b03828116911614155b15612cae576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c7848484613155565b601054839074010000000000000000000000000000000000000000900460ff161515600003612d3f576001600160a01b03811615801590612d085750600e546001600160a01b03828116911614155b15612d3f576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c7848484613211565b6000612dd983547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff067ffffffffffffffff8083166010908102680100000000000000008504831682037801000000000000000000000000000000000000000000000000860484160170010000000000000000000000000000000090950483169091029390930192909203011690565b612de4906010614084565b8210612e1c576040517f580821e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ef06001840160006010850460108087895467ffffffffffffffff68010000000000000000909104811692909106919091011681612e5d57612e5d61409b565b885491900467ffffffffffffffff80831691909101929092018216835260208301939093526040909101600020549160109168010000000000000000909104168501066134a4565b6001600160a01b0381166000908152600b6020526040812054905b8181101561123d57612ed183613098565b600101612ec0565b6001600160a01b038116600090815260066020526040812054612f1d907f0000000000000000000000000000000000000000000000000000000000000000906140ca565b90506000612f40836001600160a01b03166000908152600b602052604090205490565b905060005b612f4f8284614105565b8110156119c757612f5f84612f67565b600101612f45565b6001600160a01b038116612fa7576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612fb360006134d0565b612fda57612fc1600061353b565b612fd39061ffff16600160ff1b613f61565b905061303d565b600560008154612fe9906142d0565b90915550600554600101613029576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60055461303a90600160ff1b613f61565b90505b6000818152600a60205260409020546001600160a01b0316801561308d576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61123d818484612cb9565b6001600160a01b0381166130d8576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381166000908152600b6020526040812080546130fe90600190614105565b8154811061310e5761310e614118565b6000918252602090912060108204015461313c91600f166002026101000a900461ffff16600160ff1b613f61565b905061314a82600083612cb9565b6111a36000826136c7565b6001600160a01b0383166131805780600460008282546131759190613f61565b909155506131ae9050565b6001600160a01b038316600090815260066020526040812080548392906131a8908490614105565b90915550505b6001600160a01b03808316600081815260066020526040908190208054850190555190918516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906132049085815260200190565b60405180910390a3505050565b6001600160a01b0383161561339057600081815260086020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556001600160a01b0386168352600b9091528120805461327890600190614105565b8154811061328857613288614118565b600091825260209091206010820401546132b691600f166002026101000a900461ffff16600160ff1b613f61565b905081811461333b576000828152600a602052604081205460a01c6001600160a01b0386166000908152600b60205260409020805491925083918390811061330057613300614118565b90600052602060002090601091828204019190066002026101000a81548161ffff021916908361ffff16021790555061333982826137db565b505b6001600160a01b0384166000908152600b60205260409020805480613362576133626142ea565b600082815260209020601060001990920191820401805461ffff6002600f8516026101000a02191690559055505b6001600160a01b0382161561344e576000818152600a6020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384160190556001600160a01b0382166000818152600b60209081526040822080546001808201835582855292842060108204018054600f9092166002026101000a61ffff81810219909316928816029190911790559290915290546134499183916134449190614105565b6137db565b61345e565b6000818152600a60205260408120555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006134b1826010614319565b67ffffffffffffffff166134c483613878565b8416901c905092915050565b80546000907801000000000000000000000000000000000000000000000000810467ffffffffffffffff9081166801000000000000000090920416148015610c485750505467ffffffffffffffff808216700100000000000000000000000000000000909204161490565b805460009067ffffffffffffffff70010000000000000000000000000000000082048116917801000000000000000000000000000000000000000000000000810482169116821480156135a75750835467ffffffffffffffff8281166801000000000000000090920416145b156135de576040517f75e52f4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8067ffffffffffffffff166000036135fc575060001901600f613601565b600019015b67ffffffffffffffff8216600090815260018501602052604090205461362781836134a4565b93506136358183600061389b565b67ffffffffffffffff938416600081815260018801602052604090209190915585546fffffffffffffffffffffffffffffffff1670010000000000000000000000000000000090910277ffffffffffffffffffffffffffffffffffffffffffffffff16177801000000000000000000000000000000000000000000000000929093169190910291909117909255919050565b815467ffffffffffffffff808216916801000000000000000090041660008190036136f8575060001901600f6136fd565b600019015b835467ffffffffffffffff700100000000000000000000000000000000909104811690831603613759576040517f8acb5f2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff8216600090815260018501602052604090205461378090828561389b565b67ffffffffffffffff928316600081815260018701602052604090209190915584547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016176801000000000000000091909216021790915550565b6000828152600a60205260409020546bffffffffffffffffffffffff821115613830576040517ffcb3438c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000928352600a60205260409092206001600160a01b039290921660a09190911b7fffffffffffffffffffffffff000000000000000000000000000000000000000016019055565b6000613885826010614319565b67ffffffffffffffff1661ffff901b9050919050565b60006138a8836010614319565b67ffffffffffffffff168261ffff16901b6138c284613878565b1985166138cf9190613f61565b949350505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146113c957600080fd5b60006020828403121561391757600080fd5b8135610ef0816138d7565b80356001600160a01b038116811461147e57600080fd5b60006020828403121561394b57600080fd5b610ef082613922565b60005b8381101561396f578181015183820152602001613957565b50506000910152565b60008151808452613990816020860160208601613954565b601f01601f19169290920160200192915050565b602081526000610ef06020830184613978565b6000602082840312156139c957600080fd5b5035919050565b600080604083850312156139e357600080fd5b6139ec83613922565b946020939093013593505050565b600080600060608486031215613a0f57600080fd5b613a1884613922565b9250613a2660208501613922565b9150604084013590509250925092565b60008083601f840112613a4857600080fd5b50813567ffffffffffffffff811115613a6057600080fd5b6020830191508360208260051b8501011115613a7b57600080fd5b9250929050565b60008060008060008060a08789031215613a9b57600080fd5b86359550602087013567ffffffffffffffff811115613ab957600080fd5b613ac589828a01613a36565b979a90995096976040810135976060820135975060809091013595509350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613b4057613b40613ae8565b604052919050565b600067ffffffffffffffff821115613b6257613b62613ae8565b50601f01601f191660200190565b6000613b83613b7e84613b48565b613b17565b9050828152838383011115613b9757600080fd5b828260208301376000602084830101529392505050565b600060208284031215613bc057600080fd5b813567ffffffffffffffff811115613bd757600080fd5b8201601f81018413613be857600080fd5b6138cf84823560208401613b70565b60008060408385031215613c0a57600080fd5b50508035926020909101359150565b8035801515811461147e57600080fd5b600060208284031215613c3b57600080fd5b610ef082613c19565b60008060408385031215613c5757600080fd5b613c6083613922565b9150613c6e60208401613c19565b90509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613caf57835183529284019291840191600101613c93565b50909695505050505050565b60008060008060008060a08789031215613cd457600080fd5b86359550602087013567ffffffffffffffff811115613cf257600080fd5b613cfe89828a01613a36565b9096509450613d11905060408801613922565b925060608701359150608087013590509295509295509295565b60008060008060808587031215613d4157600080fd5b613d4a85613922565b9350613d5860208601613922565b925060408501359150606085013567ffffffffffffffff811115613d7b57600080fd5b8501601f81018713613d8c57600080fd5b613d9b87823560208401613b70565b91505092959194509250565b600080600080600080600060e0888a031215613dc257600080fd5b613dcb88613922565b9650613dd960208901613922565b95506040880135945060608801359350608088013560ff81168114613dfd57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613e2d57600080fd5b613e3683613922565b9150613c6e60208401613922565b803563ffffffff8116811461147e57600080fd5b6000808284036080811215613e6c57600080fd5b833592506060601f1982011215613e8257600080fd5b506040516060810181811067ffffffffffffffff82111715613ea657613ea6613ae8565b806040525060208401358152613ebe60408501613e44565b6020820152613ecf60608501613e44565b6040820152809150509250929050565b600181811c90821680613ef357607f821691505b602082108103613f2c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610c4857610c48613f32565b601f82111561123d576000816000526020600020601f850160051c81016020861015613f9d5750805b601f850160051c820191505b81811015613fbc57828155600101613fa9565b505050505050565b815167ffffffffffffffff811115613fde57613fde613ae8565b613ff281613fec8454613edf565b84613f74565b602080601f831160018114614027576000841561400f5750858301515b600019600386901b1c1916600185901b178555613fbc565b600085815260208120601f198616915b8281101561405657888601518255948401946001909101908401614037565b50858210156140745787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082028115828204841417610c4857610c48613f32565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082614100577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115610c4857610c48613f32565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006001600160a01b038087168352808616602084015250836040830152608060608301526141796080830184613978565b9695505050505050565b60006020828403121561419557600080fd5b8151610ef0816138d7565b6000602082840312156141b257600080fd5b815167ffffffffffffffff8111156141c957600080fd5b8201601f810184136141da57600080fd5b80516141e8613b7e82613b48565b8181528560208385010111156141fd57600080fd5b612075826020830160208601613954565b6000815461421b81613edf565b60018281168015614233576001811461426657614295565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450614295565b8560005260208060002060005b8581101561428c5781548a820152908401908201614273565b50505082870194505b5050505092915050565b60006142ab828561420e565b83516142bb818360208801613954565b01949350505050565b6000610ef0828461420e565b600060001982036142e3576142e3613f32565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b67ffffffffffffffff81811683821602808216919082811461433d5761433d613f32565b50509291505056fea164736f6c6343000817000addf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef000000000000000000000000babb6638172865996b1480210d8f2d4ed0fe9a5200000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d6271324870436e7444566d4b77766942725a437874414339785843424452634b6d626f7379725548726a62320000000000000000000000000000000000000000000000000000000000000000000000000000000000000750616c65747465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003504c540000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106103765760003560e01c80637342152f116101d1578063b65d8a0811610102578063d96ca0b9116100a0578063e985e9c51161006f578063e985e9c514610b1a578063e9d1845e14610b55578063f2fde38b14610b75578063f780bc1a14610b9557600080fd5b8063d96ca0b914610a82578063dd62ed3e14610aa2578063dd63769914610ada578063dfabc03314610afa57600080fd5b8063c6e672b9116100dc578063c6e672b914610a0d578063c87b56dd14610a2d578063d505accf14610a4d578063d547cfb714610a6d57600080fd5b8063b65d8a08146109a1578063b88d4fde146109d8578063c5ab3ba6146109f857600080fd5b806394040aec1161016f578063a22cb46511610149578063a22cb465146108fe578063a9059cbb1461091e578063b1ab93171461093e578063b3f9ea341461096b57600080fd5b806394040aec1461089857806395d89b41146108b5578063976a8435146108ca57600080fd5b806389fb4c66116101ab57806389fb4c66146108255780638a696e501461083a5780638ada6b0f1461085a5780638da5cb5b1461087a57600080fd5b80637342152f146107b85780637ecebe00146107d85780638033d5811461080557600080fd5b806333039d3d116102ab57806356d3163d116102495780636352211e116102235780636352211e1461073e5780636e8f624b1461075e57806370a0823114610776578063715018a6146107a357600080fd5b806356d3163d146106d75780635b4f472a146106f75780635e66f7141461072957600080fd5b806342842e0e1161028557806342842e0e14610661578063487a2395146106815780634d966072146106a15780634f02c420146106c157600080fd5b806333039d3d146106195780633644e515146106375780633ccfd60b1461064c57600080fd5b806309f0ef651161031857806323dbf19f116102f257806323dbf19f146105365780632e37eef61461054b57806330176e13146105b3578063313ce567146105d357600080fd5b806309f0ef65146104e057806318160ddd1461050057806323b872dd1461051657600080fd5b806306fdde031161035457806306fdde031461043b578063081812fc1461045d578063095ea7b3146104ab57806309674eb0146104cb57600080fd5b806301ffc9a71461037b57806302519da3146103b057806302fb0c5e146103f4575b600080fd5b34801561038757600080fd5b5061039b610396366004613905565b610bb5565b60405190151581526020015b60405180910390f35b3480156103bc57600080fd5b506103e66103cb366004613939565b6001600160a01b031660009081526006602052604090205490565b6040519081526020016103a7565b34801561040057600080fd5b50610409610c4e565b60408051928352815160208085019190915282015163ffffffff908116848301529101511660608201526080016103a7565b34801561044757600080fd5b50610450610d22565b6040516103a791906139a4565b34801561046957600080fd5b506104936104783660046139b7565b6008602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103a7565b3480156104b757600080fd5b5061039b6104c63660046139d0565b610db0565b3480156104d757600080fd5b506103e6610df5565b3480156104ec57600080fd5b5061039b6104fb366004613939565b610e8a565b34801561050c57600080fd5b506103e660045481565b34801561052257600080fd5b5061039b6105313660046139fa565b610ebc565b610549610544366004613a82565b610ef7565b005b34801561055757600080fd5b506105916105663660046139b7565b6011602052600090815260409020805460019091015463ffffffff8082169164010000000090041683565b6040805193845263ffffffff92831660208501529116908201526060016103a7565b3480156105bf57600080fd5b506105496105ce366004613bae565b61118f565b3480156105df57600080fd5b506106077f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff90911681526020016103a7565b34801561062557600080fd5b506103e6690179ca4da0a7d144000081565b34801561064357600080fd5b506103e66111a7565b34801561065857600080fd5b506105496111fd565b34801561066d57600080fd5b5061054961067c3660046139fa565b611222565b34801561068d57600080fd5b506103e661069c366004613bf7565b611242565b3480156106ad57600080fd5b5061039b6106bc3660046139d0565b611279565b3480156106cd57600080fd5b506103e660055481565b3480156106e357600080fd5b506105496106f2366004613939565b61131f565b34801561070357600080fd5b5060105461039b9074010000000000000000000000000000000000000000900460ff1681565b34801561073557600080fd5b506105496113cc565b34801561074a57600080fd5b506104936107593660046139b7565b611415565b34801561076a57600080fd5b506103e6600160ff1b81565b34801561078257600080fd5b506103e6610791366004613939565b60066020526000908152604090205481565b3480156107af57600080fd5b50610549611483565b3480156107c457600080fd5b506105496107d33660046139b7565b611495565b3480156107e457600080fd5b506103e66107f3366004613939565b600d6020526000908152604090205481565b34801561081157600080fd5b5061039b6108203660046139b7565b611563565b34801561083157600080fd5b506004546103e6565b34801561084657600080fd5b50610549610855366004613c29565b6115ad565b34801561086657600080fd5b50601054610493906001600160a01b031681565b34801561088657600080fd5b50600e546001600160a01b0316610493565b3480156108a457600080fd5b506103e6689b875f8b62f3b4000081565b3480156108c157600080fd5b506104506115b7565b3480156108d657600080fd5b506103e67f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b34801561090a57600080fd5b50610549610919366004613c44565b6115c4565b34801561092a57600080fd5b5061039b6109393660046139d0565b61168e565b34801561094a57600080fd5b5061095e610959366004613939565b6116db565b6040516103a79190613c77565b34801561097757600080fd5b506103e6610986366004613939565b6001600160a01b03166000908152600b602052604090205490565b3480156109ad57600080fd5b506109c16109bc366004613cbb565b6117e3565b6040805192151583526020830191909152016103a7565b3480156109e457600080fd5b506105496109f3366004613d2b565b61187e565b348015610a0457600080fd5b506005546103e6565b348015610a1957600080fd5b50610549610a28366004613c44565b6119cd565b348015610a3957600080fd5b50610450610a483660046139b7565b6119df565b348015610a5957600080fd5b50610549610a68366004613da7565b611cb1565b348015610a7957600080fd5b50610450611f7f565b348015610a8e57600080fd5b5061039b610a9d3660046139fa565b611f8c565b348015610aae57600080fd5b506103e6610abd366004613e1a565b600760209081526000928352604080842090915290825290205481565b348015610ae657600080fd5b50610549610af53660046139fa565b61207e565b348015610b0657600080fd5b50610549610b153660046139d0565b61225e565b348015610b2657600080fd5b5061039b610b35366004613e1a565b600960209081526000928352604080842090915290825290205460ff1681565b348015610b6157600080fd5b50610549610b70366004613e58565b612355565b348015610b8157600080fd5b50610549610b90366004613939565b612466565b348015610ba157600080fd5b5061095e610bb0366004613bf7565b6124bf565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fcaf91ff5000000000000000000000000000000000000000000000000000000001480610c4857507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b6040805160608101825260008082526020820181905291810182905260005b603c811015610d18576000818152601160205260409020600101544263ffffffff909116108015610cbd57506000818152601160205260409020600101544264010000000090910463ffffffff16115b15610d105760008181526011602090815260409182902082516060810184528154815260019091015463ffffffff8082169383019390935264010000000090049091169181019190915290939092509050565b600101610c6d565b5060001991509091565b60028054610d2f90613edf565b80601f0160208091040260200160405190810160405280929190818152602001828054610d5b90613edf565b8015610da85780601f10610d7d57610100808354040283529160200191610da8565b820191906000526020600020905b815481529060010190602001808311610d8b57829003601f168201915b505050505081565b6000600160ff1b82118015610dc757506000198214155b15610ddb57610dd6838361225e565b610dec565b610de58383611279565b9050610c48565b50600192915050565b6000610e856000547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff067ffffffffffffffff8083166010908102680100000000000000008504831682037801000000000000000000000000000000000000000000000000860484160170010000000000000000000000000000000090950483169091029390930192909203011690565b905090565b60006001600160a01b0382161580610c485750506001600160a01b03166000908152600c602052604090205460ff1690565b6000600160ff1b821115610eda57610ed584848461207e565b610eec565b610ee5848484611f8c565b9050610ef0565b5060015b9392505050565b6000868152601160205260409020600181015487919063ffffffff16421015610f4c576040517f352f847400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018101544264010000000090910463ffffffff161015610f99576040517fc75933e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8054600003610fd4576040517f4d45de8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b878787338888883481600454610fea9190613f61565b690179ca4da0a7d1440000101561102d576040517f1d0a391c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008061103e8a8a8a8a8a8a6117e3565b909250905081151560000361107f576040517f7fcdd1f400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808411156110b9576040517ff1cd97ea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620f42408410156110f6576040517fa15f405c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111008486611242565b831015611139576040517f383abece00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008a81526012602090815260408083206001600160a01b038b1684529091528120805486929061116b908490613f61565b9091555061117b9050338e61256e565b505050505050505050505050505050505050565b611197612605565b600f6111a38282613fc4565b5050565b60007f000000000000000000000000000000000000000000000000000000000000000146146111d857610e8561264b565b507fb5a6a53a585f3b37dceab707a157d0d4507e26a77f1df78b2da4f587b52f88d990565b611205612605565b61122061121a600e546001600160a01b031690565b476126e5565b565b61123d8383836040518060200160405280600081525061187e565b505050565b60007f0000000000000000000000000000000000000000000000000de0b6b3a764000061126f8385614084565b610ef091906140ca565b60006001600160a01b0383166112bb576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350600192915050565b611327612605565b601080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155156113c957601060009054906101000a90046001600160a01b03166001600160a01b031663d9374bff6040518163ffffffff1660e01b815260040160006040518083038186803b1580156113b057600080fd5b505afa1580156113c4573d6000803e3d6000fd5b505050505b50565b6113d4612605565b601080547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055565b6000818152600a60205260409020546001600160a01b0316600160ff1b8211158061144757506001600160a01b038116155b1561147e576040517fc5723b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b61148b612605565b6112206000612701565b61149d612605565b6000818152601160205260409020600101548190640100000000900463ffffffff16801561150557428163ffffffff161015611505576040517fc75933e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611510600142614105565b600093845260116020526040909320600101805463ffffffff94909416640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff909416939093179092555050565b6000818152601160205260408120600101544263ffffffff909116108015610c485750506000908152601160205260409020600101544264010000000090910463ffffffff161190565b6113c9338261276b565b60038054610d2f90613edf565b6001600160a01b038216611604576040517fccea9e6f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526009602090815260408083206001600160a01b0387168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b0383166116d0576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ef0338484612811565b6001600160a01b0381166000908152600b60205260408120546060919067ffffffffffffffff81111561171057611710613ae8565b604051908082528060200260200182016040528015611739578160200160208202803683370190505b50905060005b6001600160a01b0384166000908152600b60205260409020548110156117dc576001600160a01b0384166000908152600b6020526040902080548290811061178957611789614118565b600091825260209091206010820401546117b791600f166002026101000a900461ffff16600160ff1b613f61565b8282815181106117c9576117c9614118565b602090810291909101015260010161173f565b5092915050565b60008681526011602090815260408083205481516001600160a01b03881681850152808301879052606080820187905283518083039091018152608090910190925281519190920120829161183b9189918991612baa565b915081156118735760008881526012602090815260408083206001600160a01b03891684529091529020546118709085614105565b90505b965096945050505050565b600160ff1b82116118bb576040517f3f6cc76800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6118c6848484610ebc565b506001600160a01b0383163b1580159061199057506040517f150b7a0200000000000000000000000000000000000000000000000000000000808252906001600160a01b0385169063150b7a0290611928903390899088908890600401614147565b6020604051808303816000875af1158015611947573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196b9190614183565b7fffffffff000000000000000000000000000000000000000000000000000000001614155b156119c7576040517f3da6393100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b6119d5612605565b6111a3828261276b565b6000818152600a60205260409020546060906001600160a01b0316611a30576040517fab9713c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611a40600160ff1b84614105565b6010549091506001600160a01b031615611ade576010546040517fc321118c000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b039091169063c321118c90602401600060405180830381865afa158015611ab6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ef091908101906141a0565b6000600f8054611aed90613edf565b80601f0160208091040260200160405190810160405280929190818152602001828054611b1990613edf565b8015611b665780601f10611b3b57610100808354040283529160200191611b66565b820191906000526020600020905b815481529060010190602001808311611b4957829003601f168201915b505083519394505050811580159150611be2575081611b86600183614105565b81518110611b9657611b96614118565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f2f0000000000000000000000000000000000000000000000000000000000000014155b15611c7c57600f8054611bf490613edf565b80601f0160208091040260200160405190810160405280929190818152602001828054611c2090613edf565b8015611c6d5780601f10611c4257610100808354040283529160200191611c6d565b820191906000526020600020905b815481529060010190602001808311611c5057829003601f168201915b50505050509350505050919050565b600f611c8784612be4565b604051602001611c9892919061429f565b6040516020818303038152906040529350505050919050565b42841015611ceb576040517f05787bdf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160ff1b85118015611d0057506000198514155b15611d37576040517f1f3e0de800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038616611d77576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006001611d836111a7565b6001600160a01b038a81166000818152600d602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e0830190915280519201919091207f19010000000000000000000000000000000000000000000000000000000000006101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015611eaa573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580611edf5750876001600160a01b0316816001600160a01b031614155b15611f16576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0390811660009081526007602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b600f8054610d2f90613edf565b60006001600160a01b038416611fce576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03831661200e576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0384166000908152600760209081526040808320338452909152902054600019811461206a576120458382614105565b6001600160a01b03861660009081526007602090815260408083203384529091529020555b612075858585612811565b95945050505050565b6001600160a01b0383166120be576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166120fe576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600a60205260409020546001600160a01b03848116911614612151576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336001600160a01b0384161480159061218e57506001600160a01b038316600090815260096020908152604080832033845290915290205460ff16155b80156121b157506000818152600860205260409020546001600160a01b03163314155b156121e8576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6121f182610e8a565b15612228576040517f5ce7539700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61225383837f0000000000000000000000000000000000000000000000000de0b6b3a7640000612c28565b61123d838383612cb9565b6000818152600a60205260409020546001600160a01b03163381148015906122aa57506001600160a01b038116600090815260096020908152604080832033845290915290205460ff16155b156122e1576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526008602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b61235d612605565b6000828152601160205260409020600101548290640100000000900463ffffffff1680156123c557428163ffffffff1610156123c5576040517fc75933e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8251600003612400576040517f4d45de8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600091825260116020908152604092839020825181559082015160019091018054939092015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000909416911617919091179055565b61246e612605565b6001600160a01b0381166124b6576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b6113c981612701565b606060008267ffffffffffffffff8111156124dc576124dc613ae8565b604051908082528060200260200182016040528015612505578160200160208202803683370190505b509050835b6125148486613f61565b81101561256657612526600082612d4a565b6125389061ffff16600160ff1b613f61565b826125438784614105565b8151811061255357612553614118565b602090810291909101015260010161250a565b509392505050565b6001600160a01b0382166125ae576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160ff1b816004546125c19190613f61565b11156125f9576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61123d60008383612811565b600e546001600160a01b03163314611220576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016124ad565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600260405161267d91906142c4565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60003860003884865af16111a35763b12d13eb6000526004601cfd5b600e80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166127ab576040517fa41e3d3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80156127bf576127ba82612ea5565b6127c8565b6127c882612ed9565b6001600160a01b03919091166000908152600c6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6001600160a01b03838116600090815260066020526040808220549285168252812054909190612842868686612c28565b600061284d87610e8a565b9050600061285a87610e8a565b90508180156128665750805b612b9c57811561290f57600061289c7f0000000000000000000000000000000000000000000000000de0b6b3a7640000856140ca565b6001600160a01b0389166000908152600660205260409020546128e0907f0000000000000000000000000000000000000000000000000de0b6b3a7640000906140ca565b6128ea9190614105565b905060005b818110156129085761290089612f67565b6001016128ef565b5050612b9c565b80156129ab576001600160a01b038816600090815260066020526040812054612959907f0000000000000000000000000000000000000000000000000de0b6b3a7640000906140ca565b6129837f0000000000000000000000000000000000000000000000000de0b6b3a7640000876140ca565b61298d9190614105565b905060005b81811015612908576129a38a613098565b600101612992565b60006129d77f0000000000000000000000000000000000000000000000000de0b6b3a7640000886140ca565b905060005b81811015612a7d576001600160a01b038a166000908152600b6020526040812054612a0990600190614105565b6001600160a01b038c166000908152600b602052604081208054929350909183908110612a3857612a38614118565b60009182526020909120601082040154612a6691600f166002026101000a900461ffff16600160ff1b613f61565b9050612a738c8c83612cb9565b50506001016129dc565b50807f0000000000000000000000000000000000000000000000000de0b6b3a7640000612abf8b6001600160a01b031660009081526006602052604090205490565b612ac991906140ca565b612af37f0000000000000000000000000000000000000000000000000de0b6b3a7640000886140ca565b612afd9190614105565b1115612b0c57612b0c89613098565b80612b377f0000000000000000000000000000000000000000000000000de0b6b3a7640000866140ca565b7f0000000000000000000000000000000000000000000000000de0b6b3a7640000612b778b6001600160a01b031660009081526006602052604090205490565b612b8191906140ca565b612b8b9190614105565b1115612b9a57612b9a88612f67565b505b506001979650505050505050565b60008315612bdc578360051b8501855b803580851160051b94855260209485185260406000209301818110612bba5750505b501492915050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a900480612bff575050819003601f19909101908152919050565b601054839074010000000000000000000000000000000000000000900460ff161515600003612cae576001600160a01b03811615801590612c775750600e546001600160a01b03828116911614155b15612cae576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c7848484613155565b601054839074010000000000000000000000000000000000000000900460ff161515600003612d3f576001600160a01b03811615801590612d085750600e546001600160a01b03828116911614155b15612d3f576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119c7848484613211565b6000612dd983547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff067ffffffffffffffff8083166010908102680100000000000000008504831682037801000000000000000000000000000000000000000000000000860484160170010000000000000000000000000000000090950483169091029390930192909203011690565b612de4906010614084565b8210612e1c576040517f580821e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ef06001840160006010850460108087895467ffffffffffffffff68010000000000000000909104811692909106919091011681612e5d57612e5d61409b565b885491900467ffffffffffffffff80831691909101929092018216835260208301939093526040909101600020549160109168010000000000000000909104168501066134a4565b6001600160a01b0381166000908152600b6020526040812054905b8181101561123d57612ed183613098565b600101612ec0565b6001600160a01b038116600090815260066020526040812054612f1d907f0000000000000000000000000000000000000000000000000de0b6b3a7640000906140ca565b90506000612f40836001600160a01b03166000908152600b602052604090205490565b905060005b612f4f8284614105565b8110156119c757612f5f84612f67565b600101612f45565b6001600160a01b038116612fa7576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612fb360006134d0565b612fda57612fc1600061353b565b612fd39061ffff16600160ff1b613f61565b905061303d565b600560008154612fe9906142d0565b90915550600554600101613029576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60055461303a90600160ff1b613f61565b90505b6000818152600a60205260409020546001600160a01b0316801561308d576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61123d818484612cb9565b6001600160a01b0381166130d8576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381166000908152600b6020526040812080546130fe90600190614105565b8154811061310e5761310e614118565b6000918252602090912060108204015461313c91600f166002026101000a900461ffff16600160ff1b613f61565b905061314a82600083612cb9565b6111a36000826136c7565b6001600160a01b0383166131805780600460008282546131759190613f61565b909155506131ae9050565b6001600160a01b038316600090815260066020526040812080548392906131a8908490614105565b90915550505b6001600160a01b03808316600081815260066020526040908190208054850190555190918516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906132049085815260200190565b60405180910390a3505050565b6001600160a01b0383161561339057600081815260086020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556001600160a01b0386168352600b9091528120805461327890600190614105565b8154811061328857613288614118565b600091825260209091206010820401546132b691600f166002026101000a900461ffff16600160ff1b613f61565b905081811461333b576000828152600a602052604081205460a01c6001600160a01b0386166000908152600b60205260409020805491925083918390811061330057613300614118565b90600052602060002090601091828204019190066002026101000a81548161ffff021916908361ffff16021790555061333982826137db565b505b6001600160a01b0384166000908152600b60205260409020805480613362576133626142ea565b600082815260209020601060001990920191820401805461ffff6002600f8516026101000a02191690559055505b6001600160a01b0382161561344e576000818152600a6020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384160190556001600160a01b0382166000818152600b60209081526040822080546001808201835582855292842060108204018054600f9092166002026101000a61ffff81810219909316928816029190911790559290915290546134499183916134449190614105565b6137db565b61345e565b6000818152600a60205260408120555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006134b1826010614319565b67ffffffffffffffff166134c483613878565b8416901c905092915050565b80546000907801000000000000000000000000000000000000000000000000810467ffffffffffffffff9081166801000000000000000090920416148015610c485750505467ffffffffffffffff808216700100000000000000000000000000000000909204161490565b805460009067ffffffffffffffff70010000000000000000000000000000000082048116917801000000000000000000000000000000000000000000000000810482169116821480156135a75750835467ffffffffffffffff8281166801000000000000000090920416145b156135de576040517f75e52f4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8067ffffffffffffffff166000036135fc575060001901600f613601565b600019015b67ffffffffffffffff8216600090815260018501602052604090205461362781836134a4565b93506136358183600061389b565b67ffffffffffffffff938416600081815260018801602052604090209190915585546fffffffffffffffffffffffffffffffff1670010000000000000000000000000000000090910277ffffffffffffffffffffffffffffffffffffffffffffffff16177801000000000000000000000000000000000000000000000000929093169190910291909117909255919050565b815467ffffffffffffffff808216916801000000000000000090041660008190036136f8575060001901600f6136fd565b600019015b835467ffffffffffffffff700100000000000000000000000000000000909104811690831603613759576040517f8acb5f2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff8216600090815260018501602052604090205461378090828561389b565b67ffffffffffffffff928316600081815260018701602052604090209190915584547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016176801000000000000000091909216021790915550565b6000828152600a60205260409020546bffffffffffffffffffffffff821115613830576040517ffcb3438c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000928352600a60205260409092206001600160a01b039290921660a09190911b7fffffffffffffffffffffffff000000000000000000000000000000000000000016019055565b6000613885826010614319565b67ffffffffffffffff1661ffff901b9050919050565b60006138a8836010614319565b67ffffffffffffffff168261ffff16901b6138c284613878565b1985166138cf9190613f61565b949350505050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146113c957600080fd5b60006020828403121561391757600080fd5b8135610ef0816138d7565b80356001600160a01b038116811461147e57600080fd5b60006020828403121561394b57600080fd5b610ef082613922565b60005b8381101561396f578181015183820152602001613957565b50506000910152565b60008151808452613990816020860160208601613954565b601f01601f19169290920160200192915050565b602081526000610ef06020830184613978565b6000602082840312156139c957600080fd5b5035919050565b600080604083850312156139e357600080fd5b6139ec83613922565b946020939093013593505050565b600080600060608486031215613a0f57600080fd5b613a1884613922565b9250613a2660208501613922565b9150604084013590509250925092565b60008083601f840112613a4857600080fd5b50813567ffffffffffffffff811115613a6057600080fd5b6020830191508360208260051b8501011115613a7b57600080fd5b9250929050565b60008060008060008060a08789031215613a9b57600080fd5b86359550602087013567ffffffffffffffff811115613ab957600080fd5b613ac589828a01613a36565b979a90995096976040810135976060820135975060809091013595509350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613b4057613b40613ae8565b604052919050565b600067ffffffffffffffff821115613b6257613b62613ae8565b50601f01601f191660200190565b6000613b83613b7e84613b48565b613b17565b9050828152838383011115613b9757600080fd5b828260208301376000602084830101529392505050565b600060208284031215613bc057600080fd5b813567ffffffffffffffff811115613bd757600080fd5b8201601f81018413613be857600080fd5b6138cf84823560208401613b70565b60008060408385031215613c0a57600080fd5b50508035926020909101359150565b8035801515811461147e57600080fd5b600060208284031215613c3b57600080fd5b610ef082613c19565b60008060408385031215613c5757600080fd5b613c6083613922565b9150613c6e60208401613c19565b90509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613caf57835183529284019291840191600101613c93565b50909695505050505050565b60008060008060008060a08789031215613cd457600080fd5b86359550602087013567ffffffffffffffff811115613cf257600080fd5b613cfe89828a01613a36565b9096509450613d11905060408801613922565b925060608701359150608087013590509295509295509295565b60008060008060808587031215613d4157600080fd5b613d4a85613922565b9350613d5860208601613922565b925060408501359150606085013567ffffffffffffffff811115613d7b57600080fd5b8501601f81018713613d8c57600080fd5b613d9b87823560208401613b70565b91505092959194509250565b600080600080600080600060e0888a031215613dc257600080fd5b613dcb88613922565b9650613dd960208901613922565b95506040880135945060608801359350608088013560ff81168114613dfd57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215613e2d57600080fd5b613e3683613922565b9150613c6e60208401613922565b803563ffffffff8116811461147e57600080fd5b6000808284036080811215613e6c57600080fd5b833592506060601f1982011215613e8257600080fd5b506040516060810181811067ffffffffffffffff82111715613ea657613ea6613ae8565b806040525060208401358152613ebe60408501613e44565b6020820152613ecf60608501613e44565b6040820152809150509250929050565b600181811c90821680613ef357607f821691505b602082108103613f2c577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610c4857610c48613f32565b601f82111561123d576000816000526020600020601f850160051c81016020861015613f9d5750805b601f850160051c820191505b81811015613fbc57828155600101613fa9565b505050505050565b815167ffffffffffffffff811115613fde57613fde613ae8565b613ff281613fec8454613edf565b84613f74565b602080601f831160018114614027576000841561400f5750858301515b600019600386901b1c1916600185901b178555613fbc565b600085815260208120601f198616915b8281101561405657888601518255948401946001909101908401614037565b50858210156140745787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082028115828204841417610c4857610c48613f32565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082614100577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b81810381811115610c4857610c48613f32565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006001600160a01b038087168352808616602084015250836040830152608060608301526141796080830184613978565b9695505050505050565b60006020828403121561419557600080fd5b8151610ef0816138d7565b6000602082840312156141b257600080fd5b815167ffffffffffffffff8111156141c957600080fd5b8201601f810184136141da57600080fd5b80516141e8613b7e82613b48565b8181528560208385010111156141fd57600080fd5b612075826020830160208601613954565b6000815461421b81613edf565b60018281168015614233576001811461426657614295565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450614295565b8560005260208060002060005b8581101561428c5781548a820152908401908201614273565b50505082870194505b5050505092915050565b60006142ab828561420e565b83516142bb818360208801613954565b01949350505050565b6000610ef0828461420e565b600060001982036142e3576142e3613f32565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b67ffffffffffffffff81811683821602808216919082811461433d5761433d613f32565b50509291505056fea164736f6c6343000817000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000babb6638172865996b1480210d8f2d4ed0fe9a5200000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d6271324870436e7444566d4b77766942725a437874414339785843424452634b6d626f7379725548726a62320000000000000000000000000000000000000000000000000000000000000000000000000000000000000750616c65747465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003504c540000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : $owner (address): 0xBabb6638172865996B1480210D8f2D4eD0FE9a52
Arg [1] : $baseTokenURI (string): ipfs://Qmbq2HpCntDVmKwviBrZCxtAC9xXCBDRcKmbosyrUHrjb2
Arg [2] : $name (string): Palette
Arg [3] : $symbol (string): PLT
Arg [4] : $decimals (uint8): 18
-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 000000000000000000000000babb6638172865996b1480210d8f2d4ed0fe9a52
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000035
Arg [6] : 697066733a2f2f516d6271324870436e7444566d4b77766942725a4378744143
Arg [7] : 39785843424452634b6d626f7379725548726a62320000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [9] : 50616c6574746500000000000000000000000000000000000000000000000000
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [11] : 504c540000000000000000000000000000000000000000000000000000000000
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.