EIP-5615: EIP-1155 Supply Extension
A simple mechanism to fetch token supply data from EIP-1155 tokens
作者 | Pandapip1 |
---|---|
讨论-To | https://ethereum-magicians.org/t/eip-5615-eip-1155-supply-extension/10732 |
状态 | Review |
类型 | Standards Track |
分类 | ERC |
创建日期 | 2022-09-07 |
依赖 | 1155 |
英文版 | https://eips.ethereum.org/EIPS/eip-5615 |
Abstract
This EIP standardizes an existing mechanism to fetch token supply data from EIP-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);
}
Rationale
This EIP does not implement EIP-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 EIP-721 and EIP-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).
向后兼容性
This EIP is designed to be backward compatible with the OpenZeppelin ERC1155Supply
.
Security Considerations
Needs discussion.
Copyright
Copyright and related rights waived via CC0.
参考文献
Please cite this document as:
Pandapip1, "EIP-5615: EIP-1155 Supply Extension [DRAFT]," Ethereum Improvement Proposals, no. 5615, September 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5615.