Overview
S Balance
0 S
S Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 3 internal transactions
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
5036155 | 9 days ago | Contract Creation | 0 S | |||
4759733 | 10 days ago | Contract Creation | 0 S | |||
4759312 | 10 days ago | Contract Creation | 0 S |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ERC721Factory
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 ERC721Factory { 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); return address(newCollection); } 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); return address(newCollection); } } contract ERC1155Factory { function deployERC1155(address originalAddress, address royaltyRecipient, uint256 royaltyBps) public returns (address) { ERC1155 newCollection = new ERC1155(originalAddress, royaltyRecipient, royaltyBps); Ownable(newCollection).transferOwnership(msg.sender); return address(newCollection); } } contract NFTFactory { ERC721Factory public immutable erc721Factory; ERC1155Factory public immutable erc1155Factory; constructor(address _erc721Factory, address _erc1155Factory) { erc721Factory = ERC721Factory(_erc721Factory); erc1155Factory = ERC1155Factory(_erc1155Factory); } function deployERC721( address originalAddress, string memory name, string memory symbol, string memory baseURI, string memory extension, address royaltyRecipient, uint256 royaltyBps ) public returns (address newContract) { newContract = erc721Factory.deployERC721(originalAddress, name, symbol, baseURI, extension, royaltyRecipient, royaltyBps); Ownable(newContract).transferOwnership(msg.sender); return newContract; } function deployERC721Enumerable( address originalAddress, string memory name, string memory symbol, string memory baseURI, string memory extension, address royaltyRecipient, uint256 royaltyBps ) public returns (address newContract) { newContract = erc721Factory.deployERC721Enumerable( originalAddress, name, symbol, baseURI, extension, royaltyRecipient, royaltyBps ); Ownable(newContract).transferOwnership(msg.sender); return newContract; } function deployERC1155(address originalAddress, address royaltyRecipient, uint256 royaltyBps, string memory name) public returns (address newContract) { newContract = erc1155Factory.deployERC1155(originalAddress, royaltyRecipient, royaltyBps); ERC1155(newContract).setName(name); Ownable(newContract).transferOwnership(msg.sender); return newContract; } }
// 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]; } } 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)) { _burn(id); } _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 { // NFT Metadata string public name; // tokenURI overrides everything mapping(uint256 => string) private _tokenURIs; bool public burningEnabled = true; error URINotSet(); error BurningIsDisabled(); event BurningDisabled(); struct AirdropUnit { address to; uint256[] ids; uint256[] amounts; bytes data; } constructor(address originalAddress, address royaltyRecipient, uint256 royaltyBps) ERC2981(royaltyRecipient, royaltyBps) PermissionedMintingNFT() BridgedNFT(originalAddress) {} function setName(string memory _name) external onlyOwner { name = _name; } function mint(address to, uint256 id, uint256 amount, bytes memory data) public mintIsOpen onlyMinter { _mint(to, id, amount, data); } function burn(address from, uint256 id, uint256 amount) public mintIsOpen onlyMinter { if (!burningEnabled) revert BurningIsDisabled(); _burn(from, id, amount); } function disableBurning() external onlyOwner { burningEnabled = false; emit BurningDisabled(); } 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 _royaltyBps; address internal _royaltyRecipient; error Invalid(); 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 { if (bps > 10000) revert Invalid(); _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":"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
60808060405234601557614612908161001b8239f35b600080fdfe604060808152600436101561001357600080fd5b600090813560e01c8063b8ecdc1d1461010a5763d25bb7fe1461003557600080fd5b3461010657610043366101e6565b94879491949392935196611efa8089019089821067ffffffffffffffff8311176100f2579161007e979593918a9997959361032f8b396102c4565b039083f080156100e7576001600160a01b031690813b156100e357805163f2fde38b60e01b8152336004820152838160248183875af180156100d957602094506100ca575b5051908152f35b6100d390610154565b386100c3565b82513d86823e3d90fd5b8280fd5b5051903d90823e3d90fd5b634e487b7160e01b8c52604160045260248cfd5b5080fd5b503461010657610119366101e6565b948794919493929351966123b48089019089821067ffffffffffffffff8311176100f2579161007e979593918a999795936122298b396102c4565b67ffffffffffffffff811161016857604052565b634e487b7160e01b600052604160045260246000fd5b81601f820112156101e15780359067ffffffffffffffff928383116101685760405193601f8401601f19908116603f011685019081118582101761016857604052828452602083830101116101e157816000926020809301838601378301015290565b600080fd5b9060e06003198301126101e1576001600160a01b0360043581811681036101e1579267ffffffffffffffff916024358381116101e157826102299160040161017e565b936044358481116101e157836102419160040161017e565b936064358181116101e157846102599160040161017e565b936084359182116101e1576102709160040161017e565b9160a43590811681036101e1579060c43590565b919082519283825260005b8481106102b0575050826000602080949584010152601f8019910116010190565b60208183018101518483018201520161028f565b936103159061030760c09793956102f9610323969c9b9a9c60018060a01b038099168a5260e060208b015260e08a0190610284565b9088820360408a0152610284565b908682036060880152610284565b908482036080860152610284565b951660a0820152015256fe604060a081523461068d57611efa8038038061001a81610692565b928339810160e08282031261068d57610032826106cd565b60208084015190936001600160401b039390929184811161068d57816100599185016106e1565b918684015185811161068d57826100719186016106e1565b606085015186811161068d57836100899187016106e1565b9260808601519087821161068d576100a29187016106e1565b9260c06100b160a088016106cd565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b516117ad908161074d8239608051816109f70152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b8951636dac6a0960e01b8152600490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106b757604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361068d57565b919080601f8401121561068d5782516001600160401b0381116106b757602090610713601f8201601f19168301610692565b9281845282828701011161068d5760005b81811061073957508260009394955001015290565b858101830151848201840152820161072456fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101b7578063058260d7146101b257806306fdde03146101ad578063081812fc146101a8578063095ea7b3146101a357806315ff80a01461019e57806323b872dd146101995780632a55205a1461019457806342842e0e1461018f57806355f804b31461018a5780636352211e1461018557806370a0823114610180578063715018a61461017b57806383a131001461017657806387491c60146101715780638c7ea24b1461016c5780638da5cb5b1461016757806395d89b41146101625780639fd6db121461015d578063a22cb46514610158578063b88d4fde14610153578063c87b56dd1461014e578063dc6c34d514610149578063e026f63414610144578063e985e9c51461013f5763f2fde38b1461013a57600080fd5b610e3a565b610ded565b610d45565b610ce2565b610cc3565b610c39565b610bda565b610bb7565b610b0f565b610ae6565b610a4b565b610a26565b6109e1565b610983565b61092a565b6108fa565b6107c7565b6106fb565b6106c2565b6106ae565b61052a565b61043e565b6103de565b6102f5565b610242565b34610204576020366003190112610204576004356001600160e01b0319811681036102045760209060e01c604051906380ac58cd8114906301ffc9a7632a55205a82149114171715158152f35b600080fd5b6001600160a01b0381160361020457565b60409060031901126102045760043561023281610209565b9060243580151581036102045790565b34610204576102503661021a565b90610259611510565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106102b95750506000910152565b81810151838201526020016102a9565b604091602082526102e981518092816020860152602086860191016102a6565b601f01601f1916010190565b34610204576000806003193601126103db5760405190806005549061031982610ecc565b808552916020916001918281169081156103ae5750600114610356575b6103528661034681880382610759565b604051918291826102c9565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b83851061039b575050505081016020016103468261035238610336565b805486860184015293820193810161037e565b90508695506103529693506020925061034694915060ff191682840152151560051b820101929338610336565b80fd5b34610204576020366003190112610204576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561043057600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b60403660031901126102045760043561045681610209565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b0390811692169081156104ec578290823314331517156104c8575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156104df57829061049d565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f840112156102045782359167ffffffffffffffff8311610204576020808501948460051b01011161020457565b34610204576020806003193601126102045760043567ffffffffffffffff81116102045761055c9036906004016104f9565b909160ff600454161561067057600092338452600360205260ff604085205416158061065b575b6106495783905b838210610595578480f35b90919293805b6105b26105a9858886610f1c565b86810190610f3e565b905081101561063c576105c96105a9858886610f1c565b8291921015610637576106236001928260051b01356106068180600052673ec412a9852d173d60c11b601c5260206000208101015460601b151590565b610629575b61061e610619888b89610f1c565b610f74565b611606565b0161059b565b6106328161153c565b61060b565b610f06565b509392916001019061058a565b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b0316331415610583565b60405163589ed34b60e01b8152600490fd5b60609060031901126102045760043561069a81610209565b906024356106a781610209565b9060443590565b6106c06106ba36610682565b91610f81565b005b34610204576040366003190112610204576106de60243561109b565b604080516001600160a01b03939093168352602083019190915290f35b61070436610682565b61070f818385610f81565b813b61071757005b60405191602083019383851067ffffffffffffffff861117610743576106c094604052600084526116a3565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761077b57604052565b610743565b92919267ffffffffffffffff821161077b57604051916107aa601f8201601f191660200184610759565b829481845281830111610204578281602093846000960137010152565b34610204576020806003193601126102045767ffffffffffffffff60043581811161020457366023820112156102045761080b903690602481600401359101610780565b91610814611510565b825191821161077b576108318261082c600754610ecc565b6110d9565b602090601f83116001146108735750819061086393600092610868575b50508160011b916000199060031b1c19161790565b600755005b01519050388061084e565b90601f198316936108a660076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b8682106108e257505083600195106108c9575b505050811b01600755005b015160001960f88460031b161c191690553880806108be565b806001859682949686015181550195019301906108ab565b346102045760203660031901126102045760206109186004356111a1565b6040516001600160a01b039091168152f35b346102045760203660031901126102045760043561094781610209565b801561097557673ec412a9852d173d60c11b601c52600052602063ffffffff601c600c205416604051908152f35b638f4eb6046000526004601cfd5b34610204576000806003193601126103db5761099d611510565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b34610204576000366003190112610204576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461020457600036600319011261020457610a3f611510565b6004805460ff19169055005b3461020457604036600319011261020457600435610a6881610209565b602435610a73611510565b6127108111610ad457600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b604051636dac6a0960e01b8152600490fd5b34610204576000366003190112610204576002546040516001600160a01b039091168152602090f35b34610204576000806003193601126103db57604051908060065490610b3382610ecc565b808552916020916001918281169081156103ae5750600114610b5f576103528661034681880382610759565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610ba4575050505081016020016103468261035238610336565b8054868601840152938201938101610b87565b3461020457600036600319011261020457602060ff600454166040519015158152f35b3461020457610be83661021a565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261020457600435610c5181610209565b60243590610c5e82610209565b6044356064359267ffffffffffffffff808511610204573660238601121561020457846004013590811161020457366024828701011161020457610ca3838386610f81565b813b610cab57005b6106c094610cbd916024369201610780565b926116a3565b34610204576020366003190112610204576103526103466004356112f1565b34610204576000806003193601126103db57338152600360205260ff604082205416156106495733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b346102045760403660031901126102045767ffffffffffffffff60043560243582811161020457610d7a9036906004016104f9565b9190610d84611510565b60005b838110610d9057005b8060051b820135601e19833603018112156102045782019081359186831161020457602001823603811361020457600192610de791610de2610dd28589611435565b6000526009602052604060002090565b611442565b01610d87565b3461020457604036600319011261020457600435610e0a81610209565b602435610e1681610209565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461020457602036600319011261020457600435610e5781610209565b610e5f611510565b6001600160a01b03908116908115610eb357600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c92168015610efc575b6020831014610ee657565b634e487b7160e01b600052602260045260246000fd5b91607f1691610edb565b634e487b7160e01b600052603260045260246000fd5b91908110156106375760051b81013590603e1981360301821215610204570190565b903590601e1981360301821215610204570180359067ffffffffffffffff821161020457602001918160051b3603831361020457565b35610f7e81610209565b90565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b0395861695948516948116808614810215611071575084845283826001018054803314883314171561104f575b611047575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff83168602156110335750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b558338610fdc565b9091506030600c20541561106557908591610fd7565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156110d0578281029281840414901517156110cb576001546001600160a01b031691612710900490565b611085565b50600091508190565b601f81116110e5575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c83019410611141575b601f0160051c01915b82811061113657505050565b81815560010161112a565b9092508290611121565b90601f811161115957505050565b6000916000526020600020906020601f850160051c83019410611197575b601f0160051c01915b82811061118c57505050565b818155600101611180565b9092508290611177565b6000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b031690811561043057565b600754600092916111df82610ecc565b9160019081811690811561124b57506001146111fa57505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b848310611238575050500190565b818160209254858701520192019161122a565b60ff191683525050811515909102019150565b6008546000929161126e82610ecc565b9160019081811690811561124b575060011461128957505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b8483106112c7575050500190565b81816020925485870152019201916112b9565b906112ed602092828151948592016102a6565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b156114235760008181526020906009825261132f6040822054610ecc565b6113705750610f7e9061136261135d61134a61135795611738565b60405195869485016111cf565b906112da565b61125e565b03601f198101835282610759565b91611385906000526009602052604060002090565b6040519283918181549061139882610ecc565b808652926001928084169081156113ff57506001146113c2575b50505050610f7e92500382610759565b815285812095935091905b8183106113e7575050610f7e9350820101388080806113b2565b855487840185015294850194869450918301916113cd565b9350505050610f7e94925060ff191682840152151560051b820101388080806113b2565b60405163677510db60e11b8152600490fd5b919082018092116110cb57565b90929167ffffffffffffffff811161077b57611468816114628454610ecc565b8461114b565b6000601f82116001146114a857819061149993949560009261149d5750508160011b916000199060031b1c19161790565b9055565b01359050388061084e565b601f198216946114bd84600052602060002090565b91805b8781106114f85750836001959697106114de575b505050811b019055565b0135600019600384901b60f8161c191690553880806114d4565b909260206001819286860135815501940191016114c0565b6002546001600160a01b0316330361152457565b60405163118cdaa760e01b8152336004820152602490fd5b611545816111a1565b506000818152673ec412a9852d173d60c11b601c52602081208201820180546001600160a01b038116919082156115f9578290818552848360010180548015600117156115d2575b6115ca575b5050189055601c600c2080546000190190557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b558438611592565b91509192506030600c2054156115ec57849291869161158d565b634b6e7f1886526004601cfd5b63ceea21b684526004601cfd5b6000828152673ec412a9852d173d60c11b601c52602081208301830180546001600160a01b039390931692606081901b6116965783179055818152601c600c2060018154019063ffffffff821684021561168157557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea841560021b526004601cfd5b63c991cbb183526004601cfd5b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152611724575b505001906000601c8401915af115611715575b5163757a42ff60e11b0161170757565b63d1a57ed66000526004601cfd5b3d156116f7573d6000823e3d90fd5b818760c08801920160045afa5080386116e4565b90604051608081019260a0820160405260008452925b6000190192600a90603082820601855304928361174e57809350608091030191601f190191825256fea2646970667358221220c43a099d2ad9fd571d3e60294182c194354bc2b30ee9f2f6c1777fdd4be6d40164736f6c63430008190033604060a081523461068d576123b48038038061001a81610692565b928339810160e08282031261068d57610032826106cd565b60208084015190936001600160401b039390929184811161068d57816100599185016106e1565b918684015185811161068d57826100719186016106e1565b606085015186811161068d57836100899187016106e1565b9260808601519087821161068d576100a29187016106e1565b9260c06100b160a088016106cd565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b51611c67908161074d823960805181610ade0152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b8951636dac6a0960e01b8152600490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106b757604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361068d57565b919080601f8401121561068d5782516001600160401b0381116106b757602090610713601f8201601f19168301610692565b9281845282828701011161068d5760005b81811061073957508260009394955001015290565b858101830151848201840152820161072456fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101e7578063058260d7146101e257806306fdde03146101dd578063081812fc146101d8578063095ea7b3146101d357806315ff80a0146101ce57806318160ddd146101c957806323b872dd146101c45780632a55205a146101bf5780632f745c59146101ba57806342842e0e146101b55780634f6ccce7146101b057806355f804b3146101ab5780636352211e146101a657806370a08231146101a1578063715018a61461019c57806383a131001461019757806387491c60146101925780638c7ea24b1461018d5780638da5cb5b1461018857806395d89b41146101835780639fd6db121461017e578063a22cb46514610179578063b88d4fde14610174578063c87b56dd1461016f578063dc6c34d51461016a578063e026f63414610165578063e985e9c5146101605763f2fde38b1461015b57600080fd5b610f21565b610ed4565b610e2c565b610dc9565b610daa565b610d20565b610cc1565b610c9e565b610bf6565b610bcd565b610b32565b610b0d565b610ac8565b610a6a565b610a3b565b610a0b565b6108d8565b6107ff565b6107b2565b610752565b610719565b610705565b6106bb565b610563565b610477565b610417565b61032e565b61027b565b3461023d57602036600319011261023d576004356001600160e01b03198116810361023d5760209060e01c6040519063780e9d638114906380ac58cd8114906301ffc9a7632a55205a8214911417171715158152f35b600080fd5b6001600160a01b0381160361023d57565b604090600319011261023d5760043561026b81610242565b90602435801515810361023d5790565b3461023d5761028936610253565b906102926116ba565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106102f25750506000910152565b81810151838201526020016102e2565b6040916020825261032281518092816020860152602086860191016102df565b601f01601f1916010190565b3461023d576000806003193601126104145760405190806005549061035282610fb3565b808552916020916001918281169081156103e7575060011461038f575b61038b8661037f8188038261086f565b60405191829182610302565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8385106103d45750505050810160200161037f8261038b3861036f565b80548686018401529382019381016103b7565b905086955061038b9693506020925061037f94915060ff191682840152151560051b82010192933861036f565b80fd5b3461023d57602036600319011261023d576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561046957600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b604036600319011261023d5760043561048f81610242565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b03908116921690811561052557829082331433151715610501575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156105185782906104d6565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f8401121561023d5782359167ffffffffffffffff831161023d576020808501948460051b01011161023d57565b3461023d5760208060031936011261023d5760043567ffffffffffffffff811161023d57610595903690600401610532565b909160ff60045416156106a957600092338452600360205260ff6040852054161580610694575b6106825783905b8382106105ce578480f35b90919293805b6105eb6105e2858886611003565b86810190611025565b9050811015610675576106026105e2858886611003565b82919210156106705761065c6001928260051b013561063f8180600052673ec412a9852d173d60c11b601c5260206000208101015460601b151590565b610662575b610657610652888b89611003565b61105b565b6117b8565b016105d4565b61066b816116e6565b610644565b610fed565b50939291600101906105c3565b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b03163314156105bc565b60405163589ed34b60e01b8152600490fd5b3461023d57600036600319011261023d576020600a54604051908152f35b606090600319011261023d576004356106f181610242565b906024356106fe81610242565b9060443590565b610717610711366106d9565b91611068565b005b3461023d57604036600319011261023d5761073560243561118d565b604080516001600160a01b03939093168352602083019190915290f35b3461023d57604036600319011261023d5760043561076f81610242565b6024359061078661077f82611344565b83106111cb565b60018060a01b0316600052600c6020526040600020906000526020526020604060002054604051908152f35b6107bb366106d9565b6107c6818385611068565b813b6107ce57005b60405191602083019383851067ffffffffffffffff8611176107fa5761071794604052600084526119b2565b610859565b3461023d57602036600319011261023d57600435600a548110610821816111cb565b1561067057602090600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80154604051908152f35b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176107fa57604052565b92919267ffffffffffffffff82116107fa57604051916108bb601f8201601f19166020018461086f565b82948184528183011161023d578281602093846000960137010152565b3461023d5760208060031936011261023d5767ffffffffffffffff60043581811161023d573660238201121561023d5761091c903690602481600401359101610891565b916109256116ba565b82519182116107fa576109428261093d600754610fb3565b61124e565b602090601f83116001146109845750819061097493600092610979575b50508160011b916000199060031b1c19161790565b600755005b01519050388061095f565b90601f198316936109b760076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b8682106109f357505083600195106109da575b505050811b01600755005b015160001960f88460031b161c191690553880806109cf565b806001859682949686015181550195019301906109bc565b3461023d57602036600319011261023d576020610a29600435611316565b6040516001600160a01b039091168152f35b3461023d57602036600319011261023d576020610a62600435610a5d81610242565b611344565b604051908152f35b3461023d5760008060031936011261041457610a846116ba565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b3461023d57600036600319011261023d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461023d57600036600319011261023d57610b266116ba565b6004805460ff19169055005b3461023d57604036600319011261023d57600435610b4f81610242565b602435610b5a6116ba565b6127108111610bbb57600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b604051636dac6a0960e01b8152600490fd5b3461023d57600036600319011261023d576002546040516001600160a01b039091168152602090f35b3461023d5760008060031936011261041457604051908060065490610c1a82610fb3565b808552916020916001918281169081156103e75750600114610c465761038b8661037f8188038261086f565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610c8b5750505050810160200161037f8261038b3861036f565b8054868601840152938201938101610c6e565b3461023d57600036600319011261023d57602060ff600454166040519015158152f35b3461023d57610ccf36610253565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261023d57600435610d3881610242565b60243590610d4582610242565b6044356064359267ffffffffffffffff80851161023d573660238601121561023d57846004013590811161023d57366024828701011161023d57610d8a838386611068565b813b610d9257005b61071794610da4916024369201610891565b926119b2565b3461023d57602036600319011261023d5761038b61037f60043561149b565b3461023d5760008060031936011261041457338152600360205260ff604082205416156106825733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b3461023d57604036600319011261023d5767ffffffffffffffff60043560243582811161023d57610e61903690600401610532565b9190610e6b6116ba565b60005b838110610e7757005b8060051b820135601e198336030181121561023d5782019081359186831161023d57602001823603811361023d57600192610ece91610ec9610eb985896115df565b6000526009602052604060002090565b6115ec565b01610e6e565b3461023d57604036600319011261023d57600435610ef181610242565b602435610efd81610242565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461023d57602036600319011261023d57600435610f3e81610242565b610f466116ba565b6001600160a01b03908116908115610f9a57600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c92168015610fe3575b6020831014610fcd57565b634e487b7160e01b600052602260045260246000fd5b91607f1691610fc2565b634e487b7160e01b600052603260045260246000fd5b91908110156106705760051b81013590603e198136030182121561023d570190565b903590601e198136030182121561023d570180359067ffffffffffffffff821161023d57602001918160051b3603831361023d57565b3561106581610242565b90565b90611074838284611928565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b039485169585169481168086148102156111635750848452838260010180548033148833141715611141575b611139575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff83168602156111255750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b5583386110ce565b9091506030600c205415611157579085916110c9565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156111c2578281029281840414901517156111bd576001546001600160a01b031691612710900490565b611177565b50600091508190565b156111d257565b60405162461bcd60e51b815260206004820152601f60248201527f455243373231456e756d657261626c653a20494e56414c49445f494e444558006044820152606490fd5b600a5481101561067057600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80190600090565b601f811161125a575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c830194106112b6575b601f0160051c01915b8281106112ab57505050565b81815560010161129f565b9092508290611296565b90601f81116112ce57505050565b6000916000526020600020906020601f850160051c8301941061130c575b601f0160051c01915b82811061130157505050565b8181556001016112f5565b90925082906112ec565b6000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b031690811561046957565b801561136b57673ec412a9852d173d60c11b601c5260005263ffffffff601c600c20541690565b638f4eb6046000526004601cfd5b6007546000929161138982610fb3565b916001908181169081156113f557506001146113a457505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b8483106113e2575050500190565b81816020925485870152019201916113d4565b60ff191683525050811515909102019150565b6008546000929161141882610fb3565b916001908181169081156113f5575060011461143357505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b848310611471575050500190565b8181602092548587015201920191611463565b90611497602092828151948592016102df565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b156115cd576000818152602090600982526114d96040822054610fb3565b61151a57506110659061150c6115076114f461150195611a47565b6040519586948501611379565b90611484565b611408565b03601f19810183528261086f565b9161152f906000526009602052604060002090565b6040519283918181549061154282610fb3565b808652926001928084169081156115a9575060011461156c575b505050506110659250038261086f565b815285812095935091905b81831061159157505061106593508201013880808061155c565b85548784018501529485019486945091830191611577565b935050505061106594925060ff191682840152151560051b8201013880808061155c565b60405163677510db60e11b8152600490fd5b919082018092116111bd57565b90929167ffffffffffffffff81116107fa576116128161160c8454610fb3565b846112c0565b6000601f82116001146116525781906116439394956000926116475750508160011b916000199060031b1c19161790565b9055565b01359050388061095f565b601f1982169461166784600052602060002090565b91805b8781106116a2575083600195969710611688575b505050811b019055565b0135600019600384901b60f8161c1916905538808061167e565b9092602060018192868601358155019401910161166a565b6002546001600160a01b031633036116ce57565b60405163118cdaa760e01b8152336004820152602490fd5b6116f8816116f381611316565b6118bf565b6000818152673ec412a9852d173d60c11b601c52602081208201820180546001600160a01b038116919082156117ab57829081855284836001018054801560011715611784575b61177c575b5050189055601c600c2080546000190190557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b558438611744565b91509192506030600c20541561179e57849291869161173f565b634b6e7f1886526004601cfd5b63ceea21b684526004601cfd5b600a54600090838252600b602052806040832055600160401b8110156107fa57836117ec8260016118059401600a55611217565b90919082549060031b91821b91600019901b1916179055565b6001600160a01b0382169182159081156118275761182285611b53565b61136b565b8461183191611b1b565b838252673ec412a9852d173d60c11b601c5260208220840184018054606081901b6118b25784179055828252601c600c2060018154019163ffffffff831685021561189e5750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea9060021b526004601cfd5b63c991cbb184526004601cfd5b906001600160a01b03821661191557600a549181600052600b60205282604060002055600160401b8310156107fa57611905826117ec8560016119139701600a55611217565b61190e82611b53565b611a86565b565b816119238261191394611a86565b611905565b9091906001600160a01b03808216908161199a57600a5484600052600b60205280604060002055600160401b8110156107fa57846117ec82600161196f9401600a55611217565b841680611986575050611913925061190e82611b53565b039050611991575050565b61191391611b1b565b848116821461196f576119ad8484611a86565b61196f565b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152611a33575b505001906000601c8401915af115611a24575b5163757a42ff60e11b01611a1657565b63d1a57ed66000526004601cfd5b3d15611a06573d6000823e3d90fd5b818760c08801920160045afa5080386119f3565b90604051608081019260a0820160405260008452925b6000190192600a906030828206018553049283611a5d57809350608091030191601f1901918252565b611a8f81611344565b60001981019081116111bd57611adf926000938185928352600d60205260408320549460018060a01b03168352600c6020526040832094848103611aec575b50600052600d602052604060002090565b5582526020526040812055565b84845285602052611b146040852054828652806040872055600052600d602052604060002090565b5538611ace565b604090611b2781611344565b9260009160018060a01b03168252600c60205282822084835260205280838320558152600d6020522055565b600a8054600019928382018281116111bd57600092828452600b602052806040852054921015610670578484527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a7928382015491831015610670578492611bef611c009388865280837fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155600052600b602052604060002090565b55600052600b602052604060002090565b558254938415611c1d578401938085101561067057838352015555565b634e487b7160e01b83526031600452602483fdfea2646970667358221220711cd2097b25c025a3f9a34445b1ba6f2b22c54d617dacda742e1aef08eb7a7564736f6c63430008190033a2646970667358221220217cdd7203c2c869fcf61c21415c58818bd6d9e7d8a9f46298f20d41eeec2fe464736f6c63430008190033
Deployed Bytecode
0x604060808152600436101561001357600080fd5b600090813560e01c8063b8ecdc1d1461010a5763d25bb7fe1461003557600080fd5b3461010657610043366101e6565b94879491949392935196611efa8089019089821067ffffffffffffffff8311176100f2579161007e979593918a9997959361032f8b396102c4565b039083f080156100e7576001600160a01b031690813b156100e357805163f2fde38b60e01b8152336004820152838160248183875af180156100d957602094506100ca575b5051908152f35b6100d390610154565b386100c3565b82513d86823e3d90fd5b8280fd5b5051903d90823e3d90fd5b634e487b7160e01b8c52604160045260248cfd5b5080fd5b503461010657610119366101e6565b948794919493929351966123b48089019089821067ffffffffffffffff8311176100f2579161007e979593918a999795936122298b396102c4565b67ffffffffffffffff811161016857604052565b634e487b7160e01b600052604160045260246000fd5b81601f820112156101e15780359067ffffffffffffffff928383116101685760405193601f8401601f19908116603f011685019081118582101761016857604052828452602083830101116101e157816000926020809301838601378301015290565b600080fd5b9060e06003198301126101e1576001600160a01b0360043581811681036101e1579267ffffffffffffffff916024358381116101e157826102299160040161017e565b936044358481116101e157836102419160040161017e565b936064358181116101e157846102599160040161017e565b936084359182116101e1576102709160040161017e565b9160a43590811681036101e1579060c43590565b919082519283825260005b8481106102b0575050826000602080949584010152601f8019910116010190565b60208183018101518483018201520161028f565b936103159061030760c09793956102f9610323969c9b9a9c60018060a01b038099168a5260e060208b015260e08a0190610284565b9088820360408a0152610284565b908682036060880152610284565b908482036080860152610284565b951660a0820152015256fe604060a081523461068d57611efa8038038061001a81610692565b928339810160e08282031261068d57610032826106cd565b60208084015190936001600160401b039390929184811161068d57816100599185016106e1565b918684015185811161068d57826100719186016106e1565b606085015186811161068d57836100899187016106e1565b9260808601519087821161068d576100a29187016106e1565b9260c06100b160a088016106cd565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b516117ad908161074d8239608051816109f70152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b8951636dac6a0960e01b8152600490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106b757604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361068d57565b919080601f8401121561068d5782516001600160401b0381116106b757602090610713601f8201601f19168301610692565b9281845282828701011161068d5760005b81811061073957508260009394955001015290565b858101830151848201840152820161072456fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101b7578063058260d7146101b257806306fdde03146101ad578063081812fc146101a8578063095ea7b3146101a357806315ff80a01461019e57806323b872dd146101995780632a55205a1461019457806342842e0e1461018f57806355f804b31461018a5780636352211e1461018557806370a0823114610180578063715018a61461017b57806383a131001461017657806387491c60146101715780638c7ea24b1461016c5780638da5cb5b1461016757806395d89b41146101625780639fd6db121461015d578063a22cb46514610158578063b88d4fde14610153578063c87b56dd1461014e578063dc6c34d514610149578063e026f63414610144578063e985e9c51461013f5763f2fde38b1461013a57600080fd5b610e3a565b610ded565b610d45565b610ce2565b610cc3565b610c39565b610bda565b610bb7565b610b0f565b610ae6565b610a4b565b610a26565b6109e1565b610983565b61092a565b6108fa565b6107c7565b6106fb565b6106c2565b6106ae565b61052a565b61043e565b6103de565b6102f5565b610242565b34610204576020366003190112610204576004356001600160e01b0319811681036102045760209060e01c604051906380ac58cd8114906301ffc9a7632a55205a82149114171715158152f35b600080fd5b6001600160a01b0381160361020457565b60409060031901126102045760043561023281610209565b9060243580151581036102045790565b34610204576102503661021a565b90610259611510565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106102b95750506000910152565b81810151838201526020016102a9565b604091602082526102e981518092816020860152602086860191016102a6565b601f01601f1916010190565b34610204576000806003193601126103db5760405190806005549061031982610ecc565b808552916020916001918281169081156103ae5750600114610356575b6103528661034681880382610759565b604051918291826102c9565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b83851061039b575050505081016020016103468261035238610336565b805486860184015293820193810161037e565b90508695506103529693506020925061034694915060ff191682840152151560051b820101929338610336565b80fd5b34610204576020366003190112610204576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561043057600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b60403660031901126102045760043561045681610209565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b0390811692169081156104ec578290823314331517156104c8575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156104df57829061049d565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f840112156102045782359167ffffffffffffffff8311610204576020808501948460051b01011161020457565b34610204576020806003193601126102045760043567ffffffffffffffff81116102045761055c9036906004016104f9565b909160ff600454161561067057600092338452600360205260ff604085205416158061065b575b6106495783905b838210610595578480f35b90919293805b6105b26105a9858886610f1c565b86810190610f3e565b905081101561063c576105c96105a9858886610f1c565b8291921015610637576106236001928260051b01356106068180600052673ec412a9852d173d60c11b601c5260206000208101015460601b151590565b610629575b61061e610619888b89610f1c565b610f74565b611606565b0161059b565b6106328161153c565b61060b565b610f06565b509392916001019061058a565b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b0316331415610583565b60405163589ed34b60e01b8152600490fd5b60609060031901126102045760043561069a81610209565b906024356106a781610209565b9060443590565b6106c06106ba36610682565b91610f81565b005b34610204576040366003190112610204576106de60243561109b565b604080516001600160a01b03939093168352602083019190915290f35b61070436610682565b61070f818385610f81565b813b61071757005b60405191602083019383851067ffffffffffffffff861117610743576106c094604052600084526116a3565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761077b57604052565b610743565b92919267ffffffffffffffff821161077b57604051916107aa601f8201601f191660200184610759565b829481845281830111610204578281602093846000960137010152565b34610204576020806003193601126102045767ffffffffffffffff60043581811161020457366023820112156102045761080b903690602481600401359101610780565b91610814611510565b825191821161077b576108318261082c600754610ecc565b6110d9565b602090601f83116001146108735750819061086393600092610868575b50508160011b916000199060031b1c19161790565b600755005b01519050388061084e565b90601f198316936108a660076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b8682106108e257505083600195106108c9575b505050811b01600755005b015160001960f88460031b161c191690553880806108be565b806001859682949686015181550195019301906108ab565b346102045760203660031901126102045760206109186004356111a1565b6040516001600160a01b039091168152f35b346102045760203660031901126102045760043561094781610209565b801561097557673ec412a9852d173d60c11b601c52600052602063ffffffff601c600c205416604051908152f35b638f4eb6046000526004601cfd5b34610204576000806003193601126103db5761099d611510565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b34610204576000366003190112610204576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461020457600036600319011261020457610a3f611510565b6004805460ff19169055005b3461020457604036600319011261020457600435610a6881610209565b602435610a73611510565b6127108111610ad457600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b604051636dac6a0960e01b8152600490fd5b34610204576000366003190112610204576002546040516001600160a01b039091168152602090f35b34610204576000806003193601126103db57604051908060065490610b3382610ecc565b808552916020916001918281169081156103ae5750600114610b5f576103528661034681880382610759565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610ba4575050505081016020016103468261035238610336565b8054868601840152938201938101610b87565b3461020457600036600319011261020457602060ff600454166040519015158152f35b3461020457610be83661021a565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261020457600435610c5181610209565b60243590610c5e82610209565b6044356064359267ffffffffffffffff808511610204573660238601121561020457846004013590811161020457366024828701011161020457610ca3838386610f81565b813b610cab57005b6106c094610cbd916024369201610780565b926116a3565b34610204576020366003190112610204576103526103466004356112f1565b34610204576000806003193601126103db57338152600360205260ff604082205416156106495733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b346102045760403660031901126102045767ffffffffffffffff60043560243582811161020457610d7a9036906004016104f9565b9190610d84611510565b60005b838110610d9057005b8060051b820135601e19833603018112156102045782019081359186831161020457602001823603811361020457600192610de791610de2610dd28589611435565b6000526009602052604060002090565b611442565b01610d87565b3461020457604036600319011261020457600435610e0a81610209565b602435610e1681610209565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461020457602036600319011261020457600435610e5781610209565b610e5f611510565b6001600160a01b03908116908115610eb357600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c92168015610efc575b6020831014610ee657565b634e487b7160e01b600052602260045260246000fd5b91607f1691610edb565b634e487b7160e01b600052603260045260246000fd5b91908110156106375760051b81013590603e1981360301821215610204570190565b903590601e1981360301821215610204570180359067ffffffffffffffff821161020457602001918160051b3603831361020457565b35610f7e81610209565b90565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b0395861695948516948116808614810215611071575084845283826001018054803314883314171561104f575b611047575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff83168602156110335750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b558338610fdc565b9091506030600c20541561106557908591610fd7565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156110d0578281029281840414901517156110cb576001546001600160a01b031691612710900490565b611085565b50600091508190565b601f81116110e5575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c83019410611141575b601f0160051c01915b82811061113657505050565b81815560010161112a565b9092508290611121565b90601f811161115957505050565b6000916000526020600020906020601f850160051c83019410611197575b601f0160051c01915b82811061118c57505050565b818155600101611180565b9092508290611177565b6000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b031690811561043057565b600754600092916111df82610ecc565b9160019081811690811561124b57506001146111fa57505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b848310611238575050500190565b818160209254858701520192019161122a565b60ff191683525050811515909102019150565b6008546000929161126e82610ecc565b9160019081811690811561124b575060011461128957505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b8483106112c7575050500190565b81816020925485870152019201916112b9565b906112ed602092828151948592016102a6565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b156114235760008181526020906009825261132f6040822054610ecc565b6113705750610f7e9061136261135d61134a61135795611738565b60405195869485016111cf565b906112da565b61125e565b03601f198101835282610759565b91611385906000526009602052604060002090565b6040519283918181549061139882610ecc565b808652926001928084169081156113ff57506001146113c2575b50505050610f7e92500382610759565b815285812095935091905b8183106113e7575050610f7e9350820101388080806113b2565b855487840185015294850194869450918301916113cd565b9350505050610f7e94925060ff191682840152151560051b820101388080806113b2565b60405163677510db60e11b8152600490fd5b919082018092116110cb57565b90929167ffffffffffffffff811161077b57611468816114628454610ecc565b8461114b565b6000601f82116001146114a857819061149993949560009261149d5750508160011b916000199060031b1c19161790565b9055565b01359050388061084e565b601f198216946114bd84600052602060002090565b91805b8781106114f85750836001959697106114de575b505050811b019055565b0135600019600384901b60f8161c191690553880806114d4565b909260206001819286860135815501940191016114c0565b6002546001600160a01b0316330361152457565b60405163118cdaa760e01b8152336004820152602490fd5b611545816111a1565b506000818152673ec412a9852d173d60c11b601c52602081208201820180546001600160a01b038116919082156115f9578290818552848360010180548015600117156115d2575b6115ca575b5050189055601c600c2080546000190190557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b558438611592565b91509192506030600c2054156115ec57849291869161158d565b634b6e7f1886526004601cfd5b63ceea21b684526004601cfd5b6000828152673ec412a9852d173d60c11b601c52602081208301830180546001600160a01b039390931692606081901b6116965783179055818152601c600c2060018154019063ffffffff821684021561168157557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea841560021b526004601cfd5b63c991cbb183526004601cfd5b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152611724575b505001906000601c8401915af115611715575b5163757a42ff60e11b0161170757565b63d1a57ed66000526004601cfd5b3d156116f7573d6000823e3d90fd5b818760c08801920160045afa5080386116e4565b90604051608081019260a0820160405260008452925b6000190192600a90603082820601855304928361174e57809350608091030191601f190191825256fea2646970667358221220c43a099d2ad9fd571d3e60294182c194354bc2b30ee9f2f6c1777fdd4be6d40164736f6c63430008190033604060a081523461068d576123b48038038061001a81610692565b928339810160e08282031261068d57610032826106cd565b60208084015190936001600160401b039390929184811161068d57816100599185016106e1565b918684015185811161068d57826100719186016106e1565b606085015186811161068d57836100899187016106e1565b9260808601519087821161068d576100a29187016106e1565b9260c06100b160a088016106cd565b960151612710811161067c57600180546001600160a01b039889166001600160a01b03199182168117835560008481558d519182528c8201949094529198929594939290917f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb6908d90a13315610664576002549133908316176002553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08680a36004928760ff19855416178455608052855191888311610494576005928354978989811c9916801561065a575b8c8a10146105645781908c601f9a8b811161060b575b50508c908a831160011461059f578892610594575b5050600019600383901b1c191690891b1783555b805190898211610581576006548981811c91168015610577575b8c82101461056457908b828a859411610514575b50508b908983116001146104b25787926104a7575b5050600019600383901b1c191690881b176006555b805190888211610494576007548881811c9116801561048a575b8b8210146104775790818884931161042a575b508a908883116001146103c85786926103bd575b5050600019600383901b1c191690871b176007555b83519687116103aa57600854918683811c931680156103a0575b8984101461038d575084821161034b575b5050859285116001146102e75793945084929190836102dc575b50501b916000199060031b1c1916176008555b51611c67908161074d823960805181610ade0152f35b0151925038806102b3565b6008815285812093958591601f198316915b888383106103315750505010610318575b505050811b016008556102c6565b015160001960f88460031b161c1916905538808061030a565b8587015188559096019594850194879350908101906102f9565b600883528783209085808901821c8301938a8a10610384575b01901c019085905b8281106103795750610299565b83815501859061036c565b93508293610364565b634e487b7160e01b845260229052602483fd5b92607f1692610288565b634e487b7160e01b835260418252602483fd5b015190503880610259565b600787528b87208a94509190601f198416888e5b82821061041357505084116103fa575b505050811b0160075561026e565b015160001960f88460031b161c191690553880806103ec565b8385015186558d979095019493840193018e6103dc565b909150600786528a862088808501861c8201928d861061046e575b918b918695949301871c01915b828110610460575050610245565b8881558594508b9101610452565b92508192610445565b634e487b7160e01b865260228552602486fd5b90607f1690610232565b634e487b7160e01b855260418452602485fd5b015190503880610203565b600688528c88208b94509190601f198416898f5b8282106104fd57505084116104e4575b505050811b01600655610218565b015160001960f88460031b161c191690553880806104d6565b8385015186558e979095019493840193018f6104c6565b90919250600688528982892091818601881c830193861061055b575b918c918695949301881c01915b82811061054d57508d91506101ee565b8981558594508c910161053d565b92508192610530565b634e487b7160e01b875260228652602487fd5b90607f16906101da565b634e487b7160e01b865260418552602486fd5b0151905038806101ac565b8b9350908d91601f198416888b52838b20938b905b8282106105ea57505084116105d1575b505050811b0183556101c0565b015160001960f88460031b161c191690553880806105c4565b91929395968291958786015181550195019301908f918e96959493926105b4565b909192508689528a828a2091818601891c8301938610610651575b918d918695949301891c01915b82811061064357508e9150610197565b8a81558594508d9101610633565b92508192610626565b98607f1698610181565b8b51631e4fbdf760e01b815260048101879052602490fd5b8951636dac6a0960e01b8152600490fd5b600080fd5b6040519190601f01601f191682016001600160401b038111838210176106b757604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361068d57565b919080601f8401121561068d5782516001600160401b0381116106b757602090610713601f8201601f19168301610692565b9281845282828701011161068d5760005b81811061073957508260009394955001015290565b858101830151848201840152820161072456fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101e7578063058260d7146101e257806306fdde03146101dd578063081812fc146101d8578063095ea7b3146101d357806315ff80a0146101ce57806318160ddd146101c957806323b872dd146101c45780632a55205a146101bf5780632f745c59146101ba57806342842e0e146101b55780634f6ccce7146101b057806355f804b3146101ab5780636352211e146101a657806370a08231146101a1578063715018a61461019c57806383a131001461019757806387491c60146101925780638c7ea24b1461018d5780638da5cb5b1461018857806395d89b41146101835780639fd6db121461017e578063a22cb46514610179578063b88d4fde14610174578063c87b56dd1461016f578063dc6c34d51461016a578063e026f63414610165578063e985e9c5146101605763f2fde38b1461015b57600080fd5b610f21565b610ed4565b610e2c565b610dc9565b610daa565b610d20565b610cc1565b610c9e565b610bf6565b610bcd565b610b32565b610b0d565b610ac8565b610a6a565b610a3b565b610a0b565b6108d8565b6107ff565b6107b2565b610752565b610719565b610705565b6106bb565b610563565b610477565b610417565b61032e565b61027b565b3461023d57602036600319011261023d576004356001600160e01b03198116810361023d5760209060e01c6040519063780e9d638114906380ac58cd8114906301ffc9a7632a55205a8214911417171715158152f35b600080fd5b6001600160a01b0381160361023d57565b604090600319011261023d5760043561026b81610242565b90602435801515810361023d5790565b3461023d5761028936610253565b906102926116ba565b60018060a01b03166000918183526003602052604083209060ff8019835416911515161790557ffeb4923949bd61afe4bcb7aa489d3c1f1cca2165debd87a41f64cd1361c9353f8280a280f35b60005b8381106102f25750506000910152565b81810151838201526020016102e2565b6040916020825261032281518092816020860152602086860191016102df565b601f01601f1916010190565b3461023d576000806003193601126104145760405190806005549061035282610fb3565b808552916020916001918281169081156103e7575060011461038f575b61038b8661037f8188038261086f565b60405191829182610302565b0390f35b9350600584527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b8385106103d45750505050810160200161037f8261038b3861036f565b80548686018401529382019381016103b7565b905086955061038b9693506020925061037f94915060ff191682840152151560051b82010192933861036f565b80fd5b3461023d57602036600319011261023d576004356000818152673ec412a9852d173d60c11b601c5260209020810101805460601b1561046957600101546040516001600160a01b039091168152602090f35b63ceea21b66000526004601cfd5b604036600319011261023d5760043561048f81610242565b6024356000818152673ec412a9852d173d60c11b3317601c526020812082018201805491936001600160a01b03908116921690811561052557829082331433151715610501575b600101557f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258480a480f35b90508185526030600c2054156105185782906104d6565b634b6e7f1885526004601cfd5b63ceea21b685526004601cfd5b9181601f8401121561023d5782359167ffffffffffffffff831161023d576020808501948460051b01011161023d57565b3461023d5760208060031936011261023d5760043567ffffffffffffffff811161023d57610595903690600401610532565b909160ff60045416156106a957600092338452600360205260ff6040852054161580610694575b6106825783905b8382106105ce578480f35b90919293805b6105eb6105e2858886611003565b86810190611025565b9050811015610675576106026105e2858886611003565b82919210156106705761065c6001928260051b013561063f8180600052673ec412a9852d173d60c11b601c5260206000208101015460601b151590565b610662575b610657610652888b89611003565b61105b565b6117b8565b016105d4565b61066b816116e6565b610644565b610fed565b50939291600101906105c3565b604051633e34a41b60e21b8152600490fd5b506002546001600160a01b03163314156105bc565b60405163589ed34b60e01b8152600490fd5b3461023d57600036600319011261023d576020600a54604051908152f35b606090600319011261023d576004356106f181610242565b906024356106fe81610242565b9060443590565b610717610711366106d9565b91611068565b005b3461023d57604036600319011261023d5761073560243561118d565b604080516001600160a01b03939093168352602083019190915290f35b3461023d57604036600319011261023d5760043561076f81610242565b6024359061078661077f82611344565b83106111cb565b60018060a01b0316600052600c6020526040600020906000526020526020604060002054604051908152f35b6107bb366106d9565b6107c6818385611068565b813b6107ce57005b60405191602083019383851067ffffffffffffffff8611176107fa5761071794604052600084526119b2565b610859565b3461023d57602036600319011261023d57600435600a548110610821816111cb565b1561067057602090600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80154604051908152f35b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176107fa57604052565b92919267ffffffffffffffff82116107fa57604051916108bb601f8201601f19166020018461086f565b82948184528183011161023d578281602093846000960137010152565b3461023d5760208060031936011261023d5767ffffffffffffffff60043581811161023d573660238201121561023d5761091c903690602481600401359101610891565b916109256116ba565b82519182116107fa576109428261093d600754610fb3565b61124e565b602090601f83116001146109845750819061097493600092610979575b50508160011b916000199060031b1c19161790565b600755005b01519050388061095f565b90601f198316936109b760076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68890565b926000905b8682106109f357505083600195106109da575b505050811b01600755005b015160001960f88460031b161c191690553880806109cf565b806001859682949686015181550195019301906109bc565b3461023d57602036600319011261023d576020610a29600435611316565b6040516001600160a01b039091168152f35b3461023d57602036600319011261023d576020610a62600435610a5d81610242565b611344565b604051908152f35b3461023d5760008060031936011261041457610a846116ba565b600280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b3461023d57600036600319011261023d576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461023d57600036600319011261023d57610b266116ba565b6004805460ff19169055005b3461023d57604036600319011261023d57600435610b4f81610242565b602435610b5a6116ba565b6127108111610bbb57600180546001600160a01b0319166001600160a01b0393909316928317905560008190556040805192835260208301919091527f908669f35f6fb3977a956ba70597841fe541d1e8491ca3c025161e258d3bfdb691a1005b604051636dac6a0960e01b8152600490fd5b3461023d57600036600319011261023d576002546040516001600160a01b039091168152602090f35b3461023d5760008060031936011261041457604051908060065490610c1a82610fb3565b808552916020916001918281169081156103e75750600114610c465761038b8661037f8188038261086f565b9350600684527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510610c8b5750505050810160200161037f8261038b3861036f565b8054868601840152938201938101610c6e565b3461023d57600036600319011261023d57602060ff600454166040519015158152f35b3461023d57610ccf36610253565b151581601c52670a5a2e7a0000000060085233600052806030600c205560005260018060a01b0316337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206000a3005b608036600319011261023d57600435610d3881610242565b60243590610d4582610242565b6044356064359267ffffffffffffffff80851161023d573660238601121561023d57846004013590811161023d57366024828701011161023d57610d8a838386611068565b813b610d9257005b61071794610da4916024369201610891565b926119b2565b3461023d57602036600319011261023d5761038b61037f60043561149b565b3461023d5760008060031936011261041457338152600360205260ff604082205416156106825733808252600360205260408220805460ff191690557fbc74bff95226a050e21d53e829339d080fc74c0cacda3909936a18acf42d784e8280a280f35b3461023d57604036600319011261023d5767ffffffffffffffff60043560243582811161023d57610e61903690600401610532565b9190610e6b6116ba565b60005b838110610e7757005b8060051b820135601e198336030181121561023d5782019081359186831161023d57602001823603811361023d57600192610ece91610ec9610eb985896115df565b6000526009602052604060002090565b6115ec565b01610e6e565b3461023d57604036600319011261023d57600435610ef181610242565b602435610efd81610242565b601c52670a5a2e7a0000000060085260005260206030600c20546040519015158152f35b3461023d57602036600319011261023d57600435610f3e81610242565b610f466116ba565b6001600160a01b03908116908115610f9a57600254826bffffffffffffffffffffffff60a01b821617600255167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b90600182811c92168015610fe3575b6020831014610fcd57565b634e487b7160e01b600052602260045260246000fd5b91607f1691610fc2565b634e487b7160e01b600052603260045260246000fd5b91908110156106705760051b81013590603e198136030182121561023d570190565b903590601e198136030182121561023d570180359067ffffffffffffffff821161023d57602001918160051b3603831361023d57565b3561106581610242565b90565b90611074838284611928565b6000838152673ec412a9852d173d60c11b3317601c908152602082208501850180546001600160a01b039485169585169481168086148102156111635750848452838260010180548033148833141715611141575b611139575b505085851818905580600c20600019815401905583825280600c2060018154019163ffffffff83168602156111255750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080a4565b60049067ea553b3401336cea871560021b52fd5b5583386110ce565b9091506030600c205415611157579085916110c9565b600485634b6e7f188852fd5b8367ceea21b6a11481006004921560021b52fd5b634e487b7160e01b600052601160045260246000fd5b906000549182156111c2578281029281840414901517156111bd576001546001600160a01b031691612710900490565b611177565b50600091508190565b156111d257565b60405162461bcd60e51b815260206004820152601f60248201527f455243373231456e756d657261626c653a20494e56414c49445f494e444558006044820152606490fd5b600a5481101561067057600a6000527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80190600090565b601f811161125a575050565b60009060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906020601f850160051c830194106112b6575b601f0160051c01915b8281106112ab57505050565b81815560010161129f565b9092508290611296565b90601f81116112ce57505050565b6000916000526020600020906020601f850160051c8301941061130c575b601f0160051c01915b82811061130157505050565b8181556001016112f5565b90925082906112ec565b6000818152673ec412a9852d173d60c11b601c5260209020810101546001600160a01b031690811561046957565b801561136b57673ec412a9852d173d60c11b601c5260005263ffffffff601c600c20541690565b638f4eb6046000526004601cfd5b6007546000929161138982610fb3565b916001908181169081156113f557506001146113a457505050565b909192935060076000527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688906000915b8483106113e2575050500190565b81816020925485870152019201916113d4565b60ff191683525050811515909102019150565b6008546000929161141882610fb3565b916001908181169081156113f5575060011461143357505050565b909192935060086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3906000915b848310611471575050500190565b8181602092548587015201920191611463565b90611497602092828151948592016102df565b0190565b6000818152673ec412a9852d173d60c11b601c5260209020810181015460601b156115cd576000818152602090600982526114d96040822054610fb3565b61151a57506110659061150c6115076114f461150195611a47565b6040519586948501611379565b90611484565b611408565b03601f19810183528261086f565b9161152f906000526009602052604060002090565b6040519283918181549061154282610fb3565b808652926001928084169081156115a9575060011461156c575b505050506110659250038261086f565b815285812095935091905b81831061159157505061106593508201013880808061155c565b85548784018501529485019486945091830191611577565b935050505061106594925060ff191682840152151560051b8201013880808061155c565b60405163677510db60e11b8152600490fd5b919082018092116111bd57565b90929167ffffffffffffffff81116107fa576116128161160c8454610fb3565b846112c0565b6000601f82116001146116525781906116439394956000926116475750508160011b916000199060031b1c19161790565b9055565b01359050388061095f565b601f1982169461166784600052602060002090565b91805b8781106116a2575083600195969710611688575b505050811b019055565b0135600019600384901b60f8161c1916905538808061167e565b9092602060018192868601358155019401910161166a565b6002546001600160a01b031633036116ce57565b60405163118cdaa760e01b8152336004820152602490fd5b6116f8816116f381611316565b6118bf565b6000818152673ec412a9852d173d60c11b601c52602081208201820180546001600160a01b038116919082156117ab57829081855284836001018054801560011715611784575b61177c575b5050189055601c600c2080546000190190557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b558438611744565b91509192506030600c20541561179e57849291869161173f565b634b6e7f1886526004601cfd5b63ceea21b684526004601cfd5b600a54600090838252600b602052806040832055600160401b8110156107fa57836117ec8260016118059401600a55611217565b90919082549060031b91821b91600019901b1916179055565b6001600160a01b0382169182159081156118275761182285611b53565b61136b565b8461183191611b1b565b838252673ec412a9852d173d60c11b601c5260208220840184018054606081901b6118b25784179055828252601c600c2060018154019163ffffffff831685021561189e5750557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b67ea553b3401336cea9060021b526004601cfd5b63c991cbb184526004601cfd5b906001600160a01b03821661191557600a549181600052600b60205282604060002055600160401b8310156107fa57611905826117ec8560016119139701600a55611217565b61190e82611b53565b611a86565b565b816119238261191394611a86565b611905565b9091906001600160a01b03808216908161199a57600a5484600052600b60205280604060002055600160401b8110156107fa57846117ec82600161196f9401600a55611217565b841680611986575050611913925061190e82611b53565b039050611991575050565b61191391611b1b565b848116821461196f576119ad8484611a86565b61196f565b9060a46020939460405195869463150b7a028652338787015260018060a01b03166040860152606085015260808085015280518091818060a0880152611a33575b505001906000601c8401915af115611a24575b5163757a42ff60e11b01611a1657565b63d1a57ed66000526004601cfd5b3d15611a06573d6000823e3d90fd5b818760c08801920160045afa5080386119f3565b90604051608081019260a0820160405260008452925b6000190192600a906030828206018553049283611a5d57809350608091030191601f1901918252565b611a8f81611344565b60001981019081116111bd57611adf926000938185928352600d60205260408320549460018060a01b03168352600c6020526040832094848103611aec575b50600052600d602052604060002090565b5582526020526040812055565b84845285602052611b146040852054828652806040872055600052600d602052604060002090565b5538611ace565b604090611b2781611344565b9260009160018060a01b03168252600c60205282822084835260205280838320558152600d6020522055565b600a8054600019928382018281116111bd57600092828452600b602052806040852054921015610670578484527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a7928382015491831015610670578492611bef611c009388865280837fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155600052600b602052604060002090565b55600052600b602052604060002090565b558254938415611c1d578401938085101561067057838352015555565b634e487b7160e01b83526031600452602483fdfea2646970667358221220711cd2097b25c025a3f9a34445b1ba6f2b22c54d617dacda742e1aef08eb7a7564736f6c63430008190033a2646970667358221220217cdd7203c2c869fcf61c21415c58818bd6d9e7d8a9f46298f20d41eeec2fe464736f6c63430008190033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.