ERC721URIStorageLib
Title: ERC721URIStorageLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721URIStorage.sol)
Library implementing per-token URI storage for ERC-721 tokens (EIP-4906).
Designed to be composed with ERC721Lib. All state lives in an ERC-7201 slot.
Functions
erc721URIStorageStorage
function erc721URIStorageStorage() internal pure returns (ERC721URIStorageStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | ERC721URIStorageStorage |
__ERC721URIStorage_init
Initializes the ERC-721URIStorage module.
Must be called inside a pre/postInitializer block. Registers the ERC-4906 interface ID.
function __ERC721URIStorage_init() internal;registerInterface
Registers support for the ERC-4906 interface via ERC-165.
function registerInterface() internal;tokenURI
Returns the URI for tokenId.
Reverts with ERC721NonexistentToken for nonexistent tokens regardless of whether a per-token URI
entry exists, because OZ ERC721URIStorage calls _requireOwned before reading the suffix. With no base
URI it returns the per-token suffix (possibly empty). With a base URI it returns base + suffix when a
suffix is set, and the base ERC721 tokenURI (base + tokenId) otherwise.
function tokenURI(uint256 tokenId) internal view returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
_setTokenURI
Sets the token URI for tokenId and emits MetadataUpdate.
function _setTokenURI(uint256 tokenId, string memory uri) internal;Parameters
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 | |
| uri | string |
_suffixURI
Returns the per-token suffix of the tokenURI for tokenId (the stored URI, possibly empty).
OpenZeppelin v5.6 makes this a virtual hook. Library functions cannot be overridden, so a module
that needs a different suffix supplies its own tokenURI facet instead.
function _suffixURI(uint256 tokenId) internal view returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |