Skip to the content.

ERC721EnumerableUpgradeable.sol

View Source: @openzeppelin\contracts-upgradeable\token\ERC721\extensions\ERC721EnumerableUpgradeable.sol

↗ Extends: Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable ↘ Derived Contracts: ActivateToken, CreatorToken

ERC721EnumerableUpgradeable

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.

Contract Members

Constants & Variables

mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
mapping(uint256 => uint256) private _ownedTokensIndex;
uint256[] private _allTokens;
mapping(uint256 => uint256) private _allTokensIndex;
uint256[46] private __gap;

Functions

__ERC721Enumerable_init

function __ERC721Enumerable_init() internal nonpayable onlyInitializing 

Arguments

| Name | Type | Description | | ————- |————- | —–|

__ERC721Enumerable_init_unchained

function __ERC721Enumerable_init_unchained() internal nonpayable onlyInitializing 

Arguments

| Name | Type | Description | | ————- |————- | —–|

supportsInterface

See {IERC165-supportsInterface}.

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

Arguments

Name Type Description
interfaceId bytes4  

tokenOfOwnerByIndex

See {IERC721Enumerable-tokenOfOwnerByIndex}.

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

Arguments

Name Type Description
owner address  
index uint256  

totalSupply

See {IERC721Enumerable-totalSupply}.

function totalSupply() public view
returns(uint256)

Arguments

| Name | Type | Description | | ————- |————- | —–|

tokenByIndex

See {IERC721Enumerable-tokenByIndex}.

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

Arguments

Name Type Description
index uint256  

_beforeTokenTransfer

Hook that is called before any token transfer. This includes minting and burning. Calling conditions:

function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal nonpayable

Arguments

Name Type Description
from address  
to address  
tokenId uint256  

_addTokenToOwnerEnumeration

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

function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private nonpayable

Arguments

Name Type Description
to address address representing the new owner of the given token ID
tokenId uint256 uint256 ID of the token to be added to the tokens list of the given address

_addTokenToAllTokensEnumeration

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

function _addTokenToAllTokensEnumeration(uint256 tokenId) private nonpayable

Arguments

Name Type Description
tokenId uint256 uint256 ID of the token to be added to the tokens list

_removeTokenFromOwnerEnumeration

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.

function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private nonpayable

Arguments

Name Type Description
from address address representing the previous owner of the given token ID
tokenId uint256 uint256 ID of the token to be removed from the tokens list of the given address

_removeTokenFromAllTokensEnumeration

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.

function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private nonpayable

Arguments

Name Type Description
tokenId uint256 uint256 ID of the token to be removed from the tokens list

Contracts