Solidity API
SpanningERC721Enumerable
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
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]._
_addTokenToOwnerEnumeration
function _addTokenToOwnerEnumeration(bytes32 receiverAddress, uint256 tokenId) private
Private function to add a token to this extension's ownership-tracking data structures.
Name | Type | Description |
---|---|---|
receiverAddress | bytes32 | 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
function _addTokenToAllTokensEnumeration(uint256 tokenId) private
Private function to add a token to this extension's token tracking data structures.
Name | Type | Description |
---|---|---|
tokenId | uint256 | uint256 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._
Name | Type | Description |
---|---|---|
senderAddress | bytes32 | 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
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._
Name | Type | Description |
---|---|---|
tokenId | uint256 | uint256 ID of the token to be removed from the tokens list |