ERC721AFacet
ERC721AFacet
_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)._
totalSupply
function totalSupply() public view virtual returns (uint256)
_Returns the total number of tokens in existence. Burned tokens will reduce the count. To get the total number of tokens minted, please see {totalMinted}.
balanceOf
function balanceOf(address owner) public view virtual returns (uint256)
Returns the number of tokens in owner
's account.
name
function name() public view virtual returns (string)
Returns the token collection name.
symbol
function symbol() public view virtual returns (string)
Returns the token collection symbol.
ownerOf
function ownerOf(uint256 tokenId) public view virtual returns (address)
_Returns the owner of the tokenId
token.
Requirements:
tokenId
must exist._
approve
function approve(address to, uint256 tokenId) public payable virtual
_Gives permission to to
to transfer tokenId
token to another account. See {ERC721A-_approve}.
Requirements:
The caller must own the token or be an approved operator._
getApproved
function getApproved(uint256 tokenId) public view virtual returns (address)
_Returns the account approved for tokenId
token.
Requirements:
tokenId
must exist._
setApprovalForAll
function setApprovalForAll(address operator, bool approved) public virtual
_Approve or remove operator
as an operator for the caller. Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
Requirements:
The
operator
cannot be the caller.
Emits an {ApprovalForAll} event._
isApprovedForAll
function isApprovedForAll(address owner, address operator) public view virtual returns (bool)
_Returns if the operator
is allowed to manage all of the assets of owner
.
See {setApprovalForAll}._
transferFrom
function transferFrom(address from, address to, uint256 tokenId) public payable virtual
_Transfers tokenId
from from
to to
.
Requirements:
from
cannot be the zero address.to
cannot be the zero address.tokenId
token must be owned byfrom
.If the caller is not
from
, it must be approved to move this token by either {approve} or {setApprovalForAll}.
Emits a {Transfer} event._
safeTransferFrom
function safeTransferFrom(address from, address to, uint256 tokenId) public payable virtual
Equivalent to safeTransferFrom(from, to, tokenId, '')
.
safeTransferFrom
function safeTransferFrom(address from, address to, uint256 tokenId, bytes _data) public payable virtual
_Safely transfers tokenId
token from from
to to
.
Requirements:
from
cannot be the zero address.to
cannot be the zero address.tokenId
token must exist and be owned byfrom
.If the caller is not
from
, it must be approved to move this token by either {approve} or {setApprovalForAll}.If
to
refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
Emits a {Transfer} event._
_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
andto
are both non-zero,from
'stokenId
has been transferred toto
.When
from
is zero,tokenId
has been minted forto
.When
to
is zero,tokenId
has been burned byfrom
.from
andto
are never both zero._
_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
andto
are both non-zero,from
'stokenId
will be transferred toto
.When
from
is zero,tokenId
will be minted forto
.When
to
is zero,tokenId
will be burned byfrom
.from
andto
are never both zero._
Was this helpful?