ERC1155URIStorageLib
Title: ERC1155URIStorageLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol)
Library implementing per-token URI storage for ERC-1155 tokens, with an optional base URI.
Composed with ERC1155Lib: a token without a per-token URI falls back to the ERC-1155 URI template. All state lives in its own ERC-7201 slot.
Functions
erc1155URIStorageStorage
function erc1155URIStorageStorage() internal pure returns (ERC1155URIStorageStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | ERC1155URIStorageStorage |
__ERC1155URIStorage_init
Initializes the ERC-1155 URI storage module: registers IERC1155URIStorage via ERC-165.
Must be called inside a pre/postInitializer block. The base URI starts empty, as in OpenZeppelin.
function __ERC1155URIStorage_init() internal;registerInterface
Registers support for the IERC1155URIStorage interface via ERC-165.
function registerInterface() internal;uri
Returns the URI for token type tokenId.
If a per-token URI is set, returns the base URI followed by it (the base URI is empty by default).
Otherwise returns ERC1155Lib.uri, the ERC-1155 URI template, which is empty if never set.
function uri(uint256 tokenId) internal view returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
_setURI
Sets tokenURI as the per-token URI of tokenId and emits IERC1155.URI with the resolved
uri(tokenId).
function _setURI(uint256 tokenId, string memory tokenURI) internal;Parameters
| Name | Type | Description |
|---|---|---|
| tokenId | uint256 | |
| tokenURI | string |
_setBaseURI
Sets baseURI as the prefix of every non-empty per-token URI.
function _setBaseURI(string memory baseURI) internal;Parameters
| Name | Type | Description |
|---|---|---|
| baseURI | string |