Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ERC1155SupplyUpgradeable

Inherits: Initializable, ERC1155Upgradeable

Extension of ERC-1155 that adds tracking of total supply per id. Useful for scenarios where Fungible and Non-fungible tokens have to be clearly identified. Note: While a totalSupply of 1 might mean the corresponding is an NFT, there is no guarantees that no other token with the same id are not going to be minted. NOTE: This contract implies a global limit of 2**256 - 1 to the number of tokens that can be minted. CAUTION: This extension should not be added in an upgrade to an already deployed contract.

State Variables

ERC1155SupplyStorageLocation

bytes32 private constant ERC1155SupplyStorageLocation =
    0x4a593662ee04d27b6a00ebb31be7fe0c102c2ade82a7c5d764f2df05dc4e2800;

Functions

_getERC1155SupplyStorage

function _getERC1155SupplyStorage() private pure returns (ERC1155SupplyStorage storage $);

__ERC1155Supply_init

function __ERC1155Supply_init() internal onlyInitializing;

__ERC1155Supply_init_unchained

function __ERC1155Supply_init_unchained() internal onlyInitializing;

totalSupply

Total value of tokens in with a given id.

function totalSupply(uint256 id) public view virtual returns (uint256);

totalSupply

Total value of tokens.

function totalSupply() public view virtual returns (uint256);

exists

Indicates whether any token exist with a given id, or not.

function exists(uint256 id) public view virtual returns (bool);

_update

*Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from (or to) is the zero address. Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. Requirements:

  • If to refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
  • ids and values must have the same length. NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.*
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual override;

Structs

ERC1155SupplyStorage

Note: storage-location: erc7201:openzeppelin.storage.ERC1155Supply

struct ERC1155SupplyStorage {
    mapping(uint256 id => uint256) _totalSupply;
    uint256 _totalSupplyAll;
}