⚠️ This EIP is not recommended for general use or implementation as it is likely to change.

EIP-5615: EIP-1155 Supply Extension Source

A simple mechanism to fetch token supply data from EIP-1155 tokens

AuthorPandapip1
Discussions-Tohttps://ethereum-magicians.org/t/eip-5615-eip-1155-supply-extension/10732
StatusDraft
TypeStandards Track
CategoryERC
Created2022-09-07
Requires 1155

Abstract

This EIP introduces a simple mechanism to fetch token supply data from EIP-1155 tokens that is backward compatible with most existing solutions. It adds a totalSupply function, which fetches the total supply of a given token ID, and an exists function, which checks for the existence of a given token 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 returns the total supply (number of tokens in circulation) with a given ID if it exists, otherwise it MUST revert
  // @param   id  The ID of which fetch the total supply
  // @return      The total supply of the given token ID
  function totalSupply(uint256 id) external view returns (uint256);

  // @notice      This function MUST return true if the given token ID exists, otherwise it MUST return false
  // @param   id  The ID of which to check the existence
  // @return      Whether the given token ID exists or not
  function exists(uint256 id) external view returns (bool);
}

Rationale

This EIP does not extend EIP-165 as this interface was deemed simple enough that the extra complexity was unnecessary. It would also break backward compatibility with potential existing implementations.

Backwards Compatibility

This EIP is backward compatible with the OpenZeppelin ERC1155Supply.

Security Considerations

Needs discussion.

Copyright and related rights waived via CC0.

Citation

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.