Note
|
This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc721 |
This set of interfaces, contracts, and utilities are all related to the ERC721 Non-Fungible Token Standard.
Tip
|
For a walk through on how to create an ERC721 token read our ERC721 guide. |
The EIP consists of three interfaces, found here as {IERC721}, {IERC721Metadata}, and {IERC721Enumerable}. Only the first one is required in a contract to be ERC721 compliant. The core interface and the metadata extension are both implemented in {ERC721}. The enumerable extension is provided separately in {ERC721Enumerable}.
Additionally, {IERC721Receiver} can be used to prevent tokens from becoming forever locked in contracts. Imagine sending an in-game item to an exchange address that can’t send it back!. When using safeTransferFrom
, the token contract checks to see that the receiver is an {IERC721Receiver}, which implies that it knows how to handle {ERC721} tokens. If you’re writing a contract that needs to receive {ERC721} tokens, you’ll want to include this interface.
Additionally there are multiple custom extensions, including:
-
designation of addresses that can pause token transfers for all users ({ERC721Pausable}).
-
destruction of own tokens ({ERC721Burnable}).
Note
|
This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC721 (such as _mint ) and expose them as external functions in the way they prefer. On the other hand, ERC721 Presets (such as {ERC721PresetMinterPauserAutoId}) are designed using opinionated patterns to provide developers with ready to use, deployable contracts.
|
{{IERC721}}
{{IERC721Metadata}}
{{IERC721Enumerable}}
{{ERC721}}
{{ERC721Enumerable}}
{{IERC721Receiver}}
These contracts are preconfigured combinations of the above features. They can be used through inheritance or as models to copy and paste their source code.
{{ERC721PresetMinterPauserAutoId}}