Skip to content

Solidity API

SpanningERC721EnumerableUpgradeable

This implements an optional extension of {ERC721} defined in the EIP that adds enumerability of all the token ids in the contract as well as all token ids owned by each account.

ownedTokens_

mapping(bytes32 => mapping(uint256 => uint256)) ownedTokens_

ownedTokensIndex_

mapping(uint256 => uint256) ownedTokensIndex_

allTokens_

uint256[] allTokens_

allTokensIndex_

mapping(uint256 => uint256) allTokensIndex_

supportsInterface

function supportsInterface(bytes4 interfaceId) public view virtual returns (bool)

See {IERC165-supportsInterface}.

tokenOfOwnerByIndex

function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256)

See {IERC721Enumerable-tokenOfOwnerByIndex}.

tokenOfOwnerByIndex

function tokenOfOwnerByIndex(bytes32 owner, uint256 index) public view virtual returns (uint256)

See {IERC721Enumerable-tokenOfOwnerByIndex}.

totalSupply

function totalSupply() public view virtual returns (uint256)

See {IERC721Enumerable-totalSupply}.

tokenByIndex

function tokenByIndex(uint256 index) public view virtual returns (uint256)

See {IERC721Enumerable-tokenByIndex}.

_beforeTokenTransfer

function _beforeTokenTransfer(bytes32 senderAddress, bytes32 receiverAddress, uint256 tokenId) internal virtual

_Hook that is called before any token transfer. This includes minting and burning.

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, from's tokenId will be burned.
  • from cannot be the zero address.
  • to cannot be the zero address.

To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]._

_addTokenToOwnerEnumeration

function _addTokenToOwnerEnumeration(bytes32 receiverAddress, uint256 tokenId) private

Private function to add a token to this extension's ownership-tracking data structures.

NameTypeDescription
receiverAddressbytes32address representing the new owner of the given token ID
tokenIduint256uint256 ID of the token to be added to the tokens list of the given address

_addTokenToAllTokensEnumeration

function _addTokenToAllTokensEnumeration(uint256 tokenId) private

Private function to add a token to this extension's token tracking data structures.

NameTypeDescription
tokenIduint256uint256 ID of the token to be added to the tokens list

_removeTokenFromOwnerEnumeration

function _removeTokenFromOwnerEnumeration(bytes32 senderAddress, uint256 tokenId) private

Private function to remove a token from this extension's ownership-tracking data structures. Note that while the token is not assigned a new owner, the ownedTokensIndex_ mapping is not updated: this allows for gas optimizations e.g. when performing a transfer operation (avoiding double writes). This has O(1) time complexity, but alters the order of the ownedTokens array._

NameTypeDescription
senderAddressbytes32address representing the previous owner of the given token ID
tokenIduint256uint256 ID of the token to be removed from the tokens list of the given address

_removeTokenFromAllTokensEnumeration

function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private

Private function to remove a token from this extension's token tracking data structures. This has O(1) time complexity, but alters the order of the allTokens array._

NameTypeDescription
tokenIduint256uint256 ID of the token to be removed from the tokens list

__gap

uint256[46] __gap

This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps We use a standard of 50 storage slots. The amount referenced below is based on: 50 - numberOfClassMemberVariables.