{"eip":5615,"title":"ERC-1155 Supply Extension","description":"A simple mechanism to fetch token supply data from ERC-1155 tokens","authors":["Gavin John (@Pandapip1)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2023-05-25","requires":[1155],"discussionsTo":"https://ethereum-magicians.org/t/eip-5615-eip-1155-supply-extension/10732","repo":"ERCs","label":"ERC-5615","officialUrl":"https://eips.ethereum.org/EIPS/eip-5615","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5615.md","url":"https://eips.huatuo.xyz/eip-5615/","tldr":{"en":"Adds totalSupply(id) and exists(id) to ERC-1155 multi-token contracts, standardising the supply-tracking helpers that OpenZeppelin already shipped.","ja":"ERC-1155 のマルチトークンコントラクトに totalSupply(id) と exists(id) を追加し、OpenZeppelin がすでに提供していた供給量追跡のヘルパーを標準化します。","ko":"ERC-1155 멀티 토큰 컨트랙트에 totalSupply(id)와 exists(id)를 추가해, OpenZeppelin이 이미 제공하던 공급량 추적 헬퍼를 표준화합니다.","zh":"为 ERC-1155 多代币合约增加 totalSupply(id) 和 exists(id)，把 OpenZeppelin 早已提供的供应量跟踪辅助函数标准化。"},"tags":["token","multi-token","nft","supply","extension"],"explainers":{"en":{"lang":"en","tldr":"Adds totalSupply(id) and exists(id) to ERC-1155 multi-token contracts, standardising the supply-tracking helpers that OpenZeppelin already shipped.","tags":["token","multi-token","nft","supply","extension"],"related":[1155,721,20,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5615/","markdown":"## What problem does it solve?\n\n[ERC-1155](/eip-1155/) lets one contract hold many token types, each identified by an `id`. The base standard tells you how much of an `id` a given account holds, but not how many tokens of that `id` exist in total, or whether the `id` is even a real token type.\n\nMarketplaces, explorers and other contracts frequently need those answers: \"is this an edition of 100 or of 1?\", \"has this item been minted yet?\". Many implementations, most notably OpenZeppelin's `ERC1155Supply`, already exposed helper functions for this. ERC-5615 writes that existing practice down as a standard so callers can rely on the same two function signatures everywhere.\n\n## How it works\n\nThe extension adds two view functions:\n\n| Function | Returns |\n| --- | --- |\n| `totalSupply(uint256 id)` | Number of tokens of that `id` in circulation; `0` if the id does not exist |\n| `exists(uint256 id)` | Whether the id exists, previously existed, or may exist |\n\n`totalSupply` deliberately does not revert for unknown ids; it just returns zero. That leaves an ambiguity, since zero supply can mean \"nothing minted yet\" or \"this id will never be used\". `exists` is there to tell those two cases apart, which is why it is phrased loosely (\"exists, previously existed, or may exist\"): an implementation can return `true` for an id that is reserved but not yet minted, or one that has been fully burned.\n\nThe function names mirror `totalSupply` in [ERC-20](/eip-20/) and the existence checks common in [ERC-721](/eip-721/) contracts.\n\nThe ERC intentionally does not define an [ERC-165](/eip-165/) interface ID requirement. Implementations may advertise support, but callers must not depend on `supportsInterface` to detect it, because that would break compatibility with the many contracts deployed before the standard was written.\n\n## Sample code\n\nInterface plus a minimal tracking pattern inside mint/burn hooks:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC1155Supply {\n    function exists(uint256 id) external view returns (bool);\n    function totalSupply(uint256 id) external view returns (uint256);\n}\n\nabstract contract SupplyTracking is IERC1155Supply {\n    mapping(uint256 =\u003e uint256) private _supply;\n\n    function totalSupply(uint256 id) public view returns (uint256) {\n        return _supply[id];          // 0 for unknown ids, never reverts\n    }\n\n    function exists(uint256 id) public view virtual returns (bool) {\n        return _supply[id] \u003e 0;      // simplest policy; may be widened\n    }\n\n    function _afterMint(uint256 id, uint256 amount) internal {\n        _supply[id] += amount;\n    }\n\n    function _afterBurn(uint256 id, uint256 amount) internal {\n        _supply[id] -= amount;\n    }\n}\n```\n\nReading supply off-chain (ethers v6):\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst multi = new Contract(contractAddress, [\n  \"function totalSupply(uint256) view returns (uint256)\",\n  \"function exists(uint256) view returns (bool)\",\n], provider);\n\nconst id = 7n;\nif (await multi.exists(id)) {\n  console.log(\"edition size:\", await multi.totalSupply(id));\n}\n```\n\n## Things to know\n\n- Status is **Final**. It is designed to be backward compatible with OpenZeppelin's `ERC1155Supply`, so many existing contracts already conform.\n- Don't probe for this extension with `supportsInterface`; the spec says consumers must not rely on ERC-165 here. Call the functions directly and handle a revert if the contract lacks them.\n- `exists` returning `false` while `totalSupply` is `0` is the clearest signal that an id is unused; `exists` returning `true` with zero supply is legal (reserved or fully burned ids).\n- Supply tracking costs extra storage writes on every mint and burn.\n"},"ja":{"lang":"ja","tldr":"ERC-1155 のマルチトークンコントラクトに totalSupply(id) と exists(id) を追加し、OpenZeppelin がすでに提供していた供給量追跡のヘルパーを標準化します。","tags":["token","multi-token","nft","supply","extension"],"related":[1155,721,20,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5615/","markdown":"## 何を解決するのか\n\n[ERC-1155](/eip-1155/) では、1 つのコントラクトが多くのトークン種別を保持でき、それぞれが `id` で識別されます。基本標準は、あるアカウントがその `id` をどれだけ保有しているかは教えてくれますが、その `id` のトークンが合計でどれだけ存在するか、あるいはその `id` がそもそも実在するトークン種別なのかは教えてくれません。\n\nマーケットプレイス、エクスプローラー、他のコントラクトは、「これは 100 点限定のエディションか、1 点ものか」「このアイテムはもうミントされているか」といった答えをよく必要とします。多くの実装、とりわけ OpenZeppelin の `ERC1155Supply` は、そのためのヘルパー関数をすでに公開していました。ERC-5615 は、その既存の慣行を標準として書き下ろし、呼び出し側がどこでも同じ 2 つの関数シグネチャに頼れるようにします。\n\n## 仕組み\n\nこの拡張は、view 関数を 2 つ追加します。\n\n| 関数 | 戻り値 |\n| --- | --- |\n| `totalSupply(uint256 id)` | その `id` のトークンの流通量。`id` が存在しなければ `0` |\n| `exists(uint256 id)` | その id が存在する、かつて存在した、または存在しうるか |\n\n`totalSupply` は、未知の id に対して意図的にリバートせず、ゼロを返すだけです。そのためあいまいさが残ります。供給量ゼロは「まだ何もミントされていない」ことも「この id は決して使われない」ことも意味しうるからです。`exists` はその 2 つのケースを区別するためにあり、だからこそ表現が緩く（「存在する、かつて存在した、または存在しうる」）なっています。実装は、予約されているがまだミントされていない id や、完全にバーンされた id に対して `true` を返してもかまいません。\n\n関数名は、[ERC-20](/eip-20/) の `totalSupply` や、[ERC-721](/eip-721/) のコントラクトでよく見られる存在確認に倣っています。\n\nこの ERC は、[ERC-165](/eip-165/) のインターフェース ID を要件としては意図的に定義していません。実装が対応を表明してもかまいませんが、呼び出し側は検出のために `supportsInterface` に依存してはなりません。標準が書かれる前にデプロイされた多くのコントラクトとの互換性が壊れてしまうからです。\n\n## サンプルコード\n\nインターフェースと、mint/burn フック内での最小限の追跡パターンです。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC1155Supply {\n    function exists(uint256 id) external view returns (bool);\n    function totalSupply(uint256 id) external view returns (uint256);\n}\n\nabstract contract SupplyTracking is IERC1155Supply {\n    mapping(uint256 =\u003e uint256) private _supply;\n\n    function totalSupply(uint256 id) public view returns (uint256) {\n        return _supply[id];          // 0 for unknown ids, never reverts\n    }\n\n    function exists(uint256 id) public view virtual returns (bool) {\n        return _supply[id] \u003e 0;      // simplest policy; may be widened\n    }\n\n    function _afterMint(uint256 id, uint256 amount) internal {\n        _supply[id] += amount;\n    }\n\n    function _afterBurn(uint256 id, uint256 amount) internal {\n        _supply[id] -= amount;\n    }\n}\n```\n\nオフチェーンで供給量を読み取る例（ethers v6）:\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst multi = new Contract(contractAddress, [\n  \"function totalSupply(uint256) view returns (uint256)\",\n  \"function exists(uint256) view returns (bool)\",\n], provider);\n\nconst id = 7n;\nif (await multi.exists(id)) {\n  console.log(\"edition size:\", await multi.totalSupply(id));\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Final** です。OpenZeppelin の `ERC1155Supply` との後方互換性を持つように設計されているため、多くの既存コントラクトがすでに準拠しています。\n- この拡張の有無を `supportsInterface` で調べないでください。仕様は、利用側がここで ERC-165 に頼ってはならないとしています。関数を直接呼び出し、コントラクトにそれがない場合はリバートを処理してください。\n- `exists` が `false` を返し、かつ `totalSupply` が `0` であることが、id が未使用であることを示す最も明確なシグナルです。供給量がゼロのまま `exists` が `true` を返すことも許されます（予約済みまたは完全にバーンされた id）。\n- 供給量の追跡は、ミントとバーンのたびに追加のストレージ書き込みコストがかかります。\n"},"ko":{"lang":"ko","tldr":"ERC-1155 멀티 토큰 컨트랙트에 totalSupply(id)와 exists(id)를 추가해, OpenZeppelin이 이미 제공하던 공급량 추적 헬퍼를 표준화합니다.","tags":["token","multi-token","nft","supply","extension"],"related":[1155,721,20,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5615/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-1155](/eip-1155/)는 하나의 컨트랙트가 여러 토큰 종류를 보유하게 하며, 각 종류는 `id`로 식별됩니다. 기본 표준은 특정 계정이 해당 `id`를 얼마나 보유하는지는 알려주지만, 그 `id`의 토큰이 전체로 얼마나 존재하는지, 또는 그 `id`가 실제 토큰 종류인지는 알려주지 않습니다.\n\n마켓플레이스, 탐색기, 다른 컨트랙트는 \"이것은 100개 한정 에디션인가, 1개짜리인가?\", \"이 아이템은 이미 민팅되었는가?\" 같은 답이 자주 필요합니다. 많은 구현, 특히 OpenZeppelin의 `ERC1155Supply`가 이미 이를 위한 헬퍼 함수를 제공했습니다. ERC-5615는 그 기존 관행을 표준으로 기록해, 호출하는 쪽이 어디서나 같은 두 함수 시그니처에 의존할 수 있게 합니다.\n\n## 어떻게 동작하나요?\n\n이 확장은 view 함수 두 개를 추가합니다.\n\n| 함수 | 반환값 |\n| --- | --- |\n| `totalSupply(uint256 id)` | 해당 `id`의 유통 중인 토큰 수. id가 없으면 `0` |\n| `exists(uint256 id)` | 해당 id가 존재하는지, 과거에 존재했는지, 또는 존재할 수 있는지 |\n\n`totalSupply`는 알 수 없는 id에 대해 일부러 리버트하지 않고 0을 반환할 뿐입니다. 그래서 모호함이 남습니다. 공급량 0은 \"아직 아무것도 민팅되지 않았다\"는 뜻일 수도 있고 \"이 id는 결코 쓰이지 않을 것이다\"라는 뜻일 수도 있기 때문입니다. `exists`는 이 두 경우를 구별하기 위해 있으며, 그래서 표현이 느슨합니다(\"존재하거나, 과거에 존재했거나, 존재할 수 있음\"). 구현은 예약되었지만 아직 민팅되지 않은 id나 완전히 소각된 id에 대해 `true`를 반환할 수 있습니다.\n\n함수 이름은 [ERC-20](/eip-20/)의 `totalSupply`와 [ERC-721](/eip-721/) 컨트랙트에서 흔한 존재 확인을 따릅니다.\n\n이 ERC는 [ERC-165](/eip-165/) 인터페이스 ID 요구 사항을 일부러 정의하지 않습니다. 구현이 지원을 알릴 수는 있지만, 호출하는 쪽은 이를 감지하기 위해 `supportsInterface`에 의존해서는 안 됩니다. 표준이 작성되기 전에 배포된 수많은 컨트랙트와의 호환성이 깨지기 때문입니다.\n\n## 샘플 코드\n\n인터페이스와 mint/burn 훅 안에서의 최소한의 추적 패턴입니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC1155Supply {\n    function exists(uint256 id) external view returns (bool);\n    function totalSupply(uint256 id) external view returns (uint256);\n}\n\nabstract contract SupplyTracking is IERC1155Supply {\n    mapping(uint256 =\u003e uint256) private _supply;\n\n    function totalSupply(uint256 id) public view returns (uint256) {\n        return _supply[id];          // 0 for unknown ids, never reverts\n    }\n\n    function exists(uint256 id) public view virtual returns (bool) {\n        return _supply[id] \u003e 0;      // simplest policy; may be widened\n    }\n\n    function _afterMint(uint256 id, uint256 amount) internal {\n        _supply[id] += amount;\n    }\n\n    function _afterBurn(uint256 id, uint256 amount) internal {\n        _supply[id] -= amount;\n    }\n}\n```\n\n오프체인에서 공급량 읽기(ethers v6):\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst multi = new Contract(contractAddress, [\n  \"function totalSupply(uint256) view returns (uint256)\",\n  \"function exists(uint256) view returns (bool)\",\n], provider);\n\nconst id = 7n;\nif (await multi.exists(id)) {\n  console.log(\"edition size:\", await multi.totalSupply(id));\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Final**입니다. OpenZeppelin의 `ERC1155Supply`와 하위 호환되도록 설계되어 이미 많은 기존 컨트랙트가 부합합니다.\n- 이 확장을 `supportsInterface`로 탐지하지 마세요. 명세는 소비하는 쪽이 여기서 ERC-165에 의존해서는 안 된다고 합니다. 함수를 직접 호출하고, 컨트랙트에 없으면 리버트를 처리하세요.\n- `exists`가 `false`를 반환하고 `totalSupply`가 `0`인 것이 id가 사용되지 않는다는 가장 분명한 신호입니다. 공급량이 0인데 `exists`가 `true`를 반환하는 것도 허용됩니다(예약되었거나 완전히 소각된 id).\n- 공급량 추적은 매 민팅과 소각마다 추가 스토리지 쓰기 비용이 듭니다.\n"},"zh":{"lang":"zh","tldr":"为 ERC-1155 多代币合约增加 totalSupply(id) 和 exists(id)，把 OpenZeppelin 早已提供的供应量跟踪辅助函数标准化。","tags":["token","multi-token","nft","supply","extension"],"related":[1155,721,20,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5615/","markdown":"## 它解决什么问题？\n\n[ERC-1155](/eip-1155/) 允许一个合约持有多种代币类型，每种由一个 `id` 标识。基础标准能告诉你某个账户持有多少该 `id` 的代币，却不能告诉你该 `id` 的代币总共存在多少，也不能告诉你这个 `id` 是否真的是一种代币类型。\n\n市场、浏览器和其他合约经常需要这些答案：\"这是 100 份的版本，还是 1 份的？\"\"这件物品已经铸造了吗？\"许多实现，尤其是 OpenZeppelin 的 `ERC1155Supply`，早已为此提供了辅助函数。ERC-5615 把这种既有做法写成标准，让调用方可以在任何地方依赖同样的两个函数签名。\n\n## 它如何运作\n\n该扩展增加两个 view 函数：\n\n| 函数 | 返回值 |\n| --- | --- |\n| `totalSupply(uint256 id)` | 该 `id` 的流通代币数量；如果该 id 不存在则为 `0` |\n| `exists(uint256 id)` | 该 id 是否存在、曾经存在或可能存在 |\n\n`totalSupply` 对未知 id 刻意不回滚，只返回零。这就留下了歧义，因为供应量为零既可能表示\"还没铸造任何代币\"，也可能表示\"这个 id 永远不会被使用\"。`exists` 就是用来区分这两种情况的，所以它的措辞比较宽松（\"存在、曾经存在或可能存在\"）：对于已预留但尚未铸造的 id，或已被完全销毁的 id，实现可以返回 `true`。\n\n这些函数名沿用了 [ERC-20](/eip-20/) 中的 `totalSupply` 以及 [ERC-721](/eip-721/) 合约中常见的存在性检查。\n\n该 ERC 刻意不要求定义 [ERC-165](/eip-165/) 接口 ID。实现可以声明支持，但调用方不得依赖 `supportsInterface` 来检测，因为那样会破坏与标准撰写之前部署的众多合约的兼容性。\n\n## 示例代码\n\n接口，以及在 mint/burn 钩子中的最小跟踪模式：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IERC1155Supply {\n    function exists(uint256 id) external view returns (bool);\n    function totalSupply(uint256 id) external view returns (uint256);\n}\n\nabstract contract SupplyTracking is IERC1155Supply {\n    mapping(uint256 =\u003e uint256) private _supply;\n\n    function totalSupply(uint256 id) public view returns (uint256) {\n        return _supply[id];          // 0 for unknown ids, never reverts\n    }\n\n    function exists(uint256 id) public view virtual returns (bool) {\n        return _supply[id] \u003e 0;      // simplest policy; may be widened\n    }\n\n    function _afterMint(uint256 id, uint256 amount) internal {\n        _supply[id] += amount;\n    }\n\n    function _afterBurn(uint256 id, uint256 amount) internal {\n        _supply[id] -= amount;\n    }\n}\n```\n\n在链下读取供应量（ethers v6）：\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst multi = new Contract(contractAddress, [\n  \"function totalSupply(uint256) view returns (uint256)\",\n  \"function exists(uint256) view returns (bool)\",\n], provider);\n\nconst id = 7n;\nif (await multi.exists(id)) {\n  console.log(\"edition size:\", await multi.totalSupply(id));\n}\n```\n\n## 需要注意\n\n- 状态为 **Final**。它被设计为与 OpenZeppelin 的 `ERC1155Supply` 向后兼容，所以许多现有合约已经符合要求。\n- 不要用 `supportsInterface` 探测该扩展；规范规定使用方在此处不得依赖 ERC-165。请直接调用这些函数，并在合约缺少它们时处理回滚。\n- `exists` 返回 `false` 且 `totalSupply` 为 `0`，是该 id 未被使用的最明确信号；`exists` 返回 `true` 而供应量为零也是合法的（已预留或已被完全销毁的 id）。\n- 供应量跟踪会在每次铸造和销毁时带来额外的存储写入成本。\n"}},"requiredBy":[8047]}
