Feature Tip: Add private address tag to any address under My Name Tag !
ERC-1155
Overview
Max Total Supply
1
Holders
1
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
EventNFT
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./AIBOLT.sol"; import "./IEventNFT.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract EventNFT is ERC1155, Ownable, IEventNFT { using Counters for Counters.Counter; Counters.Counter private _tokenIdTracker; uint256 public constant MAX_PLANETS = 3; mapping(uint256 => Event) private _events; constructor(string memory uri) ERC1155(uri) {} function mintEvent( EventParams memory params ) public onlyOwner returns (uint256) { uint256 newEventId = _tokenIdTracker.current(); _events[newEventId] = Event( params.name, params.bottomSvg, params.topSvg, params.planet1, params.planet1Svg, params.planet2, params.planet2Svg, params.planet3, params.planet3Svg, params.sun, params.sunSvg, params.numPlanets ); _mint(msg.sender, newEventId, 1, ""); _tokenIdTracker.increment(); return newEventId; } function getEvent(uint256 eventId) public view returns (Event memory) { return _events[eventId]; } function addTokenEventToAIBOLT( address aiboltContract, uint16 aiboltId, uint256 eventId ) public { // Ensure the caller owns the EventNFT require( balanceOf(msg.sender, eventId) > 0, "Caller must own the EventNFT" ); // Here you'll want to interface with the AIBOLT contract and call its private 'addTokenEvent' method // This will depend on how you've implemented the AIBOLT contract AIBOLT(aiboltContract).addTokenEvent(aiboltId, eventId, msg.sender); // Burn the EventNFT after the event has been added _burn(msg.sender, eventId, 1); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Strings.sol"; library OrbitProxy { // AIORBIT Contract Used To Forge AIBOLT (This Contract) struct CommonValues { uint256 hue; uint256 rotationSpeed; uint256 numCircles; uint256[] radius; uint256[] distance; uint256[] strokeWidth; } function generateAIORBITTraits( uint256 _tokenId ) public pure returns (CommonValues memory) { uint256 hue = uint256(keccak256(abi.encodePacked(_tokenId, "hue"))) % 360; uint256 rotationSpeed = (uint256( keccak256(abi.encodePacked(_tokenId, "rotationSpeed")) ) % 11) + 5; uint256 numCircles = (uint256( keccak256(abi.encodePacked(_tokenId, "numCircles")) ) % 3) + 3; uint256[] memory radius = new uint256[](numCircles); uint256[] memory distance = new uint256[](numCircles); uint256[] memory strokeWidth = new uint256[](numCircles); for (uint256 i = 0; i < numCircles; i++) { radius[i] = (uint256(keccak256(abi.encodePacked(_tokenId, "radius", i))) % 40) + 20; distance[i] = (uint256(keccak256(abi.encodePacked(_tokenId, "distance", i))) % 80) + 40; strokeWidth[i] = (uint256( keccak256(abi.encodePacked(_tokenId, "strokeWidth", i)) ) % 16) + 5; } return CommonValues( hue, rotationSpeed, numCircles, radius, distance, strokeWidth ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEventNFT { struct Event { string name; string bottomSvg; string topSvg; string planet1; string planet1Svg; string planet2; string planet2Svg; string planet3; string planet3Svg; string sun; string sunSvg; uint256 numPlanets; } struct EventParams { string name; string bottomSvg; string topSvg; string planet1; string planet1Svg; string planet2; string planet2Svg; string planet3; string planet3Svg; string sun; string sunSvg; uint256 numPlanets; } function getEvent(uint256 eventId) external view returns (Event memory); }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721A { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - 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 tokenId, bytes calldata data ) external payable; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external payable; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./IERC721A.sol"; import "operator-filter-registry/src/DefaultOperatorFilterer.sol"; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is IERC721A, DefaultOperatorFilterer { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 private _currentIndex; // The number of tokens burned. uint256 private _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) private _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) private _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => TokenApprovalRef) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // ============================================================= // CONSTRUCTOR // ============================================================= constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return _currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return _burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf( address owner ) public view virtual override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(_packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = _packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); _packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface( bytes4 interfaceId ) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI( uint256 tokenId ) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, toString(tokenId))) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf( uint256 tokenId ) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf( uint256 tokenId ) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt( uint256 index ) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf( uint256 tokenId ) private view returns (uint256) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < _currentIndex) { uint256 packed = _packedOwnerships[curr]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `curr` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. while (packed == 0) { packed = _packedOwnerships[--curr]; } return packed; } } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership( uint256 packed ) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData( address owner, uint256 flags ) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or( owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags) ) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag( uint256 quantity ) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve( address to, uint256 tokenId ) public payable virtual override onlyAllowedOperator(to) { address owner = ownerOf(tokenId); if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } _tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved( uint256 tokenId ) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll( address operator, bool approved ) public virtual override onlyAllowedOperatorApproval(operator) { _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll( address owner, address operator ) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && // If within bounds, _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress( uint256 tokenId ) private view returns (uint256 approvedAddressSlot, address approvedAddress) { TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public payable virtual override onlyAllowedOperator(from) { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); ( uint256 approvedAddressSlot, address approvedAddress ) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if ( !_isSenderApprovedOrOwner( approvedAddress, from, _msgSenderERC721A() ) ) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public payable virtual override onlyAllowedOperator(from) { safeTransferFrom(from, to, tokenId, ""); } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * - 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 tokenId, bytes memory _data ) public payable virtual override onlyAllowedOperator(from) { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721Receiver(to).onERC721Received( _msgSenderERC721A(), from, tokenId, _data ) returns (bytes4 retval) { return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) // The `iszero(eq(,))` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. // The compiler will optimize the `iszero` away for performance. for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); _currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = _currentIndex; uint256 index = end - quantity; do { if ( !_checkContractOnERC721Received( address(0), to, index++, _data ) ) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (_currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ""); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); ( uint256 approvedAddressSlot, address approvedAddress ) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if ( !_isSenderApprovedOrOwner( approvedAddress, from, _msgSenderERC721A() ) ) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function toString( uint256 value ) internal pure virtual returns (string memory str) { 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. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Strings.sol"; import "./IEventNFT.sol"; import "./OrbitProxy.sol"; library BoltLib { uint256 public constant MAX_PLANETS = 3; struct AIBOLTData { string sun; string sunSvg; uint256 numPlanets; Planet[MAX_PLANETS] planets; } struct Planet { OrbitSpeed orbitSpeed; PlanetSize size; string theme; string svg; } enum OrbitSpeed { Crawl, Cruise, Dash } enum PlanetSize { Speck, Globe, Titan } function generateAIBOLTData( uint16[5] memory _tokenIds ) public pure returns (AIBOLTData memory) { uint256 totalHue = 0; uint256 totalRotationSpeed = 0; uint256 totalNumCircles = 0; uint256[] memory totalRadius = new uint256[](5); uint256[] memory totalDistance = new uint256[](5); uint256[] memory totalStrokeWidth = new uint256[](5); for (uint256 j = 0; j < 5; j++) { OrbitProxy.CommonValues memory commonValues = OrbitProxy .generateAIORBITTraits(_tokenIds[j]); totalHue += commonValues.hue; totalRotationSpeed += commonValues.rotationSpeed; totalNumCircles += commonValues.numCircles; for (uint256 i = 0; i < commonValues.numCircles; i++) { totalRadius[i] += commonValues.radius[i]; totalDistance[i] += commonValues.distance[i]; totalStrokeWidth[i] += commonValues.strokeWidth[i]; } } OrbitProxy.CommonValues memory averagedValues = OrbitProxy.CommonValues( totalHue / 5, totalRotationSpeed / 5, totalNumCircles / 5, new uint256[](5), new uint256[](5), new uint256[](5) ); for (uint256 i = 0; i < averagedValues.numCircles; i++) { averagedValues.radius[i] = totalRadius[i] / 5; averagedValues.distance[i] = totalDistance[i] / 5; averagedValues.strokeWidth[i] = totalStrokeWidth[i] / 5; } uint256 numPlanets; if (averagedValues.numCircles >= 1 && averagedValues.numCircles <= 3) { numPlanets = 1; } else if ( averagedValues.numCircles > 3 && averagedValues.numCircles <= 4 ) { numPlanets = 2; } else if ( averagedValues.numCircles > 4 && averagedValues.numCircles <= 5 ) { numPlanets = 3; } uint256[3] memory planetBiomes; // Set range for hue uint256 hue_start = 0; uint256 hue_end = 359; // Set range for planetBiomes uint256 biome_start = 0; uint256 biome_end = 5; for (uint256 i = 0; i < 3; i++) { // Add an offset to the hue for each planet uint256 hue = (averagedValues.hue + i * 60) % 360; // Scale hue to biome uint256 biome = ((hue - hue_start) * (biome_end - biome_start)) / (hue_end - hue_start) + biome_start; // Ensure biome is within valid range and convert it to an integer planetBiomes[i] = biome > biome_end ? biome_end : (biome < biome_start ? biome_start : uint256(biome)); } Planet[MAX_PLANETS] memory planets = generatePlanetData( averagedValues, numPlanets, planetBiomes ); // Default sun values string memory sun = [ "Pulsar", "Red-Giant", "White-Dwarf", "Neutron-Star" ][averagedValues.hue % 4]; return AIBOLTData(sun, "", numPlanets, planets); } function generatePlanetData( OrbitProxy.CommonValues memory averagedValues, uint256 numPlanets, uint256[3] memory planetBiomes ) public pure returns (Planet[MAX_PLANETS] memory) { Planet[MAX_PLANETS] memory planets; // Set range for rotationSpeed uint256 rotationSpeed_start = 5; uint256 rotationSpeed_end = 15; // Set range for orbitSpeed uint256 orbitSpeed_start = 0; uint256 orbitSpeed_end = 2; for (uint256 i = 0; i < numPlanets; i++) { // Scale rotationSpeed to orbitSpeed uint256 orbitSpeed = ((averagedValues.rotationSpeed - rotationSpeed_start) * (orbitSpeed_end - orbitSpeed_start)) / (rotationSpeed_end - rotationSpeed_start) + orbitSpeed_start; // Ensure orbitSpeed is within valid range orbitSpeed = orbitSpeed > orbitSpeed_end ? orbitSpeed_end : ( orbitSpeed < orbitSpeed_start ? orbitSpeed_start : orbitSpeed ); PlanetSize size = PlanetSize(averagedValues.radius[i] % numPlanets); string memory theme = [ "Habitable", "Gas-Giant", "Ice-Giant", "Artificial", "Terraformed" ][planetBiomes[i]]; planets[i] = Planet(OrbitSpeed(orbitSpeed), size, theme, ""); } return planets; } function generateTraits( AIBOLTData memory data, uint256[] memory tokenEvents, IEventNFT eventNFT ) public view returns (string memory) { string memory traits = "["; if (tokenEvents.length != 0) { traits = string( abi.encodePacked( traits, '{ "trait_type": "Sun", "value": "', data.sun, '" }' ) ); for (uint256 i = 0; i < data.numPlanets; i++) { traits = string( abi.encodePacked( traits, ',{ "trait_type": "Planet #', Strings.toString(i + 1), '", "value": "', data.planets[i].theme, '" }' ) ); } for (uint256 i = data.numPlanets; i < MAX_PLANETS; i++) { traits = string( abi.encodePacked( traits, ',{ "trait_type": "Planet #', Strings.toString(i + 1), '", "value": "Non-Existent" }' ) ); } traits = string( abi.encodePacked( traits, ',{ "trait_type": "Speed", "value": "', getOrbitSpeed(getAverageOrbitSpeed(data.planets)), '" },', '{ "trait_type": "Size", "value": "', getPlanetSize( getAveragePlanetSize(data.planets, data.numPlanets) ), '" }' ) ); } for (uint256 i = 0; i < tokenEvents.length; i++) { string memory eventName = ""; if (i == 0 || tokenEvents[i] == 1) { eventName = "Inception"; } else { eventName = eventNFT.getEvent(tokenEvents[i]).name; } traits = string( abi.encodePacked( traits, i == 0 && keccak256(abi.encodePacked((traits))) == keccak256(abi.encodePacked(("["))) ? "" : ",", '{ "trait_type": "Event #', Strings.toString(i + 1), '", "value": "', eventName, '" }' ) ); } if (tokenEvents.length == 0) { traits = string( abi.encodePacked( traits, keccak256(abi.encodePacked((traits))) == keccak256(abi.encodePacked(("["))) ? "" : ",", '{ "trait_type": "Event #0", "value": "The Void" }' ) ); } traits = string(abi.encodePacked(traits, "]")); return traits; } function generateSVG( BoltLib.AIBOLTData memory data, uint256[] memory tokenEvents, IEventNFT eventNFT ) public view returns (string memory) { uint256 tokenEventLength = tokenEvents.length; string memory eventName = "The Void"; string memory eventSVGBottom = ""; string memory eventSVGTop = ""; uint256 latestTokenEventId = 0; if (tokenEventLength != 0) { latestTokenEventId = tokenEvents[tokenEventLength - 1]; } // Generate stars string memory starsSVG = ""; if (tokenEventLength != 0) { // Revealed for (uint256 i = 0; i < 50; i++) { starsSVG = string( abi.encodePacked(starsSVG, generateStar(block.timestamp, i)) ); } } if (tokenEventLength == 1 || latestTokenEventId == 1) { eventName = "Inception"; } else if (tokenEventLength > 1) { if (latestTokenEventId != 1) { // Event is Inception eventName = eventNFT.getEvent(latestTokenEventId).name; eventSVGBottom = eventNFT .getEvent(latestTokenEventId) .bottomSvg; eventSVGTop = eventNFT.getEvent(latestTokenEventId).topSvg; } } string memory planetsSVG = ""; for (uint256 i = 0; i < data.numPlanets; i++) { planetsSVG = string( abi.encodePacked(planetsSVG, getPlanetSVG(data.planets[i], i)) ); } string memory sunColor = getSunColor(data.sun); string memory svg = string( abi.encodePacked( '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 640 640" style="background-color: black;">', '<rect width="100%" height="100%" fill="#000" />', starsSVG, eventSVGBottom, '<g transform="translate(320,320)">' ) ); if (tokenEventLength == 0) { svg = string( abi.encodePacked( svg, '<circle cx="0" cy="0" r="0">', '<animate attributeName="r" values="0;800" dur="5s" repeatCount="indefinite" />', '<animate attributeName="opacity" values="0.3;0;0" dur="5s" repeatCount="indefinite" />', '<animate attributeName="fill" values="#FFFFFF; #EDE7F6; #D1C4E9; #FFFFFF;" dur="2s" repeatCount="indefinite" />', "</circle>" ) ); } if (bytes(data.sunSvg).length != 0) { svg = string(abi.encodePacked(svg, data.sunSvg)); } else { svg = string( abi.encodePacked( svg, '<circle r="40" className="sun">', '<animate attributeName="fill" values="', sunColor, '" dur="3s" repeatCount="indefinite"/>', "</circle>", '<g transform="translate(-40,-40) scale(0.08)" className="bolt"> <path d="M624 267.629L615.767 252L533.433 256.935L377 503.701L385.233 519.33H475.8L385.233 738.129L401.7 748L611.65 462.574L603.417 446.945H508.733L624 267.629Z" fill="black" stroke="black" stroke-width="25" stroke-linejoin="round" /> </g>' ) ); } if (tokenEventLength != 0) { svg = string(abi.encodePacked(svg, planetsSVG)); } svg = string( abi.encodePacked( svg, "</g>", eventSVGTop, '<text x="60" y="590" fill="white" font-family="Monospace" font-size="24" opacity="0">', "Event #", Strings.toString(tokenEventLength), ": ", eventName, '<animate attributeName="opacity" from="0" to="1" begin="1s" dur="2s" fill="freeze"/>', "</text>" "</svg>" ) ); return svg; } function getPlanetSVG( Planet memory planet, uint256 index ) public pure returns (string memory) { if (bytes(planet.svg).length != 0) { return string(abi.encodePacked(planet.svg)); } string memory color = getPlanetColor(planet.theme); // Adjust planet size based on size trait uint256 r; if (planet.size == PlanetSize.Speck) { r = 5 * 3; } else if (planet.size == PlanetSize.Globe) { r = 10 * 3; } else if (planet.size == PlanetSize.Titan) { r = 15 * 3; } uint256 cy = (index + 1) * 100; string memory orbitTrails = generateTrails(index, cy); string memory orbitDuration; string memory planetColorDuration; if (planet.orbitSpeed == OrbitSpeed.Crawl) { orbitDuration = "10"; planetColorDuration = "8s"; } else if (planet.orbitSpeed == OrbitSpeed.Cruise) { orbitDuration = "7"; planetColorDuration = "5s"; } else if (planet.orbitSpeed == OrbitSpeed.Dash) { orbitDuration = "4"; planetColorDuration = "3s"; } return string( abi.encodePacked( "<g>", orbitTrails, '<circle cx="0" cy="-', Strings.toString(cy), '" r="', Strings.toString(r), '" className="planet', Strings.toString(index), '">', '<animate attributeName="fill" dur="', planetColorDuration, '" repeatCount="indefinite" values="', color, '"/></circle>', '<animateTransform attributeName="transform" type="rotate" from="0" to="360" dur="', orbitDuration, 's" repeatCount="indefinite"/>', "</g>" ) ); } function generateTrails( uint256 index, uint256 cy ) public pure returns (string memory) { string memory begin; string memory values; if (index == 0) { begin = "0s"; values = "1;0;0;1"; } else if (index == 1) { begin = "2s"; values = "0;1;0;0"; } else if (index == 2) { begin = "4s"; values = "0;0;1;0"; } return string( abi.encodePacked( '<circle cx="0" cy="0" r="', Strings.toString(cy), '" className="trail', Strings.toString(index), '" stroke="gray" fill="transparent" stroke-opacity="0">', '<animate attributeName="stroke-opacity" values="', values, '" dur="6s" repeatCount="indefinite" begin="', begin, '"/>', "</circle>" ) ); } function getAverageOrbitSpeed( Planet[MAX_PLANETS] memory planets ) private pure returns (OrbitSpeed) { uint256 total = 0; for (uint256 i = 0; i < planets.length; i++) { if (planets[i].orbitSpeed == OrbitSpeed.Crawl) { total += 10; } else if (planets[i].orbitSpeed == OrbitSpeed.Cruise) { total += 7; } else if (planets[i].orbitSpeed == OrbitSpeed.Dash) { total += 4; } } uint256 average = total / planets.length; if (average > 8) { return OrbitSpeed.Crawl; } else if (average > 6) { return OrbitSpeed.Cruise; } else { return OrbitSpeed.Dash; } } function getAveragePlanetSize( Planet[MAX_PLANETS] memory planets, uint256 numPlanets ) private pure returns (PlanetSize) { uint256 total = 0; for (uint256 i = 0; i < numPlanets; i++) { if (planets[i].size == PlanetSize.Speck) { total += 5 * 3; // Updated to 3x size } else if (planets[i].size == PlanetSize.Globe) { total += 10 * 3; // Updated to 3x size } else if (planets[i].size == PlanetSize.Titan) { total += 15 * 3; // Updated to 3x size } } uint256 average = total / numPlanets; if (average <= 5 * 3) { // Updated to 3x size return PlanetSize.Speck; } else if (average <= 10 * 3) { // Updated to 3x size return PlanetSize.Globe; } else { return PlanetSize.Titan; } } function getSunColor( string memory sun ) private pure returns (string memory sunColor) { if (Strings.equal(sun, "Pulsar")) { return "#808080; #A9A9A9; #C0C0C0; #808080"; // Shades of grey } else if (Strings.equal(sun, "Red-Giant")) { return "#FF4500; #FF6347; #FF7F50; #FF4500"; // Shades of orange-red } else if (Strings.equal(sun, "White-Dwarf")) { return "#FFFFFF; #F8F8FF; #F0F8FF; #FFFFFF"; // Shades of white } else if (Strings.equal(sun, "Neutron-Star")) { return "#2F4F4F; #708090; #778899; #2F4F4F"; // Shades of slate gray } } function getPlanetColor( string memory planet ) private pure returns (string memory planetColor) { if (Strings.equal(planet, "Habitable")) { return "#228B22; #006400; #8FBC8F; #228B22"; // Habitable: Shades of Green } else if (Strings.equal(planet, "Gas-Giant")) { return "#FFA500; #FF8C00; #FF7F50; #FFA500"; // Gas Giant: Shades of Orange } else if (Strings.equal(planet, "Ice-Giant")) { return "#00BFFF; #1E90FF; #4169E1; #00BFFF"; // Ice Giant: Shades of Blue } else if (Strings.equal(planet, "Artificial")) { return "#808080; #A9A9A9; #C0C0C0; #808080"; // Artificial: Shades of Grey } else if (Strings.equal(planet, "Terraformed")) { return "#FFFF00; #FFD700; #FFA500; #FFFF00"; // Terraformed: Shades of Yellow } } function getOrbitSpeed( OrbitSpeed _orbitSpeed ) private pure returns (string memory) { if (OrbitSpeed.Crawl == _orbitSpeed) { return "Crawl"; } else if (OrbitSpeed.Cruise == _orbitSpeed) { return "Cruise"; } else if (OrbitSpeed.Dash == _orbitSpeed) { return "Dash"; } return "Undefined"; } function getPlanetSize( PlanetSize _planetSize ) private pure returns (string memory) { if (PlanetSize.Speck == _planetSize) { return "Speck"; } else if (PlanetSize.Globe == _planetSize) { return "Globe"; } else if (PlanetSize.Titan == _planetSize) { return "Titan"; } return "Undefined"; } function generateStar( uint256 _seed, uint256 _index ) public pure returns (string memory) { uint256 posX = uint256( keccak256(abi.encodePacked(_seed, "starPosX", _index)) ) % 640; uint256 posY = uint256( keccak256(abi.encodePacked(_seed, "starPosY", _index)) ) % 640; // Full height now uint256 size = (uint256( keccak256(abi.encodePacked(_seed, "starSize", _index)) ) % 3) + 1; // Smaller stars uint256 duration = (uint256( keccak256(abi.encodePacked(_seed, "starDuration", _index)) ) % 4) + 1; return string( abi.encodePacked( '<circle cx="', Strings.toString(posX), '" cy="', Strings.toString(posY), '" r="', Strings.toString(size), '" fill="rgba(255,255,255,0.1)">', // Semi-transparent fill '<animate attributeName="r" values="', Strings.toString(size - 1), ";", Strings.toString(size), ";", Strings.toString(size - 1), '" dur="', Strings.toString(duration), 's" repeatCount="indefinite"/>', '<animate attributeName="fill" values="rgb(255,255,255);rgb(192,192,192);rgb(128,128,128);rgb(64,64,64);rgb(255,255,255)" dur="5s" repeatCount="indefinite"/>', "</circle>" ) ); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides functions for encoding/decoding base64 library Base64 { string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000" hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000" hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000" hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE_ENCODE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { // read 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // write 4 characters mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and( input, 0x3F)))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } function decode(string memory _data) internal pure returns (bytes memory) { bytes memory data = bytes(_data); if (data.length == 0) return new bytes(0); require(data.length % 4 == 0, "invalid base64 decoder input"); // load the table into memory bytes memory table = TABLE_DECODE; // every 4 characters represent 3 bytes uint256 decodedLen = (data.length / 4) * 3; // add some extra buffer at the end required for the writing bytes memory result = new bytes(decodedLen + 32); assembly { // padding with '=' let lastBytes := mload(add(data, mload(data))) if eq(and(lastBytes, 0xFF), 0x3d) { decodedLen := sub(decodedLen, 1) if eq(and(lastBytes, 0xFFFF), 0x3d3d) { decodedLen := sub(decodedLen, 1) } } // set the actual output length mstore(result, decodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 4 characters at a time for {} lt(dataPtr, endPtr) {} { // read 4 characters dataPtr := add(dataPtr, 4) let input := mload(dataPtr) // write 3 bytes let output := add( add( shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)), shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))), add( shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)), and(mload(add(tablePtr, and( input , 0xFF))), 0xFF) ) ) mstore(resultPtr, shl(232, output)) resultPtr := add(resultPtr, 3) } } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import { Base64 } from "./Base64.sol"; contract AIORBIT is ERC721, Ownable { using Counters for Counters.Counter; uint256 public constant MAX_TOKENS = 10000; uint256 public constant MAX_TOKENS_PER_WALLET = 10000; uint256 public constant ROYALTY_FEE_PERCENT = 5; bytes4 private constant _INTERFACE_ID_FEES = 0xb7799584; Counters.Counter private _totalTokensMinted; constructor(string memory name, string memory symbol) ERC721(name, symbol) {} struct CommonValues { uint256 hue; uint256 rotationSpeed; uint256 numCircles; uint256[] radius; uint256[] distance; uint256[] strokeWidth; } function _mint(uint256 _numTokens, address _to) internal { require(_totalTokensMinted.current() < MAX_TOKENS, "All tokens have been minted"); require(balanceOf(_to) + _numTokens <= MAX_TOKENS_PER_WALLET, "Cannot mint more tokens than allowed per wallet"); for (uint256 i = 0; i < _numTokens; i++) { uint256 tokenId = _totalTokensMinted.current() + 1; _safeMint(_to, tokenId); _totalTokensMinted.increment(); } } function mint(uint256 _numTokens, address _to) public { _mint(_numTokens, _to); } function royaltyInfo(uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount) { receiver = owner(); royaltyAmount = (_salePrice * ROYALTY_FEE_PERCENT) / 100; } function generateCommonValues(uint256 _tokenId) internal pure returns (CommonValues memory) { uint256 hue = uint256(keccak256(abi.encodePacked(_tokenId, "hue"))) % 360; uint256 rotationSpeed = uint256(keccak256(abi.encodePacked(_tokenId, "rotationSpeed"))) % 11 + 5; uint256 numCircles = uint256(keccak256(abi.encodePacked(_tokenId, "numCircles"))) % 3 + 3; uint256[] memory radius = new uint256[](numCircles); uint256[] memory distance = new uint256[](numCircles); uint256[] memory strokeWidth = new uint256[](numCircles); for (uint256 i = 0; i < numCircles; i++) { radius[i] = uint256(keccak256(abi.encodePacked(_tokenId, "radius", i))) % 40 + 20; distance[i] = uint256(keccak256(abi.encodePacked(_tokenId, "distance", i))) % 80 + 40; strokeWidth[i] = uint256(keccak256(abi.encodePacked(_tokenId, "strokeWidth", i))) % 16 + 5; } return CommonValues(hue, rotationSpeed, numCircles, radius, distance, strokeWidth); } function generateSVG(uint256 _tokenId) internal pure returns (string memory) { CommonValues memory commonValues = generateCommonValues(_tokenId); string memory svg = string( abi.encodePacked( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320">', '<rect width="320" height="320" fill="#000"/>', '<g transform="translate(0,0)">' ) ); for (uint256 i = 0; i < commonValues.numCircles; i++) { uint256 duration = (commonValues.rotationSpeed > i * 2) ? (commonValues.rotationSpeed - i * 2) : 1; uint256 hueStep = 360 / commonValues.numCircles; uint256 hue = (uint256(keccak256(abi.encodePacked(_tokenId, "hue"))) + (i * hueStep)) % 360; uint256 sat = uint256(keccak256(abi.encodePacked(_tokenId, "sat"))) % 50 + 50; string memory strokeColor = string(abi.encodePacked("hsl(", Strings.toString(hue), ",", Strings.toString(sat), "%,54%)")); string memory strokeAnimate = string(abi.encodePacked("hsl(", Strings.toString(hue), ",50%,54%);", "hsl(", Strings.toString(hue/2), ",50%,54%);", "hsl(", Strings.toString(hue), ",50%,54%);")); uint256 circleX = 160 - commonValues.distance[i] + commonValues.radius[i] + commonValues.strokeWidth[i]; uint256 circleY = circleX; string memory circleXStr = Strings.toString(circleX); string memory circleYStr = Strings.toString(circleY); string memory radiusStr = Strings.toString(commonValues.radius[i]); string memory strokeWidthStr = Strings.toString(commonValues.strokeWidth[i]); string memory durationStr = Strings.toString(duration); string memory circle = string( abi.encodePacked( '<circle cx="', circleXStr, '" cy="', circleYStr, '" r="', radiusStr, '" fill="none" stroke="', strokeColor, '" stroke-width="', strokeWidthStr, '">', '<animateTransform attributeName="transform" type="rotate" from="0 160 160" to="360 160 160" dur="', durationStr, 's" repeatCount="indefinite"/>', '<animate attributeName="stroke" values="', strokeAnimate, '" dur="', durationStr, 's" repeatCount="indefinite"/>', '</circle>' ) ); svg = string(abi.encodePacked(svg, circle)); } svg = string(abi.encodePacked(svg, '</g>', '</svg>')); return svg; } function generateAttributes(uint256 _tokenId) internal pure returns (string memory) { CommonValues memory commonValues = generateCommonValues(_tokenId); string memory attributes = string( abi.encodePacked( '{"trait_type": "distance", "value": "', Strings.toString(commonValues.distance[0]), ' - ', Strings.toString(commonValues.distance[commonValues.distance.length - 1]), ' pixels"},', '{"trait_type": "radius", "value": "', Strings.toString(commonValues.radius[0]), ' - ', Strings.toString(commonValues.radius[commonValues.radius.length - 1]), ' pixels"},', '{"trait_type": "rotation_speed", "value": "', Strings.toString(commonValues.rotationSpeed), ' seconds"},', '{"trait_type": "color", "value": "hsl(', Strings.toString(commonValues.hue), ',50%,54%)"},', '{"trait_type": "stroke_width", "value": "', Strings.toString(commonValues.strokeWidth[0]), ' - ', Strings.toString(commonValues.strokeWidth[commonValues.strokeWidth.length - 1]), ' pixels"}' ) ); return attributes; } function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist"); // Generate the SVG string string memory svg = generateSVG(_tokenId); // Get the attribute values string memory attributes = generateAttributes(_tokenId); // Encode the SVG in base64 string memory svgBase64 = Base64.encode(bytes(svg)); // Generate the JSON metadata string memory name = string(abi.encodePacked("AIORBIT #", Strings.toString(_tokenId))); string memory description = "Orbits generated on-chain by AI with 6,976,080,000 possibilities."; string memory imageUri = string(abi.encodePacked("data:image/svg+xml;base64,", svgBase64)); string memory backgroundColor = "#000000"; string memory json = string( abi.encodePacked( '{', '"name": "', name, '",', '"description": "', description, '",', '"image": "', imageUri, '",', '"background_color": "', backgroundColor, '",', '"attributes": [', attributes, ']', '}' ) ); // Encode the JSON metadata in base64 string memory jsonBase64 = Base64.encode(bytes(json)); // Combine the base64-encoded JSON metadata and SVG into the final URI return string(abi.encodePacked("data:application/json;base64,", jsonBase64)); } function withdraw() public onlyOwner { payable(owner()).transfer(address(this).balance); } function totalSupply() public view returns (uint256) { return _totalTokensMinted.current(); } function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId) || interfaceId == _INTERFACE_ID_FEES; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./AIORBIT.sol"; import "./BoltLib.sol"; import "./IEventNFT.sol"; import "./ERC721A.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/interfaces/IERC2981.sol"; import {Base64} from "./Base64.sol"; contract AIBOLT is ERC721A, Ownable, IERC2981, ReentrancyGuard, Pausable { address public eventsNFT; address payable public royaltiesRecipient; uint256 public royaltyRate = 75; // Default 7.5% royalty rate uint16 public constant AIORBIT_PER_AIBOLT = 5; AIORBIT public aiorbit; mapping(uint16 => uint256[]) public tokenIdToEvents; mapping(uint16 => uint16[AIORBIT_PER_AIBOLT]) public _aiorbitPerAibolt; uint256 public tokenPrice; mapping(address => bool) public allowList; event TokenEventAdded( uint16 indexed tokenId, uint256 indexed eventId, address indexed originalCaller ); event TokenForged(uint16[] indexed tokenIds, uint16[] indexed _aiorbitIds); modifier onlyEventNFT() { require( msg.sender == eventsNFT, "Only EventNFT can call this function" ); _; } constructor( string memory name, string memory symbol, address payable _royaltiesRecipient, address _eventsNFT, AIORBIT _aiorbit, uint256 _tokenPrice ) ERC721A(name, symbol) { royaltiesRecipient = _royaltiesRecipient; aiorbit = _aiorbit; eventsNFT = _eventsNFT; tokenPrice = _tokenPrice; pause(); } function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } function setEventNFT(address _eventsNFT) public onlyOwner { eventsNFT = _eventsNFT; } function setTokenPrice(uint256 _tokenPrice) public onlyOwner { tokenPrice = _tokenPrice; } // Mint function for owner to airdrop tokens function airdrop( address[] memory recipients, uint8[] memory howMany ) public onlyOwner { unchecked { for (uint16 i = 0; i < recipients.length; i++) { _mint(recipients[i], howMany[i]); } } } // New mint function for users to purchase token function mint(uint8 howMany) public payable nonReentrant whenNotPaused { require( totalSupply() + howMany <= 2000, "Maximum supply of 2,000 reached" ); require( balanceOf(msg.sender) + howMany <= 5, "Cannot exceed mint limit of 5 per wallet" ); require(allowList[msg.sender], "Not on the allow list"); require(msg.value == tokenPrice * howMany, "Incorrect payment value"); _mint(msg.sender, howMany); // Transfer the ether to the contract's owner payable(owner()).transfer(msg.value); } function addToAllowList(address[] memory addrs) public onlyOwner { for (uint i = 0; i < addrs.length; i++) { allowList[addrs[i]] = true; } } function removeFromAllowList(address[] memory addrs) public onlyOwner { for (uint i = 0; i < addrs.length; i++) { allowList[addrs[i]] = false; } } function forge( uint16[] memory tokenIds, uint16[] memory _aiorbitIds ) public { require( _aiorbitIds.length % AIORBIT_PER_AIBOLT == 0, "Incorrect number of AIORBIT IDs provided" ); require( tokenIds.length * AIORBIT_PER_AIBOLT == _aiorbitIds.length, "Mismatch between number of tokens and aiorbits" ); uint16 aiorbitIndex = 0; for (uint16 k = 0; k < tokenIds.length; k++) { uint16 tokenId = tokenIds[k]; require( ownerOf(tokenId) == msg.sender, "Caller must own the AIBOLT" ); uint16[AIORBIT_PER_AIBOLT] memory aiorbitIdsForToken; for (uint16 j = 0; j < AIORBIT_PER_AIBOLT; j++) { uint16 aiorbitId = _aiorbitIds[aiorbitIndex + j]; require( aiorbit.ownerOf(aiorbitId) == msg.sender, "Caller must own the AIORBITs" ); aiorbitIdsForToken[j] = aiorbitId; aiorbit.transferFrom( msg.sender, 0x000000000000000000000000000000000000dEaD, aiorbitId ); } _aiorbitPerAibolt[tokenId] = aiorbitIdsForToken; tokenIdToEvents[tokenId].push(1); // Event #1: Inception (Reveal) aiorbitIndex += AIORBIT_PER_AIBOLT; } emit TokenForged(tokenIds, _aiorbitIds); } function tokenURI( uint256 _tokenId ) public view override returns (string memory) { require(_exists(_tokenId), "Token does not exist"); IEventNFT eventNFT = IEventNFT(eventsNFT); uint256[] memory tokenEvents = tokenIdToEvents[uint16(_tokenId)]; uint256 tokenEventsLength = tokenEvents.length; uint16[AIORBIT_PER_AIBOLT] memory _aiorbitTokenIds = [ uint16(1), uint16(1), uint16(1), uint16(1), uint16(1) ]; // Revealed if (tokenEventsLength != 0) { _aiorbitTokenIds = _aiorbitPerAibolt[uint16(_tokenId)]; } BoltLib.AIBOLTData memory data = BoltLib.generateAIBOLTData( _aiorbitTokenIds ); if (tokenEvents.length > 0) { data = getLatestEventData(data, tokenEvents[tokenEventsLength - 1]); } string memory svg = BoltLib.generateSVG(data, tokenEvents, eventNFT); // Generate traits JSON string string memory traits = BoltLib.generateTraits( data, tokenEvents, eventNFT ); // Combine all parts to create the final JSON string string memory json = Base64.encode( bytes( string( abi.encodePacked( '{"name": "AIBOLT #', toString(_tokenId), '", "description": "The first ever dynamic on-chain storytelling NFTs. Every AIBOLT is fully on-chain, and their traits (visually and rarity) are upgradeable by causing Events. Events are transactions recorded on-chain. When chain of Events are stacked, a lore is written by AI that can be adapted to other mediums.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(svg)), '", "attributes": ', traits, "}" ) ) ) ); return string(abi.encodePacked("data:application/json;base64,", json)); } function getLatestEventData( BoltLib.AIBOLTData memory data, uint256 latestEventId ) public view returns (BoltLib.AIBOLTData memory) { IEventNFT.Event memory eventNFT = IEventNFT(eventsNFT).getEvent( latestEventId ); if (bytes(eventNFT.sun).length != 0) { data.sun = eventNFT.sun; data.sunSvg = eventNFT.sunSvg; } if (bytes(eventNFT.planet1).length != 0) { data.planets[0].theme = eventNFT.planet1; data.planets[0].svg = eventNFT.planet1Svg; } if (bytes(eventNFT.planet2).length != 0) { data.planets[1].theme = eventNFT.planet2; data.planets[1].svg = eventNFT.planet2Svg; } if (bytes(eventNFT.planet3).length != 0) { data.planets[2].theme = eventNFT.planet3; data.planets[2].svg = eventNFT.planet3Svg; } if (eventNFT.numPlanets != 0) { data.numPlanets = eventNFT.numPlanets; } return data; } function supportsInterface( bytes4 interfaceId ) public view virtual override(ERC721A, IERC165) returns (bool) { // Supports the following `interfaceId`s: // - IERC165: 0x01ffc9a7 // - IERC721: 0x80ac58cd // - IERC721Metadata: 0x5b5e139f // - IERC2981: 0x2a55205a return ERC721A.supportsInterface(interfaceId); } function addTokenEvent( uint16 tokenId, uint256 eventId, address originalCaller ) public onlyEventNFT { require( _exists(tokenId), "ERC721: operator query for nonexistent token" ); require( ownerOf(tokenId) == originalCaller, "Caller must own the AIBOLT" ); require(msg.sender == eventsNFT, "Not authorized Event contract"); tokenIdToEvents[tokenId].push(eventId); emit TokenEventAdded(tokenId, eventId, originalCaller); } // Override royaltyInfo function from EIP-2981 function royaltyInfo( uint256 _tokenId, uint256 _salePrice ) external view override returns (address receiver, uint256 royaltyAmount) { return (royaltiesRecipient, (_salePrice * royaltyRate) / 1000); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; address constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E; address constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol"; import {CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS} from "./lib/Constants.sol"; /** * @title OperatorFilterer * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another * registrant's entries in the OperatorFilterRegistry. * @dev This smart contract is meant to be inherited by token contracts so they can use the following: * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods. * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods. * Please note that if your token contract does not provide an owner with EIP-173, it must provide * administration methods on the contract itself to interact with the registry otherwise the subscription * will be locked to the options set during construction. */ abstract contract OperatorFilterer { /// @dev Emitted when an operator is not allowed. error OperatorNotAllowed(address operator); IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY = IOperatorFilterRegistry(CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS); /// @dev The constructor that is called when the contract is being deployed. constructor(address subscriptionOrRegistrantToCopy, bool subscribe) { // If an inheriting token contract is deployed to a network without the registry deployed, the modifier // will not revert, but the contract will need to be registered with the registry once it is deployed in // order for the modifier to filter addresses. if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { if (subscribe) { OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy); } else { if (subscriptionOrRegistrantToCopy != address(0)) { OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy); } else { OPERATOR_FILTER_REGISTRY.register(address(this)); } } } } /** * @dev A helper function to check if an operator is allowed. */ modifier onlyAllowedOperator(address from) virtual { // Allow spending tokens from addresses with balance // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred // from an EOA. if (from != msg.sender) { _checkFilterOperator(msg.sender); } _; } /** * @dev A helper function to check if an operator approval is allowed. */ modifier onlyAllowedOperatorApproval(address operator) virtual { _checkFilterOperator(operator); _; } /** * @dev A helper function to check if an operator is allowed. */ function _checkFilterOperator(address operator) internal view virtual { // Check registry code length to facilitate testing in environments without a deployed registry. if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) { // under normal circumstances, this function will revert rather than return false, but inheriting contracts // may specify their own OperatorFilterRegistry implementations, which may behave differently if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) { revert OperatorNotAllowed(operator); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface IOperatorFilterRegistry { /** * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns * true if supplied registrant address is not registered. */ function isOperatorAllowed(address registrant, address operator) external view returns (bool); /** * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner. */ function register(address registrant) external; /** * @notice Registers an address with the registry and "subscribes" to another address's filtered operators and codeHashes. */ function registerAndSubscribe(address registrant, address subscription) external; /** * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another * address without subscribing. */ function registerAndCopyEntries(address registrant, address registrantToCopy) external; /** * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner. * Note that this does not remove any filtered addresses or codeHashes. * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes. */ function unregister(address addr) external; /** * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered. */ function updateOperator(address registrant, address operator, bool filtered) external; /** * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates. */ function updateOperators(address registrant, address[] calldata operators, bool filtered) external; /** * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered. */ function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external; /** * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates. */ function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external; /** * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous * subscription if present. * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case, * subscriptions will not be forwarded. Instead the former subscription's existing entries will still be * used. */ function subscribe(address registrant, address registrantToSubscribe) external; /** * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes. */ function unsubscribe(address registrant, bool copyExistingEntries) external; /** * @notice Get the subscription address of a given registrant, if any. */ function subscriptionOf(address addr) external returns (address registrant); /** * @notice Get the set of addresses subscribed to a given registrant. * Note that order is not guaranteed as updates are made. */ function subscribers(address registrant) external returns (address[] memory); /** * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant. * Note that order is not guaranteed as updates are made. */ function subscriberAt(address registrant, uint256 index) external returns (address); /** * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr. */ function copyEntriesOf(address registrant, address registrantToCopy) external; /** * @notice Returns true if operator is filtered by a given address or its subscription. */ function isOperatorFiltered(address registrant, address operator) external returns (bool); /** * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription. */ function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool); /** * @notice Returns true if a codeHash is filtered by a given address or its subscription. */ function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool); /** * @notice Returns a list of filtered operators for a given address or its subscription. */ function filteredOperators(address addr) external returns (address[] memory); /** * @notice Returns the set of filtered codeHashes for a given address or its subscription. * Note that order is not guaranteed as updates are made. */ function filteredCodeHashes(address addr) external returns (bytes32[] memory); /** * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or * its subscription. * Note that order is not guaranteed as updates are made. */ function filteredOperatorAt(address registrant, uint256 index) external returns (address); /** * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or * its subscription. * Note that order is not guaranteed as updates are made. */ function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32); /** * @notice Returns true if an address has registered */ function isRegistered(address addr) external returns (bool); /** * @dev Convenience method to compute the code hash of an arbitrary contract */ function codeHashOf(address addr) external returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {OperatorFilterer} from "./OperatorFilterer.sol"; import {CANONICAL_CORI_SUBSCRIPTION} from "./lib/Constants.sol"; /** * @title DefaultOperatorFilterer * @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription. * @dev Please note that if your token contract does not provide an owner with EIP-173, it must provide * administration methods on the contract itself to interact with the registry otherwise the subscription * will be locked to the options set during construction. */ abstract contract DefaultOperatorFilterer is OperatorFilterer { /// @dev The constructor that is called when the contract is being deployed. constructor() OperatorFilterer(CANONICAL_CORI_SUBSCRIPTION, true) {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - 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 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - 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 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - 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 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - 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 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn(address from, uint256 id, uint256 amount) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @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 `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @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 will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo( uint256 tokenId, uint256 salePrice ) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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); } }
{ "remappings": [], "optimizer": { "enabled": false, "runs": 200 }, "evmVersion": "shanghai", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[],"name":"MAX_PLANETS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"aiboltContract","type":"address"},{"internalType":"uint16","name":"aiboltId","type":"uint16"},{"internalType":"uint256","name":"eventId","type":"uint256"}],"name":"addTokenEventToAIBOLT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"eventId","type":"uint256"}],"name":"getEvent","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"bottomSvg","type":"string"},{"internalType":"string","name":"topSvg","type":"string"},{"internalType":"string","name":"planet1","type":"string"},{"internalType":"string","name":"planet1Svg","type":"string"},{"internalType":"string","name":"planet2","type":"string"},{"internalType":"string","name":"planet2Svg","type":"string"},{"internalType":"string","name":"planet3","type":"string"},{"internalType":"string","name":"planet3Svg","type":"string"},{"internalType":"string","name":"sun","type":"string"},{"internalType":"string","name":"sunSvg","type":"string"},{"internalType":"uint256","name":"numPlanets","type":"uint256"}],"internalType":"struct IEventNFT.Event","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"bottomSvg","type":"string"},{"internalType":"string","name":"topSvg","type":"string"},{"internalType":"string","name":"planet1","type":"string"},{"internalType":"string","name":"planet1Svg","type":"string"},{"internalType":"string","name":"planet2","type":"string"},{"internalType":"string","name":"planet2Svg","type":"string"},{"internalType":"string","name":"planet3","type":"string"},{"internalType":"string","name":"planet3Svg","type":"string"},{"internalType":"string","name":"sun","type":"string"},{"internalType":"string","name":"sunSvg","type":"string"},{"internalType":"uint256","name":"numPlanets","type":"uint256"}],"internalType":"struct IEventNFT.EventParams","name":"params","type":"tuple"}],"name":"mintEvent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801562000010575f80fd5b5060405162004693380380620046938339818101604052810190620000369190620002d4565b8062000048816200007060201b60201c565b50620000696200005d6200008560201b60201c565b6200008c60201b60201c565b506200063e565b80600290816200008191906200055a565b5050565b5f33905090565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620001b08262000168565b810181811067ffffffffffffffff82111715620001d257620001d162000178565b5b80604052505050565b5f620001e66200014f565b9050620001f48282620001a5565b919050565b5f67ffffffffffffffff82111562000216576200021562000178565b5b620002218262000168565b9050602081019050919050565b5f5b838110156200024d57808201518184015260208101905062000230565b5f8484015250505050565b5f6200026e6200026884620001f9565b620001db565b9050828152602081018484840111156200028d576200028c62000164565b5b6200029a8482856200022e565b509392505050565b5f82601f830112620002b957620002b862000160565b5b8151620002cb84826020860162000258565b91505092915050565b5f60208284031215620002ec57620002eb62000158565b5b5f82015167ffffffffffffffff8111156200030c576200030b6200015c565b5b6200031a84828501620002a2565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806200037257607f821691505b6020821081036200038857620003876200032d565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620003ec7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620003af565b620003f88683620003af565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f620004426200043c620004368462000410565b62000419565b62000410565b9050919050565b5f819050919050565b6200045d8362000422565b620004756200046c8262000449565b848454620003bb565b825550505050565b5f90565b6200048b6200047d565b6200049881848462000452565b505050565b5b81811015620004bf57620004b35f8262000481565b6001810190506200049e565b5050565b601f8211156200050e57620004d8816200038e565b620004e384620003a0565b81016020851015620004f3578190505b6200050b6200050285620003a0565b8301826200049d565b50505b505050565b5f82821c905092915050565b5f620005305f198460080262000513565b1980831691505092915050565b5f6200054a83836200051f565b9150826002028217905092915050565b620005658262000323565b67ffffffffffffffff81111562000581576200058062000178565b5b6200058d82546200035a565b6200059a828285620004c3565b5f60209050601f831160018114620005d0575f8415620005bb578287015190505b620005c785826200053d565b86555062000636565b601f198416620005e0866200038e565b5f5b828110156200060957848901518255600182019150602085019450602081019050620005e2565b8683101562000629578489015162000625601f8916826200051f565b8355505b6001600288020188555050505b505050505050565b614047806200064c5f395ff3fe608060405234801561000f575f80fd5b50600436106100f2575f3560e01c8063715018a611610095578063c87f581711610064578063c87f581714610294578063e985e9c5146102b0578063f242432a146102e0578063f2fde38b146102fc576100f2565b8063715018a6146102205780638da5cb5b1461022a578063a22cb46514610248578063b545dc6514610264576100f2565b80632eb2c2d6116100d15780632eb2c2d6146101865780634e1273f4146101a25780636646d457146101d25780636d1884e0146101f0576100f2565b8062fdd58e146100f657806301ffc9a7146101265780630e89341c14610156575b5f80fd5b610110600480360381019061010b919061240d565b610318565b60405161011d919061245a565b60405180910390f35b610140600480360381019061013b91906124c8565b6103db565b60405161014d919061250d565b60405180910390f35b610170600480360381019061016b9190612526565b6104bc565b60405161017d91906125db565b60405180910390f35b6101a0600480360381019061019b91906127eb565b61054e565b005b6101bc60048036038101906101b79190612976565b6105ef565b6040516101c99190612aa3565b60405180910390f35b6101da610706565b6040516101e7919061245a565b60405180910390f35b61020a60048036038101906102059190612526565b61070b565b6040516102179190612c52565b60405180910390f35b610228610d70565b005b610232610d83565b60405161023f9190612c81565b60405180910390f35b610262600480360381019061025d9190612cc4565b610dab565b005b61027e60048036038101906102799190612ffb565b610dc1565b60405161028b919061245a565b60405180910390f35b6102ae60048036038101906102a99190613079565b610f9c565b005b6102ca60048036038101906102c591906130c9565b611062565b6040516102d7919061250d565b60405180910390f35b6102fa60048036038101906102f59190613107565b6110f0565b005b6103166004803603810190610311919061319a565b611191565b005b5f8073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610387576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037e90613235565b60405180910390fd5b5f808381526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f7fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104a557507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806104b557506104b482611213565b5b9050919050565b6060600280546104cb90613280565b80601f01602080910402602001604051908101604052809291908181526020018280546104f790613280565b80156105425780601f1061051957610100808354040283529160200191610542565b820191905f5260205f20905b81548152906001019060200180831161052557829003601f168201915b50505050509050919050565b61055661127c565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061059c575061059b8561059661127c565b611062565b5b6105db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105d290613320565b60405180910390fd5b6105e88585858585611283565b5050505050565b60608151835114610635576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062c906133ae565b60405180910390fd5b5f835167ffffffffffffffff811115610651576106506125ff565b5b60405190808252806020026020018201604052801561067f5781602001602082028036833780820191505090505b5090505f5b84518110156106fb576106cb8582815181106106a3576106a26133cc565b5b60200260200101518583815181106106be576106bd6133cc565b5b6020026020010151610318565b8282815181106106de576106dd6133cc565b5b602002602001018181525050806106f490613426565b9050610684565b508091505092915050565b600381565b61071361230f565b60055f8381526020019081526020015f20604051806101800160405290815f8201805461073f90613280565b80601f016020809104026020016040519081016040528092919081815260200182805461076b90613280565b80156107b65780601f1061078d576101008083540402835291602001916107b6565b820191905f5260205f20905b81548152906001019060200180831161079957829003601f168201915b505050505081526020016001820180546107cf90613280565b80601f01602080910402602001604051908101604052809291908181526020018280546107fb90613280565b80156108465780601f1061081d57610100808354040283529160200191610846565b820191905f5260205f20905b81548152906001019060200180831161082957829003601f168201915b5050505050815260200160028201805461085f90613280565b80601f016020809104026020016040519081016040528092919081815260200182805461088b90613280565b80156108d65780601f106108ad576101008083540402835291602001916108d6565b820191905f5260205f20905b8154815290600101906020018083116108b957829003601f168201915b505050505081526020016003820180546108ef90613280565b80601f016020809104026020016040519081016040528092919081815260200182805461091b90613280565b80156109665780601f1061093d57610100808354040283529160200191610966565b820191905f5260205f20905b81548152906001019060200180831161094957829003601f168201915b5050505050815260200160048201805461097f90613280565b80601f01602080910402602001604051908101604052809291908181526020018280546109ab90613280565b80156109f65780601f106109cd576101008083540402835291602001916109f6565b820191905f5260205f20905b8154815290600101906020018083116109d957829003601f168201915b50505050508152602001600582018054610a0f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610a3b90613280565b8015610a865780601f10610a5d57610100808354040283529160200191610a86565b820191905f5260205f20905b815481529060010190602001808311610a6957829003601f168201915b50505050508152602001600682018054610a9f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610acb90613280565b8015610b165780601f10610aed57610100808354040283529160200191610b16565b820191905f5260205f20905b815481529060010190602001808311610af957829003601f168201915b50505050508152602001600782018054610b2f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610b5b90613280565b8015610ba65780601f10610b7d57610100808354040283529160200191610ba6565b820191905f5260205f20905b815481529060010190602001808311610b8957829003601f168201915b50505050508152602001600882018054610bbf90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610beb90613280565b8015610c365780601f10610c0d57610100808354040283529160200191610c36565b820191905f5260205f20905b815481529060010190602001808311610c1957829003601f168201915b50505050508152602001600982018054610c4f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610c7b90613280565b8015610cc65780601f10610c9d57610100808354040283529160200191610cc6565b820191905f5260205f20905b815481529060010190602001808311610ca957829003601f168201915b50505050508152602001600a82018054610cdf90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610d0b90613280565b8015610d565780601f10610d2d57610100808354040283529160200191610d56565b820191905f5260205f20905b815481529060010190602001808311610d3957829003601f168201915b50505050508152602001600b820154815250509050919050565b610d78611591565b610d815f61160f565b565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610dbd610db661127c565b83836116d2565b5050565b5f610dca611591565b5f610dd56004611839565b9050604051806101800160405280845f01518152602001846020015181526020018460400151815260200184606001518152602001846080015181526020018460a0015181526020018460c0015181526020018460e00151815260200184610100015181526020018461012001518152602001846101400151815260200184610160015181525060055f8381526020019081526020015f205f820151815f019081610e80919061360a565b506020820151816001019081610e96919061360a565b506040820151816002019081610eac919061360a565b506060820151816003019081610ec2919061360a565b506080820151816004019081610ed8919061360a565b5060a0820151816005019081610eee919061360a565b5060c0820151816006019081610f04919061360a565b5060e0820151816007019081610f1a919061360a565b50610100820151816008019081610f31919061360a565b50610120820151816009019081610f48919061360a565b5061014082015181600a019081610f5f919061360a565b5061016082015181600b0155905050610f893382600160405180602001604052805f815250611845565b610f9360046119e8565b80915050919050565b5f610fa73383610318565b11610fe7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fde90613723565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff16635becc9e78383336040518463ffffffff1660e01b815260040161102493929190613750565b5f604051808303815f87803b15801561103b575f80fd5b505af115801561104d573d5f803e3d5ffd5b5050505061105d338260016119fc565b505050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b6110f861127c565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061113e575061113d8561113861127c565b611062565b5b61117d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117490613320565b60405180910390fd5b61118a8585858585611c30565b5050505050565b611199611591565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611207576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111fe906137f5565b60405180910390fd5b6112108161160f565b50565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f33905090565b81518351146112c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112be90613883565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132c90613911565b60405180910390fd5b5f61133e61127c565b905061134e818787878787611eb9565b5f5b84518110156114ee575f85828151811061136d5761136c6133cc565b5b602002602001015190505f85838151811061138b5761138a6133cc565b5b602002602001015190505f805f8481526020019081526020015f205f8b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015611427576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141e9061399f565b60405180910390fd5b8181035f808581526020019081526020015f205f8c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550815f808581526020019081526020015f205f8b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546114d391906139bd565b92505081905550505050806114e790613426565b9050611350565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516115659291906139f0565b60405180910390a461157b818787878787611ec1565b611589818787878787611ec9565b505050505050565b61159961127c565b73ffffffffffffffffffffffffffffffffffffffff166115b7610d83565b73ffffffffffffffffffffffffffffffffffffffff161461160d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160490613a6f565b60405180910390fd5b565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611740576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173790613afd565b60405180910390fd5b8060015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161182c919061250d565b60405180910390a3505050565b5f815f01549050919050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036118b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118aa90613b8b565b60405180910390fd5b5f6118bc61127c565b90505f6118c88561209f565b90505f6118d48561209f565b90506118e4835f89858589611eb9565b845f808881526020019081526020015f205f8973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461193e91906139bd565b925050819055508673ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6289896040516119bb929190613ba9565b60405180910390a46119d1835f89858589611ec1565b6119df835f89898989612117565b50505050505050565b6001815f015f828254019250508190555050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611a6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6190613c40565b60405180910390fd5b5f611a7361127c565b90505f611a7f8461209f565b90505f611a8b8461209f565b9050611aa983875f858560405180602001604052805f815250611eb9565b5f805f8781526020019081526020015f205f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905084811015611b3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3290613cce565b60405180910390fd5b8481035f808881526020019081526020015f205f8973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055505f73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628989604051611c03929190613ba9565b60405180910390a4611c2784885f868660405180602001604052805f815250611ec1565b50505050505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611c9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9590613911565b60405180910390fd5b5f611ca761127c565b90505f611cb38561209f565b90505f611cbf8561209f565b9050611ccf838989858589611eb9565b5f805f8881526020019081526020015f205f8a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905085811015611d61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d589061399f565b60405180910390fd5b8581035f808981526020019081526020015f205f8b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550855f808981526020019081526020015f205f8a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254611e0d91906139bd565b925050819055508773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628a8a604051611e8a929190613ba9565b60405180910390a4611ea0848a8a86868a611ec1565b611eae848a8a8a8a8a612117565b505050505050505050565b505050505050565b505050505050565b611ee88473ffffffffffffffffffffffffffffffffffffffff166122ed565b15612097578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401611f2e959493929190613d3e565b6020604051808303815f875af1925050508015611f6957506040513d601f19601f82011682018060405250810190611f669190613db8565b60015b61200e57611f75613def565b806308c379a003611fd15750611f89613e0e565b80611f945750611fd3565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fc891906125db565b60405180910390fd5b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161200590613f0d565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614612095576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208c90613f9b565b60405180910390fd5b505b505050505050565b60605f600167ffffffffffffffff8111156120bd576120bc6125ff565b5b6040519080825280602002602001820160405280156120eb5781602001602082028036833780820191505090505b50905082815f81518110612102576121016133cc565b5b60200260200101818152505080915050919050565b6121368473ffffffffffffffffffffffffffffffffffffffff166122ed565b156122e5578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b815260040161217c959493929190613fb9565b6020604051808303815f875af19250505080156121b757506040513d601f19601f820116820180604052508101906121b49190613db8565b60015b61225c576121c3613def565b806308c379a00361221f57506121d7613e0e565b806121e25750612221565b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221691906125db565b60405180910390fd5b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225390613f0d565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146122e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122da90613f9b565b60405180910390fd5b505b505050505050565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60405180610180016040528060608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020015f81525090565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6123a982612380565b9050919050565b6123b98161239f565b81146123c3575f80fd5b50565b5f813590506123d4816123b0565b92915050565b5f819050919050565b6123ec816123da565b81146123f6575f80fd5b50565b5f81359050612407816123e3565b92915050565b5f806040838503121561242357612422612378565b5b5f612430858286016123c6565b9250506020612441858286016123f9565b9150509250929050565b612454816123da565b82525050565b5f60208201905061246d5f83018461244b565b92915050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6124a781612473565b81146124b1575f80fd5b50565b5f813590506124c28161249e565b92915050565b5f602082840312156124dd576124dc612378565b5b5f6124ea848285016124b4565b91505092915050565b5f8115159050919050565b612507816124f3565b82525050565b5f6020820190506125205f8301846124fe565b92915050565b5f6020828403121561253b5761253a612378565b5b5f612548848285016123f9565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b8381101561258857808201518184015260208101905061256d565b5f8484015250505050565b5f601f19601f8301169050919050565b5f6125ad82612551565b6125b7818561255b565b93506125c781856020860161256b565b6125d081612593565b840191505092915050565b5f6020820190508181035f8301526125f381846125a3565b905092915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61263582612593565b810181811067ffffffffffffffff82111715612654576126536125ff565b5b80604052505050565b5f61266661236f565b9050612672828261262c565b919050565b5f67ffffffffffffffff821115612691576126906125ff565b5b602082029050602081019050919050565b5f80fd5b5f6126b86126b384612677565b61265d565b905080838252602082019050602084028301858111156126db576126da6126a2565b5b835b8181101561270457806126f088826123f9565b8452602084019350506020810190506126dd565b5050509392505050565b5f82601f830112612722576127216125fb565b5b81356127328482602086016126a6565b91505092915050565b5f80fd5b5f67ffffffffffffffff821115612759576127586125ff565b5b61276282612593565b9050602081019050919050565b828183375f83830152505050565b5f61278f61278a8461273f565b61265d565b9050828152602081018484840111156127ab576127aa61273b565b5b6127b684828561276f565b509392505050565b5f82601f8301126127d2576127d16125fb565b5b81356127e284826020860161277d565b91505092915050565b5f805f805f60a0868803121561280457612803612378565b5b5f612811888289016123c6565b9550506020612822888289016123c6565b945050604086013567ffffffffffffffff8111156128435761284261237c565b5b61284f8882890161270e565b935050606086013567ffffffffffffffff8111156128705761286f61237c565b5b61287c8882890161270e565b925050608086013567ffffffffffffffff81111561289d5761289c61237c565b5b6128a9888289016127be565b9150509295509295909350565b5f67ffffffffffffffff8211156128d0576128cf6125ff565b5b602082029050602081019050919050565b5f6128f36128ee846128b6565b61265d565b90508083825260208201905060208402830185811115612916576129156126a2565b5b835b8181101561293f578061292b88826123c6565b845260208401935050602081019050612918565b5050509392505050565b5f82601f83011261295d5761295c6125fb565b5b813561296d8482602086016128e1565b91505092915050565b5f806040838503121561298c5761298b612378565b5b5f83013567ffffffffffffffff8111156129a9576129a861237c565b5b6129b585828601612949565b925050602083013567ffffffffffffffff8111156129d6576129d561237c565b5b6129e28582860161270e565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b612a1e816123da565b82525050565b5f612a2f8383612a15565b60208301905092915050565b5f602082019050919050565b5f612a51826129ec565b612a5b81856129f6565b9350612a6683612a06565b805f5b83811015612a96578151612a7d8882612a24565b9750612a8883612a3b565b925050600181019050612a69565b5085935050505092915050565b5f6020820190508181035f830152612abb8184612a47565b905092915050565b5f82825260208201905092915050565b5f612add82612551565b612ae78185612ac3565b9350612af781856020860161256b565b612b0081612593565b840191505092915050565b5f61018083015f8301518482035f860152612b268282612ad3565b91505060208301518482036020860152612b408282612ad3565b91505060408301518482036040860152612b5a8282612ad3565b91505060608301518482036060860152612b748282612ad3565b91505060808301518482036080860152612b8e8282612ad3565b91505060a083015184820360a0860152612ba88282612ad3565b91505060c083015184820360c0860152612bc28282612ad3565b91505060e083015184820360e0860152612bdc8282612ad3565b915050610100830151848203610100860152612bf88282612ad3565b915050610120830151848203610120860152612c148282612ad3565b915050610140830151848203610140860152612c308282612ad3565b915050610160830151612c47610160860182612a15565b508091505092915050565b5f6020820190508181035f830152612c6a8184612b0b565b905092915050565b612c7b8161239f565b82525050565b5f602082019050612c945f830184612c72565b92915050565b612ca3816124f3565b8114612cad575f80fd5b50565b5f81359050612cbe81612c9a565b92915050565b5f8060408385031215612cda57612cd9612378565b5b5f612ce7858286016123c6565b9250506020612cf885828601612cb0565b9150509250929050565b5f80fd5b5f80fd5b5f67ffffffffffffffff821115612d2457612d236125ff565b5b612d2d82612593565b9050602081019050919050565b5f612d4c612d4784612d0a565b61265d565b905082815260208101848484011115612d6857612d6761273b565b5b612d7384828561276f565b509392505050565b5f82601f830112612d8f57612d8e6125fb565b5b8135612d9f848260208601612d3a565b91505092915050565b5f6101808284031215612dbe57612dbd612d02565b5b612dc961018061265d565b90505f82013567ffffffffffffffff811115612de857612de7612d06565b5b612df484828501612d7b565b5f83015250602082013567ffffffffffffffff811115612e1757612e16612d06565b5b612e2384828501612d7b565b602083015250604082013567ffffffffffffffff811115612e4757612e46612d06565b5b612e5384828501612d7b565b604083015250606082013567ffffffffffffffff811115612e7757612e76612d06565b5b612e8384828501612d7b565b606083015250608082013567ffffffffffffffff811115612ea757612ea6612d06565b5b612eb384828501612d7b565b60808301525060a082013567ffffffffffffffff811115612ed757612ed6612d06565b5b612ee384828501612d7b565b60a08301525060c082013567ffffffffffffffff811115612f0757612f06612d06565b5b612f1384828501612d7b565b60c08301525060e082013567ffffffffffffffff811115612f3757612f36612d06565b5b612f4384828501612d7b565b60e08301525061010082013567ffffffffffffffff811115612f6857612f67612d06565b5b612f7484828501612d7b565b6101008301525061012082013567ffffffffffffffff811115612f9a57612f99612d06565b5b612fa684828501612d7b565b6101208301525061014082013567ffffffffffffffff811115612fcc57612fcb612d06565b5b612fd884828501612d7b565b61014083015250610160612fee848285016123f9565b6101608301525092915050565b5f602082840312156130105761300f612378565b5b5f82013567ffffffffffffffff81111561302d5761302c61237c565b5b61303984828501612da8565b91505092915050565b5f61ffff82169050919050565b61305881613042565b8114613062575f80fd5b50565b5f813590506130738161304f565b92915050565b5f805f606084860312156130905761308f612378565b5b5f61309d868287016123c6565b93505060206130ae86828701613065565b92505060406130bf868287016123f9565b9150509250925092565b5f80604083850312156130df576130de612378565b5b5f6130ec858286016123c6565b92505060206130fd858286016123c6565b9150509250929050565b5f805f805f60a086880312156131205761311f612378565b5b5f61312d888289016123c6565b955050602061313e888289016123c6565b945050604061314f888289016123f9565b9350506060613160888289016123f9565b925050608086013567ffffffffffffffff8111156131815761318061237c565b5b61318d888289016127be565b9150509295509295909350565b5f602082840312156131af576131ae612378565b5b5f6131bc848285016123c6565b91505092915050565b7f455243313135353a2061646472657373207a65726f206973206e6f74206120765f8201527f616c6964206f776e657200000000000000000000000000000000000000000000602082015250565b5f61321f602a8361255b565b915061322a826131c5565b604082019050919050565b5f6020820190508181035f83015261324c81613213565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061329757607f821691505b6020821081036132aa576132a9613253565b5b50919050565b7f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e5f8201527f6572206f7220617070726f766564000000000000000000000000000000000000602082015250565b5f61330a602e8361255b565b9150613315826132b0565b604082019050919050565b5f6020820190508181035f830152613337816132fe565b9050919050565b7f455243313135353a206163636f756e747320616e6420696473206c656e6774685f8201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b5f61339860298361255b565b91506133a38261333e565b604082019050919050565b5f6020820190508181035f8301526133c58161338c565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f613430826123da565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613462576134616133f9565b5b600182019050919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026134c97fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261348e565b6134d3868361348e565b95508019841693508086168417925050509392505050565b5f819050919050565b5f61350e613509613504846123da565b6134eb565b6123da565b9050919050565b5f819050919050565b613527836134f4565b61353b61353382613515565b84845461349a565b825550505050565b5f90565b61354f613543565b61355a81848461351e565b505050565b5b8181101561357d576135725f82613547565b600181019050613560565b5050565b601f8211156135c2576135938161346d565b61359c8461347f565b810160208510156135ab578190505b6135bf6135b78561347f565b83018261355f565b50505b505050565b5f82821c905092915050565b5f6135e25f19846008026135c7565b1980831691505092915050565b5f6135fa83836135d3565b9150826002028217905092915050565b61361382612551565b67ffffffffffffffff81111561362c5761362b6125ff565b5b6136368254613280565b613641828285613581565b5f60209050601f831160018114613672575f8415613660578287015190505b61366a85826135ef565b8655506136d1565b601f1984166136808661346d565b5f5b828110156136a757848901518255600182019150602085019450602081019050613682565b868310156136c457848901516136c0601f8916826135d3565b8355505b6001600288020188555050505b505050505050565b7f43616c6c6572206d757374206f776e20746865204576656e744e4654000000005f82015250565b5f61370d601c8361255b565b9150613718826136d9565b602082019050919050565b5f6020820190508181035f83015261373a81613701565b9050919050565b61374a81613042565b82525050565b5f6060820190506137635f830186613741565b613770602083018561244b565b61377d6040830184612c72565b949350505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f6137df60268361255b565b91506137ea82613785565b604082019050919050565b5f6020820190508181035f83015261380c816137d3565b9050919050565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e677468205f8201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b5f61386d60288361255b565b915061387882613813565b604082019050919050565b5f6020820190508181035f83015261389a81613861565b9050919050565b7f455243313135353a207472616e7366657220746f20746865207a65726f2061645f8201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b5f6138fb60258361255b565b9150613906826138a1565b604082019050919050565b5f6020820190508181035f830152613928816138ef565b9050919050565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f5f8201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b5f613989602a8361255b565b91506139948261392f565b604082019050919050565b5f6020820190508181035f8301526139b68161397d565b9050919050565b5f6139c7826123da565b91506139d2836123da565b92508282019050808211156139ea576139e96133f9565b5b92915050565b5f6040820190508181035f830152613a088185612a47565b90508181036020830152613a1c8184612a47565b90509392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f613a5960208361255b565b9150613a6482613a25565b602082019050919050565b5f6020820190508181035f830152613a8681613a4d565b9050919050565b7f455243313135353a2073657474696e6720617070726f76616c207374617475735f8201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b5f613ae760298361255b565b9150613af282613a8d565b604082019050919050565b5f6020820190508181035f830152613b1481613adb565b9050919050565b7f455243313135353a206d696e7420746f20746865207a65726f206164647265735f8201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b5f613b7560218361255b565b9150613b8082613b1b565b604082019050919050565b5f6020820190508181035f830152613ba281613b69565b9050919050565b5f604082019050613bbc5f83018561244b565b613bc9602083018461244b565b9392505050565b7f455243313135353a206275726e2066726f6d20746865207a65726f20616464725f8201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b5f613c2a60238361255b565b9150613c3582613bd0565b604082019050919050565b5f6020820190508181035f830152613c5781613c1e565b9050919050565b7f455243313135353a206275726e20616d6f756e7420657863656564732062616c5f8201527f616e636500000000000000000000000000000000000000000000000000000000602082015250565b5f613cb860248361255b565b9150613cc382613c5e565b604082019050919050565b5f6020820190508181035f830152613ce581613cac565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b5f613d1082613cec565b613d1a8185613cf6565b9350613d2a81856020860161256b565b613d3381612593565b840191505092915050565b5f60a082019050613d515f830188612c72565b613d5e6020830187612c72565b8181036040830152613d708186612a47565b90508181036060830152613d848185612a47565b90508181036080830152613d988184613d06565b90509695505050505050565b5f81519050613db28161249e565b92915050565b5f60208284031215613dcd57613dcc612378565b5b5f613dda84828501613da4565b91505092915050565b5f8160e01c9050919050565b5f60033d1115613e0b5760045f803e613e085f51613de3565b90505b90565b5f60443d10613e9a57613e1f61236f565b60043d036004823e80513d602482011167ffffffffffffffff82111715613e47575050613e9a565b808201805167ffffffffffffffff811115613e655750505050613e9a565b80602083010160043d038501811115613e82575050505050613e9a565b613e918260200185018661262c565b82955050505050505b90565b7f455243313135353a207472616e7366657220746f206e6f6e2d455243313135355f8201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b5f613ef760348361255b565b9150613f0282613e9d565b604082019050919050565b5f6020820190508181035f830152613f2481613eeb565b9050919050565b7f455243313135353a204552433131353552656365697665722072656a656374655f8201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b5f613f8560288361255b565b9150613f9082613f2b565b604082019050919050565b5f6020820190508181035f830152613fb281613f79565b9050919050565b5f60a082019050613fcc5f830188612c72565b613fd96020830187612c72565b613fe6604083018661244b565b613ff3606083018561244b565b81810360808301526140058184613d06565b9050969550505050505056fea26469706673582212209c78aa79200a6929cbb8f3b9f48f132db88a45ff42af8be32a474cc56ee6be8364736f6c6343000814003300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106100f2575f3560e01c8063715018a611610095578063c87f581711610064578063c87f581714610294578063e985e9c5146102b0578063f242432a146102e0578063f2fde38b146102fc576100f2565b8063715018a6146102205780638da5cb5b1461022a578063a22cb46514610248578063b545dc6514610264576100f2565b80632eb2c2d6116100d15780632eb2c2d6146101865780634e1273f4146101a25780636646d457146101d25780636d1884e0146101f0576100f2565b8062fdd58e146100f657806301ffc9a7146101265780630e89341c14610156575b5f80fd5b610110600480360381019061010b919061240d565b610318565b60405161011d919061245a565b60405180910390f35b610140600480360381019061013b91906124c8565b6103db565b60405161014d919061250d565b60405180910390f35b610170600480360381019061016b9190612526565b6104bc565b60405161017d91906125db565b60405180910390f35b6101a0600480360381019061019b91906127eb565b61054e565b005b6101bc60048036038101906101b79190612976565b6105ef565b6040516101c99190612aa3565b60405180910390f35b6101da610706565b6040516101e7919061245a565b60405180910390f35b61020a60048036038101906102059190612526565b61070b565b6040516102179190612c52565b60405180910390f35b610228610d70565b005b610232610d83565b60405161023f9190612c81565b60405180910390f35b610262600480360381019061025d9190612cc4565b610dab565b005b61027e60048036038101906102799190612ffb565b610dc1565b60405161028b919061245a565b60405180910390f35b6102ae60048036038101906102a99190613079565b610f9c565b005b6102ca60048036038101906102c591906130c9565b611062565b6040516102d7919061250d565b60405180910390f35b6102fa60048036038101906102f59190613107565b6110f0565b005b6103166004803603810190610311919061319a565b611191565b005b5f8073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610387576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037e90613235565b60405180910390fd5b5f808381526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f7fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104a557507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806104b557506104b482611213565b5b9050919050565b6060600280546104cb90613280565b80601f01602080910402602001604051908101604052809291908181526020018280546104f790613280565b80156105425780601f1061051957610100808354040283529160200191610542565b820191905f5260205f20905b81548152906001019060200180831161052557829003601f168201915b50505050509050919050565b61055661127c565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061059c575061059b8561059661127c565b611062565b5b6105db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105d290613320565b60405180910390fd5b6105e88585858585611283565b5050505050565b60608151835114610635576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062c906133ae565b60405180910390fd5b5f835167ffffffffffffffff811115610651576106506125ff565b5b60405190808252806020026020018201604052801561067f5781602001602082028036833780820191505090505b5090505f5b84518110156106fb576106cb8582815181106106a3576106a26133cc565b5b60200260200101518583815181106106be576106bd6133cc565b5b6020026020010151610318565b8282815181106106de576106dd6133cc565b5b602002602001018181525050806106f490613426565b9050610684565b508091505092915050565b600381565b61071361230f565b60055f8381526020019081526020015f20604051806101800160405290815f8201805461073f90613280565b80601f016020809104026020016040519081016040528092919081815260200182805461076b90613280565b80156107b65780601f1061078d576101008083540402835291602001916107b6565b820191905f5260205f20905b81548152906001019060200180831161079957829003601f168201915b505050505081526020016001820180546107cf90613280565b80601f01602080910402602001604051908101604052809291908181526020018280546107fb90613280565b80156108465780601f1061081d57610100808354040283529160200191610846565b820191905f5260205f20905b81548152906001019060200180831161082957829003601f168201915b5050505050815260200160028201805461085f90613280565b80601f016020809104026020016040519081016040528092919081815260200182805461088b90613280565b80156108d65780601f106108ad576101008083540402835291602001916108d6565b820191905f5260205f20905b8154815290600101906020018083116108b957829003601f168201915b505050505081526020016003820180546108ef90613280565b80601f016020809104026020016040519081016040528092919081815260200182805461091b90613280565b80156109665780601f1061093d57610100808354040283529160200191610966565b820191905f5260205f20905b81548152906001019060200180831161094957829003601f168201915b5050505050815260200160048201805461097f90613280565b80601f01602080910402602001604051908101604052809291908181526020018280546109ab90613280565b80156109f65780601f106109cd576101008083540402835291602001916109f6565b820191905f5260205f20905b8154815290600101906020018083116109d957829003601f168201915b50505050508152602001600582018054610a0f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610a3b90613280565b8015610a865780601f10610a5d57610100808354040283529160200191610a86565b820191905f5260205f20905b815481529060010190602001808311610a6957829003601f168201915b50505050508152602001600682018054610a9f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610acb90613280565b8015610b165780601f10610aed57610100808354040283529160200191610b16565b820191905f5260205f20905b815481529060010190602001808311610af957829003601f168201915b50505050508152602001600782018054610b2f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610b5b90613280565b8015610ba65780601f10610b7d57610100808354040283529160200191610ba6565b820191905f5260205f20905b815481529060010190602001808311610b8957829003601f168201915b50505050508152602001600882018054610bbf90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610beb90613280565b8015610c365780601f10610c0d57610100808354040283529160200191610c36565b820191905f5260205f20905b815481529060010190602001808311610c1957829003601f168201915b50505050508152602001600982018054610c4f90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610c7b90613280565b8015610cc65780601f10610c9d57610100808354040283529160200191610cc6565b820191905f5260205f20905b815481529060010190602001808311610ca957829003601f168201915b50505050508152602001600a82018054610cdf90613280565b80601f0160208091040260200160405190810160405280929190818152602001828054610d0b90613280565b8015610d565780601f10610d2d57610100808354040283529160200191610d56565b820191905f5260205f20905b815481529060010190602001808311610d3957829003601f168201915b50505050508152602001600b820154815250509050919050565b610d78611591565b610d815f61160f565b565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610dbd610db661127c565b83836116d2565b5050565b5f610dca611591565b5f610dd56004611839565b9050604051806101800160405280845f01518152602001846020015181526020018460400151815260200184606001518152602001846080015181526020018460a0015181526020018460c0015181526020018460e00151815260200184610100015181526020018461012001518152602001846101400151815260200184610160015181525060055f8381526020019081526020015f205f820151815f019081610e80919061360a565b506020820151816001019081610e96919061360a565b506040820151816002019081610eac919061360a565b506060820151816003019081610ec2919061360a565b506080820151816004019081610ed8919061360a565b5060a0820151816005019081610eee919061360a565b5060c0820151816006019081610f04919061360a565b5060e0820151816007019081610f1a919061360a565b50610100820151816008019081610f31919061360a565b50610120820151816009019081610f48919061360a565b5061014082015181600a019081610f5f919061360a565b5061016082015181600b0155905050610f893382600160405180602001604052805f815250611845565b610f9360046119e8565b80915050919050565b5f610fa73383610318565b11610fe7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fde90613723565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff16635becc9e78383336040518463ffffffff1660e01b815260040161102493929190613750565b5f604051808303815f87803b15801561103b575f80fd5b505af115801561104d573d5f803e3d5ffd5b5050505061105d338260016119fc565b505050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16905092915050565b6110f861127c565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061113e575061113d8561113861127c565b611062565b5b61117d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117490613320565b60405180910390fd5b61118a8585858585611c30565b5050505050565b611199611591565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611207576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111fe906137f5565b60405180910390fd5b6112108161160f565b50565b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b5f33905090565b81518351146112c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112be90613883565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132c90613911565b60405180910390fd5b5f61133e61127c565b905061134e818787878787611eb9565b5f5b84518110156114ee575f85828151811061136d5761136c6133cc565b5b602002602001015190505f85838151811061138b5761138a6133cc565b5b602002602001015190505f805f8481526020019081526020015f205f8b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015611427576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141e9061399f565b60405180910390fd5b8181035f808581526020019081526020015f205f8c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550815f808581526020019081526020015f205f8b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546114d391906139bd565b92505081905550505050806114e790613426565b9050611350565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516115659291906139f0565b60405180910390a461157b818787878787611ec1565b611589818787878787611ec9565b505050505050565b61159961127c565b73ffffffffffffffffffffffffffffffffffffffff166115b7610d83565b73ffffffffffffffffffffffffffffffffffffffff161461160d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160490613a6f565b60405180910390fd5b565b5f60035f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160035f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611740576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161173790613afd565b60405180910390fd5b8060015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161182c919061250d565b60405180910390a3505050565b5f815f01549050919050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036118b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118aa90613b8b565b60405180910390fd5b5f6118bc61127c565b90505f6118c88561209f565b90505f6118d48561209f565b90506118e4835f89858589611eb9565b845f808881526020019081526020015f205f8973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461193e91906139bd565b925050819055508673ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6289896040516119bb929190613ba9565b60405180910390a46119d1835f89858589611ec1565b6119df835f89898989612117565b50505050505050565b6001815f015f828254019250508190555050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611a6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6190613c40565b60405180910390fd5b5f611a7361127c565b90505f611a7f8461209f565b90505f611a8b8461209f565b9050611aa983875f858560405180602001604052805f815250611eb9565b5f805f8781526020019081526020015f205f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905084811015611b3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3290613cce565b60405180910390fd5b8481035f808881526020019081526020015f205f8973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055505f73ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628989604051611c03929190613ba9565b60405180910390a4611c2784885f868660405180602001604052805f815250611ec1565b50505050505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611c9e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9590613911565b60405180910390fd5b5f611ca761127c565b90505f611cb38561209f565b90505f611cbf8561209f565b9050611ccf838989858589611eb9565b5f805f8881526020019081526020015f205f8a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905085811015611d61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d589061399f565b60405180910390fd5b8581035f808981526020019081526020015f205f8b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550855f808981526020019081526020015f205f8a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254611e0d91906139bd565b925050819055508773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628a8a604051611e8a929190613ba9565b60405180910390a4611ea0848a8a86868a611ec1565b611eae848a8a8a8a8a612117565b505050505050505050565b505050505050565b505050505050565b611ee88473ffffffffffffffffffffffffffffffffffffffff166122ed565b15612097578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401611f2e959493929190613d3e565b6020604051808303815f875af1925050508015611f6957506040513d601f19601f82011682018060405250810190611f669190613db8565b60015b61200e57611f75613def565b806308c379a003611fd15750611f89613e0e565b80611f945750611fd3565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fc891906125db565b60405180910390fd5b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161200590613f0d565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614612095576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208c90613f9b565b60405180910390fd5b505b505050505050565b60605f600167ffffffffffffffff8111156120bd576120bc6125ff565b5b6040519080825280602002602001820160405280156120eb5781602001602082028036833780820191505090505b50905082815f81518110612102576121016133cc565b5b60200260200101818152505080915050919050565b6121368473ffffffffffffffffffffffffffffffffffffffff166122ed565b156122e5578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b815260040161217c959493929190613fb9565b6020604051808303815f875af19250505080156121b757506040513d601f19601f820116820180604052508101906121b49190613db8565b60015b61225c576121c3613def565b806308c379a00361221f57506121d7613e0e565b806121e25750612221565b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221691906125db565b60405180910390fd5b505b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161225390613f0d565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146122e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122da90613f9b565b60405180910390fd5b505b505050505050565b5f808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60405180610180016040528060608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001606081526020015f81525090565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6123a982612380565b9050919050565b6123b98161239f565b81146123c3575f80fd5b50565b5f813590506123d4816123b0565b92915050565b5f819050919050565b6123ec816123da565b81146123f6575f80fd5b50565b5f81359050612407816123e3565b92915050565b5f806040838503121561242357612422612378565b5b5f612430858286016123c6565b9250506020612441858286016123f9565b9150509250929050565b612454816123da565b82525050565b5f60208201905061246d5f83018461244b565b92915050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6124a781612473565b81146124b1575f80fd5b50565b5f813590506124c28161249e565b92915050565b5f602082840312156124dd576124dc612378565b5b5f6124ea848285016124b4565b91505092915050565b5f8115159050919050565b612507816124f3565b82525050565b5f6020820190506125205f8301846124fe565b92915050565b5f6020828403121561253b5761253a612378565b5b5f612548848285016123f9565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b8381101561258857808201518184015260208101905061256d565b5f8484015250505050565b5f601f19601f8301169050919050565b5f6125ad82612551565b6125b7818561255b565b93506125c781856020860161256b565b6125d081612593565b840191505092915050565b5f6020820190508181035f8301526125f381846125a3565b905092915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61263582612593565b810181811067ffffffffffffffff82111715612654576126536125ff565b5b80604052505050565b5f61266661236f565b9050612672828261262c565b919050565b5f67ffffffffffffffff821115612691576126906125ff565b5b602082029050602081019050919050565b5f80fd5b5f6126b86126b384612677565b61265d565b905080838252602082019050602084028301858111156126db576126da6126a2565b5b835b8181101561270457806126f088826123f9565b8452602084019350506020810190506126dd565b5050509392505050565b5f82601f830112612722576127216125fb565b5b81356127328482602086016126a6565b91505092915050565b5f80fd5b5f67ffffffffffffffff821115612759576127586125ff565b5b61276282612593565b9050602081019050919050565b828183375f83830152505050565b5f61278f61278a8461273f565b61265d565b9050828152602081018484840111156127ab576127aa61273b565b5b6127b684828561276f565b509392505050565b5f82601f8301126127d2576127d16125fb565b5b81356127e284826020860161277d565b91505092915050565b5f805f805f60a0868803121561280457612803612378565b5b5f612811888289016123c6565b9550506020612822888289016123c6565b945050604086013567ffffffffffffffff8111156128435761284261237c565b5b61284f8882890161270e565b935050606086013567ffffffffffffffff8111156128705761286f61237c565b5b61287c8882890161270e565b925050608086013567ffffffffffffffff81111561289d5761289c61237c565b5b6128a9888289016127be565b9150509295509295909350565b5f67ffffffffffffffff8211156128d0576128cf6125ff565b5b602082029050602081019050919050565b5f6128f36128ee846128b6565b61265d565b90508083825260208201905060208402830185811115612916576129156126a2565b5b835b8181101561293f578061292b88826123c6565b845260208401935050602081019050612918565b5050509392505050565b5f82601f83011261295d5761295c6125fb565b5b813561296d8482602086016128e1565b91505092915050565b5f806040838503121561298c5761298b612378565b5b5f83013567ffffffffffffffff8111156129a9576129a861237c565b5b6129b585828601612949565b925050602083013567ffffffffffffffff8111156129d6576129d561237c565b5b6129e28582860161270e565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b612a1e816123da565b82525050565b5f612a2f8383612a15565b60208301905092915050565b5f602082019050919050565b5f612a51826129ec565b612a5b81856129f6565b9350612a6683612a06565b805f5b83811015612a96578151612a7d8882612a24565b9750612a8883612a3b565b925050600181019050612a69565b5085935050505092915050565b5f6020820190508181035f830152612abb8184612a47565b905092915050565b5f82825260208201905092915050565b5f612add82612551565b612ae78185612ac3565b9350612af781856020860161256b565b612b0081612593565b840191505092915050565b5f61018083015f8301518482035f860152612b268282612ad3565b91505060208301518482036020860152612b408282612ad3565b91505060408301518482036040860152612b5a8282612ad3565b91505060608301518482036060860152612b748282612ad3565b91505060808301518482036080860152612b8e8282612ad3565b91505060a083015184820360a0860152612ba88282612ad3565b91505060c083015184820360c0860152612bc28282612ad3565b91505060e083015184820360e0860152612bdc8282612ad3565b915050610100830151848203610100860152612bf88282612ad3565b915050610120830151848203610120860152612c148282612ad3565b915050610140830151848203610140860152612c308282612ad3565b915050610160830151612c47610160860182612a15565b508091505092915050565b5f6020820190508181035f830152612c6a8184612b0b565b905092915050565b612c7b8161239f565b82525050565b5f602082019050612c945f830184612c72565b92915050565b612ca3816124f3565b8114612cad575f80fd5b50565b5f81359050612cbe81612c9a565b92915050565b5f8060408385031215612cda57612cd9612378565b5b5f612ce7858286016123c6565b9250506020612cf885828601612cb0565b9150509250929050565b5f80fd5b5f80fd5b5f67ffffffffffffffff821115612d2457612d236125ff565b5b612d2d82612593565b9050602081019050919050565b5f612d4c612d4784612d0a565b61265d565b905082815260208101848484011115612d6857612d6761273b565b5b612d7384828561276f565b509392505050565b5f82601f830112612d8f57612d8e6125fb565b5b8135612d9f848260208601612d3a565b91505092915050565b5f6101808284031215612dbe57612dbd612d02565b5b612dc961018061265d565b90505f82013567ffffffffffffffff811115612de857612de7612d06565b5b612df484828501612d7b565b5f83015250602082013567ffffffffffffffff811115612e1757612e16612d06565b5b612e2384828501612d7b565b602083015250604082013567ffffffffffffffff811115612e4757612e46612d06565b5b612e5384828501612d7b565b604083015250606082013567ffffffffffffffff811115612e7757612e76612d06565b5b612e8384828501612d7b565b606083015250608082013567ffffffffffffffff811115612ea757612ea6612d06565b5b612eb384828501612d7b565b60808301525060a082013567ffffffffffffffff811115612ed757612ed6612d06565b5b612ee384828501612d7b565b60a08301525060c082013567ffffffffffffffff811115612f0757612f06612d06565b5b612f1384828501612d7b565b60c08301525060e082013567ffffffffffffffff811115612f3757612f36612d06565b5b612f4384828501612d7b565b60e08301525061010082013567ffffffffffffffff811115612f6857612f67612d06565b5b612f7484828501612d7b565b6101008301525061012082013567ffffffffffffffff811115612f9a57612f99612d06565b5b612fa684828501612d7b565b6101208301525061014082013567ffffffffffffffff811115612fcc57612fcb612d06565b5b612fd884828501612d7b565b61014083015250610160612fee848285016123f9565b6101608301525092915050565b5f602082840312156130105761300f612378565b5b5f82013567ffffffffffffffff81111561302d5761302c61237c565b5b61303984828501612da8565b91505092915050565b5f61ffff82169050919050565b61305881613042565b8114613062575f80fd5b50565b5f813590506130738161304f565b92915050565b5f805f606084860312156130905761308f612378565b5b5f61309d868287016123c6565b93505060206130ae86828701613065565b92505060406130bf868287016123f9565b9150509250925092565b5f80604083850312156130df576130de612378565b5b5f6130ec858286016123c6565b92505060206130fd858286016123c6565b9150509250929050565b5f805f805f60a086880312156131205761311f612378565b5b5f61312d888289016123c6565b955050602061313e888289016123c6565b945050604061314f888289016123f9565b9350506060613160888289016123f9565b925050608086013567ffffffffffffffff8111156131815761318061237c565b5b61318d888289016127be565b9150509295509295909350565b5f602082840312156131af576131ae612378565b5b5f6131bc848285016123c6565b91505092915050565b7f455243313135353a2061646472657373207a65726f206973206e6f74206120765f8201527f616c6964206f776e657200000000000000000000000000000000000000000000602082015250565b5f61321f602a8361255b565b915061322a826131c5565b604082019050919050565b5f6020820190508181035f83015261324c81613213565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061329757607f821691505b6020821081036132aa576132a9613253565b5b50919050565b7f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e5f8201527f6572206f7220617070726f766564000000000000000000000000000000000000602082015250565b5f61330a602e8361255b565b9150613315826132b0565b604082019050919050565b5f6020820190508181035f830152613337816132fe565b9050919050565b7f455243313135353a206163636f756e747320616e6420696473206c656e6774685f8201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b5f61339860298361255b565b91506133a38261333e565b604082019050919050565b5f6020820190508181035f8301526133c58161338c565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f613430826123da565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613462576134616133f9565b5b600182019050919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026134c97fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261348e565b6134d3868361348e565b95508019841693508086168417925050509392505050565b5f819050919050565b5f61350e613509613504846123da565b6134eb565b6123da565b9050919050565b5f819050919050565b613527836134f4565b61353b61353382613515565b84845461349a565b825550505050565b5f90565b61354f613543565b61355a81848461351e565b505050565b5b8181101561357d576135725f82613547565b600181019050613560565b5050565b601f8211156135c2576135938161346d565b61359c8461347f565b810160208510156135ab578190505b6135bf6135b78561347f565b83018261355f565b50505b505050565b5f82821c905092915050565b5f6135e25f19846008026135c7565b1980831691505092915050565b5f6135fa83836135d3565b9150826002028217905092915050565b61361382612551565b67ffffffffffffffff81111561362c5761362b6125ff565b5b6136368254613280565b613641828285613581565b5f60209050601f831160018114613672575f8415613660578287015190505b61366a85826135ef565b8655506136d1565b601f1984166136808661346d565b5f5b828110156136a757848901518255600182019150602085019450602081019050613682565b868310156136c457848901516136c0601f8916826135d3565b8355505b6001600288020188555050505b505050505050565b7f43616c6c6572206d757374206f776e20746865204576656e744e4654000000005f82015250565b5f61370d601c8361255b565b9150613718826136d9565b602082019050919050565b5f6020820190508181035f83015261373a81613701565b9050919050565b61374a81613042565b82525050565b5f6060820190506137635f830186613741565b613770602083018561244b565b61377d6040830184612c72565b949350505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f6137df60268361255b565b91506137ea82613785565b604082019050919050565b5f6020820190508181035f83015261380c816137d3565b9050919050565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e677468205f8201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b5f61386d60288361255b565b915061387882613813565b604082019050919050565b5f6020820190508181035f83015261389a81613861565b9050919050565b7f455243313135353a207472616e7366657220746f20746865207a65726f2061645f8201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b5f6138fb60258361255b565b9150613906826138a1565b604082019050919050565b5f6020820190508181035f830152613928816138ef565b9050919050565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f5f8201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b5f613989602a8361255b565b91506139948261392f565b604082019050919050565b5f6020820190508181035f8301526139b68161397d565b9050919050565b5f6139c7826123da565b91506139d2836123da565b92508282019050808211156139ea576139e96133f9565b5b92915050565b5f6040820190508181035f830152613a088185612a47565b90508181036020830152613a1c8184612a47565b90509392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f613a5960208361255b565b9150613a6482613a25565b602082019050919050565b5f6020820190508181035f830152613a8681613a4d565b9050919050565b7f455243313135353a2073657474696e6720617070726f76616c207374617475735f8201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b5f613ae760298361255b565b9150613af282613a8d565b604082019050919050565b5f6020820190508181035f830152613b1481613adb565b9050919050565b7f455243313135353a206d696e7420746f20746865207a65726f206164647265735f8201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b5f613b7560218361255b565b9150613b8082613b1b565b604082019050919050565b5f6020820190508181035f830152613ba281613b69565b9050919050565b5f604082019050613bbc5f83018561244b565b613bc9602083018461244b565b9392505050565b7f455243313135353a206275726e2066726f6d20746865207a65726f20616464725f8201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b5f613c2a60238361255b565b9150613c3582613bd0565b604082019050919050565b5f6020820190508181035f830152613c5781613c1e565b9050919050565b7f455243313135353a206275726e20616d6f756e7420657863656564732062616c5f8201527f616e636500000000000000000000000000000000000000000000000000000000602082015250565b5f613cb860248361255b565b9150613cc382613c5e565b604082019050919050565b5f6020820190508181035f830152613ce581613cac565b9050919050565b5f81519050919050565b5f82825260208201905092915050565b5f613d1082613cec565b613d1a8185613cf6565b9350613d2a81856020860161256b565b613d3381612593565b840191505092915050565b5f60a082019050613d515f830188612c72565b613d5e6020830187612c72565b8181036040830152613d708186612a47565b90508181036060830152613d848185612a47565b90508181036080830152613d988184613d06565b90509695505050505050565b5f81519050613db28161249e565b92915050565b5f60208284031215613dcd57613dcc612378565b5b5f613dda84828501613da4565b91505092915050565b5f8160e01c9050919050565b5f60033d1115613e0b5760045f803e613e085f51613de3565b90505b90565b5f60443d10613e9a57613e1f61236f565b60043d036004823e80513d602482011167ffffffffffffffff82111715613e47575050613e9a565b808201805167ffffffffffffffff811115613e655750505050613e9a565b80602083010160043d038501811115613e82575050505050613e9a565b613e918260200185018661262c565b82955050505050505b90565b7f455243313135353a207472616e7366657220746f206e6f6e2d455243313135355f8201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b5f613ef760348361255b565b9150613f0282613e9d565b604082019050919050565b5f6020820190508181035f830152613f2481613eeb565b9050919050565b7f455243313135353a204552433131353552656365697665722072656a656374655f8201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b5f613f8560288361255b565b9150613f9082613f2b565b604082019050919050565b5f6020820190508181035f830152613fb281613f79565b9050919050565b5f60a082019050613fcc5f830188612c72565b613fd96020830187612c72565b613fe6604083018661244b565b613ff3606083018561244b565b81810360808301526140058184613d06565b9050969550505050505056fea26469706673582212209c78aa79200a6929cbb8f3b9f48f132db88a45ff42af8be32a474cc56ee6be8364736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : uri (string):
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.