Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
NFTFactory
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.7 <0.9.0; import {ERC721} from "./ERC721.sol"; import {ERC721Enumerable} from "./ERC721Enumerable.sol"; import {ERC1155} from "./ERC1155.sol"; import {Ownable} from "./Ownable.sol"; contract NFTFactory { function deployERC721(address originalAddress, string memory name, string memory symbol, string memory baseURI, string memory extension, address royaltyRecipient, uint256 royaltyBps) public returns (address) { ERC721 newCollection = new ERC721(originalAddress, name, symbol, baseURI, extension, royaltyRecipient, royaltyBps); Ownable(newCollection).transferOwnership(msg.sender); address newAddress = address(newCollection); return newAddress; } function deployERC721Enumerable(address originalAddress, string memory name, string memory symbol, string memory baseURI, string memory extension, address royaltyRecipient, uint256 royaltyBps) public returns (address) { ERC721 newCollection = new ERC721Enumerable(originalAddress, name, symbol, baseURI, extension, royaltyRecipient, royaltyBps); Ownable(newCollection).transferOwnership(msg.sender); address newAddress = address(newCollection); return newAddress; } function deployERC1155(address originalAddress, address royaltyRecipient, uint256 royaltyBps) public returns (address) { ERC1155 newCollection = new ERC1155(originalAddress, royaltyRecipient, royaltyBps); Ownable(newCollection).transferOwnership(msg.sender); address newAddress = address(newCollection); return newAddress; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {ERC721Base} from "./ERC721Base.sol"; import {LibString} from "./utils/LibString.sol"; import {ERC2981} from "./ERC2981.sol"; import {PermissionedMintingNFT} from "./PermissionedMintingNFT.sol"; import {BridgedNFT} from "./BridgedNFT.sol"; contract ERC721 is ERC721Base, ERC2981, PermissionedMintingNFT, BridgedNFT { // NFT Metadata string private _name; string private _symbol; string private _baseURI; string private _extension; mapping(uint256 => string) private _tokenURIs; // Custom errors error TokenExists(); error MismatchedLengths(); constructor( address originalAddress, string memory name, string memory symbol, string memory baseURI, string memory hasExtension, address royaltyRecipient, uint256 royaltyBps ) ERC2981(royaltyRecipient, royaltyBps) PermissionedMintingNFT() BridgedNFT(originalAddress) { _name = name; _symbol = symbol; _baseURI = baseURI; _extension = hasExtension; } function name() public view override returns (string memory) { return _name; } function symbol() public view override returns (string memory) { return _symbol; } function tokenURI(uint256 tokenId) public view override returns (string memory) { if (!_exists(tokenId)) revert TokenDoesNotExist(); if (bytes(_tokenURIs[tokenId]).length != 0) { return _tokenURIs[tokenId]; } return string(abi.encodePacked(_baseURI, LibString.toString(tokenId), _extension)); } function setBaseURI(string memory baseURI) external onlyOwner { _baseURI = baseURI; } function batchSetTokenURIs(uint256 startId, string[] calldata uris) public onlyOwner { for (uint256 i = 0; i < uris.length; ++i) { _tokenURIs[startId + i] = uris[i]; } } function mint(address to, uint256 id) public mintIsOpen onlyMinter { if (_exists(id)) revert TokenExists(); _mint(to, id); } struct AirdropUnit { address to; uint256[] ids; } function bulkAirdrop(AirdropUnit[] calldata airdropUnits) public mintIsOpen onlyMinter { for (uint256 i = 0; i < airdropUnits.length; ++i) { for (uint256 j = 0; j < airdropUnits[i].ids.length; j++) { uint256 id = airdropUnits[i].ids[j]; if (_exists(id)) revert TokenExists(); _mint(airdropUnits[i].to, id); } } } function setRoyalties(address recipient, uint256 bps) external onlyOwner { _setRoyalties(recipient, bps); } function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool result) { /// @solidity memory-safe-assembly assembly { let s := shr(224, interfaceId) // ERC165: 0x01ffc9a7, ERC2981: 0x2a55205a, ERC721: 0x80ac58cd result := or(eq(s, 0x01ffc9a7), eq(s, 0x2a55205a)) result := or(result, eq(s, 0x80ac58cd)) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {ERC721} from "./ERC721.sol"; contract ERC721Enumerable is ERC721 { // array with all token IDs, used for enumeration uint256[] private _allTokens; // Mapping from token ID to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; // Mapping from owner to list-as-mapping of owned token IDs mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens; // Mapping from token ID to index in the ownedTokens mapping mapping(uint256 tokenId => uint256) private _ownedTokensIndex; function totalSupply() public view returns (uint256) { return _allTokens.length; } function tokenByIndex(uint256 index) public view returns (uint256) { require(index < totalSupply(), "ERC721Enumerable: INVALID_INDEX"); return _allTokens[index]; } function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { require(index < balanceOf(owner), "ERC721Enumerable: INVALID_INDEX"); return _ownedTokens[owner][index]; } constructor(address originalAddress, string memory name, string memory symbol, string memory baseURI, string memory hasExtension, address royaltyRecipient, uint256 royaltyBps) ERC721(originalAddress, name, symbol, baseURI, hasExtension, royaltyRecipient, royaltyBps) {} function _beforeTokenTransfer(address _from, address _to, uint256 _tokenId) internal override { if (_from == address(0)) { _addTokenToAllTokensEnumeration(_tokenId); } else if (_from != _to){ _removeTokenFromOwnerEnumeration(_from, _tokenId); } if (_to == address(0)) { _removeTokenFromAllTokensEnumeration(_tokenId); _removeTokenFromOwnerEnumeration(_from, _tokenId); } else if (_to != _from){ _addTokenToOwnerEnumeration(_to, _tokenId); } } /* From OZ ERC721Enumerable */ /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { // NOTE: Balance has not been incremented yet when this is called. // Because of this, we don't subtract 1 from balanceOf(to) to get the index. // Not only is this correct, it also prevents underflow on mint. // The alternative would be moving this to the _afterTokenTransfer hook, // but that would breack CEI (reentrancy) uint256 length = balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). // this decrement is safe because balanceOf has not been updated yet // so if a user is sending their last token, balanceOf(from) will return 1 // and the value of lastTokenIndex will correctly be 0 uint256 lastTokenIndex = balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex]; _ownedTokensByOwner[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokensByOwner[lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /* ERC165 */ function supportsInterface(bytes4 interfaceId) public pure override returns (bool result) { /// @solidity memory-safe-assembly assembly { let s := shr(224, interfaceId) // ERC165: 0x01ffc9a7 // ERC2981: 0x2a55205a result := or(eq(s, 0x01ffc9a7), eq(s, 0x2a55205a)) // ERC721: 0x80ac58cd result := or(result, eq(s, 0x80ac58cd)) // ERC721Enumerable: 0x780e9d63 result := or(result, eq(s, 0x780e9d63)) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {ERC1155Base} from "./ERC1155Base.sol"; import {ERC2981} from "./ERC2981.sol"; import {LibString} from "./utils/LibString.sol"; import {PermissionedMintingNFT} from "./PermissionedMintingNFT.sol"; import {BridgedNFT} from "./BridgedNFT.sol"; contract ERC1155 is ERC1155Base, ERC2981, PermissionedMintingNFT, BridgedNFT { // tokenURI overrides everything mapping(uint256 => string) private _tokenURIs; error URINotSet(); struct AirdropUnit { address to; uint256[] ids; uint256[] amounts; bytes data; } constructor( address originalAddress, address royaltyRecipient, uint256 royaltyBps ) ERC2981(royaltyRecipient, royaltyBps) PermissionedMintingNFT() BridgedNFT(originalAddress) {} function mint(address to, uint256 id, uint256 amount, bytes memory data) public mintIsOpen onlyMinter { _mint(to, id, amount, data); } function bulkAirdrop(AirdropUnit[] calldata airdrops) public mintIsOpen onlyMinter { for (uint256 i = 0; i < airdrops.length; ++i) { _batchMint(airdrops[i].to, airdrops[i].ids, airdrops[i].amounts, airdrops[i].data); } } function batchSetTokenURIs(uint256 startId, string[] calldata uris) public onlyMinter { for (uint256 i = 0; i < uris.length; ++i) { _tokenURIs[startId + i] = uris[i]; } } function setRoyalties(address recipient, uint256 bps) external onlyOwner { _setRoyalties(recipient, bps); } function uri(uint256 id) public view override returns (string memory) { if (bytes(_tokenURIs[id]).length != 0) { return _tokenURIs[id]; } else { revert URINotSet(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; /** * @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 { 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() != msg.sender) { revert OwnableUnauthorizedAccount(msg.sender); } } /** * @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.4; /// @notice Simple ERC721 implementation with storage hitchhiking. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC721.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC721.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC721/ERC721.sol) /// /// @dev Note: /// - The ERC721 standard allows for self-approvals. /// For performance, this implementation WILL NOT revert for such actions. /// Please add any checks with overrides if desired. /// - For performance, methods are made payable where permitted by the ERC721 standard. /// - The `safeTransfer` functions use the identity precompile (0x4) /// to copy memory internally. /// /// If you are overriding: /// - NEVER violate the ERC721 invariant: /// the balance of an owner MUST always be equal to their number of ownership slots. /// The transfer functions do not have an underflow guard for user token balances. /// - Make sure all variables written to storage are properly cleaned // (e.g. the bool value for `isApprovedForAll` MUST be either 1 or 0 under the hood). /// - Check that the overridden function is actually used in the function you want to /// change the behavior of. Much of the code has been manually inlined for performance. abstract contract ERC721Base { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev An account can hold up to 4294967295 tokens. uint256 internal constant _MAX_ACCOUNT_BALANCE = 0xffffffff; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Only the token owner or an approved account can manage the token. error NotOwnerNorApproved(); /// @dev The token does not exist. error TokenDoesNotExist(); /// @dev The token already exists. error TokenAlreadyExists(); /// @dev Cannot query the balance for the zero address. error BalanceQueryForZeroAddress(); /// @dev Cannot mint or transfer to the zero address. error TransferToZeroAddress(); /// @dev The token must be owned by `from`. error TransferFromIncorrectOwner(); /// @dev The recipient's balance has overflowed. error AccountBalanceOverflow(); /// @dev Cannot safely transfer to a contract that does not implement /// the ERC721Receiver interface. error TransferToNonERC721ReceiverImplementer(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Emitted when token `id` is transferred from `from` to `to`. event Transfer(address indexed from, address indexed to, uint256 indexed id); /// @dev Emitted when `owner` enables `account` to manage the `id` token. event Approval(address indexed owner, address indexed account, uint256 indexed id); /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens. event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved); /// @dev `keccak256(bytes("Transfer(address,address,uint256)"))`. uint256 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; /// @dev `keccak256(bytes("Approval(address,address,uint256)"))`. uint256 private constant _APPROVAL_EVENT_SIGNATURE = 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925; /// @dev `keccak256(bytes("ApprovalForAll(address,address,bool)"))`. uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE = 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ownership data slot of `id` is given by: /// ``` /// mstore(0x00, id) /// mstore(0x1c, _ERC721_MASTER_SLOT_SEED) /// let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) /// ``` /// Bits Layout: /// - [0..159] `addr` /// - [160..255] `extraData` /// /// The approved address slot is given by: `add(1, ownershipSlot)`. /// /// See: https://notes.ethereum.org/%40vbuterin/verkle_tree_eip /// /// The balance slot of `owner` is given by: /// ``` /// mstore(0x1c, _ERC721_MASTER_SLOT_SEED) /// mstore(0x00, owner) /// let balanceSlot := keccak256(0x0c, 0x1c) /// ``` /// Bits Layout: /// - [0..31] `balance` /// - [32..255] `aux` /// /// The `operator` approval slot of `owner` is given by: /// ``` /// mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, operator)) /// mstore(0x00, owner) /// let operatorApprovalSlot := keccak256(0x0c, 0x30) /// ``` uint256 private constant _ERC721_MASTER_SLOT_SEED = 0x7d8825530a5a2e7a << 192; /// @dev Pre-shifted and pre-masked constant. uint256 private constant _ERC721_MASTER_SLOT_SEED_MASKED = 0x0a5a2e7a00000000; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC721 METADATA */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the token collection name. function name() public view virtual returns (string memory); /// @dev Returns the token collection symbol. function symbol() public view virtual returns (string memory); /// @dev Returns the Uniform Resource Identifier (URI) for token `id`. function tokenURI(uint256 id) public view virtual returns (string memory); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC721 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the owner of token `id`. /// /// Requirements: /// - Token `id` must exist. function ownerOf(uint256 id) public view virtual returns (address result) { result = _ownerOf(id); /// @solidity memory-safe-assembly assembly { if iszero(result) { mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`. revert(0x1c, 0x04) } } } /// @dev Returns the number of tokens owned by `owner`. /// /// Requirements: /// - `owner` must not be the zero address. function balanceOf(address owner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // Revert if the `owner` is the zero address. if iszero(owner) { mstore(0x00, 0x8f4eb604) // `BalanceQueryForZeroAddress()`. revert(0x1c, 0x04) } mstore(0x1c, _ERC721_MASTER_SLOT_SEED) mstore(0x00, owner) result := and(sload(keccak256(0x0c, 0x1c)), _MAX_ACCOUNT_BALANCE) } } /// @dev Returns the account approved to manage token `id`. /// /// Requirements: /// - Token `id` must exist. function getApproved(uint256 id) public view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) if iszero(shl(96, sload(ownershipSlot))) { mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`. revert(0x1c, 0x04) } result := sload(add(1, ownershipSlot)) } } /// @dev Sets `account` as the approved account to manage token `id`. /// /// Requirements: /// - Token `id` must exist. /// - The caller must be the owner of the token, /// or an approved operator for the token owner. /// /// Emits an {Approval} event. function approve(address account, uint256 id) public payable virtual { _approve(msg.sender, account, id); } /// @dev Returns whether `operator` is approved to manage the tokens of `owner`. function isApprovedForAll(address owner, address operator) public view virtual returns (bool result) { /// @solidity memory-safe-assembly assembly { mstore(0x1c, operator) mstore(0x08, _ERC721_MASTER_SLOT_SEED_MASKED) mstore(0x00, owner) result := sload(keccak256(0x0c, 0x30)) } } /// @dev Sets whether `operator` is approved to manage the tokens of the caller. /// /// Emits an {ApprovalForAll} event. function setApprovalForAll(address operator, bool isApproved) public virtual { /// @solidity memory-safe-assembly assembly { // Convert to 0 or 1. isApproved := iszero(iszero(isApproved)) // Update the `isApproved` for (`msg.sender`, `operator`). mstore(0x1c, operator) mstore(0x08, _ERC721_MASTER_SLOT_SEED_MASKED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x30), isApproved) // Emit the {ApprovalForAll} event. mstore(0x00, isApproved) // forgefmt: disable-next-item log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator))) } } /// @dev Transfers token `id` from `from` to `to`. /// /// Requirements: /// /// - Token `id` must exist. /// - `from` must be the owner of the token. /// - `to` cannot be the zero address. /// - The caller must be the owner of the token, or be approved to manage the token. /// /// Emits a {Transfer} event. function transferFrom(address from, address to, uint256 id) public payable virtual { _beforeTokenTransfer(from, to, id); /// @solidity memory-safe-assembly assembly { // Clear the upper 96 bits. let bitmaskAddress := shr(96, not(0)) from := and(bitmaskAddress, from) to := and(bitmaskAddress, to) // Load the ownership data. mstore(0x00, id) mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, caller())) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let ownershipPacked := sload(ownershipSlot) let owner := and(bitmaskAddress, ownershipPacked) // Revert if the token does not exist, or if `from` is not the owner. if iszero(mul(owner, eq(owner, from))) { // `TokenDoesNotExist()`, `TransferFromIncorrectOwner()`. mstore(shl(2, iszero(owner)), 0xceea21b6a1148100) revert(0x1c, 0x04) } // Load, check, and update the token approval. { mstore(0x00, from) let approvedAddress := sload(add(1, ownershipSlot)) // Revert if the caller is not the owner, nor approved. if iszero(or(eq(caller(), from), eq(caller(), approvedAddress))) { if iszero(sload(keccak256(0x0c, 0x30))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Delete the approved address if any. if approvedAddress { sstore(add(1, ownershipSlot), 0) } } // Update with the new owner. sstore(ownershipSlot, xor(ownershipPacked, xor(from, to))) // Decrement the balance of `from`. { let fromBalanceSlot := keccak256(0x0c, 0x1c) sstore(fromBalanceSlot, sub(sload(fromBalanceSlot), 1)) } // Increment the balance of `to`. { mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x1c) let toBalanceSlotPacked := add(sload(toBalanceSlot), 1) // Revert if `to` is the zero address, or if the account balance overflows. if iszero(mul(to, and(toBalanceSlotPacked, _MAX_ACCOUNT_BALANCE))) { // `TransferToZeroAddress()`, `AccountBalanceOverflow()`. mstore(shl(2, iszero(to)), 0xea553b3401336cea) revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceSlotPacked) } // Emit the {Transfer} event. log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id) } _afterTokenTransfer(from, to, id); } /// @dev Equivalent to `safeTransferFrom(from, to, id, "")`. function safeTransferFrom(address from, address to, uint256 id) public payable virtual { transferFrom(from, to, id); if (_hasCode(to)) _checkOnERC721Received(from, to, id, ""); } /// @dev Transfers token `id` from `from` to `to`. /// /// Requirements: /// /// - Token `id` must exist. /// - `from` must be the owner of the token. /// - `to` cannot be the zero address. /// - The caller must be the owner of the token, or be approved to manage the token. /// - If `to` refers to a smart contract, it must implement /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. /// /// Emits a {Transfer} event. function safeTransferFrom(address from, address to, uint256 id, bytes calldata data) public payable virtual { transferFrom(from, to, id); if (_hasCode(to)) _checkOnERC721Received(from, to, id, data); } /// @dev Returns true if this contract implements the interface defined by `interfaceId`. /// See: https://eips.ethereum.org/EIPS/eip-165 /// This function call must use less than 30000 gas. function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) { /// @solidity memory-safe-assembly assembly { let s := shr(224, interfaceId) // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f. result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL QUERY FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns if token `id` exists. function _exists(uint256 id) internal view virtual returns (bool result) { /// @solidity memory-safe-assembly assembly { mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) result := iszero(iszero(shl(96, sload(add(id, add(id, keccak256(0x00, 0x20))))))) } } /// @dev Returns the owner of token `id`. /// Returns the zero address instead of reverting if the token does not exist. function _ownerOf(uint256 id) internal view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) result := shr(96, shl(96, sload(add(id, add(id, keccak256(0x00, 0x20)))))) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL DATA HITCHHIKING FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ // For performance, no events are emitted for the hitchhiking setters. // Please emit your own events if required. /// @dev Returns the auxiliary data for `owner`. /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data. /// Auxiliary data can be set for any address, even if it does not have any tokens. function _getAux(address owner) internal view virtual returns (uint224 result) { /// @solidity memory-safe-assembly assembly { mstore(0x1c, _ERC721_MASTER_SLOT_SEED) mstore(0x00, owner) result := shr(32, sload(keccak256(0x0c, 0x1c))) } } /// @dev Set the auxiliary data for `owner` to `value`. /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data. /// Auxiliary data can be set for any address, even if it does not have any tokens. function _setAux(address owner, uint224 value) internal virtual { /// @solidity memory-safe-assembly assembly { mstore(0x1c, _ERC721_MASTER_SLOT_SEED) mstore(0x00, owner) let balanceSlot := keccak256(0x0c, 0x1c) let packed := sload(balanceSlot) sstore(balanceSlot, xor(packed, shl(32, xor(value, shr(32, packed))))) } } /// @dev Returns the extra data for token `id`. /// Minting, transferring, burning a token will not change the extra data. /// The extra data can be set on a non-existent token. function _getExtraData(uint256 id) internal view virtual returns (uint96 result) { /// @solidity memory-safe-assembly assembly { mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) result := shr(160, sload(add(id, add(id, keccak256(0x00, 0x20))))) } } /// @dev Sets the extra data for token `id` to `value`. /// Minting, transferring, burning a token will not change the extra data. /// The extra data can be set on a non-existent token. function _setExtraData(uint256 id, uint96 value) internal virtual { /// @solidity memory-safe-assembly assembly { mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let packed := sload(ownershipSlot) sstore(ownershipSlot, xor(packed, shl(160, xor(value, shr(160, packed))))) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL MINT FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Mints token `id` to `to`. /// /// Requirements: /// /// - Token `id` must not exist. /// - `to` cannot be the zero address. /// /// Emits a {Transfer} event. function _mint(address to, uint256 id) internal virtual { _beforeTokenTransfer(address(0), to, id); /// @solidity memory-safe-assembly assembly { // Clear the upper 96 bits. to := shr(96, shl(96, to)) // Load the ownership data. mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let ownershipPacked := sload(ownershipSlot) // Revert if the token already exists. if shl(96, ownershipPacked) { mstore(0x00, 0xc991cbb1) // `TokenAlreadyExists()`. revert(0x1c, 0x04) } // Update with the owner. sstore(ownershipSlot, or(ownershipPacked, to)) // Increment the balance of the owner. { mstore(0x00, to) let balanceSlot := keccak256(0x0c, 0x1c) let balanceSlotPacked := add(sload(balanceSlot), 1) // Revert if `to` is the zero address, or if the account balance overflows. if iszero(mul(to, and(balanceSlotPacked, _MAX_ACCOUNT_BALANCE))) { // `TransferToZeroAddress()`, `AccountBalanceOverflow()`. mstore(shl(2, iszero(to)), 0xea553b3401336cea) revert(0x1c, 0x04) } sstore(balanceSlot, balanceSlotPacked) } // Emit the {Transfer} event. log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, 0, to, id) } _afterTokenTransfer(address(0), to, id); } /// @dev Mints token `id` to `to`, and updates the extra data for token `id` to `value`. /// Does NOT check if token `id` already exists (assumes `id` is auto-incrementing). /// /// Requirements: /// /// - `to` cannot be the zero address. /// /// Emits a {Transfer} event. function _mintAndSetExtraDataUnchecked(address to, uint256 id, uint96 value) internal virtual { _beforeTokenTransfer(address(0), to, id); /// @solidity memory-safe-assembly assembly { // Clear the upper 96 bits. to := shr(96, shl(96, to)) // Update with the owner and extra data. mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) sstore(add(id, add(id, keccak256(0x00, 0x20))), or(shl(160, value), to)) // Increment the balance of the owner. { mstore(0x00, to) let balanceSlot := keccak256(0x0c, 0x1c) let balanceSlotPacked := add(sload(balanceSlot), 1) // Revert if `to` is the zero address, or if the account balance overflows. if iszero(mul(to, and(balanceSlotPacked, _MAX_ACCOUNT_BALANCE))) { // `TransferToZeroAddress()`, `AccountBalanceOverflow()`. mstore(shl(2, iszero(to)), 0xea553b3401336cea) revert(0x1c, 0x04) } sstore(balanceSlot, balanceSlotPacked) } // Emit the {Transfer} event. log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, 0, to, id) } _afterTokenTransfer(address(0), to, id); } /// @dev Equivalent to `_safeMint(to, id, "")`. function _safeMint(address to, uint256 id) internal virtual { _safeMint(to, id, ""); } /// @dev Mints token `id` to `to`. /// /// Requirements: /// /// - Token `id` must not exist. /// - `to` cannot be the zero address. /// - If `to` refers to a smart contract, it must implement /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. /// /// Emits a {Transfer} event. function _safeMint(address to, uint256 id, bytes memory data) internal virtual { _mint(to, id); if (_hasCode(to)) _checkOnERC721Received(address(0), to, id, data); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL BURN FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Equivalent to `_burn(address(0), id)`. function _burn(uint256 id) internal virtual { _burn(address(0), id); } /// @dev Destroys token `id`, using `by`. /// /// Requirements: /// /// - Token `id` must exist. /// - If `by` is not the zero address, /// it must be the owner of the token, or be approved to manage the token. /// /// Emits a {Transfer} event. function _burn(address by, uint256 id) internal virtual { address owner = ownerOf(id); _beforeTokenTransfer(owner, address(0), id); /// @solidity memory-safe-assembly assembly { // Clear the upper 96 bits. by := shr(96, shl(96, by)) // Load the ownership data. mstore(0x00, id) mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, by)) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let ownershipPacked := sload(ownershipSlot) // Reload the owner in case it is changed in `_beforeTokenTransfer`. owner := shr(96, shl(96, ownershipPacked)) // Revert if the token does not exist. if iszero(owner) { mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`. revert(0x1c, 0x04) } // Load and check the token approval. { mstore(0x00, owner) let approvedAddress := sload(add(1, ownershipSlot)) // If `by` is not the zero address, do the authorization check. // Revert if the `by` is not the owner, nor approved. if iszero(or(iszero(by), or(eq(by, owner), eq(by, approvedAddress)))) { if iszero(sload(keccak256(0x0c, 0x30))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Delete the approved address if any. if approvedAddress { sstore(add(1, ownershipSlot), 0) } } // Clear the owner. sstore(ownershipSlot, xor(ownershipPacked, owner)) // Decrement the balance of `owner`. { let balanceSlot := keccak256(0x0c, 0x1c) sstore(balanceSlot, sub(sload(balanceSlot), 1)) } // Emit the {Transfer} event. log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, owner, 0, id) } _afterTokenTransfer(owner, address(0), id); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL APPROVAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns whether `account` is the owner of token `id`, or is approved to manage it. /// /// Requirements: /// - Token `id` must exist. function _isApprovedOrOwner(address account, uint256 id) internal view virtual returns (bool result) { /// @solidity memory-safe-assembly assembly { result := 1 // Clear the upper 96 bits. account := shr(96, shl(96, account)) // Load the ownership data. mstore(0x00, id) mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, account)) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let owner := shr(96, shl(96, sload(ownershipSlot))) // Revert if the token does not exist. if iszero(owner) { mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`. revert(0x1c, 0x04) } // Check if `account` is the `owner`. if iszero(eq(account, owner)) { mstore(0x00, owner) // Check if `account` is approved to manage the token. if iszero(sload(keccak256(0x0c, 0x30))) { result := eq(account, sload(add(1, ownershipSlot))) } } } } /// @dev Returns the account approved to manage token `id`. /// Returns the zero address instead of reverting if the token does not exist. function _getApproved(uint256 id) internal view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { mstore(0x00, id) mstore(0x1c, _ERC721_MASTER_SLOT_SEED) result := sload(add(1, add(id, add(id, keccak256(0x00, 0x20))))) } } /// @dev Equivalent to `_approve(address(0), account, id)`. function _approve(address account, uint256 id) internal virtual { _approve(address(0), account, id); } /// @dev Sets `account` as the approved account to manage token `id`, using `by`. /// /// Requirements: /// - Token `id` must exist. /// - If `by` is not the zero address, `by` must be the owner /// or an approved operator for the token owner. /// /// Emits a {Approval} event. function _approve(address by, address account, uint256 id) internal virtual { assembly { // Clear the upper 96 bits. let bitmaskAddress := shr(96, not(0)) account := and(bitmaskAddress, account) by := and(bitmaskAddress, by) // Load the owner of the token. mstore(0x00, id) mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, by)) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let owner := and(bitmaskAddress, sload(ownershipSlot)) // Revert if the token does not exist. if iszero(owner) { mstore(0x00, 0xceea21b6) // `TokenDoesNotExist()`. revert(0x1c, 0x04) } // If `by` is not the zero address, do the authorization check. // Revert if `by` is not the owner, nor approved. if iszero(or(iszero(by), eq(by, owner))) { mstore(0x00, owner) if iszero(sload(keccak256(0x0c, 0x30))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Sets `account` as the approved account to manage `id`. sstore(add(1, ownershipSlot), account) // Emit the {Approval} event. log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, owner, account, id) } } /// @dev Approve or remove the `operator` as an operator for `by`, /// without authorization checks. /// /// Emits an {ApprovalForAll} event. function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual { /// @solidity memory-safe-assembly assembly { // Clear the upper 96 bits. by := shr(96, shl(96, by)) operator := shr(96, shl(96, operator)) // Convert to 0 or 1. isApproved := iszero(iszero(isApproved)) // Update the `isApproved` for (`by`, `operator`). mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, operator)) mstore(0x00, by) sstore(keccak256(0x0c, 0x30), isApproved) // Emit the {ApprovalForAll} event. mstore(0x00, isApproved) log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, by, operator) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL TRANSFER FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Equivalent to `_transfer(address(0), from, to, id)`. function _transfer(address from, address to, uint256 id) internal virtual { _transfer(address(0), from, to, id); } /// @dev Transfers token `id` from `from` to `to`. /// /// Requirements: /// /// - Token `id` must exist. /// - `from` must be the owner of the token. /// - `to` cannot be the zero address. /// - If `by` is not the zero address, /// it must be the owner of the token, or be approved to manage the token. /// /// Emits a {Transfer} event. function _transfer(address by, address from, address to, uint256 id) internal virtual { _beforeTokenTransfer(from, to, id); /// @solidity memory-safe-assembly assembly { // Clear the upper 96 bits. let bitmaskAddress := shr(96, not(0)) from := and(bitmaskAddress, from) to := and(bitmaskAddress, to) by := and(bitmaskAddress, by) // Load the ownership data. mstore(0x00, id) mstore(0x1c, or(_ERC721_MASTER_SLOT_SEED, by)) let ownershipSlot := add(id, add(id, keccak256(0x00, 0x20))) let ownershipPacked := sload(ownershipSlot) let owner := and(bitmaskAddress, ownershipPacked) // Revert if the token does not exist, or if `from` is not the owner. if iszero(mul(owner, eq(owner, from))) { // `TokenDoesNotExist()`, `TransferFromIncorrectOwner()`. mstore(shl(2, iszero(owner)), 0xceea21b6a1148100) revert(0x1c, 0x04) } // Load, check, and update the token approval. { mstore(0x00, from) let approvedAddress := sload(add(1, ownershipSlot)) // If `by` is not the zero address, do the authorization check. // Revert if the `by` is not the owner, nor approved. if iszero(or(iszero(by), or(eq(by, from), eq(by, approvedAddress)))) { if iszero(sload(keccak256(0x0c, 0x30))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Delete the approved address if any. if approvedAddress { sstore(add(1, ownershipSlot), 0) } } // Update with the new owner. sstore(ownershipSlot, xor(ownershipPacked, xor(from, to))) // Decrement the balance of `from`. { let fromBalanceSlot := keccak256(0x0c, 0x1c) sstore(fromBalanceSlot, sub(sload(fromBalanceSlot), 1)) } // Increment the balance of `to`. { mstore(0x00, to) let toBalanceSlot := keccak256(0x0c, 0x1c) let toBalanceSlotPacked := add(sload(toBalanceSlot), 1) // Revert if `to` is the zero address, or if the account balance overflows. if iszero(mul(to, and(toBalanceSlotPacked, _MAX_ACCOUNT_BALANCE))) { // `TransferToZeroAddress()`, `AccountBalanceOverflow()`. mstore(shl(2, iszero(to)), 0xea553b3401336cea) revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceSlotPacked) } // Emit the {Transfer} event. log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id) } _afterTokenTransfer(from, to, id); } /// @dev Equivalent to `_safeTransfer(from, to, id, "")`. function _safeTransfer(address from, address to, uint256 id) internal virtual { _safeTransfer(from, to, id, ""); } /// @dev Transfers token `id` from `from` to `to`. /// /// Requirements: /// /// - Token `id` must exist. /// - `from` must be the owner of the token. /// - `to` cannot be the zero address. /// - The caller must be the owner of the token, or be approved to manage the token. /// - If `to` refers to a smart contract, it must implement /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. /// /// Emits a {Transfer} event. function _safeTransfer(address from, address to, uint256 id, bytes memory data) internal virtual { _transfer(address(0), from, to, id); if (_hasCode(to)) _checkOnERC721Received(from, to, id, data); } /// @dev Equivalent to `_safeTransfer(by, from, to, id, "")`. function _safeTransfer(address by, address from, address to, uint256 id) internal virtual { _safeTransfer(by, from, to, id, ""); } /// @dev Transfers token `id` from `from` to `to`. /// /// Requirements: /// /// - Token `id` must exist. /// - `from` must be the owner of the token. /// - `to` cannot be the zero address. /// - If `by` is not the zero address, /// it must be the owner of the token, or be approved to manage the token. /// - If `to` refers to a smart contract, it must implement /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. /// /// Emits a {Transfer} event. function _safeTransfer(address by, address from, address to, uint256 id, bytes memory data) internal virtual { _transfer(by, from, to, id); if (_hasCode(to)) _checkOnERC721Received(from, to, id, data); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HOOKS FOR OVERRIDING */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Hook that is called before any token transfers, including minting and burning. function _beforeTokenTransfer(address from, address to, uint256 id) internal virtual {} /// @dev Hook that is called after any token transfers, including minting and burning. function _afterTokenTransfer(address from, address to, uint256 id) internal virtual {} /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PRIVATE HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns if `a` has bytecode of non-zero length. function _hasCode(address a) private view returns (bool result) { /// @solidity memory-safe-assembly assembly { result := extcodesize(a) // Can handle dirty upper bits. } } /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`. /// Reverts if the target does not support the function correctly. function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data) private { /// @solidity memory-safe-assembly assembly { // Prepare the calldata. let m := mload(0x40) let onERC721ReceivedSelector := 0x150b7a02 mstore(m, onERC721ReceivedSelector) mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`. mstore(add(m, 0x40), shr(96, shl(96, from))) mstore(add(m, 0x60), id) mstore(add(m, 0x80), 0x80) let n := mload(data) mstore(add(m, 0xa0), n) if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) } // Revert if the call reverts. if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) { if returndatasize() { // Bubble up the revert if the call reverts. returndatacopy(m, 0x00, returndatasize()) revert(m, returndatasize()) } } // Load the returndata and compare it. if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) { mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`. revert(0x1c, 0x04) } } } }
// 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(); /// @dev The input string must be a 7-bit ASCII. error StringNot7BitASCII(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The constant returned when the `search` is not found in the string. uint256 internal constant NOT_FOUND = type(uint256).max; /// @dev Lookup for '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'. uint128 internal constant ALPHANUMERIC_7_BIT_ASCII = 0x7fffffe07fffffe03ff000000000000; /// @dev Lookup for 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'. uint128 internal constant LETTERS_7_BIT_ASCII = 0x7fffffe07fffffe0000000000000000; /// @dev Lookup for 'abcdefghijklmnopqrstuvwxyz'. uint128 internal constant LOWERCASE_7_BIT_ASCII = 0x7fffffe000000000000000000000000; /// @dev Lookup for 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. uint128 internal constant UPPERCASE_7_BIT_ASCII = 0x7fffffe0000000000000000; /// @dev Lookup for '0123456789'. uint128 internal constant DIGITS_7_BIT_ASCII = 0x3ff000000000000; /// @dev Lookup for '0123456789abcdefABCDEF'. uint128 internal constant HEXDIGITS_7_BIT_ASCII = 0x7e0000007e03ff000000000000; /// @dev Lookup for '01234567'. uint128 internal constant OCTDIGITS_7_BIT_ASCII = 0xff000000000000; /// @dev Lookup for '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'. uint128 internal constant PRINTABLE_7_BIT_ASCII = 0x7fffffffffffffffffffffff00003e00; /// @dev Lookup for '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'. uint128 internal constant PUNCTUATION_7_BIT_ASCII = 0x78000001f8000001fc00fffe00000000; /// @dev Lookup for ' \t\n\r\x0b\x0c'. uint128 internal constant WHITESPACE_7_BIT_ASCII = 0x100003e00; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* DECIMAL OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the base 10 decimal representation of `value`. function toString(uint256 value) internal pure returns (string memory result) { /// @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. result := add(mload(0x40), 0x80) mstore(0x40, add(result, 0x20)) // Allocate memory. mstore(result, 0) // Zeroize the slot after the string. let end := result // Cache the end of the memory to calculate the length later. 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 {} { result := add(result, w) // `sub(result, 1)`. // Store the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(result, add(48, mod(temp, 10))) temp := div(temp, 10) // Keep dividing `temp` until zero. if iszero(temp) { break } } let n := sub(end, result) result := sub(result, 0x20) // Move the pointer 32 bytes back to make room for the length. mstore(result, n) // Store the length. } } /// @dev Returns the base 10 decimal representation of `value`. function toString(int256 value) internal pure returns (string memory result) { if (value >= 0) return toString(uint256(value)); unchecked { result = 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 n := mload(result) // Load the string length. mstore(result, 0x2d) // Store the '-' character. result := sub(result, 1) // Move back the string pointer by a byte. mstore(result, add(n, 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 result) { result = toHexStringNoPrefix(value, length); /// @solidity memory-safe-assembly assembly { let n := add(mload(result), 2) // Compute the length. mstore(result, 0x3078) // Store the "0x" prefix. result := sub(result, 2) // Move the pointer. mstore(result, n) // Store the length. } } /// @dev Returns the hexadecimal representation of `value`, /// left-padded to an input length of `length` bytes. /// The output is not prefixed with "0x" and is 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 result) { /// @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. result := add(mload(0x40), and(add(shl(1, length), 0x42), not(0x1f))) mstore(0x40, add(result, 0x20)) // Allocate memory. mstore(result, 0) // Zeroize the slot after the string. let end := result // Cache the end to calculate the length later. // Store "0123456789abcdef" in scratch space. mstore(0x0f, 0x30313233343536373839616263646566) let start := sub(result, 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 {} { result := add(result, w) // `sub(result, 2)`. mstore8(add(result, 1), mload(and(temp, 15))) mstore8(result, mload(and(shr(4, temp), 15))) temp := shr(8, temp) if iszero(xor(result, start)) { break } } if temp { mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`. revert(0x1c, 0x04) } let n := sub(end, result) result := sub(result, 0x20) mstore(result, n) // Store the length. } } /// @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 result) { result = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let n := add(mload(result), 2) // Compute the length. mstore(result, 0x3078) // Store the "0x" prefix. result := sub(result, 2) // Move the pointer. mstore(result, n) // Store 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 result) { result = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let o := eq(byte(0, mload(add(result, 0x20))), 0x30) // Whether leading zero is present. let n := add(mload(result), 2) // Compute the length. mstore(add(result, o), 0x3078) // Store the "0x" prefix, accounting for leading zero. result := sub(add(result, o), 2) // Move the pointer, accounting for leading zero. mstore(result, sub(n, o)) // Store 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 result) { result = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let o := eq(byte(0, mload(add(result, 0x20))), 0x30) // Whether leading zero is present. let n := mload(result) // Get the length. result := add(result, o) // Move the pointer, accounting for leading zero. mstore(result, sub(n, o)) // Store 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 result) { /// @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. result := add(mload(0x40), 0x80) mstore(0x40, add(result, 0x20)) // Allocate memory. mstore(result, 0) // Zeroize the slot after the string. let end := result // Cache the end to calculate the length later. mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup. 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 {} { result := add(result, w) // `sub(result, 2)`. mstore8(add(result, 1), mload(and(temp, 15))) mstore8(result, mload(and(shr(4, temp), 15))) temp := shr(8, temp) if iszero(temp) { break } } let n := sub(end, result) result := sub(result, 0x20) mstore(result, n) // Store the length. } } /// @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 result) { result = toHexString(value); /// @solidity memory-safe-assembly assembly { let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...` let o := add(result, 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 result) { result = toHexStringNoPrefix(value); /// @solidity memory-safe-assembly assembly { let n := add(mload(result), 2) // Compute the length. mstore(result, 0x3078) // Store the "0x" prefix. result := sub(result, 2) // Move the pointer. mstore(result, n) // Store 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 result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) // Allocate 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(result, 0x80)) mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup. result := add(result, 2) mstore(result, 40) // Store the length. let o := add(result, 0x20) mstore(add(o, 40), 0) // Zeroize the slot after the string. 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 result) { result = toHexStringNoPrefix(raw); /// @solidity memory-safe-assembly assembly { let n := add(mload(result), 2) // Compute the length. mstore(result, 0x3078) // Store the "0x" prefix. result := sub(result, 2) // Move the pointer. mstore(result, n) // Store 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 result) { /// @solidity memory-safe-assembly assembly { let n := mload(raw) result := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix. mstore(result, add(n, n)) // Store the length of the output. mstore(0x0f, 0x30313233343536373839616263646566) // Store the "0123456789abcdef" lookup. let o := add(result, 0x20) let end := add(raw, n) 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 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 { result := 1 let mask := shl(7, div(not(0), 255)) 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) } } } /// @dev Returns if this string is a 7-bit ASCII string, /// AND all characters are in the `allowed` lookup. /// Note: If `s` is empty, returns true regardless of `allowed`. function is7BitASCII(string memory s, uint128 allowed) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { result := 1 if mload(s) { let allowed_ := shr(128, shl(128, allowed)) let o := add(s, 0x20) for { let end := add(o, mload(s)) } 1 {} { result := and(result, shr(byte(0, mload(o)), allowed_)) o := add(o, 1) if iszero(and(result, lt(o, end))) { break } } } } } /// @dev Converts the bytes in the 7-bit ASCII string `s` to /// an allowed lookup for use in `is7BitASCII(s, allowed)`. /// To save runtime gas, you can cache the result in an immutable variable. function to7BitASCIIAllowedLookup(string memory s) internal pure returns (uint128 result) { /// @solidity memory-safe-assembly assembly { if mload(s) { let o := add(s, 0x20) for { let end := add(o, mload(s)) } 1 {} { result := or(result, shl(byte(0, mload(o)), 1)) o := add(o, 1) if iszero(lt(o, end)) { break } } if shr(128, result) { mstore(0x00, 0xc9807e0d) // `StringNot7BitASCII()`. revert(0x1c, 0x04) } } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* 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 `needle` replaced with `replacement`. function replace(string memory subject, string memory needle, string memory replacement) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) let needleLen := mload(needle) let replacementLen := mload(replacement) let d := sub(result, subject) // Memory difference. let i := add(subject, 0x20) // Subject bytes pointer. let end := add(i, mload(subject)) if iszero(gt(needleLen, mload(subject))) { let subjectSearchEnd := add(sub(end, needleLen), 1) let h := 0 // The hash of `needle`. if iszero(lt(needleLen, 0x20)) { h := keccak256(add(needle, 0x20), needleLen) } let s := mload(add(needle, 0x20)) for { let m := shl(3, sub(0x20, and(needleLen, 0x1f))) } 1 {} { let t := mload(i) // Whether the first `needleLen % 32` bytes of `subject` and `needle` matches. if iszero(shr(m, xor(t, s))) { if h { if iszero(eq(keccak256(i, needleLen), h)) { mstore(add(i, d), t) i := add(i, 1) if iszero(lt(i, subjectSearchEnd)) { break } continue } } // Copy the `replacement` one word at a time. for { let j := 0 } 1 {} { mstore(add(add(i, d), j), mload(add(add(replacement, 0x20), j))) j := add(j, 0x20) if iszero(lt(j, replacementLen)) { break } } d := sub(add(d, replacementLen), needleLen) if needleLen { i := add(i, needleLen) if iszero(lt(i, subjectSearchEnd)) { break } continue } } mstore(add(i, d), t) i := add(i, 1) if iszero(lt(i, subjectSearchEnd)) { break } } } let n := add(sub(d, add(result, 0x20)), end) // Copy the rest of the string one word at a time. for {} lt(i, end) { i := add(i, 0x20) } { mstore(add(i, d), mload(i)) } let o := add(i, d) mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate memory. mstore(result, n) // Store the length. } } /// @dev Returns the byte index of the first location of `needle` in `subject`, /// needleing from left to right, starting from `from`. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found. function indexOf(string memory subject, string memory needle, uint256 from) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { result := not(0) // Initialize to `NOT_FOUND`. for { let subjectLen := mload(subject) } 1 {} { if iszero(mload(needle)) { result := from if iszero(gt(from, subjectLen)) { break } result := subjectLen break } let needleLen := mload(needle) let subjectStart := add(subject, 0x20) subject := add(subjectStart, from) let end := add(sub(add(subjectStart, subjectLen), needleLen), 1) let m := shl(3, sub(0x20, and(needleLen, 0x1f))) let s := mload(add(needle, 0x20)) if iszero(and(lt(subject, end), lt(from, subjectLen))) { break } if iszero(lt(needleLen, 0x20)) { for { let h := keccak256(add(needle, 0x20), needleLen) } 1 {} { if iszero(shr(m, xor(mload(subject), s))) { if eq(keccak256(subject, needleLen), 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 `needle` in `subject`, /// needleing from left to right. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found. function indexOf(string memory subject, string memory needle) internal pure returns (uint256 result) { result = indexOf(subject, needle, 0); } /// @dev Returns the byte index of the first location of `needle` in `subject`, /// needleing from right to left, starting from `from`. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found. function lastIndexOf(string memory subject, string memory needle, uint256 from) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { for {} 1 {} { result := not(0) // Initialize to `NOT_FOUND`. let needleLen := mload(needle) if gt(needleLen, mload(subject)) { break } let w := result let fromMax := sub(mload(subject), needleLen) 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(needle, 0x20), needleLen) } 1 {} { if eq(keccak256(subject, needleLen), 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 `needle` in `subject`, /// needleing from right to left. /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `needle` is not found. function lastIndexOf(string memory subject, string memory needle) internal pure returns (uint256 result) { result = lastIndexOf(subject, needle, type(uint256).max); } /// @dev Returns true if `needle` is found in `subject`, false otherwise. function contains(string memory subject, string memory needle) internal pure returns (bool) { return indexOf(subject, needle) != NOT_FOUND; } /// @dev Returns whether `subject` starts with `needle`. function startsWith(string memory subject, string memory needle) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { let needleLen := mload(needle) // Just using keccak256 directly is actually cheaper. // forgefmt: disable-next-item result := and( iszero(gt(needleLen, mload(subject))), eq( keccak256(add(subject, 0x20), needleLen), keccak256(add(needle, 0x20), needleLen) ) ) } } /// @dev Returns whether `subject` ends with `needle`. function endsWith(string memory subject, string memory needle) internal pure returns (bool result) { /// @solidity memory-safe-assembly assembly { let needleLen := mload(needle) // Whether `needle` is not longer than `subject`. let inRange := iszero(gt(needleLen, mload(subject))) // Just using keccak256 directly is actually cheaper. // forgefmt: disable-next-item result := and( eq( keccak256( // `subject + 0x20 + max(subjectLen - needleLen, 0)`. add(add(subject, 0x20), mul(inRange, sub(mload(subject), needleLen))), needleLen ), keccak256(add(needle, 0x20), needleLen) ), inRange ) } } /// @dev Returns `subject` repeated `times`. function repeat(string memory subject, uint256 times) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { let subjectLen := mload(subject) if iszero(or(iszero(times), iszero(subjectLen))) { result := mload(0x40) subject := add(subject, 0x20) let o := add(result, 0x20) for {} 1 {} { // Copy the `subject` one word at a time. for { let j := 0 } 1 {} { mstore(add(o, j), mload(add(subject, j))) j := add(j, 0x20) if iszero(lt(j, subjectLen)) { break } } o := add(o, subjectLen) times := sub(times, 1) if iszero(times) { break } } mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate memory. mstore(result, sub(o, add(result, 0x20))) // Store the length. } } } /// @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 subjectLen := mload(subject) if iszero(gt(subjectLen, end)) { end := subjectLen } if iszero(gt(subjectLen, start)) { start := subjectLen } if lt(start, end) { result := mload(0x40) let n := sub(end, start) let i := add(subject, start) let w := not(0x1f) // Copy the `subject` one word at a time, backwards. for { let j := and(add(n, 0x1f), w) } 1 {} { mstore(add(result, j), mload(add(i, j))) j := add(j, w) // `sub(j, 0x20)`. if iszero(j) { break } } let o := add(add(result, 0x20), n) mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate memory. mstore(result, n) // Store the length. } } } /// @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, type(uint256).max); } /// @dev Returns all the indices of `needle` in `subject`. /// The indices are byte offsets. function indicesOf(string memory subject, string memory needle) internal pure returns (uint256[] memory result) { /// @solidity memory-safe-assembly assembly { let searchLen := mload(needle) if iszero(gt(searchLen, mload(subject))) { result := mload(0x40) let i := add(subject, 0x20) let o := add(result, 0x20) let subjectSearchEnd := add(sub(add(i, mload(subject)), searchLen), 1) let h := 0 // The hash of `needle`. if iszero(lt(searchLen, 0x20)) { h := keccak256(add(needle, 0x20), searchLen) } let s := mload(add(needle, 0x20)) for { let m := shl(3, sub(0x20, and(searchLen, 0x1f))) } 1 {} { let t := mload(i) // Whether the first `searchLen % 32` bytes of `subject` and `needle` matches. if iszero(shr(m, xor(t, s))) { if h { if iszero(eq(keccak256(i, searchLen), h)) { i := add(i, 1) if iszero(lt(i, subjectSearchEnd)) { break } continue } } mstore(o, sub(i, add(subject, 0x20))) // Append to `result`. o := add(o, 0x20) i := add(i, searchLen) // Advance `i` by `searchLen`. if searchLen { if iszero(lt(i, subjectSearchEnd)) { break } continue } } i := add(i, 1) if iszero(lt(i, subjectSearchEnd)) { break } } mstore(result, shr(5, sub(o, add(result, 0x20)))) // Store the length of `result`. // Allocate memory for result. // We allocate one more word, so this array can be recycled for {split}. mstore(0x40, add(o, 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)) for { let prevIndex := 0 } 1 {} { let index := mload(indexPtr) mstore(indexPtr, 0x60) if iszero(eq(index, prevIndex)) { let element := mload(0x40) let l := sub(index, prevIndex) mstore(element, l) // Store the length of the element. // Copy the `subject` one word at a time, backwards. for { let o := and(add(l, 0x1f), w) } 1 {} { mstore(add(element, o), mload(add(add(subject, prevIndex), o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } mstore(add(add(element, 0x20), l), 0) // Zeroize the slot after the string. // Allocate memory for the length and the bytes, rounded up to a multiple of 32. mstore(0x40, add(element, and(add(l, 0x3f), w))) mstore(indexPtr, element) // Store the `element` into the array. } 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 { result := mload(0x40) let w := not(0x1f) let aLen := mload(a) // Copy `a` one word at a time, backwards. for { let o := and(add(aLen, 0x20), w) } 1 {} { mstore(add(result, o), mload(add(a, o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } let bLen := mload(b) let output := add(result, aLen) // Copy `b` one word at a time, backwards. for { let o := and(add(bLen, 0x20), w) } 1 {} { mstore(add(output, o), mload(add(b, o))) o := add(o, w) // `sub(o, 0x20)`. if iszero(o) { break } } let totalLen := add(aLen, bLen) let last := add(add(result, 0x20), totalLen) mstore(last, 0) // Zeroize the slot after the string. mstore(result, totalLen) // Store the length. mstore(0x40, add(last, 0x20)) // Allocate memory. } } /// @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 n := mload(subject) if n { result := mload(0x40) let o := add(result, 0x20) let d := sub(subject, result) let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff) for { let end := add(o, n) } 1 {} { let b := byte(0, mload(add(d, o))) mstore8(o, xor(and(shr(b, flags), 0x20), b)) o := add(o, 1) if eq(o, end) { break } } mstore(result, n) // Store the length. mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate 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) // Store the length. let o := add(result, 0x20) mstore(o, s) // Store the bytes of the string. mstore(add(o, n), 0) // Zeroize the slot after the string. mstore(0x40, add(result, 0x40)) // Allocate memory. } } /// @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 { result := mload(0x40) let end := add(s, mload(s)) let o := add(result, 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(o, c) o := add(o, 1) continue } let t := shr(248, mload(c)) mstore(o, mload(and(t, 0x1f))) o := add(o, shr(5, t)) } mstore(o, 0) // Zeroize the slot after the string. mstore(result, sub(o, add(result, 0x20))) // Store the length. mstore(0x40, add(o, 0x20)) // Allocate 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 { result := mload(0x40) let o := add(result, 0x20) if addDoubleQuotes { mstore8(o, 34) o := add(1, o) } // 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 { let end := add(s, mload(s)) } 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(o, c) o := add(o, 1) continue } mstore8(o, 0x5c) // "\\". mstore8(add(o, 1), c) o := add(o, 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(o, mload(0x19)) // "\\u00XX". o := add(o, 6) continue } mstore8(o, 0x5c) // "\\". mstore8(add(o, 1), mload(add(c, 8))) o := add(o, 2) } if addDoubleQuotes { mstore8(o, 34) o := add(1, o) } mstore(o, 0) // Zeroize the slot after the string. mstore(result, sub(o, add(result, 0x20))) // Store the length. mstore(0x40, add(o, 0x20)) // Allocate 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 Encodes `s` so that it can be safely used in a URI, /// just like `encodeURIComponent` in JavaScript. /// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent /// See: https://datatracker.ietf.org/doc/html/rfc2396 /// See: https://datatracker.ietf.org/doc/html/rfc3986 function encodeURIComponent(string memory s) internal pure returns (string memory result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) // Store "0123456789ABCDEF" in scratch space. // Uppercased to be consistent with JavaScript's implementation. mstore(0x0f, 0x30313233343536373839414243444546) let o := add(result, 0x20) for { let end := add(s, mload(s)) } iszero(eq(s, end)) {} { s := add(s, 1) let c := and(mload(s), 0xff) // If not in `[0-9A-Z-a-z-.!~*'()]`. if iszero(and(1, shr(c, 0x47fffffe07fffffe03ff678200000000))) { mstore8(o, 0x25) // '%'. mstore8(add(o, 1), mload(and(shr(4, c), 15))) mstore8(add(o, 2), mload(and(c, 15))) o := add(o, 3) continue } mstore8(o, c) o := add(o, 1) } mstore(result, sub(o, add(result, 0x20))) // Store the length. mstore(o, 0) // Zeroize the slot after the string. mstore(0x40, add(o, 0x20)) // Allocate memory. } } /// @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 { result := mload(0x40) // Grab the free memory pointer. mstore(0x40, add(result, 0x40)) // Allocate 2 words (1 for the length, 1 for the bytes). mstore(result, 0) // Zeroize the length slot. mstore(add(result, 0x1f), packed) // Store the length and bytes. mstore(add(add(result, 0x20), mload(result)), 0) // Right pad with zeroes. } } /// @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 aLen := mload(a) // We don't need to zero right pad the strings, // since this is our own custom non-standard packing scheme. result := mul( or( // Load the length and the bytes of `a` and `b`. shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), mload(sub(add(b, 0x1e), aLen))), // `totalLen != 0 && totalLen < 31`. Abuses underflow. // Assumes that the lengths are valid and within the block gas limit. lt(sub(add(aLen, 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 { resultA := mload(0x40) // Grab the free memory pointer. 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 retUnpaddedSize := 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, retUnpaddedSize), 0) mstore(retStart, 0x20) // Store the return offset. // End the transaction, returning the string. return(retStart, and(not(0x1f), add(0x1f, retUnpaddedSize))) } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.7 <0.9.0; abstract contract ERC2981 { // ERC165 bytes to add to interface array - set in parent contract bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; uint256 internal constant _SCALING_FACTOR = 10**12; uint256 internal _royaltyBps; address internal _royaltyRecipient; constructor(address recipient, uint256 royaltyBps) { _setRoyalties(recipient, royaltyBps); } // Called with the sale price to determine how much royalty // is owed and to whom. function royaltyInfo(uint256, uint256 _salePrice) external view virtual returns (address, uint256) { if (_royaltyBps == 0) { return (address(0), 0); } uint256 royaltyAmount = (_salePrice * _royaltyBps) / 10000; return (_royaltyRecipient, royaltyAmount); } function _setRoyalties(address recipient, uint256 bps) internal { require(bps <= 10000, "ERC721: INVALID_BPS"); _royaltyRecipient = recipient; _royaltyBps = bps; emit RoyaltiesSet(recipient, bps); } event RoyaltiesSet(address receiver, uint256 bps); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import {Ownable} from "./Ownable.sol"; /** * @title PermissionedMintingNFT * @dev Base contract for NFT collections with permissioned minting functionality */ abstract contract PermissionedMintingNFT is Ownable { // Mapping of addresses allowed to mint mapping(address => bool) private _minters; // Global minting enabled flag bool public mintingEnabled = true; // Events event MintRightsGranted(address indexed minter); event MintRightsRevoked(address indexed minter); // Custom errors error NotMinter(); error MintClosed(); constructor() Ownable(msg.sender) {} // Modifiers modifier mintIsOpen() { if (!mintingEnabled) { revert MintClosed(); } _; } modifier onlyMinter() { if (!_minters[msg.sender] && owner() != msg.sender) { revert NotMinter(); } _; } // Minter management functions function setCanMint(address newMinter, bool canMint) external onlyOwner { _minters[newMinter] = canMint; emit MintRightsGranted(newMinter); } function renounceMintingRights() external { if (!_minters[msg.sender]) { revert NotMinter(); } _minters[msg.sender] = false; emit MintRightsRevoked(msg.sender); } function closeMinting() external onlyOwner { mintingEnabled = false; } // Internal helper function _isMinter(address account) internal view returns (bool) { return _minters[account] || account == owner(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /** * @title BridgedNFT * @dev Base contract for NFTs that are bridged from another chain */ abstract contract BridgedNFT { // The address of the original collection on the source chain address public immutable originalCollectionAddress; constructor(address originalAddress) { originalCollectionAddress = originalAddress; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Simple ERC1155 implementation. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC1155.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC1155/ERC1155.sol) /// /// @dev Note: /// - The ERC1155 standard allows for self-approvals. /// For performance, this implementation WILL NOT revert for such actions. /// Please add any checks with overrides if desired. /// - The transfer functions use the identity precompile (0x4) /// to copy memory internally. /// /// If you are overriding: /// - Make sure all variables written to storage are properly cleaned // (e.g. the bool value for `isApprovedForAll` MUST be either 1 or 0 under the hood). /// - Check that the overridden function is actually used in the function you want to /// change the behavior of. Much of the code has been manually inlined for performance. abstract contract ERC1155Base { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The lengths of the input arrays are not the same. error ArrayLengthsMismatch(); /// @dev Cannot mint or transfer to the zero address. error TransferToZeroAddress(); /// @dev The recipient's balance has overflowed. error AccountBalanceOverflow(); /// @dev Insufficient balance. error InsufficientBalance(); /// @dev Only the token owner or an approved account can manage the tokens. error NotOwnerNorApproved(); /// @dev Cannot safely transfer to a contract that does not implement /// the ERC1155Receiver interface. error TransferToNonERC1155ReceiverImplementer(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Emitted when `amount` of token `id` is transferred /// from `from` to `to` by `operator`. event TransferSingle( address indexed operator, address indexed from, address indexed to, uint256 id, uint256 amount ); /// @dev Emitted when `amounts` of token `ids` are transferred /// from `from` to `to` by `operator`. event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] amounts ); /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens. event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved); /// @dev Emitted when the Uniform Resource Identifier (URI) for token `id` /// is updated to `value`. This event is not used in the base contract. /// You may need to emit this event depending on your URI logic. /// /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata event URI(string value, uint256 indexed id); /// @dev `keccak256(bytes("TransferSingle(address,address,address,uint256,uint256)"))`. uint256 private constant _TRANSFER_SINGLE_EVENT_SIGNATURE = 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62; /// @dev `keccak256(bytes("TransferBatch(address,address,address,uint256[],uint256[])"))`. uint256 private constant _TRANSFER_BATCH_EVENT_SIGNATURE = 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb; /// @dev `keccak256(bytes("ApprovalForAll(address,address,bool)"))`. uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE = 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The `ownerSlotSeed` of a given owner is given by. /// ``` /// let ownerSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner)) /// ``` /// /// The balance slot of `owner` is given by. /// ``` /// mstore(0x20, ownerSlotSeed) /// mstore(0x00, id) /// let balanceSlot := keccak256(0x00, 0x40) /// ``` /// /// The operator approval slot of `owner` is given by. /// ``` /// mstore(0x20, ownerSlotSeed) /// mstore(0x00, operator) /// let operatorApprovalSlot := keccak256(0x0c, 0x34) /// ``` uint256 private constant _ERC1155_MASTER_SLOT_SEED = 0x9a31110384e0b0c9; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC1155 METADATA */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the URI for token `id`. /// /// You can either return the same templated URI for all token IDs, /// (e.g. "https://example.com/api/{id}.json"), /// or return a unique URI for each `id`. /// /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata function uri(uint256 id) public view virtual returns (string memory); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC1155 */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the amount of `id` owned by `owner`. function balanceOf(address owner, uint256 id) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { mstore(0x20, _ERC1155_MASTER_SLOT_SEED) mstore(0x14, owner) mstore(0x00, id) result := sload(keccak256(0x00, 0x40)) } } /// @dev Returns whether `operator` is approved to manage the tokens of `owner`. function isApprovedForAll(address owner, address operator) public view virtual returns (bool result) { /// @solidity memory-safe-assembly assembly { mstore(0x20, _ERC1155_MASTER_SLOT_SEED) mstore(0x14, owner) mstore(0x00, operator) result := sload(keccak256(0x0c, 0x34)) } } /// @dev Sets whether `operator` is approved to manage the tokens of the caller. /// /// Emits a {ApprovalForAll} event. function setApprovalForAll(address operator, bool isApproved) public virtual { /// @solidity memory-safe-assembly assembly { // Convert to 0 or 1. isApproved := iszero(iszero(isApproved)) // Update the `isApproved` for (`msg.sender`, `operator`). mstore(0x20, _ERC1155_MASTER_SLOT_SEED) mstore(0x14, caller()) mstore(0x00, operator) sstore(keccak256(0x0c, 0x34), isApproved) // Emit the {ApprovalForAll} event. mstore(0x00, isApproved) // forgefmt: disable-next-line log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator))) } } /// @dev Transfers `amount` of `id` from `from` to `to`. /// /// Requirements: /// - `to` cannot be the zero address. /// - `from` must have at least `amount` of `id`. /// - If the caller is not `from`, /// it must be approved to manage the tokens of `from`. /// - If `to` refers to a smart contract, it must implement /// {ERC1155-onERC1155Received}, which is called upon a batch transfer. /// /// Emits a {TransferSingle} event. function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) public virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(from, to, _single(id), _single(amount), data); } /// @solidity memory-safe-assembly assembly { let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from)) let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to)) mstore(0x20, fromSlotSeed) // Clear the upper 96 bits. from := shr(96, fromSlotSeed) to := shr(96, toSlotSeed) // Revert if `to` is the zero address. if iszero(to) { mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`. revert(0x1c, 0x04) } // If the caller is not `from`, do the authorization check. if iszero(eq(caller(), from)) { mstore(0x00, caller()) if iszero(sload(keccak256(0x0c, 0x34))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Subtract and store the updated balance of `from`. { mstore(0x00, id) let fromBalanceSlot := keccak256(0x00, 0x40) let fromBalance := sload(fromBalanceSlot) if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } sstore(fromBalanceSlot, sub(fromBalance, amount)) } // Increase and store the updated balance of `to`. { mstore(0x20, toSlotSeed) let toBalanceSlot := keccak256(0x00, 0x40) let toBalanceBefore := sload(toBalanceSlot) let toBalanceAfter := add(toBalanceBefore, amount) if lt(toBalanceAfter, toBalanceBefore) { mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`. revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceAfter) } // Emit a {TransferSingle} event. mstore(0x20, amount) log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), from, to) } if (_useAfterTokenTransfer()) { _afterTokenTransfer(from, to, _single(id), _single(amount), data); } /// @solidity memory-safe-assembly assembly { // Do the {onERC1155Received} check if `to` is a smart contract. if extcodesize(to) { // Prepare the calldata. let m := mload(0x40) // `onERC1155Received(address,address,uint256,uint256,bytes)`. mstore(m, 0xf23a6e61) mstore(add(m, 0x20), caller()) mstore(add(m, 0x40), from) mstore(add(m, 0x60), id) mstore(add(m, 0x80), amount) mstore(add(m, 0xa0), 0xa0) calldatacopy(add(m, 0xc0), sub(data.offset, 0x20), add(0x20, data.length)) // Revert if the call reverts. if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, data.length), m, 0x20)) { if returndatasize() { // Bubble up the revert if the call reverts. returndatacopy(m, 0x00, returndatasize()) revert(m, returndatasize()) } } // Load the returndata and compare it with the function selector. if iszero(eq(mload(m), shl(224, 0xf23a6e61))) { mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`. revert(0x1c, 0x04) } } } } /// @dev Transfers `amounts` of `ids` from `from` to `to`. /// /// Requirements: /// - `to` cannot be the zero address. /// - `from` must have at least `amount` of `id`. /// - `ids` and `amounts` must have the same length. /// - If the caller is not `from`, /// it must be approved to manage the tokens of `from`. /// - If `to` refers to a smart contract, it must implement /// {ERC1155-onERC1155BatchReceived}, which is called upon a batch transfer. /// /// Emits a {TransferBatch} event. function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) public virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(from, to, ids, amounts, data); } /// @solidity memory-safe-assembly assembly { if iszero(eq(ids.length, amounts.length)) { mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`. revert(0x1c, 0x04) } let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from)) let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to)) mstore(0x20, fromSlotSeed) // Clear the upper 96 bits. from := shr(96, fromSlotSeed) to := shr(96, toSlotSeed) // Revert if `to` is the zero address. if iszero(to) { mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`. revert(0x1c, 0x04) } // If the caller is not `from`, do the authorization check. if iszero(eq(caller(), from)) { mstore(0x00, caller()) if iszero(sload(keccak256(0x0c, 0x34))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Loop through all the `ids` and update the balances. { for { let i := shl(5, ids.length) } i {} { i := sub(i, 0x20) let amount := calldataload(add(amounts.offset, i)) // Subtract and store the updated balance of `from`. { mstore(0x20, fromSlotSeed) mstore(0x00, calldataload(add(ids.offset, i))) let fromBalanceSlot := keccak256(0x00, 0x40) let fromBalance := sload(fromBalanceSlot) if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } sstore(fromBalanceSlot, sub(fromBalance, amount)) } // Increase and store the updated balance of `to`. { mstore(0x20, toSlotSeed) let toBalanceSlot := keccak256(0x00, 0x40) let toBalanceBefore := sload(toBalanceSlot) let toBalanceAfter := add(toBalanceBefore, amount) if lt(toBalanceAfter, toBalanceBefore) { mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`. revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceAfter) } } } // Emit a {TransferBatch} event. { let m := mload(0x40) // Copy the `ids`. mstore(m, 0x40) let n := add(0x20, shl(5, ids.length)) let o := add(m, 0x40) calldatacopy(o, sub(ids.offset, 0x20), n) // Copy the `amounts`. mstore(add(m, 0x20), add(0x40, n)) calldatacopy(add(o, n), sub(amounts.offset, 0x20), n) // Do the emit. log4(m, add(add(n, n), 0x40), _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), from, to) } } if (_useAfterTokenTransfer()) { _afterTokenTransferCalldata(from, to, ids, amounts, data); } /// @solidity memory-safe-assembly assembly { // Do the {onERC1155BatchReceived} check if `to` is a smart contract. if extcodesize(to) { mstore(0x00, to) // Cache `to` to prevent stack too deep. let m := mload(0x40) // Prepare the calldata. // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`. mstore(m, 0xbc197c81) mstore(add(m, 0x20), caller()) mstore(add(m, 0x40), from) // Copy the `ids`. mstore(add(m, 0x60), 0xa0) let n := add(0x20, shl(5, ids.length)) let o := add(m, 0xc0) calldatacopy(o, sub(ids.offset, 0x20), n) // Copy the `amounts`. let s := add(0xa0, n) mstore(add(m, 0x80), s) calldatacopy(add(o, n), sub(amounts.offset, 0x20), n) // Copy the `data`. mstore(add(m, 0xa0), add(s, n)) calldatacopy(add(o, add(n, n)), sub(data.offset, 0x20), add(0x20, data.length)) let nAll := add(0xc4, add(data.length, add(n, n))) // Revert if the call reverts. if iszero(call(gas(), mload(0x00), 0, add(m, 0x1c), nAll, m, 0x20)) { if returndatasize() { // Bubble up the revert if the call reverts. returndatacopy(m, 0x00, returndatasize()) revert(m, returndatasize()) } } // Load the returndata and compare it with the function selector. if iszero(eq(mload(m), shl(224, 0xbc197c81))) { mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`. revert(0x1c, 0x04) } } } } /// @dev Returns the amounts of `ids` for `owners. /// /// Requirements: /// - `owners` and `ids` must have the same length. function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) public view virtual returns (uint256[] memory balances) { /// @solidity memory-safe-assembly assembly { if iszero(eq(ids.length, owners.length)) { mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`. revert(0x1c, 0x04) } balances := mload(0x40) mstore(balances, ids.length) let o := add(balances, 0x20) let i := shl(5, ids.length) mstore(0x40, add(i, o)) // Loop through all the `ids` and load the balances. for {} i {} { i := sub(i, 0x20) let owner := calldataload(add(owners.offset, i)) mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner))) mstore(0x00, calldataload(add(ids.offset, i))) mstore(add(o, i), sload(keccak256(0x00, 0x40))) } } } /// @dev Returns true if this contract implements the interface defined by `interfaceId`. /// See: https://eips.ethereum.org/EIPS/eip-165 /// This function call must use less than 30000 gas. function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) { /// @solidity memory-safe-assembly assembly { let s := shr(224, interfaceId) // ERC165: 0x01ffc9a7, ERC1155: 0xd9b67a26, ERC1155MetadataURI: 0x0e89341c. result := or(or(eq(s, 0x01ffc9a7), eq(s, 0xd9b67a26)), eq(s, 0x0e89341c)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL MINT FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Mints `amount` of `id` to `to`. /// /// Requirements: /// - `to` cannot be the zero address. /// - If `to` refers to a smart contract, it must implement /// {ERC1155-onERC1155Received}, which is called upon a batch transfer. /// /// Emits a {TransferSingle} event. function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(address(0), to, _single(id), _single(amount), data); } /// @solidity memory-safe-assembly assembly { let to_ := shl(96, to) // Revert if `to` is the zero address. if iszero(to_) { mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`. revert(0x1c, 0x04) } // Increase and store the updated balance of `to`. { mstore(0x20, _ERC1155_MASTER_SLOT_SEED) mstore(0x14, to) mstore(0x00, id) let toBalanceSlot := keccak256(0x00, 0x40) let toBalanceBefore := sload(toBalanceSlot) let toBalanceAfter := add(toBalanceBefore, amount) if lt(toBalanceAfter, toBalanceBefore) { mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`. revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceAfter) } // Emit a {TransferSingle} event. mstore(0x20, amount) log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), 0, shr(96, to_)) } if (_useAfterTokenTransfer()) { _afterTokenTransfer(address(0), to, _single(id), _single(amount), data); } if (_hasCode(to)) _checkOnERC1155Received(address(0), to, id, amount, data); } /// @dev Mints `amounts` of `ids` to `to`. /// /// Requirements: /// - `to` cannot be the zero address. /// - `ids` and `amounts` must have the same length. /// - If `to` refers to a smart contract, it must implement /// {ERC1155-onERC1155BatchReceived}, which is called upon a batch transfer. /// /// Emits a {TransferBatch} event. function _batchMint( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(address(0), to, ids, amounts, data); } /// @solidity memory-safe-assembly assembly { if iszero(eq(mload(ids), mload(amounts))) { mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`. revert(0x1c, 0x04) } let to_ := shl(96, to) // Revert if `to` is the zero address. if iszero(to_) { mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`. revert(0x1c, 0x04) } // Loop through all the `ids` and update the balances. { mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_)) for { let i := shl(5, mload(ids)) } i { i := sub(i, 0x20) } { let amount := mload(add(amounts, i)) // Increase and store the updated balance of `to`. { mstore(0x00, mload(add(ids, i))) let toBalanceSlot := keccak256(0x00, 0x40) let toBalanceBefore := sload(toBalanceSlot) let toBalanceAfter := add(toBalanceBefore, amount) if lt(toBalanceAfter, toBalanceBefore) { mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`. revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceAfter) } } } // Emit a {TransferBatch} event. { let m := mload(0x40) // Copy the `ids`. mstore(m, 0x40) let n := add(0x20, shl(5, mload(ids))) let o := add(m, 0x40) pop(staticcall(gas(), 4, ids, n, o, n)) // Copy the `amounts`. mstore(add(m, 0x20), add(0x40, returndatasize())) o := add(o, returndatasize()) n := add(0x20, shl(5, mload(amounts))) pop(staticcall(gas(), 4, amounts, n, o, n)) n := sub(add(o, returndatasize()), m) // Do the emit. log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), 0, shr(96, to_)) } } if (_useAfterTokenTransfer()) { _afterTokenTransfer(address(0), to, ids, amounts, data); } if (_hasCode(to)) _checkOnERC1155BatchReceived(address(0), to, ids, amounts, data); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL BURN FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Equivalent to `_burn(address(0), from, id, amount)`. function _burn(address from, uint256 id, uint256 amount) internal virtual { _burn(address(0), from, id, amount); } /// @dev Destroys `amount` of `id` from `from`. /// /// Requirements: /// - `from` must have at least `amount` of `id`. /// - If `by` is not the zero address, it must be either `from`, /// or approved to manage the tokens of `from`. /// /// Emits a {TransferSingle} event. function _burn(address by, address from, uint256 id, uint256 amount) internal virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(from, address(0), _single(id), _single(amount), ""); } /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_)) // If `by` is not the zero address, and not equal to `from`, // check if it is approved to manage all the tokens of `from`. if iszero(or(iszero(shl(96, by)), eq(shl(96, by), from_))) { mstore(0x00, by) if iszero(sload(keccak256(0x0c, 0x34))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Decrease and store the updated balance of `from`. { mstore(0x00, id) let fromBalanceSlot := keccak256(0x00, 0x40) let fromBalance := sload(fromBalanceSlot) if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } sstore(fromBalanceSlot, sub(fromBalance, amount)) } // Emit a {TransferSingle} event. mstore(0x20, amount) log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), 0) } if (_useAfterTokenTransfer()) { _afterTokenTransfer(from, address(0), _single(id), _single(amount), ""); } } /// @dev Equivalent to `_batchBurn(address(0), from, ids, amounts)`. function _batchBurn(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual { _batchBurn(address(0), from, ids, amounts); } /// @dev Destroys `amounts` of `ids` from `from`. /// /// Requirements: /// - `ids` and `amounts` must have the same length. /// - `from` must have at least `amounts` of `ids`. /// - If `by` is not the zero address, it must be either `from`, /// or approved to manage the tokens of `from`. /// /// Emits a {TransferBatch} event. function _batchBurn(address by, address from, uint256[] memory ids, uint256[] memory amounts) internal virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(from, address(0), ids, amounts, ""); } /// @solidity memory-safe-assembly assembly { if iszero(eq(mload(ids), mload(amounts))) { mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`. revert(0x1c, 0x04) } let from_ := shl(96, from) mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_)) // If `by` is not the zero address, and not equal to `from`, // check if it is approved to manage all the tokens of `from`. let by_ := shl(96, by) if iszero(or(iszero(by_), eq(by_, from_))) { mstore(0x00, by) if iszero(sload(keccak256(0x0c, 0x34))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Loop through all the `ids` and update the balances. { for { let i := shl(5, mload(ids)) } i { i := sub(i, 0x20) } { let amount := mload(add(amounts, i)) // Decrease and store the updated balance of `from`. { mstore(0x00, mload(add(ids, i))) let fromBalanceSlot := keccak256(0x00, 0x40) let fromBalance := sload(fromBalanceSlot) if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } sstore(fromBalanceSlot, sub(fromBalance, amount)) } } } // Emit a {TransferBatch} event. { let m := mload(0x40) // Copy the `ids`. mstore(m, 0x40) let n := add(0x20, shl(5, mload(ids))) let o := add(m, 0x40) pop(staticcall(gas(), 4, ids, n, o, n)) // Copy the `amounts`. mstore(add(m, 0x20), add(0x40, returndatasize())) o := add(o, returndatasize()) n := add(0x20, shl(5, mload(amounts))) pop(staticcall(gas(), 4, amounts, n, o, n)) n := sub(add(o, returndatasize()), m) // Do the emit. log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), 0) } } if (_useAfterTokenTransfer()) { _afterTokenTransfer(from, address(0), ids, amounts, ""); } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL APPROVAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Approve or remove the `operator` as an operator for `by`, /// without authorization checks. /// /// Emits a {ApprovalForAll} event. function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual { /// @solidity memory-safe-assembly assembly { // Convert to 0 or 1. isApproved := iszero(iszero(isApproved)) // Update the `isApproved` for (`by`, `operator`). mstore(0x20, _ERC1155_MASTER_SLOT_SEED) mstore(0x14, by) mstore(0x00, operator) sstore(keccak256(0x0c, 0x34), isApproved) // Emit the {ApprovalForAll} event. mstore(0x00, isApproved) let m := shr(96, not(0)) log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, and(m, by), and(m, operator)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL TRANSFER FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Equivalent to `_safeTransfer(address(0), from, to, id, amount, data)`. function _safeTransfer(address from, address to, uint256 id, uint256 amount, bytes memory data) internal virtual { _safeTransfer(address(0), from, to, id, amount, data); } /// @dev Transfers `amount` of `id` from `from` to `to`. /// /// Requirements: /// - `to` cannot be the zero address. /// - `from` must have at least `amount` of `id`. /// - If `by` is not the zero address, it must be either `from`, /// or approved to manage the tokens of `from`. /// - If `to` refers to a smart contract, it must implement /// {ERC1155-onERC1155Received}, which is called upon a batch transfer. /// /// Emits a {TransferSingle} event. function _safeTransfer( address by, address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(from, to, _single(id), _single(amount), data); } /// @solidity memory-safe-assembly assembly { let from_ := shl(96, from) let to_ := shl(96, to) // Revert if `to` is the zero address. if iszero(to_) { mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`. revert(0x1c, 0x04) } mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_)) // If `by` is not the zero address, and not equal to `from`, // check if it is approved to manage all the tokens of `from`. let by_ := shl(96, by) if iszero(or(iszero(by_), eq(by_, from_))) { mstore(0x00, by) if iszero(sload(keccak256(0x0c, 0x34))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Subtract and store the updated balance of `from`. { mstore(0x00, id) let fromBalanceSlot := keccak256(0x00, 0x40) let fromBalance := sload(fromBalanceSlot) if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } sstore(fromBalanceSlot, sub(fromBalance, amount)) } // Increase and store the updated balance of `to`. { mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_)) let toBalanceSlot := keccak256(0x00, 0x40) let toBalanceBefore := sload(toBalanceSlot) let toBalanceAfter := add(toBalanceBefore, amount) if lt(toBalanceAfter, toBalanceBefore) { mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`. revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceAfter) } // Emit a {TransferSingle} event. mstore(0x20, amount) // forgefmt: disable-next-line log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_)) } if (_useAfterTokenTransfer()) { _afterTokenTransfer(from, to, _single(id), _single(amount), data); } if (_hasCode(to)) _checkOnERC1155Received(from, to, id, amount, data); } /// @dev Equivalent to `_safeBatchTransfer(address(0), from, to, ids, amounts, data)`. function _safeBatchTransfer( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { _safeBatchTransfer(address(0), from, to, ids, amounts, data); } /// @dev Transfers `amounts` of `ids` from `from` to `to`. /// /// Requirements: /// - `to` cannot be the zero address. /// - `ids` and `amounts` must have the same length. /// - `from` must have at least `amounts` of `ids`. /// - If `by` is not the zero address, it must be either `from`, /// or approved to manage the tokens of `from`. /// - If `to` refers to a smart contract, it must implement /// {ERC1155-onERC1155BatchReceived}, which is called upon a batch transfer. /// /// Emits a {TransferBatch} event. function _safeBatchTransfer( address by, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { if (_useBeforeTokenTransfer()) { _beforeTokenTransfer(from, to, ids, amounts, data); } /// @solidity memory-safe-assembly assembly { if iszero(eq(mload(ids), mload(amounts))) { mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`. revert(0x1c, 0x04) } let from_ := shl(96, from) let to_ := shl(96, to) // Revert if `to` is the zero address. if iszero(to_) { mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`. revert(0x1c, 0x04) } let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, from_) let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, to_) mstore(0x20, fromSlotSeed) // If `by` is not the zero address, and not equal to `from`, // check if it is approved to manage all the tokens of `from`. let by_ := shl(96, by) if iszero(or(iszero(by_), eq(by_, from_))) { mstore(0x00, by) if iszero(sload(keccak256(0x0c, 0x34))) { mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`. revert(0x1c, 0x04) } } // Loop through all the `ids` and update the balances. { for { let i := shl(5, mload(ids)) } i { i := sub(i, 0x20) } { let amount := mload(add(amounts, i)) // Subtract and store the updated balance of `from`. { mstore(0x20, fromSlotSeed) mstore(0x00, mload(add(ids, i))) let fromBalanceSlot := keccak256(0x00, 0x40) let fromBalance := sload(fromBalanceSlot) if gt(amount, fromBalance) { mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`. revert(0x1c, 0x04) } sstore(fromBalanceSlot, sub(fromBalance, amount)) } // Increase and store the updated balance of `to`. { mstore(0x20, toSlotSeed) let toBalanceSlot := keccak256(0x00, 0x40) let toBalanceBefore := sload(toBalanceSlot) let toBalanceAfter := add(toBalanceBefore, amount) if lt(toBalanceAfter, toBalanceBefore) { mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`. revert(0x1c, 0x04) } sstore(toBalanceSlot, toBalanceAfter) } } } // Emit a {TransferBatch} event. { let m := mload(0x40) // Copy the `ids`. mstore(m, 0x40) let n := add(0x20, shl(5, mload(ids))) let o := add(m, 0x40) pop(staticcall(gas(), 4, ids, n, o, n)) // Copy the `amounts`. mstore(add(m, 0x20), add(0x40, returndatasize())) o := add(o, returndatasize()) n := add(0x20, shl(5, mload(amounts))) pop(staticcall(gas(), 4, amounts, n, o, n)) n := sub(add(o, returndatasize()), m) // Do the emit. log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_)) } } if (_useAfterTokenTransfer()) { _afterTokenTransfer(from, to, ids, amounts, data); } if (_hasCode(to)) _checkOnERC1155BatchReceived(from, to, ids, amounts, data); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HOOKS FOR OVERRIDING */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Override this function to return true if `_beforeTokenTransfer` is used. /// This is to help the compiler avoid producing dead bytecode. function _useBeforeTokenTransfer() internal view virtual returns (bool) { return false; } /// @dev Hook that is called before any token transfer. /// This includes minting and burning, as well as batched variants. /// /// The same hook is called on both single and batched variants. /// For single transfers, the length of the `id` and `amount` arrays are 1. function _beforeTokenTransfer( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /// @dev Override this function to return true if `_afterTokenTransfer` is used. /// This is to help the compiler avoid producing dead bytecode. function _useAfterTokenTransfer() internal view virtual returns (bool) { return false; } /// @dev Hook that is called after any token transfer. /// This includes minting and burning, as well as batched variants. /// /// The same hook is called on both single and batched variants. /// For single transfers, the length of the `id` and `amount` arrays are 1. function _afterTokenTransfer( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PRIVATE HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Helper for calling the `_afterTokenTransfer` hook. /// This is to help the compiler avoid producing dead bytecode. function _afterTokenTransferCalldata( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) private { if (_useAfterTokenTransfer()) { _afterTokenTransfer(from, to, ids, amounts, data); } } /// @dev Returns if `a` has bytecode of non-zero length. function _hasCode(address a) private view returns (bool result) { /// @solidity memory-safe-assembly assembly { result := extcodesize(a) // Can handle dirty upper bits. } } /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155Received} on `to`. /// Reverts if the target does not support the function correctly. function _checkOnERC1155Received( address from, address to, uint256 id, uint256 amount, bytes memory data ) private { /// @solidity memory-safe-assembly assembly { // Prepare the calldata. let m := mload(0x40) // `onERC1155Received(address,address,uint256,uint256,bytes)`. mstore(m, 0xf23a6e61) mstore(add(m, 0x20), caller()) mstore(add(m, 0x40), shr(96, shl(96, from))) mstore(add(m, 0x60), id) mstore(add(m, 0x80), amount) mstore(add(m, 0xa0), 0xa0) let n := mload(data) mstore(add(m, 0xc0), n) if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xe0), n)) } // Revert if the call reverts. if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, n), m, 0x20)) { if returndatasize() { // Bubble up the revert if the call reverts. returndatacopy(m, 0x00, returndatasize()) revert(m, returndatasize()) } } // Load the returndata and compare it with the function selector. if iszero(eq(mload(m), shl(224, 0xf23a6e61))) { mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`. revert(0x1c, 0x04) } } } /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155BatchReceived} on `to`. /// Reverts if the target does not support the function correctly. function _checkOnERC1155BatchReceived( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { /// @solidity memory-safe-assembly assembly { // Prepare the calldata. let m := mload(0x40) // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`. mstore(m, 0xbc197c81) mstore(add(m, 0x20), caller()) mstore(add(m, 0x40), shr(96, shl(96, from))) // Copy the `ids`. mstore(add(m, 0x60), 0xa0) let n := add(0x20, shl(5, mload(ids))) let o := add(m, 0xc0) pop(staticcall(gas(), 4, ids, n, o, n)) // Copy the `amounts`. let s := add(0xa0, returndatasize()) mstore(add(m, 0x80), s) o := add(o, returndatasize()) n := add(0x20, shl(5, mload(amounts))) pop(staticcall(gas(), 4, amounts, n, o, n)) // Copy the `data`. mstore(add(m, 0xa0), add(s, returndatasize())) o := add(o, returndatasize()) n := add(0x20, mload(data)) pop(staticcall(gas(), 4, data, n, o, n)) n := sub(add(o, returndatasize()), add(m, 0x1c)) // Revert if the call reverts. if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) { if returndatasize() { // Bubble up the revert if the call reverts. returndatacopy(m, 0x00, returndatasize()) revert(m, returndatasize()) } } // Load the returndata and compare it with the function selector. if iszero(eq(mload(m), shl(224, 0xbc197c81))) { mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`. revert(0x1c, 0x04) } } } /// @dev Returns `x` in an array with a single element. function _single(uint256 x) private pure returns (uint256[] memory result) { /// @solidity memory-safe-assembly assembly { result := mload(0x40) mstore(0x40, add(result, 0x40)) mstore(result, 1) mstore(add(result, 0x20), x) } } }
{ "remappings": [ "forge-std/=lib/forge-std/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"originalAddress","type":"address"},{"internalType":"address","name":"royaltyRecipient","type":"address"},{"internalType":"uint256","name":"royaltyBps","type":"uint256"}],"name":"deployERC1155","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"originalAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"string","name":"extension","type":"string"},{"internalType":"address","name":"royaltyRecipient","type":"address"},{"internalType":"uint256","name":"royaltyBps","type":"uint256"}],"name":"deployERC721","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"originalAddress","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"string","name":"extension","type":"string"},{"internalType":"address","name":"royaltyRecipient","type":"address"},{"internalType":"uint256","name":"royaltyBps","type":"uint256"}],"name":"deployERC721Enumerable","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60808060405234601557615d97908161001b8239f35b600080fdfe608060408181526004908136101561001657600080fd5b600092833560e01c908163840013101461016257508063b8ecdc1d146101185763d25bb7fe1461004557600080fd5b3461011457610053366102be565b94879491949392935196611f5a8089019089821067ffffffffffffffff831117610101579161008e979593918a99979593611a5e8b3961039c565b039084f080156100f7576001600160a01b031691823b156100f35781519063f2fde38b60e01b82523390820152838160248183875af180156100e957602094506100da575b5051908152f35b6100e39061022c565b386100d3565b82513d86823e3d90fd5b8380fd5b81513d85823e3d90fd5b634e487b7160e01b8d5260418c5260248dfd5b8280fd5b503461011457610127366102be565b948794919493929351966123aa8089019089821067ffffffffffffffff831117610101579161008e979593918a999795936139b88b3961039c565b9050346100f35760603660031901126100f3576001600160a01b03908335828116908190036102285760243583811680910361022457611657918284019284841067ffffffffffffffff85111761021157916060939185936104078539825260208201526044358682015203019085f080156100e9571691823b156100f35781519063f2fde38b60e01b82523390820152838160248183875af180156100e957602094506100da575051908152f35b634e487b7160e01b895260418852602489fd5b8680fd5b8580fd5b67ffffffffffffffff811161024057604052565b634e487b7160e01b600052604160045260246000fd5b81601f820112156102b95780359067ffffffffffffffff928383116102405760405193601f8401601f19908116603f011685019081118582101761024057604052828452602083830101116102b957816000926020809301838601378301015290565b600080fd5b9060e06003198301126102b9576001600160a01b0360043581811681036102b9579267ffffffffffffffff916024358381116102b9578261030191600401610256565b936044358481116102b9578361031991600401610256565b936064358181116102b9578461033191600401610256565b936084359182116102b95761034891600401610256565b9160a43590811681036102b9579060c43590565b919082519283825260005b848110610388575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610367565b936103ed906103df60c09793956103d16103fb969c9b9a9c60018060a01b038099168a5260e060208b015260e08a019061035c565b9088820360408a015261035c565b90868203606088015261035c565b90848203608086015261035c565b951660a0820152015256fe60a03461016e57601f61165738819003918201601f1916830191906001600160401b0383118484101761017357816060928592604095865283398101031261016e5761004a82610189565b908061005860208501610189565b93015190612710821161012b577f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb68160018060a01b0380961660018060a01b031994818660015416176001558060005582519182526020820152a133156101145760025491339083161760025551923391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3600160ff1960045416176004556080526114b9908161019e823960805181610a310152f35b51631e4fbdf760e01b815260006004820152602490fd5b5162461bcd60e51b815260206004820152601360248201527f4552433732313a20494e56414c49445f425053000000000000000000000000006044820152606490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361016e5756fe608080604052600436101561001357600080fd5b60003560e01c908162fdd58e146110ba5750806301ffc9a71461106d578063058260d7146110095780630e89341c14610f9a5780632a55205a14610f615780632eb2c2d614610d155780634e1273f414610c2a578063715018a614610bcd578063731133e914610a6057806383a1310014610a1b57806383a9c14c1461075857806387491c60146107335780638c7ea24b146106735780638da5cb5b1461064a5780639fd6db1214610627578063a22cb465146105c8578063dc6c34d514610562578063e026f63414610374578063e985e9c51461032e578063f242432a146101985763f2fde38b1461010557600080fd5b346101935760203660031901126101935761011e6110f4565b610126611457565b6001600160a01b0390811690811561017a57600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b600080fd5b346101935760a0366003190112610193576101b16110f4565b6101b961110a565b60443591606435906084356001600160401b038111610193576101e090369060040161117f565b9091679a31110384e0b0c99060601b81179460601b179160209480865260601c938360601c93841561032057853303610304575b87600052604060002080548084116102f6578390039055865260406000208054908282019182106102e857558086528385337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6260406000a4833b61027457005b60405196879563f23a6e618752338888015260408701526060860152608085015260a08085015281850190601f190160c085013760c401906000601c8401915af1156102d9575b51630dc5919f60e01b016102cb57005b639c05499b6000526004601cfd5b3d156102bb573d6000823e3d90fd5b6301336cea6000526004601cfd5b63f4d678b86000526004601cfd5b336000526034600c205461021457634b6e7f186000526004601cfd5b63ea553b346000526004601cfd5b34610193576040366003190112610193576103476110f4565b61034f61110a565b90679a31110384e0b0c960205260145260005260206034600c20546040519015158152f35b34610193576040366003190112610193576024356001600160401b038111610193576103a490369060040161114f565b33600052600360205260ff60406000205416158061054d575b61053b57906000915b8083106103cf57005b6005926103e081851b840184611425565b8260049692963501806004351161052557600052816020526040600020916001600160401b03821161050f576104168354611213565b90601f82116104cc575b50506000601f8211600114610465578190600195969760009261045a575b5050600019600383901b1c191690841b1790555b0191906103c6565b01359050878061043e565b601f198216968360005260206000209160005b8981106104b457508360019798991061049a575b505050831b83019055610452565b0135600019600384901b60f8161c1916905586808061048c565b90926020600181928686013581550194019101610478565b83600052602060002090601f8401811c820160208510610508575b601f8401821c830181106104fc575050610420565b600081556001016104e7565b50816104e7565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b03163314156103bd565b346101935760003660031901126101935733600052600360205260ff604060002054161561053b57336000526003602052604060002060ff198154169055337fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e600080a2005b34610193576105d636611120565b1515679a31110384e0b0c96020523360145281600052806034600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b3461019357600036600319011261019357602060ff600454166040519015158152f35b34610193576000366003190112610193576002546040516001600160a01b039091168152602090f35b346101935760403660031901126101935761068c6110f4565b602435610697611457565b61271081116106f857600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b60405162461bcd60e51b81526020600482015260136024820152724552433732313a20494e56414c49445f42505360681b6044820152606490fd5b346101935760003660031901126101935761074c611457565b6004805460ff19169055005b3461019357602080600319360112610193576004356001600160401b0381116101935761078990369060040161114f565b60ff6004541615610a0957336000526003835260ff6040600020541615806109f4575b61053b5760005b8181106107bc57005b6107c78183856113b8565b356001600160a01b03811690818103610193576107f16107e88486886113b8565b878101906113f0565b909161084c61080e61080487898b6113b8565b60408101906113f0565b91909361084461081f898b8d6113b8565b9561083c61083260609889810190611425565b9990943691611362565b943691611362565b9536916111cd565b9484518251036109e65782841b801561032057679a31110384e0b0c9178a5281518a94939291600591821b805b6109b157506000604051604081528451841b880160408201818760045afa503d604001888201527f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb3d8201918a51861b8a0160408401818d60045afa5060408133943d01030190a4823b6108f7575b505050505050506001016107b3565b60405195869463bc197c81865233878701526000604087015260a0918280928801528451841b880160c09581878a019160045afa503d9081830160808901523d8801948151901b890190818787019160045afa503d0101908501523d019580518501809288019160045afa5060a482601c963d010301906000868401915af1156109a2575b516343e6837f60e01b01610995578085818080806108e8565b600490639c05499b600052fd5b3d1561097c573d6000823e3d90fd5b809192939495965087015181850151600052604060002080549182019182106102e857558b959493929190601f190180610879565b633b800a466000526004601cfd5b506002546001600160a01b03163314156107ac565b60405163589ed34b60e01b8152600490fd5b34610193576000366003190112610193576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461019357608036600319011261019357610a796110f4565b604435906024356064356001600160401b038111610193573660238201121561019357610ab09036906024816004013591016111cd565b9160ff6004541615610a0957336000526020926003845260ff604060002054161580610bb8575b61053b578160601b1561032057679a31110384e0b0c98452816014528260005260406000208054908682019182106102e857558484526001600160a01b0382166000337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62604083a4813b610b4757005b60405194859363f23a6e6185523386860152600060408601526060850152608084015260a08084015280518091818060c0870152610ba4575b505060c401906000601c8401915af1156102d95751630dc5919f60e01b016102cb57005b818660e08701920160045afa508086610b80565b506002546001600160a01b0316331415610ad7565b3461019357600036600319011261019357610be6611457565b600280546001600160a01b031981169091556000906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b34610193576040366003190112610193576001600160401b0360043581811161019357610c5b90369060040161114f565b909160243590811161019357610c7590369060040161114f565b92909183036109e6576040519280845260051b6020928184868201016040525b610cde575050506040519181839283018184528251809152816040850193019160005b828110610cc757505050500390f35b835185528695509381019392810192600101610cb8565b818290601f1980940193828186948801013560601b679a31110384e0b0c91788528401013560005260406000205490870152610c95565b346101935760a036600319011261019357610d2e6110f4565b610d3661110a565b6001600160401b039060443582811161019357610d5790369060040161114f565b60649391933582811161019357610d7290369060040161114f565b909260843590811161019357610d8c90369060040161117f565b9183036109e657679a31110384e0b0c9928760601b84176020528560601b841760601c15610320578760601b841760601c3303610f45575b60051b9586805b610ee7575060405193604085528760200190601f198080940197838960408a013760608b0160208901520190828260608c8a010137898001968960601b821760601c908c60601b831760601c907f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb339160808c0190a48860601b811760601c3b610e5157005b602099836101049960e09363bc197c819c60601b811760601c6000526040519e8f9d8e528d8f3391015260601b1760601c60408d015260a060608d015260c08c013760c0810160808b01528901013760e0840160a0870152828701910161010084870101370101601c8201600080515af115610ed8575b516343e6837f60e01b016102cb57005b3d15610ec8573d6000823e3d90fd5b80601f19809101918a60601b8717602052818185010135600052604060002080548084848c010135116102f65783838b010135900390558860601b87176020526040600020918254918901013581019081106102e857829155610dcb565b336000526034600c2054610dc457634b6e7f186000526004601cfd5b3461019357604036600319011261019357610f7d602435611329565b604080516001600160a01b03939093168352602083019190915290f35b346101935760208060031936011261019357610fb760043561124d565b6040518092602082528251908160208401526000935b828510610ff0575050604092506000838284010152601f80199101168101030190f35b8481018201518686016040015293810193859350610fcd565b346101935761101736611120565b90611020611457565b60018060a01b03169081600052600360205260406000209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f600080a2005b34610193576020366003190112610193576004356001600160e01b0319811681036101935760209060e01c60405190630e89341c8114906301ffc9a763d9b67a2682149114171715158152f35b34610193576040366003190112610193576020906110d66110f4565b679a31110384e0b0c983526014526024356000526040600020548152f35b600435906001600160a01b038216820361019357565b602435906001600160a01b038216820361019357565b6040906003190112610193576004356001600160a01b0381168103610193579060243580151581036101935790565b9181601f84011215610193578235916001600160401b038311610193576020808501948460051b01011161019357565b9181601f84011215610193578235916001600160401b038311610193576020838186019501011161019357565b90601f801991011681019081106001600160401b0382111761050f57604052565b9291926001600160401b03821161050f57604051916111f6601f8201601f1916602001846111ac565b829481845281830111610193578281602093846000960137010152565b90600182811c92168015611243575b602083101461122d57565b634e487b7160e01b600052602260045260246000fd5b91607f1691611222565b600090808252602090600582526112676040842054611213565b1561131757825260058152604082206040519283918181549061128982611213565b808652926001928084169081156112f357506001146112b6575b505050506112b3925003826111ac565b90565b815285812095935091905b8183106112db5750506112b39350820101388080806112a3565b855487840185015294850194869450918301916112c1565b93505050506112b394925060ff191682840152151560051b820101388080806112a3565b6040516305989e3d60e51b8152600490fd5b9060005491821561135957828102928184041490151715610525576001546001600160a01b031691612710900490565b50600091508190565b9092916001600160401b03841161050f578360051b602092602060405161138b828501826111ac565b809781520191810192831161019357905b8282106113a95750505050565b8135815290830190830161139c565b91908110156113da5760051b81013590607e1981360301821215610193570190565b634e487b7160e01b600052603260045260246000fd5b903590601e198136030182121561019357018035906001600160401b03821161019357602001918160051b3603831361019357565b903590601e198136030182121561019357018035906001600160401b0382116101935760200191813603831361019357565b6002546001600160a01b0316330361146b57565b60405163118cdaa760e01b8152336004820152602490fdfea2646970667358221220cc4987dc456eb86d107d9d1df52eff6099d0905be0a16c6a42dc118267c9324964736f6c63430008190033604060a08152346106c057611f5a8038038061001a816106c5565b928339810160e0828203126106c05761003282610700565b60208084015190936001600160401b03939092918481116106c05781610059918501610714565b91868401518581116106c05782610071918601610714565b60608501518681116106c05783610089918701610714565b926080860151908782116106c0576100a2918701610714565b9260c06100b160a08801610700565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b516117da9081610780823960805181610ade0152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b895162461bcd60e51b8152600481018a9052601360248201527f4552433732313a20494e56414c49445f425053000000000000000000000000006044820152606490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106ea57604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036106c057565b919080601f840112156106c05782516001600160401b0381116106ea57602090610746601f8201601f191683016106c5565b928184528282870101116106c05760005b81811061076c57508260009394955001015290565b858101830151848201840152820161075756fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101c7578063058260d7146101c257806306fdde03146101bd578063081812fc146101b8578063095ea7b3146101b357806315ff80a0146101ae57806323b872dd146101a95780632a55205a146101a457806340c10f191461019f57806342842e0e1461019a57806355f804b3146101955780636352211e1461019057806370a082311461018b578063715018a61461018657806383a131001461018157806387491c601461017c5780638c7ea24b146101775780638da5cb5b1461017257806395d89b411461016d5780639fd6db1214610168578063a22cb46514610163578063b88d4fde1461015e578063c87b56dd14610159578063dc6c34d514610154578063e026f6341461014f578063e985e9c51461014a5763f2fde38b1461014557600080fd5b610f4a565b610efd565b610e55565b610df2565b610dd3565b610d49565b610cea565b610cc7565b610c1f565b610bf6565b610b32565b610b0d565b610ac8565b610a6a565b610a11565b6109c7565b610894565b6107c8565b610708565b6106cf565b6106bb565b61053a565b61044e565b6103ee565b610305565b610252565b34610214576020366003190112610214576004356001600160e01b0319811681036102145760209060e01c604051906380ac58cd8114906301ffc9a7632a55205a82149114171715158152f35b600080fd5b6001600160a01b0381160361021457565b60409060031901126102145760043561024281610219565b9060243580151581036102145790565b34610214576102603661022a565b90610269611607565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106102c95750506000910152565b81810151838201526020016102b9565b604091602082526102f981518092816020860152602086860191016102b6565b601f01601f1916010190565b34610214576000806003193601126103eb5760405190806005549061032982610fdc565b808552916020916001918281169081156103be5750600114610366575b6103628661035681880382610826565b604051918291826102d9565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8385106103ab575050505081016020016103568261036238610346565b805486860184015293820193810161038e565b90508695506103629693506020925061035694915060ff191682840152151560051b820101929338610346565b80fd5b34610214576020366003190112610214576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561044057600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b60403660031901126102145760043561046681610219565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b0390811692169081156104fc578290823314331517156104d8575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156104ef5782906104ad565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f840112156102145782359167ffffffffffffffff8311610214576020808501948460051b01011161021457565b3461021457602080600319360112610214576004803567ffffffffffffffff81116102145761056c9036908301610509565b92909160ff8154161561068057600093338552600360205260409360ff604087205416158061066b575b61065a5785925b8284106105a8578680f35b909192939495805b6105c76105be87878761102c565b88810190611053565b905081101561064b576105f1816105eb6105e289898961102c565b8a810190611053565b90611089565b356000818152673ec412a9852d173d60c11b601c5260209020810181015460601b61063b579061063560019261063061062b8a8a8a61102c565b611099565b611633565b016105b0565b8851632ae3f45d60e11b81528490fd5b5095949360010192919061059d565b604051633e34a41b60e21b81528390fd5b506002546001600160a01b0316331415610596565b60405163589ed34b60e01b8152fd5b6060906003190112610214576004356106a781610219565b906024356106b481610219565b9060443590565b6106cd6106c73661068f565b916110a6565b005b34610214576040366003190112610214576106eb6024356111c0565b604080516001600160a01b03939093168352602083019190915290f35b346102145760403660031901126102145760043561072581610219565b60243560ff60045416156107b65733600052600360205260ff6040600020541615806107a1575b61078f576000818152673ec412a9852d173d60c11b601c5260209020810181015460601b61077d576106cd91611633565b604051632ae3f45d60e11b8152600490fd5b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b031633141561074c565b60405163589ed34b60e01b8152600490fd5b6107d13661068f565b6107dc8183856110a6565b813b6107e457005b60405191602083019383851067ffffffffffffffff861117610810576106cd94604052600084526116d0565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761084857604052565b610810565b92919267ffffffffffffffff82116108485760405191610877601f8201601f191660200184610826565b829481845281830111610214578281602093846000960137010152565b34610214576020806003193601126102145767ffffffffffffffff6004358181116102145736602382011215610214576108d890369060248160040135910161084d565b916108e1611607565b8251918211610848576108fe826108f9600754610fdc565b6111fe565b602090601f83116001146109405750819061093093600092610935575b50508160011b916000199060031b1c19161790565b600755005b01519050388061091b565b90601f1983169361097360076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b8682106109af5750508360019510610996575b505050811b01600755005b015160001960f88460031b161c1916905538808061098b565b80600185968294968601518155019501930190610978565b34610214576020366003190112610214576004356000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b0316801561044057602090604051908152f35b3461021457602036600319011261021457600435610a2e81610219565b8015610a5c57673ec412a9852d173d60c11b601c52600052602063ffffffff601c600c205416604051908152f35b638f4eb6046000526004601cfd5b34610214576000806003193601126103eb57610a84611607565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b34610214576000366003190112610214576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461021457600036600319011261021457610b26611607565b6004805460ff19169055005b3461021457604036600319011261021457600435610b4f81610219565b602435610b5a611607565b6127108111610bbb57600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b60405162461bcd60e51b81526020600482015260136024820152724552433732313a20494e56414c49445f42505360681b6044820152606490fd5b34610214576000366003190112610214576002546040516001600160a01b039091168152602090f35b34610214576000806003193601126103eb57604051908060065490610c4382610fdc565b808552916020916001918281169081156103be5750600114610c6f576103628661035681880382610826565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610cb4575050505081016020016103568261036238610346565b8054868601840152938201938101610c97565b3461021457600036600319011261021457602060ff600454166040519015158152f35b3461021457610cf83661022a565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261021457600435610d6181610219565b60243590610d6e82610219565b6044356064359267ffffffffffffffff808511610214573660238601121561021457846004013590811161021457366024828701011161021457610db38383866110a6565b813b610dbb57005b6106cd94610dcd91602436920161084d565b926116d0565b34610214576020366003190112610214576103626103566004356113e8565b34610214576000806003193601126103eb57338152600360205260ff6040822054161561078f5733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b346102145760403660031901126102145767ffffffffffffffff60043560243582811161021457610e8a903690600401610509565b9190610e94611607565b60005b838110610ea057005b8060051b820135601e19833603018112156102145782019081359186831161021457602001823603811361021457600192610ef791610ef2610ee2858961152c565b6000526009602052604060002090565b611539565b01610e97565b3461021457604036600319011261021457600435610f1a81610219565b602435610f2681610219565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461021457602036600319011261021457600435610f6781610219565b610f6f611607565b6001600160a01b03908116908115610fc357600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c9216801561100c575b6020831014610ff657565b634e487b7160e01b600052602260045260246000fd5b91607f1691610feb565b634e487b7160e01b600052603260045260246000fd5b919081101561104e5760051b81013590603e1981360301821215610214570190565b611016565b903590601e1981360301821215610214570180359067ffffffffffffffff821161021457602001918160051b3603831361021457565b919081101561104e5760051b0190565b356110a381610219565b90565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b03958616959485169481168086148102156111965750848452838260010180548033148833141715611174575b61116c575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff83168602156111585750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b558338611101565b9091506030600c20541561118a579085916110fc565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156111f5578281029281840414901517156111f0576001546001600160a01b031691612710900490565b6111aa565b50600091508190565b601f811161120a575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c83019410611266575b601f0160051c01915b82811061125b57505050565b81815560010161124f565b9092508290611246565b90601f811161127e57505050565b6000916000526020600020906020601f850160051c830194106112bc575b601f0160051c01915b8281106112b157505050565b8181556001016112a5565b909250829061129c565b600754600092916112d682610fdc565b9160019081811690811561134257506001146112f157505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b84831061132f575050500190565b8181602092548587015201920191611321565b60ff191683525050811515909102019150565b6008546000929161136582610fdc565b91600190818116908115611342575060011461138057505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b8483106113be575050500190565b81816020925485870152019201916113b0565b906113e4602092828151948592016102b6565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b1561151a576000818152602090600982526114266040822054610fdc565b61146757506110a39061145961145461144161144e95611765565b60405195869485016112c6565b906113d1565b611355565b03601f198101835282610826565b9161147c906000526009602052604060002090565b6040519283918181549061148f82610fdc565b808652926001928084169081156114f657506001146114b9575b505050506110a392500382610826565b815285812095935091905b8183106114de5750506110a39350820101388080806114a9565b855487840185015294850194869450918301916114c4565b93505050506110a394925060ff191682840152151560051b820101388080806114a9565b60405163677510db60e11b8152600490fd5b919082018092116111f057565b90929167ffffffffffffffff81116108485761155f816115598454610fdc565b84611270565b6000601f821160011461159f5781906115909394956000926115945750508160011b916000199060031b1c19161790565b9055565b01359050388061091b565b601f198216946115b484600052602060002090565b91805b8781106115ef5750836001959697106115d5575b505050811b019055565b0135600019600384901b60f8161c191690553880806115cb565b909260206001819286860135815501940191016115b7565b6002546001600160a01b0316330361161b57565b60405163118cdaa760e01b8152336004820152602490fd5b6000828152673ec412a9852d173d60c11b601c52602081208301830180546001600160a01b039390931692606081901b6116c35783179055818152601c600c2060018154019063ffffffff82168402156116ae57557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea841560021b526004601cfd5b63c991cbb183526004601cfd5b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152611751575b505001906000601c8401915af115611742575b5163757a42ff60e11b0161173457565b63d1a57ed66000526004601cfd5b3d15611724573d6000823e3d90fd5b818760c08801920160045afa508038611711565b90604051608081019260a0820160405260008452925b6000190192600a90603082820601855304928361177b57809350608091030191601f190191825256fea2646970667358221220790f325a1205f7c153b3592f75d1f8cc9c1e1fbc5ab9c7611749a5e0504410a264736f6c63430008190033604060a08152346106c0576123aa8038038061001a816106c5565b928339810160e0828203126106c05761003282610700565b60208084015190936001600160401b03939092918481116106c05781610059918501610714565b91868401518581116106c05782610071918601610714565b60608501518681116106c05783610089918701610714565b926080860151908782116106c0576100a2918701610714565b9260c06100b160a08801610700565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b51611c2a9081610780823960805181610bca0152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b895162461bcd60e51b8152600481018a9052601360248201527f4552433732313a20494e56414c49445f425053000000000000000000000000006044820152606490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106ea57604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036106c057565b919080601f840112156106c05782516001600160401b0381116106ea57602090610746601f8201601f191683016106c5565b928184528282870101116106c05760005b81811061076c57508260009394955001015290565b858101830151848201840152820161075756fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101f7578063058260d7146101f257806306fdde03146101ed578063081812fc146101e8578063095ea7b3146101e357806315ff80a0146101de57806318160ddd146101d957806323b872dd146101d45780632a55205a146101cf5780632f745c59146101ca57806340c10f19146101c557806342842e0e146101c05780634f6ccce7146101bb57806355f804b3146101b65780636352211e146101b157806370a08231146101ac578063715018a6146101a757806383a13100146101a257806387491c601461019d5780638c7ea24b146101985780638da5cb5b1461019357806395d89b411461018e5780639fd6db1214610189578063a22cb46514610184578063b88d4fde1461017f578063c87b56dd1461017a578063dc6c34d514610175578063e026f63414610170578063e985e9c51461016b5763f2fde38b1461016657600080fd5b611036565b610fe9565b610f41565b610ede565b610ebf565b610e35565b610dd6565b610db3565b610d0b565b610ce2565b610c1e565b610bf9565b610bb4565b610b56565b610b27565b610add565b6109aa565b6108cc565b61087f565b6107bf565b61075f565b610726565b610712565b6106c8565b610573565b610487565b610427565b61033e565b61028b565b3461024d57602036600319011261024d576004356001600160e01b03198116810361024d5760209060e01c6040519063780e9d638114906380ac58cd8114906301ffc9a7632a55205a8214911417171715158152f35b600080fd5b6001600160a01b0381160361024d57565b604090600319011261024d5760043561027b81610252565b90602435801515810361024d5790565b3461024d5761029936610263565b906102a26117b1565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106103025750506000910152565b81810151838201526020016102f2565b6040916020825261033281518092816020860152602086860191016102ef565b601f01601f1916010190565b3461024d5760008060031936011261042457604051908060055490610362826110c8565b808552916020916001918281169081156103f7575060011461039f575b61039b8661038f81880382610941565b60405191829182610312565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8385106103e45750505050810160200161038f8261039b3861037f565b80548686018401529382019381016103c7565b905086955061039b9693506020925061038f94915060ff191682840152151560051b82010192933861037f565b80fd5b3461024d57602036600319011261024d576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561047957600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b604036600319011261024d5760043561049f81610252565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b03908116921690811561053557829082331433151715610511575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156105285782906104e6565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f8401121561024d5782359167ffffffffffffffff831161024d576020808501948460051b01011161024d57565b3461024d5760208060031936011261024d576004803567ffffffffffffffff811161024d576105a59036908301610542565b92909160ff815416156106b957600093338552600360205260409360ff60408720541615806106a4575b6106935785925b8284106105e1578680f35b909192939495805b6106006105f7878787611118565b8881019061113a565b90508110156106845761062a8161062461061b898989611118565b8a81019061113a565b90611170565b356000818152673ec412a9852d173d60c11b601c5260209020810181015460601b610674579061066e6001926106696106648a8a8a611118565b611180565b6117dd565b016105e9565b8851632ae3f45d60e11b81528490fd5b509594936001019291906105d6565b604051633e34a41b60e21b81528390fd5b506002546001600160a01b03163314156105cf565b60405163589ed34b60e01b8152fd5b3461024d57600036600319011261024d576020600a54604051908152f35b606090600319011261024d576004356106fe81610252565b9060243561070b81610252565b9060443590565b61072461071e366106e6565b9161118d565b005b3461024d57604036600319011261024d576107426024356112b2565b604080516001600160a01b03939093168352602083019190915290f35b3461024d57604036600319011261024d5760043561077c81610252565b6024359061079361078c8261143b565b83106112f0565b60018060a01b0316600052600c6020526040600020906000526020526020604060002054604051908152f35b3461024d57604036600319011261024d576004356107dc81610252565b60243560ff600454161561086d5733600052600360205260ff604060002054161580610858575b610846576000818152673ec412a9852d173d60c11b601c5260209020810181015460601b61083457610724916117dd565b604051632ae3f45d60e11b8152600490fd5b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b0316331415610803565b60405163589ed34b60e01b8152600490fd5b610888366106e6565b61089381838561118d565b813b61089b57005b60405191602083019383851067ffffffffffffffff8611176108c7576107249460405260008452611975565b61092b565b3461024d57602036600319011261024d57600435600a5481106108ee816112f0565b1561092657602090600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80154604051908152f35b611102565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176108c757604052565b92919267ffffffffffffffff82116108c7576040519161098d601f8201601f191660200184610941565b82948184528183011161024d578281602093846000960137010152565b3461024d5760208060031936011261024d5767ffffffffffffffff60043581811161024d573660238201121561024d576109ee903690602481600401359101610963565b916109f76117b1565b82519182116108c757610a1482610a0f6007546110c8565b611373565b602090601f8311600114610a5657508190610a4693600092610a4b575b50508160011b916000199060031b1c19161790565b600755005b015190503880610a31565b90601f19831693610a8960076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b868210610ac55750508360019510610aac575b505050811b01600755005b015160001960f88460031b161c19169055388080610aa1565b80600185968294968601518155019501930190610a8e565b3461024d57602036600319011261024d576004356000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b0316801561047957602090604051908152f35b3461024d57602036600319011261024d576020610b4e600435610b4981610252565b61143b565b604051908152f35b3461024d5760008060031936011261042457610b706117b1565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b3461024d57600036600319011261024d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461024d57600036600319011261024d57610c126117b1565b6004805460ff19169055005b3461024d57604036600319011261024d57600435610c3b81610252565b602435610c466117b1565b6127108111610ca757600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b60405162461bcd60e51b81526020600482015260136024820152724552433732313a20494e56414c49445f42505360681b6044820152606490fd5b3461024d57600036600319011261024d576002546040516001600160a01b039091168152602090f35b3461024d5760008060031936011261042457604051908060065490610d2f826110c8565b808552916020916001918281169081156103f75750600114610d5b5761039b8661038f81880382610941565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610da05750505050810160200161038f8261039b3861037f565b8054868601840152938201938101610d83565b3461024d57600036600319011261024d57602060ff600454166040519015158152f35b3461024d57610de436610263565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261024d57600435610e4d81610252565b60243590610e5a82610252565b6044356064359267ffffffffffffffff80851161024d573660238601121561024d57846004013590811161024d57366024828701011161024d57610e9f83838661118d565b813b610ea757005b61072494610eb9916024369201610963565b92611975565b3461024d57602036600319011261024d5761039b61038f600435611592565b3461024d5760008060031936011261042457338152600360205260ff604082205416156108465733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b3461024d57604036600319011261024d5767ffffffffffffffff60043560243582811161024d57610f76903690600401610542565b9190610f806117b1565b60005b838110610f8c57005b8060051b820135601e198336030181121561024d5782019081359186831161024d57602001823603811361024d57600192610fe391610fde610fce85896116d6565b6000526009602052604060002090565b6116e3565b01610f83565b3461024d57604036600319011261024d5760043561100681610252565b60243561101281610252565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461024d57602036600319011261024d5760043561105381610252565b61105b6117b1565b6001600160a01b039081169081156110af57600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c921680156110f8575b60208310146110e257565b634e487b7160e01b600052602260045260246000fd5b91607f16916110d7565b634e487b7160e01b600052603260045260246000fd5b91908110156109265760051b81013590603e198136030182121561024d570190565b903590601e198136030182121561024d570180359067ffffffffffffffff821161024d57602001918160051b3603831361024d57565b91908110156109265760051b0190565b3561118a81610252565b90565b906111998382846118e4565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b039485169585169481168086148102156112885750848452838260010180548033148833141715611266575b61125e575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff831686021561124a5750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b5583386111f3565b9091506030600c20541561127c579085916111ee565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156112e7578281029281840414901517156112e2576001546001600160a01b031691612710900490565b61129c565b50600091508190565b156112f757565b60405162461bcd60e51b815260206004820152601f60248201527f455243373231456e756d657261626c653a20494e56414c49445f494e444558006044820152606490fd5b600a5481101561092657600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80190600090565b601f811161137f575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c830194106113db575b601f0160051c01915b8281106113d057505050565b8181556001016113c4565b90925082906113bb565b90601f81116113f357505050565b6000916000526020600020906020601f850160051c83019410611431575b601f0160051c01915b82811061142657505050565b81815560010161141a565b9092508290611411565b801561146257673ec412a9852d173d60c11b601c5260005263ffffffff601c600c20541690565b638f4eb6046000526004601cfd5b60075460009291611480826110c8565b916001908181169081156114ec575060011461149b57505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b8483106114d9575050500190565b81816020925485870152019201916114cb565b60ff191683525050811515909102019150565b6008546000929161150f826110c8565b916001908181169081156114ec575060011461152a57505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b848310611568575050500190565b818160209254858701520192019161155a565b9061158e602092828151948592016102ef565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b156116c4576000818152602090600982526115d060408220546110c8565b611611575061118a906116036115fe6115eb6115f895611a0a565b6040519586948501611470565b9061157b565b6114ff565b03601f198101835282610941565b91611626906000526009602052604060002090565b60405192839181815490611639826110c8565b808652926001928084169081156116a05750600114611663575b5050505061118a92500382610941565b815285812095935091905b81831061168857505061118a935082010138808080611653565b8554878401850152948501948694509183019161166e565b935050505061118a94925060ff191682840152151560051b82010138808080611653565b60405163677510db60e11b8152600490fd5b919082018092116112e257565b90929167ffffffffffffffff81116108c7576117098161170384546110c8565b846113e5565b6000601f821160011461174957819061173a93949560009261173e5750508160011b916000199060031b1c19161790565b9055565b013590503880610a31565b601f1982169461175e84600052602060002090565b91805b87811061179957508360019596971061177f575b505050811b019055565b0135600019600384901b60f8161c19169055388080611775565b90926020600181928686013581550194019101611761565b6002546001600160a01b031633036117c557565b60405163118cdaa760e01b8152336004820152602490fd5b600a54600090838252600b602052806040832055600160401b8110156108c7578361181182600161182a9401600a5561133c565b90919082549060031b91821b91600019901b1916179055565b6001600160a01b03821691821590811561184c5761184785611b16565b611462565b8461185691611ade565b838252673ec412a9852d173d60c11b601c5260208220840184018054606081901b6118d75784179055828252601c600c2060018154019163ffffffff83168502156118c35750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea9060021b526004601cfd5b63c991cbb184526004601cfd5b9091906001600160a01b03808216908161195d57600a5484600052600b60205280604060002055600160401b8110156108c7578461181182600161192b9401600a5561133c565b841680611949575050611947925061194282611b16565b611a49565b565b039050611954575050565b61194791611ade565b848116821461192b576119708484611a49565b61192b565b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a08801526119f6575b505001906000601c8401915af1156119e7575b5163757a42ff60e11b016119d957565b63d1a57ed66000526004601cfd5b3d156119c9573d6000823e3d90fd5b818760c08801920160045afa5080386119b6565b90604051608081019260a0820160405260008452925b6000190192600a906030828206018553049283611a2057809350608091030191601f1901918252565b611a528161143b565b60001981019081116112e257611aa2926000938185928352600d60205260408320549460018060a01b03168352600c6020526040832094848103611aaf575b50600052600d602052604060002090565b5582526020526040812055565b84845285602052611ad76040852054828652806040872055600052600d602052604060002090565b5538611a91565b604090611aea8161143b565b9260009160018060a01b03168252600c60205282822084835260205280838320558152600d6020522055565b600a8054600019928382018281116112e257600092828452600b602052806040852054921015610926578484527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a7928382015491831015610926578492611bb2611bc39388865280837fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155600052600b602052604060002090565b55600052600b602052604060002090565b558254938415611be0578401938085101561092657838352015555565b634e487b7160e01b83526031600452602483fdfea2646970667358221220a1669c30a8d33b0cd0b640406bfefcba6568c8b47c132486bb1bd5d351efd01564736f6c63430008190033a2646970667358221220f762a5d2c9e9ae23685474e461604e1de668a260ad108e0ad7ee73a38e0cba9864736f6c63430008190033
Deployed Bytecode
0x608060408181526004908136101561001657600080fd5b600092833560e01c908163840013101461016257508063b8ecdc1d146101185763d25bb7fe1461004557600080fd5b3461011457610053366102be565b94879491949392935196611f5a8089019089821067ffffffffffffffff831117610101579161008e979593918a99979593611a5e8b3961039c565b039084f080156100f7576001600160a01b031691823b156100f35781519063f2fde38b60e01b82523390820152838160248183875af180156100e957602094506100da575b5051908152f35b6100e39061022c565b386100d3565b82513d86823e3d90fd5b8380fd5b81513d85823e3d90fd5b634e487b7160e01b8d5260418c5260248dfd5b8280fd5b503461011457610127366102be565b948794919493929351966123aa8089019089821067ffffffffffffffff831117610101579161008e979593918a999795936139b88b3961039c565b9050346100f35760603660031901126100f3576001600160a01b03908335828116908190036102285760243583811680910361022457611657918284019284841067ffffffffffffffff85111761021157916060939185936104078539825260208201526044358682015203019085f080156100e9571691823b156100f35781519063f2fde38b60e01b82523390820152838160248183875af180156100e957602094506100da575051908152f35b634e487b7160e01b895260418852602489fd5b8680fd5b8580fd5b67ffffffffffffffff811161024057604052565b634e487b7160e01b600052604160045260246000fd5b81601f820112156102b95780359067ffffffffffffffff928383116102405760405193601f8401601f19908116603f011685019081118582101761024057604052828452602083830101116102b957816000926020809301838601378301015290565b600080fd5b9060e06003198301126102b9576001600160a01b0360043581811681036102b9579267ffffffffffffffff916024358381116102b9578261030191600401610256565b936044358481116102b9578361031991600401610256565b936064358181116102b9578461033191600401610256565b936084359182116102b95761034891600401610256565b9160a43590811681036102b9579060c43590565b919082519283825260005b848110610388575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610367565b936103ed906103df60c09793956103d16103fb969c9b9a9c60018060a01b038099168a5260e060208b015260e08a019061035c565b9088820360408a015261035c565b90868203606088015261035c565b90848203608086015261035c565b951660a0820152015256fe60a03461016e57601f61165738819003918201601f1916830191906001600160401b0383118484101761017357816060928592604095865283398101031261016e5761004a82610189565b908061005860208501610189565b93015190612710821161012b577f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb68160018060a01b0380961660018060a01b031994818660015416176001558060005582519182526020820152a133156101145760025491339083161760025551923391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3600160ff1960045416176004556080526114b9908161019e823960805181610a310152f35b51631e4fbdf760e01b815260006004820152602490fd5b5162461bcd60e51b815260206004820152601360248201527f4552433732313a20494e56414c49445f425053000000000000000000000000006044820152606490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361016e5756fe608080604052600436101561001357600080fd5b60003560e01c908162fdd58e146110ba5750806301ffc9a71461106d578063058260d7146110095780630e89341c14610f9a5780632a55205a14610f615780632eb2c2d614610d155780634e1273f414610c2a578063715018a614610bcd578063731133e914610a6057806383a1310014610a1b57806383a9c14c1461075857806387491c60146107335780638c7ea24b146106735780638da5cb5b1461064a5780639fd6db1214610627578063a22cb465146105c8578063dc6c34d514610562578063e026f63414610374578063e985e9c51461032e578063f242432a146101985763f2fde38b1461010557600080fd5b346101935760203660031901126101935761011e6110f4565b610126611457565b6001600160a01b0390811690811561017a57600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b600080fd5b346101935760a0366003190112610193576101b16110f4565b6101b961110a565b60443591606435906084356001600160401b038111610193576101e090369060040161117f565b9091679a31110384e0b0c99060601b81179460601b179160209480865260601c938360601c93841561032057853303610304575b87600052604060002080548084116102f6578390039055865260406000208054908282019182106102e857558086528385337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6260406000a4833b61027457005b60405196879563f23a6e618752338888015260408701526060860152608085015260a08085015281850190601f190160c085013760c401906000601c8401915af1156102d9575b51630dc5919f60e01b016102cb57005b639c05499b6000526004601cfd5b3d156102bb573d6000823e3d90fd5b6301336cea6000526004601cfd5b63f4d678b86000526004601cfd5b336000526034600c205461021457634b6e7f186000526004601cfd5b63ea553b346000526004601cfd5b34610193576040366003190112610193576103476110f4565b61034f61110a565b90679a31110384e0b0c960205260145260005260206034600c20546040519015158152f35b34610193576040366003190112610193576024356001600160401b038111610193576103a490369060040161114f565b33600052600360205260ff60406000205416158061054d575b61053b57906000915b8083106103cf57005b6005926103e081851b840184611425565b8260049692963501806004351161052557600052816020526040600020916001600160401b03821161050f576104168354611213565b90601f82116104cc575b50506000601f8211600114610465578190600195969760009261045a575b5050600019600383901b1c191690841b1790555b0191906103c6565b01359050878061043e565b601f198216968360005260206000209160005b8981106104b457508360019798991061049a575b505050831b83019055610452565b0135600019600384901b60f8161c1916905586808061048c565b90926020600181928686013581550194019101610478565b83600052602060002090601f8401811c820160208510610508575b601f8401821c830181106104fc575050610420565b600081556001016104e7565b50816104e7565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b03163314156103bd565b346101935760003660031901126101935733600052600360205260ff604060002054161561053b57336000526003602052604060002060ff198154169055337fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e600080a2005b34610193576105d636611120565b1515679a31110384e0b0c96020523360145281600052806034600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b3461019357600036600319011261019357602060ff600454166040519015158152f35b34610193576000366003190112610193576002546040516001600160a01b039091168152602090f35b346101935760403660031901126101935761068c6110f4565b602435610697611457565b61271081116106f857600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b60405162461bcd60e51b81526020600482015260136024820152724552433732313a20494e56414c49445f42505360681b6044820152606490fd5b346101935760003660031901126101935761074c611457565b6004805460ff19169055005b3461019357602080600319360112610193576004356001600160401b0381116101935761078990369060040161114f565b60ff6004541615610a0957336000526003835260ff6040600020541615806109f4575b61053b5760005b8181106107bc57005b6107c78183856113b8565b356001600160a01b03811690818103610193576107f16107e88486886113b8565b878101906113f0565b909161084c61080e61080487898b6113b8565b60408101906113f0565b91909361084461081f898b8d6113b8565b9561083c61083260609889810190611425565b9990943691611362565b943691611362565b9536916111cd565b9484518251036109e65782841b801561032057679a31110384e0b0c9178a5281518a94939291600591821b805b6109b157506000604051604081528451841b880160408201818760045afa503d604001888201527f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb3d8201918a51861b8a0160408401818d60045afa5060408133943d01030190a4823b6108f7575b505050505050506001016107b3565b60405195869463bc197c81865233878701526000604087015260a0918280928801528451841b880160c09581878a019160045afa503d9081830160808901523d8801948151901b890190818787019160045afa503d0101908501523d019580518501809288019160045afa5060a482601c963d010301906000868401915af1156109a2575b516343e6837f60e01b01610995578085818080806108e8565b600490639c05499b600052fd5b3d1561097c573d6000823e3d90fd5b809192939495965087015181850151600052604060002080549182019182106102e857558b959493929190601f190180610879565b633b800a466000526004601cfd5b506002546001600160a01b03163314156107ac565b60405163589ed34b60e01b8152600490fd5b34610193576000366003190112610193576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461019357608036600319011261019357610a796110f4565b604435906024356064356001600160401b038111610193573660238201121561019357610ab09036906024816004013591016111cd565b9160ff6004541615610a0957336000526020926003845260ff604060002054161580610bb8575b61053b578160601b1561032057679a31110384e0b0c98452816014528260005260406000208054908682019182106102e857558484526001600160a01b0382166000337fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62604083a4813b610b4757005b60405194859363f23a6e6185523386860152600060408601526060850152608084015260a08084015280518091818060c0870152610ba4575b505060c401906000601c8401915af1156102d95751630dc5919f60e01b016102cb57005b818660e08701920160045afa508086610b80565b506002546001600160a01b0316331415610ad7565b3461019357600036600319011261019357610be6611457565b600280546001600160a01b031981169091556000906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b34610193576040366003190112610193576001600160401b0360043581811161019357610c5b90369060040161114f565b909160243590811161019357610c7590369060040161114f565b92909183036109e6576040519280845260051b6020928184868201016040525b610cde575050506040519181839283018184528251809152816040850193019160005b828110610cc757505050500390f35b835185528695509381019392810192600101610cb8565b818290601f1980940193828186948801013560601b679a31110384e0b0c91788528401013560005260406000205490870152610c95565b346101935760a036600319011261019357610d2e6110f4565b610d3661110a565b6001600160401b039060443582811161019357610d5790369060040161114f565b60649391933582811161019357610d7290369060040161114f565b909260843590811161019357610d8c90369060040161117f565b9183036109e657679a31110384e0b0c9928760601b84176020528560601b841760601c15610320578760601b841760601c3303610f45575b60051b9586805b610ee7575060405193604085528760200190601f198080940197838960408a013760608b0160208901520190828260608c8a010137898001968960601b821760601c908c60601b831760601c907f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb339160808c0190a48860601b811760601c3b610e5157005b602099836101049960e09363bc197c819c60601b811760601c6000526040519e8f9d8e528d8f3391015260601b1760601c60408d015260a060608d015260c08c013760c0810160808b01528901013760e0840160a0870152828701910161010084870101370101601c8201600080515af115610ed8575b516343e6837f60e01b016102cb57005b3d15610ec8573d6000823e3d90fd5b80601f19809101918a60601b8717602052818185010135600052604060002080548084848c010135116102f65783838b010135900390558860601b87176020526040600020918254918901013581019081106102e857829155610dcb565b336000526034600c2054610dc457634b6e7f186000526004601cfd5b3461019357604036600319011261019357610f7d602435611329565b604080516001600160a01b03939093168352602083019190915290f35b346101935760208060031936011261019357610fb760043561124d565b6040518092602082528251908160208401526000935b828510610ff0575050604092506000838284010152601f80199101168101030190f35b8481018201518686016040015293810193859350610fcd565b346101935761101736611120565b90611020611457565b60018060a01b03169081600052600360205260406000209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f600080a2005b34610193576020366003190112610193576004356001600160e01b0319811681036101935760209060e01c60405190630e89341c8114906301ffc9a763d9b67a2682149114171715158152f35b34610193576040366003190112610193576020906110d66110f4565b679a31110384e0b0c983526014526024356000526040600020548152f35b600435906001600160a01b038216820361019357565b602435906001600160a01b038216820361019357565b6040906003190112610193576004356001600160a01b0381168103610193579060243580151581036101935790565b9181601f84011215610193578235916001600160401b038311610193576020808501948460051b01011161019357565b9181601f84011215610193578235916001600160401b038311610193576020838186019501011161019357565b90601f801991011681019081106001600160401b0382111761050f57604052565b9291926001600160401b03821161050f57604051916111f6601f8201601f1916602001846111ac565b829481845281830111610193578281602093846000960137010152565b90600182811c92168015611243575b602083101461122d57565b634e487b7160e01b600052602260045260246000fd5b91607f1691611222565b600090808252602090600582526112676040842054611213565b1561131757825260058152604082206040519283918181549061128982611213565b808652926001928084169081156112f357506001146112b6575b505050506112b3925003826111ac565b90565b815285812095935091905b8183106112db5750506112b39350820101388080806112a3565b855487840185015294850194869450918301916112c1565b93505050506112b394925060ff191682840152151560051b820101388080806112a3565b6040516305989e3d60e51b8152600490fd5b9060005491821561135957828102928184041490151715610525576001546001600160a01b031691612710900490565b50600091508190565b9092916001600160401b03841161050f578360051b602092602060405161138b828501826111ac565b809781520191810192831161019357905b8282106113a95750505050565b8135815290830190830161139c565b91908110156113da5760051b81013590607e1981360301821215610193570190565b634e487b7160e01b600052603260045260246000fd5b903590601e198136030182121561019357018035906001600160401b03821161019357602001918160051b3603831361019357565b903590601e198136030182121561019357018035906001600160401b0382116101935760200191813603831361019357565b6002546001600160a01b0316330361146b57565b60405163118cdaa760e01b8152336004820152602490fdfea2646970667358221220cc4987dc456eb86d107d9d1df52eff6099d0905be0a16c6a42dc118267c9324964736f6c63430008190033604060a08152346106c057611f5a8038038061001a816106c5565b928339810160e0828203126106c05761003282610700565b60208084015190936001600160401b03939092918481116106c05781610059918501610714565b91868401518581116106c05782610071918601610714565b60608501518681116106c05783610089918701610714565b926080860151908782116106c0576100a2918701610714565b9260c06100b160a08801610700565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b516117da9081610780823960805181610ade0152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b895162461bcd60e51b8152600481018a9052601360248201527f4552433732313a20494e56414c49445f425053000000000000000000000000006044820152606490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106ea57604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036106c057565b919080601f840112156106c05782516001600160401b0381116106ea57602090610746601f8201601f191683016106c5565b928184528282870101116106c05760005b81811061076c57508260009394955001015290565b858101830151848201840152820161075756fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101c7578063058260d7146101c257806306fdde03146101bd578063081812fc146101b8578063095ea7b3146101b357806315ff80a0146101ae57806323b872dd146101a95780632a55205a146101a457806340c10f191461019f57806342842e0e1461019a57806355f804b3146101955780636352211e1461019057806370a082311461018b578063715018a61461018657806383a131001461018157806387491c601461017c5780638c7ea24b146101775780638da5cb5b1461017257806395d89b411461016d5780639fd6db1214610168578063a22cb46514610163578063b88d4fde1461015e578063c87b56dd14610159578063dc6c34d514610154578063e026f6341461014f578063e985e9c51461014a5763f2fde38b1461014557600080fd5b610f4a565b610efd565b610e55565b610df2565b610dd3565b610d49565b610cea565b610cc7565b610c1f565b610bf6565b610b32565b610b0d565b610ac8565b610a6a565b610a11565b6109c7565b610894565b6107c8565b610708565b6106cf565b6106bb565b61053a565b61044e565b6103ee565b610305565b610252565b34610214576020366003190112610214576004356001600160e01b0319811681036102145760209060e01c604051906380ac58cd8114906301ffc9a7632a55205a82149114171715158152f35b600080fd5b6001600160a01b0381160361021457565b60409060031901126102145760043561024281610219565b9060243580151581036102145790565b34610214576102603661022a565b90610269611607565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106102c95750506000910152565b81810151838201526020016102b9565b604091602082526102f981518092816020860152602086860191016102b6565b601f01601f1916010190565b34610214576000806003193601126103eb5760405190806005549061032982610fdc565b808552916020916001918281169081156103be5750600114610366575b6103628661035681880382610826565b604051918291826102d9565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8385106103ab575050505081016020016103568261036238610346565b805486860184015293820193810161038e565b90508695506103629693506020925061035694915060ff191682840152151560051b820101929338610346565b80fd5b34610214576020366003190112610214576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561044057600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b60403660031901126102145760043561046681610219565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b0390811692169081156104fc578290823314331517156104d8575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156104ef5782906104ad565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f840112156102145782359167ffffffffffffffff8311610214576020808501948460051b01011161021457565b3461021457602080600319360112610214576004803567ffffffffffffffff81116102145761056c9036908301610509565b92909160ff8154161561068057600093338552600360205260409360ff604087205416158061066b575b61065a5785925b8284106105a8578680f35b909192939495805b6105c76105be87878761102c565b88810190611053565b905081101561064b576105f1816105eb6105e289898961102c565b8a810190611053565b90611089565b356000818152673ec412a9852d173d60c11b601c5260209020810181015460601b61063b579061063560019261063061062b8a8a8a61102c565b611099565b611633565b016105b0565b8851632ae3f45d60e11b81528490fd5b5095949360010192919061059d565b604051633e34a41b60e21b81528390fd5b506002546001600160a01b0316331415610596565b60405163589ed34b60e01b8152fd5b6060906003190112610214576004356106a781610219565b906024356106b481610219565b9060443590565b6106cd6106c73661068f565b916110a6565b005b34610214576040366003190112610214576106eb6024356111c0565b604080516001600160a01b03939093168352602083019190915290f35b346102145760403660031901126102145760043561072581610219565b60243560ff60045416156107b65733600052600360205260ff6040600020541615806107a1575b61078f576000818152673ec412a9852d173d60c11b601c5260209020810181015460601b61077d576106cd91611633565b604051632ae3f45d60e11b8152600490fd5b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b031633141561074c565b60405163589ed34b60e01b8152600490fd5b6107d13661068f565b6107dc8183856110a6565b813b6107e457005b60405191602083019383851067ffffffffffffffff861117610810576106cd94604052600084526116d0565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761084857604052565b610810565b92919267ffffffffffffffff82116108485760405191610877601f8201601f191660200184610826565b829481845281830111610214578281602093846000960137010152565b34610214576020806003193601126102145767ffffffffffffffff6004358181116102145736602382011215610214576108d890369060248160040135910161084d565b916108e1611607565b8251918211610848576108fe826108f9600754610fdc565b6111fe565b602090601f83116001146109405750819061093093600092610935575b50508160011b916000199060031b1c19161790565b600755005b01519050388061091b565b90601f1983169361097360076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b8682106109af5750508360019510610996575b505050811b01600755005b015160001960f88460031b161c1916905538808061098b565b80600185968294968601518155019501930190610978565b34610214576020366003190112610214576004356000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b0316801561044057602090604051908152f35b3461021457602036600319011261021457600435610a2e81610219565b8015610a5c57673ec412a9852d173d60c11b601c52600052602063ffffffff601c600c205416604051908152f35b638f4eb6046000526004601cfd5b34610214576000806003193601126103eb57610a84611607565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b34610214576000366003190112610214576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461021457600036600319011261021457610b26611607565b6004805460ff19169055005b3461021457604036600319011261021457600435610b4f81610219565b602435610b5a611607565b6127108111610bbb57600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b60405162461bcd60e51b81526020600482015260136024820152724552433732313a20494e56414c49445f42505360681b6044820152606490fd5b34610214576000366003190112610214576002546040516001600160a01b039091168152602090f35b34610214576000806003193601126103eb57604051908060065490610c4382610fdc565b808552916020916001918281169081156103be5750600114610c6f576103628661035681880382610826565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610cb4575050505081016020016103568261036238610346565b8054868601840152938201938101610c97565b3461021457600036600319011261021457602060ff600454166040519015158152f35b3461021457610cf83661022a565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261021457600435610d6181610219565b60243590610d6e82610219565b6044356064359267ffffffffffffffff808511610214573660238601121561021457846004013590811161021457366024828701011161021457610db38383866110a6565b813b610dbb57005b6106cd94610dcd91602436920161084d565b926116d0565b34610214576020366003190112610214576103626103566004356113e8565b34610214576000806003193601126103eb57338152600360205260ff6040822054161561078f5733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b346102145760403660031901126102145767ffffffffffffffff60043560243582811161021457610e8a903690600401610509565b9190610e94611607565b60005b838110610ea057005b8060051b820135601e19833603018112156102145782019081359186831161021457602001823603811361021457600192610ef791610ef2610ee2858961152c565b6000526009602052604060002090565b611539565b01610e97565b3461021457604036600319011261021457600435610f1a81610219565b602435610f2681610219565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461021457602036600319011261021457600435610f6781610219565b610f6f611607565b6001600160a01b03908116908115610fc357600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c9216801561100c575b6020831014610ff657565b634e487b7160e01b600052602260045260246000fd5b91607f1691610feb565b634e487b7160e01b600052603260045260246000fd5b919081101561104e5760051b81013590603e1981360301821215610214570190565b611016565b903590601e1981360301821215610214570180359067ffffffffffffffff821161021457602001918160051b3603831361021457565b919081101561104e5760051b0190565b356110a381610219565b90565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b03958616959485169481168086148102156111965750848452838260010180548033148833141715611174575b61116c575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff83168602156111585750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b558338611101565b9091506030600c20541561118a579085916110fc565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156111f5578281029281840414901517156111f0576001546001600160a01b031691612710900490565b6111aa565b50600091508190565b601f811161120a575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c83019410611266575b601f0160051c01915b82811061125b57505050565b81815560010161124f565b9092508290611246565b90601f811161127e57505050565b6000916000526020600020906020601f850160051c830194106112bc575b601f0160051c01915b8281106112b157505050565b8181556001016112a5565b909250829061129c565b600754600092916112d682610fdc565b9160019081811690811561134257506001146112f157505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b84831061132f575050500190565b8181602092548587015201920191611321565b60ff191683525050811515909102019150565b6008546000929161136582610fdc565b91600190818116908115611342575060011461138057505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b8483106113be575050500190565b81816020925485870152019201916113b0565b906113e4602092828151948592016102b6565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b1561151a576000818152602090600982526114266040822054610fdc565b61146757506110a39061145961145461144161144e95611765565b60405195869485016112c6565b906113d1565b611355565b03601f198101835282610826565b9161147c906000526009602052604060002090565b6040519283918181549061148f82610fdc565b808652926001928084169081156114f657506001146114b9575b505050506110a392500382610826565b815285812095935091905b8183106114de5750506110a39350820101388080806114a9565b855487840185015294850194869450918301916114c4565b93505050506110a394925060ff191682840152151560051b820101388080806114a9565b60405163677510db60e11b8152600490fd5b919082018092116111f057565b90929167ffffffffffffffff81116108485761155f816115598454610fdc565b84611270565b6000601f821160011461159f5781906115909394956000926115945750508160011b916000199060031b1c19161790565b9055565b01359050388061091b565b601f198216946115b484600052602060002090565b91805b8781106115ef5750836001959697106115d5575b505050811b019055565b0135600019600384901b60f8161c191690553880806115cb565b909260206001819286860135815501940191016115b7565b6002546001600160a01b0316330361161b57565b60405163118cdaa760e01b8152336004820152602490fd5b6000828152673ec412a9852d173d60c11b601c52602081208301830180546001600160a01b039390931692606081901b6116c35783179055818152601c600c2060018154019063ffffffff82168402156116ae57557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea841560021b526004601cfd5b63c991cbb183526004601cfd5b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152611751575b505001906000601c8401915af115611742575b5163757a42ff60e11b0161173457565b63d1a57ed66000526004601cfd5b3d15611724573d6000823e3d90fd5b818760c08801920160045afa508038611711565b90604051608081019260a0820160405260008452925b6000190192600a90603082820601855304928361177b57809350608091030191601f190191825256fea2646970667358221220790f325a1205f7c153b3592f75d1f8cc9c1e1fbc5ab9c7611749a5e0504410a264736f6c63430008190033604060a08152346106c0576123aa8038038061001a816106c5565b928339810160e0828203126106c05761003282610700565b60208084015190936001600160401b03939092918481116106c05781610059918501610714565b91868401518581116106c05782610071918601610714565b60608501518681116106c05783610089918701610714565b926080860151908782116106c0576100a2918701610714565b9260c06100b160a08801610700565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b51611c2a9081610780823960805181610bca0152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b895162461bcd60e51b8152600481018a9052601360248201527f4552433732313a20494e56414c49445f425053000000000000000000000000006044820152606490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106ea57604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036106c057565b919080601f840112156106c05782516001600160401b0381116106ea57602090610746601f8201601f191683016106c5565b928184528282870101116106c05760005b81811061076c57508260009394955001015290565b858101830151848201840152820161075756fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101f7578063058260d7146101f257806306fdde03146101ed578063081812fc146101e8578063095ea7b3146101e357806315ff80a0146101de57806318160ddd146101d957806323b872dd146101d45780632a55205a146101cf5780632f745c59146101ca57806340c10f19146101c557806342842e0e146101c05780634f6ccce7146101bb57806355f804b3146101b65780636352211e146101b157806370a08231146101ac578063715018a6146101a757806383a13100146101a257806387491c601461019d5780638c7ea24b146101985780638da5cb5b1461019357806395d89b411461018e5780639fd6db1214610189578063a22cb46514610184578063b88d4fde1461017f578063c87b56dd1461017a578063dc6c34d514610175578063e026f63414610170578063e985e9c51461016b5763f2fde38b1461016657600080fd5b611036565b610fe9565b610f41565b610ede565b610ebf565b610e35565b610dd6565b610db3565b610d0b565b610ce2565b610c1e565b610bf9565b610bb4565b610b56565b610b27565b610add565b6109aa565b6108cc565b61087f565b6107bf565b61075f565b610726565b610712565b6106c8565b610573565b610487565b610427565b61033e565b61028b565b3461024d57602036600319011261024d576004356001600160e01b03198116810361024d5760209060e01c6040519063780e9d638114906380ac58cd8114906301ffc9a7632a55205a8214911417171715158152f35b600080fd5b6001600160a01b0381160361024d57565b604090600319011261024d5760043561027b81610252565b90602435801515810361024d5790565b3461024d5761029936610263565b906102a26117b1565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106103025750506000910152565b81810151838201526020016102f2565b6040916020825261033281518092816020860152602086860191016102ef565b601f01601f1916010190565b3461024d5760008060031936011261042457604051908060055490610362826110c8565b808552916020916001918281169081156103f7575060011461039f575b61039b8661038f81880382610941565b60405191829182610312565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8385106103e45750505050810160200161038f8261039b3861037f565b80548686018401529382019381016103c7565b905086955061039b9693506020925061038f94915060ff191682840152151560051b82010192933861037f565b80fd5b3461024d57602036600319011261024d576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561047957600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b604036600319011261024d5760043561049f81610252565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b03908116921690811561053557829082331433151715610511575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156105285782906104e6565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f8401121561024d5782359167ffffffffffffffff831161024d576020808501948460051b01011161024d57565b3461024d5760208060031936011261024d576004803567ffffffffffffffff811161024d576105a59036908301610542565b92909160ff815416156106b957600093338552600360205260409360ff60408720541615806106a4575b6106935785925b8284106105e1578680f35b909192939495805b6106006105f7878787611118565b8881019061113a565b90508110156106845761062a8161062461061b898989611118565b8a81019061113a565b90611170565b356000818152673ec412a9852d173d60c11b601c5260209020810181015460601b610674579061066e6001926106696106648a8a8a611118565b611180565b6117dd565b016105e9565b8851632ae3f45d60e11b81528490fd5b509594936001019291906105d6565b604051633e34a41b60e21b81528390fd5b506002546001600160a01b03163314156105cf565b60405163589ed34b60e01b8152fd5b3461024d57600036600319011261024d576020600a54604051908152f35b606090600319011261024d576004356106fe81610252565b9060243561070b81610252565b9060443590565b61072461071e366106e6565b9161118d565b005b3461024d57604036600319011261024d576107426024356112b2565b604080516001600160a01b03939093168352602083019190915290f35b3461024d57604036600319011261024d5760043561077c81610252565b6024359061079361078c8261143b565b83106112f0565b60018060a01b0316600052600c6020526040600020906000526020526020604060002054604051908152f35b3461024d57604036600319011261024d576004356107dc81610252565b60243560ff600454161561086d5733600052600360205260ff604060002054161580610858575b610846576000818152673ec412a9852d173d60c11b601c5260209020810181015460601b61083457610724916117dd565b604051632ae3f45d60e11b8152600490fd5b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b0316331415610803565b60405163589ed34b60e01b8152600490fd5b610888366106e6565b61089381838561118d565b813b61089b57005b60405191602083019383851067ffffffffffffffff8611176108c7576107249460405260008452611975565b61092b565b3461024d57602036600319011261024d57600435600a5481106108ee816112f0565b1561092657602090600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80154604051908152f35b611102565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176108c757604052565b92919267ffffffffffffffff82116108c7576040519161098d601f8201601f191660200184610941565b82948184528183011161024d578281602093846000960137010152565b3461024d5760208060031936011261024d5767ffffffffffffffff60043581811161024d573660238201121561024d576109ee903690602481600401359101610963565b916109f76117b1565b82519182116108c757610a1482610a0f6007546110c8565b611373565b602090601f8311600114610a5657508190610a4693600092610a4b575b50508160011b916000199060031b1c19161790565b600755005b015190503880610a31565b90601f19831693610a8960076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b868210610ac55750508360019510610aac575b505050811b01600755005b015160001960f88460031b161c19169055388080610aa1565b80600185968294968601518155019501930190610a8e565b3461024d57602036600319011261024d576004356000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b0316801561047957602090604051908152f35b3461024d57602036600319011261024d576020610b4e600435610b4981610252565b61143b565b604051908152f35b3461024d5760008060031936011261042457610b706117b1565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b3461024d57600036600319011261024d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461024d57600036600319011261024d57610c126117b1565b6004805460ff19169055005b3461024d57604036600319011261024d57600435610c3b81610252565b602435610c466117b1565b6127108111610ca757600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b60405162461bcd60e51b81526020600482015260136024820152724552433732313a20494e56414c49445f42505360681b6044820152606490fd5b3461024d57600036600319011261024d576002546040516001600160a01b039091168152602090f35b3461024d5760008060031936011261042457604051908060065490610d2f826110c8565b808552916020916001918281169081156103f75750600114610d5b5761039b8661038f81880382610941565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610da05750505050810160200161038f8261039b3861037f565b8054868601840152938201938101610d83565b3461024d57600036600319011261024d57602060ff600454166040519015158152f35b3461024d57610de436610263565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261024d57600435610e4d81610252565b60243590610e5a82610252565b6044356064359267ffffffffffffffff80851161024d573660238601121561024d57846004013590811161024d57366024828701011161024d57610e9f83838661118d565b813b610ea757005b61072494610eb9916024369201610963565b92611975565b3461024d57602036600319011261024d5761039b61038f600435611592565b3461024d5760008060031936011261042457338152600360205260ff604082205416156108465733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b3461024d57604036600319011261024d5767ffffffffffffffff60043560243582811161024d57610f76903690600401610542565b9190610f806117b1565b60005b838110610f8c57005b8060051b820135601e198336030181121561024d5782019081359186831161024d57602001823603811361024d57600192610fe391610fde610fce85896116d6565b6000526009602052604060002090565b6116e3565b01610f83565b3461024d57604036600319011261024d5760043561100681610252565b60243561101281610252565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461024d57602036600319011261024d5760043561105381610252565b61105b6117b1565b6001600160a01b039081169081156110af57600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c921680156110f8575b60208310146110e257565b634e487b7160e01b600052602260045260246000fd5b91607f16916110d7565b634e487b7160e01b600052603260045260246000fd5b91908110156109265760051b81013590603e198136030182121561024d570190565b903590601e198136030182121561024d570180359067ffffffffffffffff821161024d57602001918160051b3603831361024d57565b91908110156109265760051b0190565b3561118a81610252565b90565b906111998382846118e4565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b039485169585169481168086148102156112885750848452838260010180548033148833141715611266575b61125e575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff831686021561124a5750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b5583386111f3565b9091506030600c20541561127c579085916111ee565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156112e7578281029281840414901517156112e2576001546001600160a01b031691612710900490565b61129c565b50600091508190565b156112f757565b60405162461bcd60e51b815260206004820152601f60248201527f455243373231456e756d657261626c653a20494e56414c49445f494e444558006044820152606490fd5b600a5481101561092657600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80190600090565b601f811161137f575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c830194106113db575b601f0160051c01915b8281106113d057505050565b8181556001016113c4565b90925082906113bb565b90601f81116113f357505050565b6000916000526020600020906020601f850160051c83019410611431575b601f0160051c01915b82811061142657505050565b81815560010161141a565b9092508290611411565b801561146257673ec412a9852d173d60c11b601c5260005263ffffffff601c600c20541690565b638f4eb6046000526004601cfd5b60075460009291611480826110c8565b916001908181169081156114ec575060011461149b57505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b8483106114d9575050500190565b81816020925485870152019201916114cb565b60ff191683525050811515909102019150565b6008546000929161150f826110c8565b916001908181169081156114ec575060011461152a57505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b848310611568575050500190565b818160209254858701520192019161155a565b9061158e602092828151948592016102ef565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b156116c4576000818152602090600982526115d060408220546110c8565b611611575061118a906116036115fe6115eb6115f895611a0a565b6040519586948501611470565b9061157b565b6114ff565b03601f198101835282610941565b91611626906000526009602052604060002090565b60405192839181815490611639826110c8565b808652926001928084169081156116a05750600114611663575b5050505061118a92500382610941565b815285812095935091905b81831061168857505061118a935082010138808080611653565b8554878401850152948501948694509183019161166e565b935050505061118a94925060ff191682840152151560051b82010138808080611653565b60405163677510db60e11b8152600490fd5b919082018092116112e257565b90929167ffffffffffffffff81116108c7576117098161170384546110c8565b846113e5565b6000601f821160011461174957819061173a93949560009261173e5750508160011b916000199060031b1c19161790565b9055565b013590503880610a31565b601f1982169461175e84600052602060002090565b91805b87811061179957508360019596971061177f575b505050811b019055565b0135600019600384901b60f8161c19169055388080611775565b90926020600181928686013581550194019101611761565b6002546001600160a01b031633036117c557565b60405163118cdaa760e01b8152336004820152602490fd5b600a54600090838252600b602052806040832055600160401b8110156108c7578361181182600161182a9401600a5561133c565b90919082549060031b91821b91600019901b1916179055565b6001600160a01b03821691821590811561184c5761184785611b16565b611462565b8461185691611ade565b838252673ec412a9852d173d60c11b601c5260208220840184018054606081901b6118d75784179055828252601c600c2060018154019163ffffffff83168502156118c35750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea9060021b526004601cfd5b63c991cbb184526004601cfd5b9091906001600160a01b03808216908161195d57600a5484600052600b60205280604060002055600160401b8110156108c7578461181182600161192b9401600a5561133c565b841680611949575050611947925061194282611b16565b611a49565b565b039050611954575050565b61194791611ade565b848116821461192b576119708484611a49565b61192b565b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a08801526119f6575b505001906000601c8401915af1156119e7575b5163757a42ff60e11b016119d957565b63d1a57ed66000526004601cfd5b3d156119c9573d6000823e3d90fd5b818760c08801920160045afa5080386119b6565b90604051608081019260a0820160405260008452925b6000190192600a906030828206018553049283611a2057809350608091030191601f1901918252565b611a528161143b565b60001981019081116112e257611aa2926000938185928352600d60205260408320549460018060a01b03168352600c6020526040832094848103611aaf575b50600052600d602052604060002090565b5582526020526040812055565b84845285602052611ad76040852054828652806040872055600052600d602052604060002090565b5538611a91565b604090611aea8161143b565b9260009160018060a01b03168252600c60205282822084835260205280838320558152600d6020522055565b600a8054600019928382018281116112e257600092828452600b602052806040852054921015610926578484527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a7928382015491831015610926578492611bb2611bc39388865280837fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155600052600b602052604060002090565b55600052600b602052604060002090565b558254938415611be0578401938085101561092657838352015555565b634e487b7160e01b83526031600452602483fdfea2646970667358221220a1669c30a8d33b0cd0b640406bfefcba6568c8b47c132486bb1bd5d351efd01564736f6c63430008190033a2646970667358221220f762a5d2c9e9ae23685474e461604e1de668a260ad108e0ad7ee73a38e0cba9864736f6c63430008190033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.