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()
- __ERC721Enumerable_init_unchained()
- supportsInterface(bytes4 interfaceId)
- tokenOfOwnerByIndex(address owner, uint256 index)
- totalSupply()
- tokenByIndex(uint256 index)
- _beforeTokenTransfer(address from, address to, uint256 tokenId)
- _addTokenToOwnerEnumeration(address to, uint256 tokenId)
- _addTokenToAllTokensEnumeration(uint256 tokenId)
- _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
- _removeTokenFromAllTokensEnumeration(uint256 tokenId)
__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:
- When
from
andto
are both non-zero,from
’stokenId
will be transferred toto
. - When
from
is zero,tokenId
will be minted forto
. - When
to
is zero,from
’stokenId
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].
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
- ActivateToken
- AddressUpgradeable
- ContextUpgradeable
- CreatorToken
- CustomToken
- ERC165Upgradeable
- ERC20Upgradeable
- ERC721BurnableUpgradeable
- ERC721EnumerableUpgradeable
- ERC721Upgradeable
- ERC721URIStorageUpgradeable
- IERC165Upgradeable
- IERC20MetadataUpgradeable
- IERC20Upgradeable
- IERC721EnumerableUpgradeable
- IERC721MetadataUpgradeable
- IERC721ReceiverUpgradeable
- IERC721Upgradeable
- ImmutableEntity
- ImmutableProduct
- Initializable
- Migrations
- OwnableUpgradeable
- ProductActivate
- StringCommon
- StringsUpgradeable