LensBaseERC721
Inherits: ERC165, ILensERC721
*Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including the Metadata extension, but not including the Enumerable extension, which is available separately as {ERC721Enumerable}. Modifications:
- Refactored _operatorApprovals setter into an internal function to allow meta-transactions.
- Constructor replaced with an initializer.
- Mint timestamp is now stored in a TokenData struct alongside the owner address.*
State Variables
_name
string private _name;
_symbol
string private _symbol;
_tokenData
mapping(uint256 => Types.TokenData) private _tokenData;
_balances
mapping(address => uint256) private _balances;
_tokenApprovals
mapping(uint256 => address) private _tokenApprovals;
_operatorApprovals
mapping(address => mapping(address => bool)) private _operatorApprovals;
__DEPRECATED__ownedTokens
mapping(address => mapping(uint256 => uint256)) private __DEPRECATED__ownedTokens;
__DEPRECATED__ownedTokensIndex
mapping(uint256 => uint256) private __DEPRECATED__ownedTokensIndex;
_totalSupply
uint256 private _totalSupply;
__DEPRECATED__allTokensIndex
mapping(uint256 => uint256) private __DEPRECATED__allTokensIndex;
_nonces
mapping(address => uint256) private _nonces;
Functions
_initialize
Initializes the ERC721 name and symbol.
function _initialize(string calldata name_, string calldata symbol_) internal;
Parameters
| Name | Type | Description | 
|---|---|---|
| name_ | string | The name to set. | 
| symbol_ | string | The symbol to set. | 
tokenURI
Returns the Uniform Resource Identifier (URI) for tokenId token.
function tokenURI(uint256 tokenId) external view virtual returns (string memory);
supportsInterface
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool);
nonces
function nonces(address signer) public view override returns (uint256);
getDomainSeparator
Returns the EIP-712 domain separator for this contract.
function getDomainSeparator() external view virtual override returns (bytes32);
Returns
| Name | Type | Description | 
|---|---|---|
| <none> | bytes32 | bytes32 The domain separator. | 
balanceOf
See {IERC721-balanceOf}.
function balanceOf(address owner) public view virtual override returns (uint256);
ownerOf
See {IERC721-ownerOf}.
function ownerOf(uint256 tokenId) public view virtual override returns (address);
mintTimestampOf
See {IERC721Timestamped-mintTimestampOf}
function mintTimestampOf(uint256 tokenId) public view virtual override returns (uint256);
tokenDataOf
See {IERC721Timestamped-tokenDataOf}
function tokenDataOf(uint256 tokenId) public view virtual override returns (Types.TokenData memory);
exists
See {IERC721Timestamped-exists}
function exists(uint256 tokenId) public view virtual override returns (bool);
name
See {IERC721Metadata-name}.
function name() public view virtual override returns (string memory);
symbol
See {IERC721Metadata-symbol}.
function symbol() public view virtual override returns (string memory);
totalSupply
function totalSupply() external view virtual override returns (uint256);
approve
See {IERC721-approve}.
function approve(address to, uint256 tokenId) public virtual override;
getApproved
See {IERC721-getApproved}.
function getApproved(uint256 tokenId) public view virtual override returns (address);
setApprovalForAll
See {IERC721-setApprovalForAll}.
function setApprovalForAll(address operator, bool approved) public virtual override;
isApprovedForAll
See {IERC721-isApprovedForAll}.
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool);
transferFrom
See {IERC721-transferFrom}.
function transferFrom(address from, address to, uint256 tokenId) public virtual override;
safeTransferFrom
See {IERC721-safeTransferFrom}.
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override;
safeTransferFrom
See {IERC721-safeTransferFrom}.
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override;
burn
*Burns tokenId.
Requirements:
- The caller must own tokenIdor be an approved operator.*
function burn(uint256 tokenId) public virtual override;
_unsafeOwnerOf
Returns the owner of the tokenId token.
It is prefixed as unsafe as it does not revert when the token does not exist.
function _unsafeOwnerOf(uint256 tokenId) internal view returns (address);
Parameters
| Name | Type | Description | 
|---|---|---|
| tokenId | uint256 | The token whose owner is being queried. | 
Returns
| Name | Type | Description | 
|---|---|---|
| <none> | address | address The address owning the given token, zero address if the token does not exist. | 
_safeTransfer
*Safely transfers tokenId token from from to to, checking first that contract recipients
are aware of the ERC721 protocol to prevent tokens from being forever locked.
_data is additional data, it has no specified format and it is sent in call to to.
This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
implement alternative mechanisms to perform a token transfer, such as signature-based.
Requirements:
- fromcannot be the zero address.
- tocannot be the zero address.
- tokenIdtoken must exist and be owned by- from.
- If torefers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event.*
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual;
_exists
Returns whether tokenId exists.
Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
Tokens start existing when they are minted (_mint),
and stop existing when they are burned (_burn).
function _exists(uint256 tokenId) internal view virtual returns (bool);
_isApprovedOrOwner
*Returns whether spender is allowed to manage tokenId.
Requirements:
- tokenIdmust exist.*
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool);
_mint
*Mints tokenId and transfers it to to.
WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
Requirements:
- tokenIdmust not exist.
- tocannot be the zero address. Emits a {Transfer} event.*
function _mint(address to, uint256 tokenId) internal virtual;
_burn
*Destroys tokenId.
The approval is cleared when the token is burned.
Requirements:
- tokenIdmust exist. Emits a {Transfer} event.*
function _burn(uint256 tokenId) internal virtual;
_transfer
*Transfers tokenId from from to to.
As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
Requirements:
- tocannot be the zero address.
- tokenIdtoken must be owned by- from. Emits a {Transfer} event.*
function _transfer(address from, address to, uint256 tokenId) internal virtual;
_approve
Approve to to operate on tokenId
Emits a {Approval} event.
function _approve(address to, uint256 tokenId) internal virtual;
_setOperatorApproval
Refactored from the original OZ ERC721 implementation: approve or revoke approval from
operator to operate on all tokens owned by owner.
Emits a {ApprovalForAll} event.
function _setOperatorApproval(address owner, address operator, bool approved) internal virtual;
_checkOnERC721Received
Private function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool);
Parameters
| Name | Type | Description | 
|---|---|---|
| from | address | address representing the previous owner of the given token ID | 
| to | address | target address that will receive the tokens | 
| tokenId | uint256 | uint256 ID of the token to be transferred | 
| _data | bytes | bytes optional data to send along with the call | 
Returns
| Name | Type | Description | 
|---|---|---|
| <none> | bool | bool whether the call correctly returned the expected magic value | 
_beforeTokenTransfer
*Hook that is called before any token transfer. This includes minting and burning. Calling conditions:
- When fromandtoare both non-zero,from'stokenIdwill be transferred toto.
- When fromis zero,tokenIdwill be minted forto.
- When tois zero,from'stokenIdwill be burned.
- fromand- toare never both zero. 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 virtual;