ERC-1155 Supply Extension
ERC-5615 is an Ethereum Improvement Proposal that extends the ERC-1155 token standard by adding a totalSupply function and an exists function. These functions were modeled after the ERC-721 and ERC-20 standards. The totalSupply function returns the total number of tokens that have been minted for a given token ID, while the exists function checks if a token with a given ID exists. The exists function is included to differentiate between the two ways that totalSupply could equal zero.
The proposal is designed to be backward compatible with the OpenZeppelin ERC1155Supply. There are no security considerations for this proposal, and copyright and related rights have been waived via CC0.
Overall, ERC-5615 aims to make it easier for developers to track the total supply of tokens and check if a token with a given ID exists. This can be useful for various use cases, such as managing inventory or tracking ownership of unique assets.
Video
Original
Abstract
This ERC standardizes an existing mechanism to fetch token supply data from ERC-1155 tokens. It adds a totalSupply
function, which fetches the number of tokens with a given id
, and an exists
function, which checks for the existence of a given id
.
Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
interface ERC1155Supply is ERC1155 { // @notice This function MUST return whether the given token id exists, previously existed, or may exist // @param id The token id of which to check the existence // @return Whether the given token id exists, previously existed, or may exist function exists(uint256 id) external view returns (bool); // @notice This function MUST return the number of tokens with a given id. If the token id does not exist, it MUST return 0. // @param id The token id of which fetch the total supply // @return The total supply of the given token id function totalSupply(uint256 id) external view returns (uint256); }
Implementations MAY support ERC-165 interface discovery, but consumers MUST NOT rely on it.
Rationale
This ERC does not implement ERC-165, as this interface is simple enough that the extra complexity is unnecessary and would cause incompatibilities with pre-existing implementations.
The totalSupply
and exists
functions were modeled after ERC-721 and ERC-20.
totalSupply
does not revert if the token ID does not exist, since contracts that care about that case should use exists
instead (which might return false even if totalSupply
is zero).
exists
is included to differentiate between the two ways that totalSupply
could equal zero (either no tokens with the given ID have been minted yet, or no tokens with the given ID will ever be minted).
Backwards Compatibility
This ERC is designed to be backward compatible with the OpenZeppelin ERC1155Supply
.
Security Considerations
None.
Copyright
Copyright and related rights waived via CC0.
Adopted by projects
Not miss a beat of EIPs' update?
Subscribe EIPs Fun to receive the latest updates of EIPs Good for Buidlers to follow up.
View all