ERC721AUpgradeableInternal

ERC721AUpgradeableInternal

_Implementation of the ERC721 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)._

_BITMASK_ADDRESS_DATA_ENTRY

uint256 _BITMASK_ADDRESS_DATA_ENTRY

_BITPOS_NUMBER_MINTED

uint256 _BITPOS_NUMBER_MINTED

_BITPOS_NUMBER_BURNED

uint256 _BITPOS_NUMBER_BURNED

_BITPOS_AUX

uint256 _BITPOS_AUX

_BITMASK_AUX_COMPLEMENT

uint256 _BITMASK_AUX_COMPLEMENT

_BITPOS_START_TIMESTAMP

uint256 _BITPOS_START_TIMESTAMP

_BITMASK_BURNED

uint256 _BITMASK_BURNED

_BITPOS_NEXT_INITIALIZED

uint256 _BITPOS_NEXT_INITIALIZED

_BITMASK_NEXT_INITIALIZED

uint256 _BITMASK_NEXT_INITIALIZED

_BITPOS_EXTRA_DATA

uint256 _BITPOS_EXTRA_DATA

_BITMASK_EXTRA_DATA_COMPLEMENT

uint256 _BITMASK_EXTRA_DATA_COMPLEMENT

_BITMASK_ADDRESS

uint256 _BITMASK_ADDRESS

_MAX_MINT_ERC2309_QUANTITY_LIMIT

uint256 _MAX_MINT_ERC2309_QUANTITY_LIMIT

_TRANSFER_EVENT_SIGNATURE

bytes32 _TRANSFER_EVENT_SIGNATURE

_startTokenId

function _startTokenId() internal view virtual returns (uint256)

Returns the starting token ID. To change the starting token ID, please override this function.

_nextTokenId

function _nextTokenId() internal view virtual returns (uint256)

Returns the next token ID to be minted.

_totalMinted

function _totalMinted() internal view virtual returns (uint256)

Returns the total amount of tokens minted in the contract.

_totalBurned

function _totalBurned() internal view virtual returns (uint256)

Returns the total number of tokens burned.

_numberMinted

function _numberMinted(address owner) internal view returns (uint256)

Returns the number of tokens minted by owner.

_numberBurned

function _numberBurned(address owner) internal view returns (uint256)

Returns the number of tokens burned by or on behalf of owner.

_getAux

function _getAux(address owner) internal view returns (uint64)

Returns the auxiliary data for owner. (e.g. number of whitelist mint slots used).

_setAux

function _setAux(address owner, uint64 aux) internal virtual

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.

_baseURI

function _baseURI() internal view virtual returns (string)

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.

_ownershipOf

function _ownershipOf(uint256 tokenId) internal view virtual returns (struct IERC721AUpgradeable.TokenOwnership)

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.

_ownershipAt

function _ownershipAt(uint256 index) internal view virtual returns (struct IERC721AUpgradeable.TokenOwnership)

Returns the unpacked TokenOwnership struct at index.

_ownershipIsInitialized

function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool)

Returns whether the ownership slot at index is initialized. An uninitialized slot does not necessarily mean that the slot has no owner.

_initializeOwnershipAt

function _initializeOwnershipAt(uint256 index) internal virtual

Initializes the ownership slot minted at index for efficiency purposes.

_packedOwnershipOf

function _packedOwnershipOf(uint256 tokenId) internal view returns (uint256 packed)

Returns the packed ownership data of tokenId.

_unpackedOwnership

function _unpackedOwnership(uint256 packed) internal pure returns (struct IERC721AUpgradeable.TokenOwnership ownership)

Returns the unpacked TokenOwnership struct from packed.

_packOwnershipData

function _packOwnershipData(address owner, uint256 flags) internal view returns (uint256 result)

Packs ownership data into a single uint256.

_nextInitializedFlag

function _nextInitializedFlag(uint256 quantity) internal pure returns (uint256 result)

Returns the nextInitialized flag set if quantity equals 1.

_exists

function _exists(uint256 tokenId) internal view virtual returns (bool result)

_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}.

_isSenderApprovedOrOwner

function _isSenderApprovedOrOwner(address approvedAddress, address owner, address msgSender) internal pure returns (bool result)

Returns whether msgSender is equal to approvedAddress or owner.

_getApprovedSlotAndAddress

function _getApprovedSlotAndAddress(uint256 tokenId) internal view returns (uint256 approvedAddressSlot, address approvedAddress)

Returns the storage slot and value for the approved address of tokenId.

_beforeTokenTransfers

function _beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal virtual

_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._

_afterTokenTransfers

function _afterTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal virtual

_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._

_checkContractOnERC721Received

function _checkContractOnERC721Received(address from, address to, uint256 tokenId, bytes _data) internal returns (bool)

_internal 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._

_mint

function _mint(address to, uint256 quantity) internal virtual

_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._

_mintERC2309

function _mintERC2309(address to, uint256 quantity) internal virtual

_Mints quantity tokens and transfers them to to.

This function is intended for efficient minting only during contract creation.

It emits only one {ConsecutiveTransfer} as defined in ERC2309, instead of a sequence of {Transfer} event(s).

Calling this function outside of contract creation WILL make your contract non-compliant with the ERC721 standard. For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 {ConsecutiveTransfer} event is only permissible during contract creation.

Requirements:

  • to cannot be the zero address.

  • quantity must be greater than 0.

Emits a {ConsecutiveTransfer} event._

_safeMint

function _safeMint(address to, uint256 quantity, bytes _data) internal virtual

_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._

_safeMint

function _safeMint(address to, uint256 quantity) internal virtual

Equivalent to _safeMint(to, quantity, '').

_approve

function _approve(address to, uint256 tokenId) internal virtual

Equivalent to _approve(to, tokenId, false).

_ownerOf

function _ownerOf(uint256 tokenId) internal view returns (address)

_approve

function _approve(address to, uint256 tokenId, bool approvalCheck) internal virtual

_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:

  • tokenId must exist.

Emits an {Approval} event._

_burn

function _burn(uint256 tokenId) internal virtual

Equivalent to _burn(tokenId, false).

_isApprovedForAll

function _isApprovedForAll(address owner, address operator) internal view returns (bool)

_burn

function _burn(uint256 tokenId, bool approvalCheck) internal virtual

_Destroys tokenId. The approval is cleared when the token is burned.

Requirements:

  • tokenId must exist.

Emits a {Transfer} event._

_setExtraDataAt

function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual

Directly sets the extra data for the ownership data index.

_extraData

function _extraData(address from, address to, uint24 previousExtraData) internal view virtual returns (uint24)

_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._

_nextExtraData

function _nextExtraData(address from, address to, uint256 prevOwnershipPacked) internal view returns (uint256)

Returns the next extra data for the packed ownership data. The returned result is shifted into position.

_msgSenderERC721A

function _msgSenderERC721A() internal view virtual returns (address)

_Returns the message sender (defaults to msg.sender).

If you are writing GSN compatible contracts, you need to override this function._

_toString

function _toString(uint256 value) internal pure virtual returns (string str)

Converts a uint256 to its ASCII string decimal representation.

_revert

function _revert(bytes4 errorSelector) internal pure

For more efficient reverts.

Was this helpful?