ERC-20
Overview
Max Total Supply
6,969 PLT
Holders
1,693 ( -0.059%)
Market
Price
$60.08 @ 0.023264 ETH (-1.94%)
Onchain Market Cap
$418,684.47
Circulating Supply Market Cap
$418,684.47
Other Info
Token Contract (WITH 18 Decimals)
Balance
0.033333333 PLTValue
$2.00 ( ~0.000774465080390425 Eth) [0.0005%]Loading...
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 {ERC404} from "./404/ERC404.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 ERC404, Ownable { using LibString for uint256; /// @dev The address of the account performing the airdrop. address public minter; /// @dev The URL to the metadata for the tokenURI. string public baseTokenURI; /// @dev State var to effectively revoke access to transfer control. bool public trading; /// @dev State var to effectively revoke access to transfer control. bool public locked; /// @dev Slot for contract render. PaletteRenderer public renderer; /** * @dev Modifier to check if trading is ready. * @param $from The address to transfer from. */ modifier onlyTrading(address $from) { /// @dev Exempt mints as well as transfers from the owner from /// the trading status check. if (trading == false) { if ($from != address(0) && $from != owner()) { revert LibPalette.TokenLoading(); } } _; } /// @dev Initialize Palette. constructor( address $owner, address $minter, string memory $baseTokenURI, string memory $name, string memory $symbol, uint8 $decimals ) ERC404($name, $symbol, $decimals) Ownable($owner) { /// @dev Set the base token URI. baseTokenURI = $baseTokenURI; /// @dev Set the minter for the airdrop. minter = $minter; } /** * @notice Airdrop all of the tokens to the users. * @param $recipients Array of recipients to airdrop to. * @param $amounts Array of amounts to airdrop to each recipient. */ function mint( address[] calldata $recipients, uint256[] calldata $amounts ) public payable { /// @dev Prevent array issues. if ($recipients.length != $amounts.length) { revert LibPalette.MintInvalid(); } /// @dev Ensure that the minter is the one calling this function. if (msg.sender != minter && msg.sender != owner()) { revert LibPalette.MinterInvalid(); } /// @dev Make sure that trading status has not been locked. if(locked == true) revert LibPalette.TradingLocked(); /// @dev Mint the tokens to the recipients. for (uint256 i; i < $recipients.length; i++) { _mintERC20($recipients[i], $amounts[i]); } } /** * @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 allowances. _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 minter for the airdrop. * @param $minter The address of the minter to set. */ function setMinter(address $minter) public onlyOwner { /// @dev Make sure that trading status has not been locked. if(locked == true) revert LibPalette.TradingLocked(); /// @dev Update the state of the minter for the airdrop. minter = $minter; } /** * @notice Allow the owner to set the trading status. * @param $trading The status to set the trading status to. */ function setTrading(bool $trading) public onlyOwner { /// @dev Make sure that trading status has not been locked. if(locked == true) revert LibPalette.TradingLocked(); /// @dev Update the state of trading for a specific user. trading = $trading; } /** * @notice Revoke access to the transfer control. * @param $locked The status to set the locked status to. */ function setLocked(bool $locked) public onlyOwner { /// @dev Make sure that trading status has not been locked. if(locked == true) revert LibPalette.TradingLocked(); /// @dev Update the state of trading for a specific user. locked = $locked; } /** * @notice Allow the owner to withdraw the contract balance. */ function withdraw() public onlyOwner { SafeTransferLib.safeTransferETH(owner(), address(this).balance); } /** * @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 {DoubleEndedQueue} from "./lib/DoubleEndedQueue.sol"; import {ERC721Events} from "./lib/ERC721Events.sol"; import {ERC20Events} from "./lib/ERC20Events.sol"; abstract contract ERC404 is IERC404 { using DoubleEndedQueue for DoubleEndedQueue.Uint256Deque; /// @dev The queue of ERC-721 tokens stored in the contract. DoubleEndedQueue.Uint256Deque 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 => uint256[]) 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 (!_isValidTokenId(id_)) { revert InvalidTokenId(); } if (erc721Owner == address(0)) { revert NotFound(); } } function owned( address owner_ ) public view virtual returns (uint256[] memory) { return _owned[owner_]; } 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_] = _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 a possibly valid ERC-721 token id. /// 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) { if (_isValidTokenId(valueOrId_)) { 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(); } 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 a possible valid token id. function transferFrom( address from_, address to_, uint256 valueOrId_ ) public virtual returns (bool) { if (_isValidTokenId(valueOrId_)) { 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 minting 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(); } // We only need to check ERC-721 transfer exempt status for the recipient // since the sender being ERC-721 transfer exempt means they have already // had their ERC-721s stripped away during the rebalancing process. 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 minting tokens from 0x0. if (from_ == address(0)) { revert InvalidSender(); } // Prevent burning tokens to 0x0. if (to_ == address(0)) { revert InvalidRecipient(); } 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 _transferERC20WithERC721 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 large 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 _transferERC20WithERC721 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 (!_isValidTokenId(id_)) { 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 (ERC-20 only). /// @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(); } // permit cannot be used for ERC-721 token approvals, so ensure // the value does not fall within the valid range of ERC-721 token ids. if (_isValidTokenId(value_)) { 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 For a token token id to be considered valid, it just needs /// to fall within the range of possible token ids, it does not /// necessarily have to be minted yet. function _isValidTokenId(uint256 id_) internal pure returns (bool) { return id_ > ID_ENCODING_PREFIX && id_ != type(uint256).max; } /// @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 = _owned[from_][_owned[from_].length - 1]; if (updatedId != id_) { uint256 updatedIndex = _getOwnedIndex(id_); // update _owned for sender _owned[from_][updatedIndex] = 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(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 = _owned[from_][indexOfLastToken]; _transferERC721(from_, to_, tokenId); unchecked { ++i; } } // If the transfer changes either the sender or the recipient's holdings from a fractional to a non-fractional // amount (or vice versa), adjust ERC-721s. // First 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. // // Process: // Take the difference between the whole number of tokens before and after the transfer for the sender. // If that difference is greater than the number of ERC-721s transferred (whole units), then there was // an additional ERC-721 lost due to the fractional portion of the transfer. // If this is a self-send and the before and after balances are equal (not always the case but often), // then no ERC-721s will be lost here. if ( erc20BalanceOfSenderBefore / units - erc20BalanceOf(from_) / units > nftsToTransfer ) { _withdrawAndStoreERC721(from_); } // Then, check if the transfer causes the receiver to gain a whole new token which requires gaining // an additional ERC-721. // // Process: // Take the difference between the whole number of tokens before and after the transfer for the recipient. // If that difference is greater than the number of ERC-721s transferred (whole units), then there was // an additional ERC-721 gained due to the fractional portion of the transfer. // Again, for self-sends where the before and after balances are equal, no ERC-721s will be gained here. 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 = _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 = _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(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 The token does not exist. error TokenInvalid(); /// @dev The token is not ready to be traded. error TokenLoading(); /// @dev An invalid minter is attempting to mint. error MintInvalid(); /// @dev An invalid minter is attempting to mint. error MinterInvalid(); /// @dev Transfer state has been locked already. error TradingLocked(); }
// 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 uint256 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 `Uint256Deque`. This data structure can only be used in storage, and not in memory. * * ```solidity * DoubleEndedQueue.Uint256Deque queue; * ``` */ library DoubleEndedQueue { /** * @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 Indices are 128 bits so begin and end are packed in a single storage slot for efficient access. * * 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 Uint256Deque { uint128 _begin; uint128 _end; mapping(uint128 index => uint256) _data; } /** * @dev Inserts an item at the end of the queue. * * Reverts with {QueueFull} if the queue is full. */ function pushBack(Uint256Deque storage deque, uint256 value) internal { unchecked { uint128 backIndex = deque._end; if (backIndex + 1 == deque._begin) revert QueueFull(); deque._data[backIndex] = value; deque._end = backIndex + 1; } } /** * @dev Removes the item at the end of the queue and returns it. * * Reverts with {QueueEmpty} if the queue is empty. */ function popBack( Uint256Deque storage deque ) internal returns (uint256 value) { unchecked { uint128 backIndex = deque._end; if (backIndex == deque._begin) revert QueueEmpty(); --backIndex; value = deque._data[backIndex]; delete deque._data[backIndex]; deque._end = backIndex; } } /** * @dev Inserts an item at the beginning of the queue. * * Reverts with {QueueFull} if the queue is full. */ function pushFront(Uint256Deque storage deque, uint256 value) internal { unchecked { uint128 frontIndex = deque._begin - 1; if (frontIndex == deque._end) revert QueueFull(); deque._data[frontIndex] = value; deque._begin = frontIndex; } } /** * @dev Removes the item at the beginning of the queue and returns it. * * Reverts with `QueueEmpty` if the queue is empty. */ function popFront( Uint256Deque storage deque ) internal returns (uint256 value) { unchecked { uint128 frontIndex = deque._begin; if (frontIndex == deque._end) revert QueueEmpty(); value = deque._data[frontIndex]; delete deque._data[frontIndex]; deque._begin = frontIndex + 1; } } /** * @dev Returns the item at the beginning of the queue. * * Reverts with `QueueEmpty` if the queue is empty. */ function front( Uint256Deque storage deque ) internal view returns (uint256 value) { if (empty(deque)) revert QueueEmpty(); return deque._data[deque._begin]; } /** * @dev Returns the item at the end of the queue. * * Reverts with `QueueEmpty` if the queue is empty. */ function back( Uint256Deque storage deque ) internal view returns (uint256 value) { if (empty(deque)) revert QueueEmpty(); unchecked { return deque._data[deque._end - 1]; } } /** * @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( Uint256Deque storage deque, uint256 index ) internal view returns (uint256 value) { if (index >= length(deque)) revert QueueOutOfBounds(); // By construction, length is a uint128, so the check above ensures that index can be safely downcast to uint128 unchecked { return deque._data[deque._begin + uint128(index)]; } } /** * @dev Resets the queue back to being empty. * * NOTE: The current items are left behind in storage. This does not affect the functioning of the queue, but misses * out on potential gas refunds. */ function clear(Uint256Deque storage deque) internal { deque._begin = 0; deque._end = 0; } /** * @dev Returns the number of items in the queue. */ function length( Uint256Deque storage deque ) internal view returns (uint256) { unchecked { return uint256(deque._end - deque._begin); } } /** * @dev Returns true if the queue is empty. */ function empty(Uint256Deque storage deque) internal view returns (bool) { return deque._end == deque._begin; } }
// 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":"address","name":"$minter","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":"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":"MintInvalid","type":"error"},{"inputs":[],"name":"MintLimitReached","type":"error"},{"inputs":[],"name":"MinterInvalid","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":"QueueEmpty","type":"error"},{"inputs":[],"name":"QueueFull","type":"error"},{"inputs":[],"name":"QueueOutOfBounds","type":"error"},{"inputs":[],"name":"RecipientIsERC721TransferExempt","type":"error"},{"inputs":[],"name":"TokenInvalid","type":"error"},{"inputs":[],"name":"TokenLoading","type":"error"},{"inputs":[],"name":"TradingLocked","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnsafeRecipient","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":[{"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":[],"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":[],"name":"locked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"$recipients","type":"address[]"},{"internalType":"uint256[]","name":"$amounts","type":"uint256[]"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"minted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"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":"bool","name":"$locked","type":"bool"}],"name":"setLocked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"$minter","type":"address"}],"name":"setMinter","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":[{"internalType":"bool","name":"$trading","type":"bool"}],"name":"setTrading","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":"trading","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
6101006040523480156200001257600080fd5b5060405162003fab38038062003fab8339810160408190526200003591620002f4565b85838383600262000047848262000457565b50600362000056838262000457565b5060128160ff1610156200007d576040516398790fd560e01b815260040160405180910390fd5b60ff811660808190526200009390600a62000638565b60a0524660c052620000a462000121565b60e0525050506001600160a01b038116620000d957604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b620000e481620001bd565b506010620000f3858262000457565b5050600f80546001600160a01b0319166001600160a01b03959095169490941790935550620006ce92505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600260405162000155919062000650565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b600e80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b03811681146200022757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200025457600080fd5b81516001600160401b03808211156200027157620002716200022c565b604051601f8301601f19908116603f011681019082821181831017156200029c576200029c6200022c565b8160405283815260209250866020858801011115620002ba57600080fd5b600091505b83821015620002de5785820183015181830184015290820190620002bf565b6000602085830101528094505050505092915050565b60008060008060008060c087890312156200030e57600080fd5b62000319876200020f565b955062000329602088016200020f565b60408801519095506001600160401b03808211156200034757600080fd5b620003558a838b0162000242565b955060608901519150808211156200036c57600080fd5b6200037a8a838b0162000242565b945060808901519150808211156200039157600080fd5b50620003a089828a0162000242565b92505060a087015160ff81168114620003b857600080fd5b809150509295509295509295565b600181811c90821680620003db57607f821691505b602082108103620003fc57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562000452576000816000526020600020601f850160051c810160208610156200042d5750805b601f850160051c820191505b818110156200044e5782815560010162000439565b5050505b505050565b81516001600160401b038111156200047357620004736200022c565b6200048b81620004848454620003c6565b8462000402565b602080601f831160018114620004c35760008415620004aa5750858301515b600019600386901b1c1916600185901b1785556200044e565b600085815260208120601f198616915b82811015620004f457888601518255948401946001909101908401620004d3565b5085821015620005135787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156200057a5781600019048211156200055e576200055e62000523565b808516156200056c57918102915b93841c93908002906200053e565b509250929050565b600082620005935750600162000632565b81620005a25750600062000632565b8160018114620005bb5760028114620005c657620005e6565b600191505062000632565b60ff841115620005da57620005da62000523565b50506001821b62000632565b5060208310610133831016604e8410600b84101617156200060b575081810a62000632565b62000617838362000539565b80600019048211156200062e576200062e62000523565b0290505b92915050565b60006200064960ff84168362000582565b9392505050565b60008083546200066081620003c6565b600182811680156200067b57600181146200069157620006c2565b60ff1984168752821515830287019450620006c2565b8760005260208060002060005b85811015620006b95781548a8201529084019082016200069e565b50505082870194505b50929695505050505050565b60805160a05160c05160e051613856620007556000396000610d4601526000610d160152600081816107b301528181611ba20152818161222401528181612268015281816122e10152818161230b0152818161235f0152818161240b015281816124580152818161249c015281816124c301526128130152600061055c01526138566000f3fe60806040526004361061033f5760003560e01c80638ada6b0f116101b0578063cf309012116100ec578063dfabc03311610095578063ec44acf21161006f578063ec44acf214610a27578063f2fde38b14610a41578063f780bc1a14610a61578063fca3b5aa14610a8157600080fd5b8063dfabc033146109b9578063e467f7e0146109d9578063e985e9c5146109ec57600080fd5b8063d96ca0b9116100c6578063d96ca0b914610941578063dd62ed3e14610961578063dd6376991461099957600080fd5b8063cf309012146108ed578063d505accf1461090c578063d547cfb71461092c57600080fd5b8063a9059cbb11610159578063b88d4fde11610133578063b88d4fde14610878578063c5ab3ba614610898578063c6e672b9146108ad578063c87b56dd146108cd57600080fd5b8063a9059cbb146107f5578063b1ab931714610815578063b3f9ea341461084257600080fd5b806395d89b411161018a57806395d89b411461078c578063976a8435146107a1578063a22cb465146107d557600080fd5b80638ada6b0f146107285780638da5cb5b1461074e5780638f70ccf71461076c57600080fd5b80633644e5151161027f5780636352211e11610228578063715018a611610202578063715018a6146106b15780637ecebe00146106c657806389fb4c66146106f35780638a696e501461070857600080fd5b80636352211e146106305780636e8f624b1461065057806370a082311461068457600080fd5b80634d966072116102595780634d966072146105da5780634f02c420146105fa57806356d3163d1461061057600080fd5b80633644e515146105905780633ccfd60b146105a557806342842e0e146105ba57600080fd5b806309674eb0116102ec578063211e28b6116102c6578063211e28b6146104e857806323b872dd1461050a57806330176e131461052a578063313ce5671461054a57600080fd5b806309674eb01461046d57806309f0ef65146104b257806318160ddd146104d257600080fd5b8063075461721161031d57806307546172146103df578063081812fc14610417578063095ea7b31461044d57600080fd5b806301ffc9a71461034457806302519da31461037957806306fdde03146103bd575b600080fd5b34801561035057600080fd5b5061036461035f366004612f78565b610aa1565b60405190151581526020015b60405180910390f35b34801561038557600080fd5b506103af610394366004612fac565b6001600160a01b031660009081526006602052604090205490565b604051908152602001610370565b3480156103c957600080fd5b506103d2610b3a565b6040516103709190613017565b3480156103eb57600080fd5b50600f546103ff906001600160a01b031681565b6040516001600160a01b039091168152602001610370565b34801561042357600080fd5b506103ff61043236600461302a565b6008602052600090815260409020546001600160a01b031681565b34801561045957600080fd5b50610364610468366004613043565b610bc8565b34801561047957600080fd5b506000546fffffffffffffffffffffffffffffffff808216700100000000000000000000000000000000909204811691909103166103af565b3480156104be57600080fd5b506103646104cd366004612fac565b610c06565b3480156104de57600080fd5b506103af60045481565b3480156104f457600080fd5b5061050861050336600461307d565b610c38565b005b34801561051657600080fd5b50610364610525366004613098565b610cbd565b34801561053657600080fd5b5061050861054536600461319a565b610cfa565b34801561055657600080fd5b5061057e7f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff9091168152602001610370565b34801561059c57600080fd5b506103af610d12565b3480156105b157600080fd5b50610508610d68565b3480156105c657600080fd5b506105086105d5366004613098565b610d8d565b3480156105e657600080fd5b506103646105f5366004613043565b610dad565b34801561060657600080fd5b506103af60055481565b34801561061c57600080fd5b5061050861062b366004612fac565b610e53565b34801561063c57600080fd5b506103ff61064b36600461302a565b610f0d565b34801561065c57600080fd5b506103af7f800000000000000000000000000000000000000000000000000000000000000081565b34801561069057600080fd5b506103af61069f366004612fac565b60066020526000908152604090205481565b3480156106bd57600080fd5b50610508610fa9565b3480156106d257600080fd5b506103af6106e1366004612fac565b600d6020526000908152604090205481565b3480156106ff57600080fd5b506004546103af565b34801561071457600080fd5b5061050861072336600461307d565b610fbb565b34801561073457600080fd5b506011546103ff906201000090046001600160a01b031681565b34801561075a57600080fd5b50600e546001600160a01b03166103ff565b34801561077857600080fd5b5061050861078736600461307d565b610fc5565b34801561079857600080fd5b506103d2611044565b3480156107ad57600080fd5b506103af7f000000000000000000000000000000000000000000000000000000000000000081565b3480156107e157600080fd5b506105086107f03660046131eb565b611051565b34801561080157600080fd5b50610364610810366004613043565b61111b565b34801561082157600080fd5b50610835610830366004612fac565b611168565b604051610370919061321e565b34801561084e57600080fd5b506103af61085d366004612fac565b6001600160a01b03166000908152600b602052604090205490565b34801561088457600080fd5b50610508610893366004613262565b6111d4565b3480156108a457600080fd5b506005546103af565b3480156108b957600080fd5b506105086108c83660046131eb565b611325565b3480156108d957600080fd5b506103d26108e836600461302a565b611337565b3480156108f957600080fd5b5060115461036490610100900460ff1681565b34801561091857600080fd5b506105086109273660046132de565b611630565b34801561093857600080fd5b506103d26118f2565b34801561094d57600080fd5b5061036461095c366004613098565b6118ff565b34801561096d57600080fd5b506103af61097c366004613351565b600760209081526000928352604080842090915290825290205481565b3480156109a557600080fd5b506105086109b4366004613098565b6119f1565b3480156109c557600080fd5b506105086109d4366004613043565b611bd1565b6105086109e73660046133c7565b611cc8565b3480156109f857600080fd5b50610364610a07366004613351565b600960209081526000928352604080842090915290825290205460ff1681565b348015610a3357600080fd5b506011546103649060ff1681565b348015610a4d57600080fd5b50610508610a5c366004612fac565b611dff565b348015610a6d57600080fd5b50610835610a7c366004613433565b611e58565b348015610a8d57600080fd5b50610508610a9c366004612fac565b611ef5565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fcaf91ff5000000000000000000000000000000000000000000000000000000001480610b3457507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b60028054610b4790613455565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7390613455565b8015610bc05780601f10610b9557610100808354040283529160200191610bc0565b820191906000526020600020905b815481529060010190602001808311610ba357829003601f168201915b505050505081565b6000610bd382611f7d565b15610be757610be28383611bd1565b610bf8565b610bf18383610dad565b9050610b34565b50600192915050565b905090565b60006001600160a01b0382161580610b345750506001600160a01b03166000908152600c602052604090205460ff1690565b610c40611fb2565b601154610100900460ff161515600103610c86576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60118054911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909216919091179055565b6000610cc882611f7d565b15610cdd57610cd88484846119f1565b610cef565b610ce88484846118ff565b9050610cf3565b5060015b9392505050565b610d02611fb2565b6010610d0e82826134f8565b5050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610d4357610c01611ff8565b507f000000000000000000000000000000000000000000000000000000000000000090565b610d70611fb2565b610d8b610d85600e546001600160a01b031690565b47612092565b565b610da8838383604051806020016040528060008152506111d4565b505050565b60006001600160a01b038316610def576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350600192915050565b610e5b611fb2565b601180547fffffffffffffffffffff0000000000000000000000000000000000000000ffff16620100006001600160a01b03848116820292909217928390559091041615610f0a57601160029054906101000a90046001600160a01b03166001600160a01b031663d9374bff6040518163ffffffff1660e01b815260040160006040518083038186803b158015610ef157600080fd5b505afa158015610f05573d6000803e3d6000fd5b505050505b50565b6000818152600a60205260409020546001600160a01b0316610f2e82611f7d565b610f64576040517f3f6cc76800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038116610fa4576040517fc5723b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b610fb1611fb2565b610d8b60006120ae565b610f0a3382612118565b610fcd611fb2565b601154610100900460ff161515600103611013576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b60038054610b4790613455565b6001600160a01b038216611091576040517fccea9e6f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526009602090815260408083206001600160a01b0387168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b03831661115d576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610cf33384846121be565b6001600160a01b0381166000908152600b60209081526040918290208054835181840281018401909452808452606093928301828280156111c857602002820191906000526020600020905b8154815260200190600101908083116111b4575b50505050509050919050565b6111dd82611f7d565b611213576040517f3f6cc76800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61121e848484610cbd565b506001600160a01b0383163b158015906112e857506040517f150b7a0200000000000000000000000000000000000000000000000000000000808252906001600160a01b0385169063150b7a02906112809033908990889088906004016135b8565b6020604051808303816000875af115801561129f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c391906135f4565b7fffffffff000000000000000000000000000000000000000000000000000000001614155b1561131f576040517f3da6393100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b61132d611fb2565b610d0e8282612118565b6000818152600a60205260409020546060906001600160a01b0316611388576040517fab9713c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006113b47f800000000000000000000000000000000000000000000000000000000000000084613640565b6011549091506201000090046001600160a01b03161561145d576011546040517fc321118c00000000000000000000000000000000000000000000000000000000815260048101859052620100009091046001600160a01b03169063c321118c90602401600060405180830381865afa158015611435573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cf39190810190613653565b60006010805461146c90613455565b80601f016020809104026020016040519081016040528092919081815260200182805461149890613455565b80156114e55780601f106114ba576101008083540402835291602001916114e5565b820191906000526020600020905b8154815290600101906020018083116114c857829003601f168201915b505083519394505050811580159150611561575081611505600183613640565b81518110611515576115156136c1565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f2f0000000000000000000000000000000000000000000000000000000000000014155b156115fb576010805461157390613455565b80601f016020809104026020016040519081016040528092919081815260200182805461159f90613455565b80156115ec5780601f106115c1576101008083540402835291602001916115ec565b820191906000526020600020905b8154815290600101906020018083116115cf57829003601f168201915b50505050509350505050919050565b601061160684612534565b604051602001611617929190613781565b6040516020818303038152906040529350505050919050565b4284101561166a576040517f05787bdf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61167385611f7d565b156116aa576040517f1f3e0de800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0386166116ea576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060016116f6610d12565b6001600160a01b038a81166000818152600d602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e0830190915280519201919091207f19010000000000000000000000000000000000000000000000000000000000006101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa15801561181d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806118525750876001600160a01b0316816001600160a01b031614155b15611889576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0390811660009081526007602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60108054610b4790613455565b60006001600160a01b038416611941576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038316611981576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416600090815260076020908152604080832033845290915290205460001981146119dd576119b88382613640565b6001600160a01b03861660009081526007602090815260408083203384529091529020555b6119e88585856121be565b95945050505050565b6001600160a01b038316611a31576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216611a71576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600a60205260409020546001600160a01b03848116911614611ac4576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336001600160a01b03841614801590611b0157506001600160a01b038316600090815260096020908152604080832033845290915290205460ff16155b8015611b2457506000818152600860205260409020546001600160a01b03163314155b15611b5b576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611b6482610c06565b15611b9b576040517f5ce7539700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bc683837f0000000000000000000000000000000000000000000000000000000000000000612578565b610da88383836125f1565b6000818152600a60205260409020546001600160a01b0316338114801590611c1d57506001600160a01b038116600090815260096020908152604080832033845290915290205460ff16155b15611c54576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526008602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b828114611d01576040517f2e83472600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f546001600160a01b03163314801590611d275750600e546001600160a01b03163314155b15611d5e576040517fc5bb4a4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601154610100900460ff161515600103611da4576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b83811015610f0557611df7858583818110611dc457611dc46136c1565b9050602002016020810190611dd99190612fac565b848484818110611deb57611deb6136c1565b9050602002013561266a565b600101611da7565b611e07611fb2565b6001600160a01b038116611e4f576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610f0a816120ae565b606060008267ffffffffffffffff811115611e7557611e756130d4565b604051908082528060200260200182016040528015611e9e578160200160208202803683370190505b509050835b611ead84866137a6565b811015611eed57611ebf60008261271d565b82611eca8784613640565b81518110611eda57611eda6136c1565b6020908102919091010152600101611ea3565b509392505050565b611efd611fb2565b601154610100900460ff161515600103611f43576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60007f800000000000000000000000000000000000000000000000000000000000000082118015610b34575050600019141590565b600e546001600160a01b03163314610d8b576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611e46565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600260405161202a91906137b9565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60003860003884865af1610d0e5763b12d13eb6000526004601cfd5b600e80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216612158576040517fa41e3d3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561216c57612167826127c0565b612175565b612175826127f4565b6001600160a01b03919091166000908152600c6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6001600160a01b038381166000908152600660205260408082205492851682528120549091906121ef868686612578565b60006121fa87610c06565b9050600061220787610c06565b90508180156122135750805b6125265781156122bc5760006122497f0000000000000000000000000000000000000000000000000000000000000000856137c5565b6001600160a01b03891660009081526006602052604090205461228d907f0000000000000000000000000000000000000000000000000000000000000000906137c5565b6122979190613640565b905060005b818110156122b5576122ad89612882565b60010161229c565b5050612526565b8015612358576001600160a01b038816600090815260066020526040812054612306907f0000000000000000000000000000000000000000000000000000000000000000906137c5565b6123307f0000000000000000000000000000000000000000000000000000000000000000876137c5565b61233a9190613640565b905060005b818110156122b5576123508a6129e0565b60010161233f565b60006123847f0000000000000000000000000000000000000000000000000000000000000000886137c5565b905060005b81811015612407576001600160a01b038a166000908152600b60205260408120546123b690600190613640565b6001600160a01b038c166000908152600b6020526040812080549293509091839081106123e5576123e56136c1565b906000526020600020015490506123fd8c8c836125f1565b5050600101612389565b50807f00000000000000000000000000000000000000000000000000000000000000006124498b6001600160a01b031660009081526006602052604090205490565b61245391906137c5565b61247d7f0000000000000000000000000000000000000000000000000000000000000000886137c5565b6124879190613640565b111561249657612496896129e0565b806124c17f0000000000000000000000000000000000000000000000000000000000000000866137c5565b7f00000000000000000000000000000000000000000000000000000000000000006125018b6001600160a01b031660009081526006602052604090205490565b61250b91906137c5565b6125159190613640565b11156125245761252488612882565b505b506001979650505050505050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a90048061254f575050819003601f19909101908152919050565b601154839060ff1615156000036125e6576001600160a01b038116158015906125af5750600e546001600160a01b03828116911614155b156125e6576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61131f848484612a7a565b601154839060ff16151560000361265f576001600160a01b038116158015906126285750600e546001600160a01b03828116911614155b1561265f576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61131f848484612b36565b6001600160a01b0382166126aa576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f8000000000000000000000000000000000000000000000000000000000000000816004546126d991906137a6565b1115612711576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610da8600083836121be565b600061275783546fffffffffffffffffffffffffffffffff8082167001000000000000000000000000000000009092048116919091031690565b821061278f576040517f580821e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5081546fffffffffffffffffffffffffffffffff908116820116600090815260018301602052604090205492915050565b6001600160a01b0381166000908152600b6020526040812054905b81811015610da8576127ec836129e0565b6001016127db565b6001600160a01b038116600090815260066020526040812054612838907f0000000000000000000000000000000000000000000000000000000000000000906137c5565b9050600061285b836001600160a01b03166000908152600b602052604090205490565b905060005b61286a8284613640565b81101561131f5761287a84612882565b600101612860565b6001600160a01b0381166128c2576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546fffffffffffffffffffffffffffffffff8082167001000000000000000000000000000000009092041614612906576128ff6000612d3e565b9050612985565b60056000815461291590613800565b90915550600554600101612955576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600554612982907f80000000000000000000000000000000000000000000000000000000000000006137a6565b90505b6000818152600a60205260409020546001600160a01b031680156129d5576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610da88184846125f1565b6001600160a01b038116612a20576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381166000908152600b602052604081208054612a4690600190613640565b81548110612a5657612a566136c1565b90600052602060002001549050612a6f826000836125f1565b610d0e600082612df3565b6001600160a01b038316612aa5578060046000828254612a9a91906137a6565b90915550612ad39050565b6001600160a01b03831660009081526006602052604081208054839290612acd908490613640565b90915550505b6001600160a01b03808316600081815260066020526040908190208054850190555190918516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612b299085815260200190565b60405180910390a3505050565b6001600160a01b03831615612c5957600081815260086020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556001600160a01b0386168352600b90915281208054612b9d90600190613640565b81548110612bad57612bad6136c1565b90600052602060002001549050818114612c1a576000828152600a602052604081205460a01c6001600160a01b0386166000908152600b602052604090208054919250839183908110612c0257612c026136c1565b600091825260209091200155612c188282612ead565b505b6001600160a01b0384166000908152600b60205260409020805480612c4157612c4161381a565b60019003818190600052602060002001600090559055505b6001600160a01b03821615612ce8576000818152600a6020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038716908101909155808452600b83529083208054600181810183558286529385200185905592529054612ce3918391612cde9190613640565b612ead565b612cf8565b6000818152600a60205260408120555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b80546000906fffffffffffffffffffffffffffffffff7001000000000000000000000000000000008204811691168103612da4576040517f75e52f4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600019016fffffffffffffffffffffffffffffffff9081166000818152600185016020526040812080549190558454909216700100000000000000000000000000000000909102179092555090565b81546fffffffffffffffffffffffffffffffff80821660001901917001000000000000000000000000000000009004811690821603612e5e576040517f8acb5f2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff16600081815260018401602052604090209190915581547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016179055565b6000828152600a60205260409020546bffffffffffffffffffffffff821115612f02576040517ffcb3438c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000928352600a60205260409092206001600160a01b039290921660a09190911b7fffffffffffffffffffffffff000000000000000000000000000000000000000016019055565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610f0a57600080fd5b600060208284031215612f8a57600080fd5b8135610cf381612f4a565b80356001600160a01b0381168114610fa457600080fd5b600060208284031215612fbe57600080fd5b610cf382612f95565b60005b83811015612fe2578181015183820152602001612fca565b50506000910152565b60008151808452613003816020860160208601612fc7565b601f01601f19169290920160200192915050565b602081526000610cf36020830184612feb565b60006020828403121561303c57600080fd5b5035919050565b6000806040838503121561305657600080fd5b61305f83612f95565b946020939093013593505050565b80358015158114610fa457600080fd5b60006020828403121561308f57600080fd5b610cf38261306d565b6000806000606084860312156130ad57600080fd5b6130b684612f95565b92506130c460208501612f95565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561312c5761312c6130d4565b604052919050565b600067ffffffffffffffff82111561314e5761314e6130d4565b50601f01601f191660200190565b600061316f61316a84613134565b613103565b905082815283838301111561318357600080fd5b828260208301376000602084830101529392505050565b6000602082840312156131ac57600080fd5b813567ffffffffffffffff8111156131c357600080fd5b8201601f810184136131d457600080fd5b6131e38482356020840161315c565b949350505050565b600080604083850312156131fe57600080fd5b61320783612f95565b91506132156020840161306d565b90509250929050565b6020808252825182820181905260009190848201906040850190845b818110156132565783518352928401929184019160010161323a565b50909695505050505050565b6000806000806080858703121561327857600080fd5b61328185612f95565b935061328f60208601612f95565b925060408501359150606085013567ffffffffffffffff8111156132b257600080fd5b8501601f810187136132c357600080fd5b6132d28782356020840161315c565b91505092959194509250565b600080600080600080600060e0888a0312156132f957600080fd5b61330288612f95565b965061331060208901612f95565b95506040880135945060608801359350608088013560ff8116811461333457600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561336457600080fd5b61336d83612f95565b915061321560208401612f95565b60008083601f84011261338d57600080fd5b50813567ffffffffffffffff8111156133a557600080fd5b6020830191508360208260051b85010111156133c057600080fd5b9250929050565b600080600080604085870312156133dd57600080fd5b843567ffffffffffffffff808211156133f557600080fd5b6134018883890161337b565b9096509450602087013591508082111561341a57600080fd5b506134278782880161337b565b95989497509550505050565b6000806040838503121561344657600080fd5b50508035926020909101359150565b600181811c9082168061346957607f821691505b6020821081036134a2577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f821115610da8576000816000526020600020601f850160051c810160208610156134d15750805b601f850160051c820191505b818110156134f0578281556001016134dd565b505050505050565b815167ffffffffffffffff811115613512576135126130d4565b613526816135208454613455565b846134a8565b602080601f83116001811461355b57600084156135435750858301515b600019600386901b1c1916600185901b1785556134f0565b600085815260208120601f198616915b8281101561358a5788860151825594840194600190910190840161356b565b50858210156135a85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006001600160a01b038087168352808616602084015250836040830152608060608301526135ea6080830184612feb565b9695505050505050565b60006020828403121561360657600080fd5b8151610cf381612f4a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610b3457610b34613611565b60006020828403121561366557600080fd5b815167ffffffffffffffff81111561367c57600080fd5b8201601f8101841361368d57600080fd5b805161369b61316a82613134565b8181528560208385010111156136b057600080fd5b6119e8826020830160208601612fc7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081546136fd81613455565b60018281168015613715576001811461374857613777565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450613777565b8560005260208060002060005b8581101561376e5781548a820152908401908201613755565b50505082870194505b5050505092915050565b600061378d82856136f0565b835161379d818360208801612fc7565b01949350505050565b80820180821115610b3457610b34613611565b6000610cf382846136f0565b6000826137fb577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000600019820361381357613813613611565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea164736f6c6343000817000a000000000000000000000000babb6638172865996b1480210d8f2d4ed0fe9a5200000000000000000000000054239a172810ba1c65e1f6e647d8546e6b1273b900000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000043697066733a2f2f6261667962656962656335753479337973656966717a65337661796277726b786d37736b757a34633371693369336763736c33337065737a7775612f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000750616c65747465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003504c540000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361061033f5760003560e01c80638ada6b0f116101b0578063cf309012116100ec578063dfabc03311610095578063ec44acf21161006f578063ec44acf214610a27578063f2fde38b14610a41578063f780bc1a14610a61578063fca3b5aa14610a8157600080fd5b8063dfabc033146109b9578063e467f7e0146109d9578063e985e9c5146109ec57600080fd5b8063d96ca0b9116100c6578063d96ca0b914610941578063dd62ed3e14610961578063dd6376991461099957600080fd5b8063cf309012146108ed578063d505accf1461090c578063d547cfb71461092c57600080fd5b8063a9059cbb11610159578063b88d4fde11610133578063b88d4fde14610878578063c5ab3ba614610898578063c6e672b9146108ad578063c87b56dd146108cd57600080fd5b8063a9059cbb146107f5578063b1ab931714610815578063b3f9ea341461084257600080fd5b806395d89b411161018a57806395d89b411461078c578063976a8435146107a1578063a22cb465146107d557600080fd5b80638ada6b0f146107285780638da5cb5b1461074e5780638f70ccf71461076c57600080fd5b80633644e5151161027f5780636352211e11610228578063715018a611610202578063715018a6146106b15780637ecebe00146106c657806389fb4c66146106f35780638a696e501461070857600080fd5b80636352211e146106305780636e8f624b1461065057806370a082311461068457600080fd5b80634d966072116102595780634d966072146105da5780634f02c420146105fa57806356d3163d1461061057600080fd5b80633644e515146105905780633ccfd60b146105a557806342842e0e146105ba57600080fd5b806309674eb0116102ec578063211e28b6116102c6578063211e28b6146104e857806323b872dd1461050a57806330176e131461052a578063313ce5671461054a57600080fd5b806309674eb01461046d57806309f0ef65146104b257806318160ddd146104d257600080fd5b8063075461721161031d57806307546172146103df578063081812fc14610417578063095ea7b31461044d57600080fd5b806301ffc9a71461034457806302519da31461037957806306fdde03146103bd575b600080fd5b34801561035057600080fd5b5061036461035f366004612f78565b610aa1565b60405190151581526020015b60405180910390f35b34801561038557600080fd5b506103af610394366004612fac565b6001600160a01b031660009081526006602052604090205490565b604051908152602001610370565b3480156103c957600080fd5b506103d2610b3a565b6040516103709190613017565b3480156103eb57600080fd5b50600f546103ff906001600160a01b031681565b6040516001600160a01b039091168152602001610370565b34801561042357600080fd5b506103ff61043236600461302a565b6008602052600090815260409020546001600160a01b031681565b34801561045957600080fd5b50610364610468366004613043565b610bc8565b34801561047957600080fd5b506000546fffffffffffffffffffffffffffffffff808216700100000000000000000000000000000000909204811691909103166103af565b3480156104be57600080fd5b506103646104cd366004612fac565b610c06565b3480156104de57600080fd5b506103af60045481565b3480156104f457600080fd5b5061050861050336600461307d565b610c38565b005b34801561051657600080fd5b50610364610525366004613098565b610cbd565b34801561053657600080fd5b5061050861054536600461319a565b610cfa565b34801561055657600080fd5b5061057e7f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff9091168152602001610370565b34801561059c57600080fd5b506103af610d12565b3480156105b157600080fd5b50610508610d68565b3480156105c657600080fd5b506105086105d5366004613098565b610d8d565b3480156105e657600080fd5b506103646105f5366004613043565b610dad565b34801561060657600080fd5b506103af60055481565b34801561061c57600080fd5b5061050861062b366004612fac565b610e53565b34801561063c57600080fd5b506103ff61064b36600461302a565b610f0d565b34801561065c57600080fd5b506103af7f800000000000000000000000000000000000000000000000000000000000000081565b34801561069057600080fd5b506103af61069f366004612fac565b60066020526000908152604090205481565b3480156106bd57600080fd5b50610508610fa9565b3480156106d257600080fd5b506103af6106e1366004612fac565b600d6020526000908152604090205481565b3480156106ff57600080fd5b506004546103af565b34801561071457600080fd5b5061050861072336600461307d565b610fbb565b34801561073457600080fd5b506011546103ff906201000090046001600160a01b031681565b34801561075a57600080fd5b50600e546001600160a01b03166103ff565b34801561077857600080fd5b5061050861078736600461307d565b610fc5565b34801561079857600080fd5b506103d2611044565b3480156107ad57600080fd5b506103af7f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b3480156107e157600080fd5b506105086107f03660046131eb565b611051565b34801561080157600080fd5b50610364610810366004613043565b61111b565b34801561082157600080fd5b50610835610830366004612fac565b611168565b604051610370919061321e565b34801561084e57600080fd5b506103af61085d366004612fac565b6001600160a01b03166000908152600b602052604090205490565b34801561088457600080fd5b50610508610893366004613262565b6111d4565b3480156108a457600080fd5b506005546103af565b3480156108b957600080fd5b506105086108c83660046131eb565b611325565b3480156108d957600080fd5b506103d26108e836600461302a565b611337565b3480156108f957600080fd5b5060115461036490610100900460ff1681565b34801561091857600080fd5b506105086109273660046132de565b611630565b34801561093857600080fd5b506103d26118f2565b34801561094d57600080fd5b5061036461095c366004613098565b6118ff565b34801561096d57600080fd5b506103af61097c366004613351565b600760209081526000928352604080842090915290825290205481565b3480156109a557600080fd5b506105086109b4366004613098565b6119f1565b3480156109c557600080fd5b506105086109d4366004613043565b611bd1565b6105086109e73660046133c7565b611cc8565b3480156109f857600080fd5b50610364610a07366004613351565b600960209081526000928352604080842090915290825290205460ff1681565b348015610a3357600080fd5b506011546103649060ff1681565b348015610a4d57600080fd5b50610508610a5c366004612fac565b611dff565b348015610a6d57600080fd5b50610835610a7c366004613433565b611e58565b348015610a8d57600080fd5b50610508610a9c366004612fac565b611ef5565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fcaf91ff5000000000000000000000000000000000000000000000000000000001480610b3457507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b60028054610b4790613455565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7390613455565b8015610bc05780601f10610b9557610100808354040283529160200191610bc0565b820191906000526020600020905b815481529060010190602001808311610ba357829003601f168201915b505050505081565b6000610bd382611f7d565b15610be757610be28383611bd1565b610bf8565b610bf18383610dad565b9050610b34565b50600192915050565b905090565b60006001600160a01b0382161580610b345750506001600160a01b03166000908152600c602052604090205460ff1690565b610c40611fb2565b601154610100900460ff161515600103610c86576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60118054911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff909216919091179055565b6000610cc882611f7d565b15610cdd57610cd88484846119f1565b610cef565b610ce88484846118ff565b9050610cf3565b5060015b9392505050565b610d02611fb2565b6010610d0e82826134f8565b5050565b60007f00000000000000000000000000000000000000000000000000000000000000014614610d4357610c01611ff8565b507fca3a2e1ee9ee713c26e2ab8b5c100957988bf0a102be11ad8cc49cc3efc45d2990565b610d70611fb2565b610d8b610d85600e546001600160a01b031690565b47612092565b565b610da8838383604051806020016040528060008152506111d4565b505050565b60006001600160a01b038316610def576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b03881680855290835292819020869055518581529192917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350600192915050565b610e5b611fb2565b601180547fffffffffffffffffffff0000000000000000000000000000000000000000ffff16620100006001600160a01b03848116820292909217928390559091041615610f0a57601160029054906101000a90046001600160a01b03166001600160a01b031663d9374bff6040518163ffffffff1660e01b815260040160006040518083038186803b158015610ef157600080fd5b505afa158015610f05573d6000803e3d6000fd5b505050505b50565b6000818152600a60205260409020546001600160a01b0316610f2e82611f7d565b610f64576040517f3f6cc76800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038116610fa4576040517fc5723b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b610fb1611fb2565b610d8b60006120ae565b610f0a3382612118565b610fcd611fb2565b601154610100900460ff161515600103611013576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b60038054610b4790613455565b6001600160a01b038216611091576040517fccea9e6f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526009602090815260408083206001600160a01b0387168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b03831661115d576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610cf33384846121be565b6001600160a01b0381166000908152600b60209081526040918290208054835181840281018401909452808452606093928301828280156111c857602002820191906000526020600020905b8154815260200190600101908083116111b4575b50505050509050919050565b6111dd82611f7d565b611213576040517f3f6cc76800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61121e848484610cbd565b506001600160a01b0383163b158015906112e857506040517f150b7a0200000000000000000000000000000000000000000000000000000000808252906001600160a01b0385169063150b7a02906112809033908990889088906004016135b8565b6020604051808303816000875af115801561129f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c391906135f4565b7fffffffff000000000000000000000000000000000000000000000000000000001614155b1561131f576040517f3da6393100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b61132d611fb2565b610d0e8282612118565b6000818152600a60205260409020546060906001600160a01b0316611388576040517fab9713c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006113b47f800000000000000000000000000000000000000000000000000000000000000084613640565b6011549091506201000090046001600160a01b03161561145d576011546040517fc321118c00000000000000000000000000000000000000000000000000000000815260048101859052620100009091046001600160a01b03169063c321118c90602401600060405180830381865afa158015611435573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cf39190810190613653565b60006010805461146c90613455565b80601f016020809104026020016040519081016040528092919081815260200182805461149890613455565b80156114e55780601f106114ba576101008083540402835291602001916114e5565b820191906000526020600020905b8154815290600101906020018083116114c857829003601f168201915b505083519394505050811580159150611561575081611505600183613640565b81518110611515576115156136c1565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f2f0000000000000000000000000000000000000000000000000000000000000014155b156115fb576010805461157390613455565b80601f016020809104026020016040519081016040528092919081815260200182805461159f90613455565b80156115ec5780601f106115c1576101008083540402835291602001916115ec565b820191906000526020600020905b8154815290600101906020018083116115cf57829003601f168201915b50505050509350505050919050565b601061160684612534565b604051602001611617929190613781565b6040516020818303038152906040529350505050919050565b4284101561166a576040517f05787bdf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61167385611f7d565b156116aa576040517f1f3e0de800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0386166116ea576040517f5461585f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060016116f6610d12565b6001600160a01b038a81166000818152600d602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e0830190915280519201919091207f19010000000000000000000000000000000000000000000000000000000000006101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa15801561181d573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615806118525750876001600160a01b0316816001600160a01b031614155b15611889576040517f815e1d6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0390811660009081526007602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b60108054610b4790613455565b60006001600160a01b038416611941576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038316611981576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416600090815260076020908152604080832033845290915290205460001981146119dd576119b88382613640565b6001600160a01b03861660009081526007602090815260408083203384529091529020555b6119e88585856121be565b95945050505050565b6001600160a01b038316611a31576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216611a71576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600a60205260409020546001600160a01b03848116911614611ac4576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336001600160a01b03841614801590611b0157506001600160a01b038316600090815260096020908152604080832033845290915290205460ff16155b8015611b2457506000818152600860205260409020546001600160a01b03163314155b15611b5b576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611b6482610c06565b15611b9b576040517f5ce7539700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bc683837f0000000000000000000000000000000000000000000000000de0b6b3a7640000612578565b610da88383836125f1565b6000818152600a60205260409020546001600160a01b0316338114801590611c1d57506001600160a01b038116600090815260096020908152604080832033845290915290205460ff16155b15611c54576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526008602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b828114611d01576040517f2e83472600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f546001600160a01b03163314801590611d275750600e546001600160a01b03163314155b15611d5e576040517fc5bb4a4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601154610100900460ff161515600103611da4576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b83811015610f0557611df7858583818110611dc457611dc46136c1565b9050602002016020810190611dd99190612fac565b848484818110611deb57611deb6136c1565b9050602002013561266a565b600101611da7565b611e07611fb2565b6001600160a01b038116611e4f576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610f0a816120ae565b606060008267ffffffffffffffff811115611e7557611e756130d4565b604051908082528060200260200182016040528015611e9e578160200160208202803683370190505b509050835b611ead84866137a6565b811015611eed57611ebf60008261271d565b82611eca8784613640565b81518110611eda57611eda6136c1565b6020908102919091010152600101611ea3565b509392505050565b611efd611fb2565b601154610100900460ff161515600103611f43576040517fd623127200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b60007f800000000000000000000000000000000000000000000000000000000000000082118015610b34575050600019141590565b600e546001600160a01b03163314610d8b576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611e46565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600260405161202a91906137b9565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b60003860003884865af1610d0e5763b12d13eb6000526004601cfd5b600e80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216612158576040517fa41e3d3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561216c57612167826127c0565b612175565b612175826127f4565b6001600160a01b03919091166000908152600c6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6001600160a01b038381166000908152600660205260408082205492851682528120549091906121ef868686612578565b60006121fa87610c06565b9050600061220787610c06565b90508180156122135750805b6125265781156122bc5760006122497f0000000000000000000000000000000000000000000000000de0b6b3a7640000856137c5565b6001600160a01b03891660009081526006602052604090205461228d907f0000000000000000000000000000000000000000000000000de0b6b3a7640000906137c5565b6122979190613640565b905060005b818110156122b5576122ad89612882565b60010161229c565b5050612526565b8015612358576001600160a01b038816600090815260066020526040812054612306907f0000000000000000000000000000000000000000000000000de0b6b3a7640000906137c5565b6123307f0000000000000000000000000000000000000000000000000de0b6b3a7640000876137c5565b61233a9190613640565b905060005b818110156122b5576123508a6129e0565b60010161233f565b60006123847f0000000000000000000000000000000000000000000000000de0b6b3a7640000886137c5565b905060005b81811015612407576001600160a01b038a166000908152600b60205260408120546123b690600190613640565b6001600160a01b038c166000908152600b6020526040812080549293509091839081106123e5576123e56136c1565b906000526020600020015490506123fd8c8c836125f1565b5050600101612389565b50807f0000000000000000000000000000000000000000000000000de0b6b3a76400006124498b6001600160a01b031660009081526006602052604090205490565b61245391906137c5565b61247d7f0000000000000000000000000000000000000000000000000de0b6b3a7640000886137c5565b6124879190613640565b111561249657612496896129e0565b806124c17f0000000000000000000000000000000000000000000000000de0b6b3a7640000866137c5565b7f0000000000000000000000000000000000000000000000000de0b6b3a76400006125018b6001600160a01b031660009081526006602052604090205490565b61250b91906137c5565b6125159190613640565b11156125245761252488612882565b505b506001979650505050505050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a90048061254f575050819003601f19909101908152919050565b601154839060ff1615156000036125e6576001600160a01b038116158015906125af5750600e546001600160a01b03828116911614155b156125e6576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61131f848484612a7a565b601154839060ff16151560000361265f576001600160a01b038116158015906126285750600e546001600160a01b03828116911614155b1561265f576040517ffb2141b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61131f848484612b36565b6001600160a01b0382166126aa576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f8000000000000000000000000000000000000000000000000000000000000000816004546126d991906137a6565b1115612711576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610da8600083836121be565b600061275783546fffffffffffffffffffffffffffffffff8082167001000000000000000000000000000000009092048116919091031690565b821061278f576040517f580821e700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5081546fffffffffffffffffffffffffffffffff908116820116600090815260018301602052604090205492915050565b6001600160a01b0381166000908152600b6020526040812054905b81811015610da8576127ec836129e0565b6001016127db565b6001600160a01b038116600090815260066020526040812054612838907f0000000000000000000000000000000000000000000000000de0b6b3a7640000906137c5565b9050600061285b836001600160a01b03166000908152600b602052604090205490565b905060005b61286a8284613640565b81101561131f5761287a84612882565b600101612860565b6001600160a01b0381166128c2576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546fffffffffffffffffffffffffffffffff8082167001000000000000000000000000000000009092041614612906576128ff6000612d3e565b9050612985565b60056000815461291590613800565b90915550600554600101612955576040517f303b682f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600554612982907f80000000000000000000000000000000000000000000000000000000000000006137a6565b90505b6000818152600a60205260409020546001600160a01b031680156129d5576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610da88184846125f1565b6001600160a01b038116612a20576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381166000908152600b602052604081208054612a4690600190613640565b81548110612a5657612a566136c1565b90600052602060002001549050612a6f826000836125f1565b610d0e600082612df3565b6001600160a01b038316612aa5578060046000828254612a9a91906137a6565b90915550612ad39050565b6001600160a01b03831660009081526006602052604081208054839290612acd908490613640565b90915550505b6001600160a01b03808316600081815260066020526040908190208054850190555190918516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612b299085815260200190565b60405180910390a3505050565b6001600160a01b03831615612c5957600081815260086020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690556001600160a01b0386168352600b90915281208054612b9d90600190613640565b81548110612bad57612bad6136c1565b90600052602060002001549050818114612c1a576000828152600a602052604081205460a01c6001600160a01b0386166000908152600b602052604090208054919250839183908110612c0257612c026136c1565b600091825260209091200155612c188282612ead565b505b6001600160a01b0384166000908152600b60205260409020805480612c4157612c4161381a565b60019003818190600052602060002001600090559055505b6001600160a01b03821615612ce8576000818152600a6020908152604080832080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038716908101909155808452600b83529083208054600181810183558286529385200185905592529054612ce3918391612cde9190613640565b612ead565b612cf8565b6000818152600a60205260408120555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b80546000906fffffffffffffffffffffffffffffffff7001000000000000000000000000000000008204811691168103612da4576040517f75e52f4f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600019016fffffffffffffffffffffffffffffffff9081166000818152600185016020526040812080549190558454909216700100000000000000000000000000000000909102179092555090565b81546fffffffffffffffffffffffffffffffff80821660001901917001000000000000000000000000000000009004811690821603612e5e576040517f8acb5f2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6fffffffffffffffffffffffffffffffff16600081815260018401602052604090209190915581547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016179055565b6000828152600a60205260409020546bffffffffffffffffffffffff821115612f02576040517ffcb3438c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000928352600a60205260409092206001600160a01b039290921660a09190911b7fffffffffffffffffffffffff000000000000000000000000000000000000000016019055565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114610f0a57600080fd5b600060208284031215612f8a57600080fd5b8135610cf381612f4a565b80356001600160a01b0381168114610fa457600080fd5b600060208284031215612fbe57600080fd5b610cf382612f95565b60005b83811015612fe2578181015183820152602001612fca565b50506000910152565b60008151808452613003816020860160208601612fc7565b601f01601f19169290920160200192915050565b602081526000610cf36020830184612feb565b60006020828403121561303c57600080fd5b5035919050565b6000806040838503121561305657600080fd5b61305f83612f95565b946020939093013593505050565b80358015158114610fa457600080fd5b60006020828403121561308f57600080fd5b610cf38261306d565b6000806000606084860312156130ad57600080fd5b6130b684612f95565b92506130c460208501612f95565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561312c5761312c6130d4565b604052919050565b600067ffffffffffffffff82111561314e5761314e6130d4565b50601f01601f191660200190565b600061316f61316a84613134565b613103565b905082815283838301111561318357600080fd5b828260208301376000602084830101529392505050565b6000602082840312156131ac57600080fd5b813567ffffffffffffffff8111156131c357600080fd5b8201601f810184136131d457600080fd5b6131e38482356020840161315c565b949350505050565b600080604083850312156131fe57600080fd5b61320783612f95565b91506132156020840161306d565b90509250929050565b6020808252825182820181905260009190848201906040850190845b818110156132565783518352928401929184019160010161323a565b50909695505050505050565b6000806000806080858703121561327857600080fd5b61328185612f95565b935061328f60208601612f95565b925060408501359150606085013567ffffffffffffffff8111156132b257600080fd5b8501601f810187136132c357600080fd5b6132d28782356020840161315c565b91505092959194509250565b600080600080600080600060e0888a0312156132f957600080fd5b61330288612f95565b965061331060208901612f95565b95506040880135945060608801359350608088013560ff8116811461333457600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561336457600080fd5b61336d83612f95565b915061321560208401612f95565b60008083601f84011261338d57600080fd5b50813567ffffffffffffffff8111156133a557600080fd5b6020830191508360208260051b85010111156133c057600080fd5b9250929050565b600080600080604085870312156133dd57600080fd5b843567ffffffffffffffff808211156133f557600080fd5b6134018883890161337b565b9096509450602087013591508082111561341a57600080fd5b506134278782880161337b565b95989497509550505050565b6000806040838503121561344657600080fd5b50508035926020909101359150565b600181811c9082168061346957607f821691505b6020821081036134a2577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f821115610da8576000816000526020600020601f850160051c810160208610156134d15750805b601f850160051c820191505b818110156134f0578281556001016134dd565b505050505050565b815167ffffffffffffffff811115613512576135126130d4565b613526816135208454613455565b846134a8565b602080601f83116001811461355b57600084156135435750858301515b600019600386901b1c1916600185901b1785556134f0565b600085815260208120601f198616915b8281101561358a5788860151825594840194600190910190840161356b565b50858210156135a85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006001600160a01b038087168352808616602084015250836040830152608060608301526135ea6080830184612feb565b9695505050505050565b60006020828403121561360657600080fd5b8151610cf381612f4a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b81810381811115610b3457610b34613611565b60006020828403121561366557600080fd5b815167ffffffffffffffff81111561367c57600080fd5b8201601f8101841361368d57600080fd5b805161369b61316a82613134565b8181528560208385010111156136b057600080fd5b6119e8826020830160208601612fc7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081546136fd81613455565b60018281168015613715576001811461374857613777565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450613777565b8560005260208060002060005b8581101561376e5781548a820152908401908201613755565b50505082870194505b5050505092915050565b600061378d82856136f0565b835161379d818360208801612fc7565b01949350505050565b80820180821115610b3457610b34613611565b6000610cf382846136f0565b6000826137fb577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000600019820361381357613813613611565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea164736f6c6343000817000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000babb6638172865996b1480210d8f2d4ed0fe9a5200000000000000000000000054239a172810ba1c65e1f6e647d8546e6b1273b900000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000043697066733a2f2f6261667962656962656335753479337973656966717a65337661796277726b786d37736b757a34633371693369336763736c33337065737a7775612f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000750616c65747465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003504c540000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : $owner (address): 0xBabb6638172865996B1480210D8f2D4eD0FE9a52
Arg [1] : $minter (address): 0x54239a172810ba1c65e1f6e647D8546e6B1273B9
Arg [2] : $baseTokenURI (string): ipfs://bafybeibec5u4y3yseifqze3vaybwrkxm7skuz4c3qi3i3gcsl33peszwua/
Arg [3] : $name (string): Palette
Arg [4] : $symbol (string): PLT
Arg [5] : $decimals (uint8): 18
-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 000000000000000000000000babb6638172865996b1480210d8f2d4ed0fe9a52
Arg [1] : 00000000000000000000000054239a172810ba1c65e1f6e647d8546e6b1273b9
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000180
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000043
Arg [7] : 697066733a2f2f6261667962656962656335753479337973656966717a653376
Arg [8] : 61796277726b786d37736b757a34633371693369336763736c33337065737a77
Arg [9] : 75612f0000000000000000000000000000000000000000000000000000000000
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [11] : 50616c6574746500000000000000000000000000000000000000000000000000
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [13] : 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.