{"eip":7546,"title":"Upgradeable Clone for Scalable Contracts","description":"An upgradeable, cloneable, horizontally extensible proxy pattern.","authors":["Shogo Ochiai (@shogochiai) \u003cshogo.ochiai@pm.me\u003e","Kai Hiroi (@KaiHiroi) \u003ckai.hiroi@pm.me\u003e"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-10-25","requires":[165,1967,7201],"discussionsTo":"https://ethereum-magicians.org/t/eip-7546-upgradeable-clone/16256","repo":"ERCs","label":"ERC-7546","officialUrl":"https://eips.ethereum.org/EIPS/eip-7546","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7546.md","url":"https://eips.huatuo.xyz/eip-7546/","tldr":{"en":"A draft proxy pattern that combines per-function upgrades (like Diamonds) with beacon-style shared upgrades, so many cloned proxies can be upgraded function by function in one transaction.","ja":"関数単位のアップグレード（Diamond のような方式）と、Beacon 型の共有アップグレードを組み合わせたドラフトのプロキシパターン。複製された多数のプロキシを、1 回のトランザクションで関数ごとにアップグレードできる。","ko":"함수 단위 업그레이드(Diamond 방식)와 비콘식 공유 업그레이드를 결합한 초안 프록시 패턴. 복제된 많은 프록시를 한 번의 트랜잭션으로 함수별로 업그레이드할 수 있다.","zh":"一种草案代理模式，把按函数升级（类似 Diamond）与信标式共享升级结合起来，使大量克隆代理可以在一笔交易中逐函数升级。"},"tags":["proxy","upgradeability","clone","factory","solidity"],"explainers":{"en":{"lang":"en","tldr":"A draft proxy pattern that combines per-function upgrades (like Diamonds) with beacon-style shared upgrades, so many cloned proxies can be upgraded function by function in one transaction.","tags":["proxy","upgradeability","clone","factory","solidity"],"related":[2535,1967,1167,7201,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7546/","markdown":"## What problem does it solve?\n\nExisting proxy standards each cover part of the space:\n\n| Need | Existing answer |\n| --- | --- |\n| Cheap clones, no upgrades | [ERC-1167](/eip-1167/) minimal proxy |\n| Upgrade the whole contract | UUPS / transparent proxies |\n| Upgrade many clones at once | Beacon proxy from [ERC-1967](/eip-1967/) |\n| Upgrade individual functions | [ERC-2535](/eip-2535/) Diamonds |\n\nWhat is missing is **function-level upgrades for a factory of clones**. A Diamond stores its selector-to-facet table inside each proxy, so upgrading 1,000 cloned Diamonds means 1,000 updates. ERC-7546, the *Upgradeable Clone Standard* (UCS), fills that gap. Splitting logic per function also helps with the 24,576-byte contract size limit.\n\n## How it works\n\nOne logical contract is split into three parts:\n\n1. **Proxy**: holds the state (balance, storage). It stores the address of a Dictionary in the ERC-1967-style slot `bytes32(uint256(keccak256('erc7546.proxy.dictionary')) - 1)`. On every call it asks the Dictionary `getImplementation(msg.sig)` and delegatecalls the result. It should define no external functions of its own, to avoid selector clashes, and emits `DictionaryUpgraded` when the Dictionary changes.\n2. **Dictionary**: a shared registry mapping function selectors to implementation addresses, with `getImplementation` and usually `setImplementation`, emitting `ImplementationUpgraded`. It may also answer ERC-165 `supportsInterface` for the whole set.\n3. **Function contracts**: the logic, one or more functions each. They run in the proxy's storage via delegatecall.\n\nBecause many proxies can point at the same Dictionary, one `setImplementation` call upgrades a function for **all** of them at once, like a beacon but per function.\n\n## Sample code\n\nA minimal UCS proxy (simplified from the spec's design):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IDictionary {\n    function getImplementation(bytes4 selector) external view returns (address);\n}\n\ncontract UCSProxy {\n    // bytes32(uint256(keccak256(\"erc7546.proxy.dictionary\")) - 1)\n    bytes32 internal constant DICTIONARY_SLOT =\n        0x267691be3525af8a813d30db0c9e2bad08f63baecf6dceb85e2cf3676cff56f4;\n\n    event DictionaryUpgraded(address dictionary);\n\n    constructor(address dictionary, bytes memory initData) {\n        assembly { sstore(DICTIONARY_SLOT, dictionary) }\n        emit DictionaryUpgraded(dictionary);\n        if (initData.length \u003e 0) {\n            (bool ok, ) = address(this).call(initData);\n            require(ok, \"init failed\");\n        }\n    }\n\n    fallback() external payable {\n        address dict;\n        assembly { dict := sload(DICTIONARY_SLOT) }\n        address impl = IDictionary(dict).getImplementation(msg.sig);\n        require(impl != address(0), \"no impl\");\n        assembly {\n            calldatacopy(0, 0, calldatasize())\n            let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)\n            returndatacopy(0, 0, returndatasize())\n            switch ok case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) }\n        }\n    }\n}\n```\n\n## Things to know\n\n- Status is **Draft**.\n- All function contracts share the proxy's storage, so layout collisions are a real risk. The spec does not fix a method but suggests namespaced storage such as [ERC-7201](/eip-7201/).\n- Whoever controls the Dictionary controls every connected proxy's code. Do not attach a proxy to a Dictionary run by an untrusted admin, and consider allowing a switch to another Dictionary.\n- Hard-coding the Dictionary address (immutable) can permanently lock you out of changes if the Dictionary admin differs from yours.\n- Register a selector only on a function contract that actually implements it; a mismatch makes calls fail. The proxy is not meant to be called with `DELEGATECALL`.\n"},"ja":{"lang":"ja","tldr":"関数単位のアップグレード（Diamond のような方式）と、Beacon 型の共有アップグレードを組み合わせたドラフトのプロキシパターン。複製された多数のプロキシを、1 回のトランザクションで関数ごとにアップグレードできる。","tags":["proxy","upgradeability","clone","factory","solidity"],"related":[2535,1967,1167,7201,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7546/","markdown":"## 何を解決するのか\n\n既存のプロキシ標準は、それぞれ領域の一部をカバーしています。\n\n| 必要なこと | 既存の解 |\n| --- | --- |\n| 安価なクローン、アップグレードなし | [ERC-1167](/eip-1167/) ミニマルプロキシ |\n| コントラクト全体をアップグレード | UUPS / トランスペアレントプロキシ |\n| 多数のクローンを一度にアップグレード | [ERC-1967](/eip-1967/) の Beacon プロキシ |\n| 個々の関数をアップグレード | [ERC-2535](/eip-2535/) Diamond |\n\n欠けているのは、**クローンのファクトリーに対する関数単位のアップグレード**です。Diamond はセレクターから facet への対応表を各プロキシの内部に保持するため、1,000 個の Diamond クローンをアップグレードするには 1,000 回の更新が必要です。ERC-7546、*Upgradeable Clone Standard*（UCS）はこの隙間を埋めます。ロジックを関数ごとに分割することは、24,576 バイトのコントラクトサイズ制限への対処にも役立ちます。\n\n## 仕組み\n\n1 つの論理的なコントラクトを 3 つの部分に分割します。\n\n1. **Proxy**: 状態（残高、ストレージ）を保持します。ERC-1967 形式のスロット `bytes32(uint256(keccak256('erc7546.proxy.dictionary')) - 1)` に Dictionary のアドレスを保存します。呼び出しのたびに Dictionary に `getImplementation(msg.sig)` を問い合わせ、その結果に delegatecall します。セレクターの衝突を避けるため、自身の external 関数は定義しないようにし、Dictionary が変更されたときは `DictionaryUpgraded` を emit します。\n2. **Dictionary**: 関数セレクターを実装アドレスに対応づける共有レジストリです。`getImplementation` と、通常は `setImplementation` を持ち、`ImplementationUpgraded` を emit します。セット全体について ERC-165 の `supportsInterface` に答えることもあります。\n3. **Function contracts**: ロジック本体で、それぞれ 1 つ以上の関数を持ちます。delegatecall によってプロキシのストレージ上で実行されます。\n\n多数のプロキシが同じ Dictionary を指せるため、`setImplementation` を 1 回呼ぶだけで、**すべて**のプロキシの関数を一度にアップグレードできます。Beacon のようですが、関数単位です。\n\n## サンプルコード\n\n最小限の UCS プロキシ（仕様の設計を簡略化したもの）:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IDictionary {\n    function getImplementation(bytes4 selector) external view returns (address);\n}\n\ncontract UCSProxy {\n    // bytes32(uint256(keccak256(\"erc7546.proxy.dictionary\")) - 1)\n    bytes32 internal constant DICTIONARY_SLOT =\n        0x267691be3525af8a813d30db0c9e2bad08f63baecf6dceb85e2cf3676cff56f4;\n\n    event DictionaryUpgraded(address dictionary);\n\n    constructor(address dictionary, bytes memory initData) {\n        assembly { sstore(DICTIONARY_SLOT, dictionary) }\n        emit DictionaryUpgraded(dictionary);\n        if (initData.length \u003e 0) {\n            (bool ok, ) = address(this).call(initData);\n            require(ok, \"init failed\");\n        }\n    }\n\n    fallback() external payable {\n        address dict;\n        assembly { dict := sload(DICTIONARY_SLOT) }\n        address impl = IDictionary(dict).getImplementation(msg.sig);\n        require(impl != address(0), \"no impl\");\n        assembly {\n            calldatacopy(0, 0, calldatasize())\n            let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)\n            returndatacopy(0, 0, returndatasize())\n            switch ok case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) }\n        }\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。\n- すべての function contract はプロキシのストレージを共有するため、レイアウトの衝突は現実的なリスクです。仕様は方法を定めていませんが、[ERC-7201](/eip-7201/) のような名前空間付きストレージを提案しています。\n- Dictionary を管理する者は、接続されたすべてのプロキシのコードを支配します。信頼できない管理者が運用する Dictionary にプロキシを接続しないでください。別の Dictionary に切り替えられるようにすることも検討してください。\n- Dictionary のアドレスをハードコード（immutable）すると、Dictionary の管理者があなたと異なる場合、変更が永久にできなくなる可能性があります。\n- セレクターは、それを実際に実装している function contract にのみ登録してください。不一致があると呼び出しが失敗します。プロキシは `DELEGATECALL` で呼び出されることを想定していません。\n"},"ko":{"lang":"ko","tldr":"함수 단위 업그레이드(Diamond 방식)와 비콘식 공유 업그레이드를 결합한 초안 프록시 패턴. 복제된 많은 프록시를 한 번의 트랜잭션으로 함수별로 업그레이드할 수 있다.","tags":["proxy","upgradeability","clone","factory","solidity"],"related":[2535,1967,1167,7201,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7546/","markdown":"## 어떤 문제를 해결하나요?\n\n기존 프록시 표준은 각각 영역의 일부만 다룹니다.\n\n| 필요 | 기존 해법 |\n| --- | --- |\n| 저렴한 클론, 업그레이드 없음 | [ERC-1167](/eip-1167/) 미니멀 프록시 |\n| 컨트랙트 전체 업그레이드 | UUPS / 투명 프록시 |\n| 많은 클론을 한꺼번에 업그레이드 | [ERC-1967](/eip-1967/)의 비콘 프록시 |\n| 개별 함수 업그레이드 | [ERC-2535](/eip-2535/) Diamond |\n\n빠져 있는 것은 **클론 팩토리를 위한 함수 단위 업그레이드**입니다. Diamond는 셀렉터와 facet의 매핑 표를 각 프록시 안에 저장하므로, 복제된 Diamond 1,000개를 업그레이드하려면 1,000번의 업데이트가 필요합니다. ERC-7546, *Upgradeable Clone Standard*(UCS)가 이 틈을 메웁니다. 로직을 함수별로 나누면 24,576바이트 컨트랙트 크기 제한에도 도움이 됩니다.\n\n## 어떻게 동작하나요?\n\n하나의 논리적 컨트랙트를 세 부분으로 나눕니다.\n\n1. **Proxy**: 상태(잔액, 스토리지)를 보관합니다. ERC-1967 방식의 슬롯 `bytes32(uint256(keccak256('erc7546.proxy.dictionary')) - 1)`에 Dictionary의 주소를 저장합니다. 호출할 때마다 Dictionary에 `getImplementation(msg.sig)`를 물어보고 그 결과로 delegatecall합니다. 셀렉터 충돌을 피하려면 자체 external 함수를 정의하지 않아야 하며, Dictionary가 바뀌면 `DictionaryUpgraded`를 emit합니다.\n2. **Dictionary**: 함수 셀렉터를 구현 주소에 매핑하는 공유 레지스트리입니다. `getImplementation`과 보통 `setImplementation`을 제공하고 `ImplementationUpgraded`를 emit합니다. 집합 전체에 대해 ERC-165 `supportsInterface`에 응답할 수도 있습니다.\n3. **Function contracts**: 로직 본체이며 각각 하나 이상의 함수를 가집니다. delegatecall을 통해 프록시의 스토리지에서 실행됩니다.\n\n많은 프록시가 같은 Dictionary를 가리킬 수 있으므로, `setImplementation`을 한 번 호출하면 **모든** 프록시의 함수가 한꺼번에 업그레이드됩니다. 비콘과 비슷하지만 함수 단위입니다.\n\n## 샘플 코드\n\n최소한의 UCS 프록시(명세의 설계를 단순화한 것):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IDictionary {\n    function getImplementation(bytes4 selector) external view returns (address);\n}\n\ncontract UCSProxy {\n    // bytes32(uint256(keccak256(\"erc7546.proxy.dictionary\")) - 1)\n    bytes32 internal constant DICTIONARY_SLOT =\n        0x267691be3525af8a813d30db0c9e2bad08f63baecf6dceb85e2cf3676cff56f4;\n\n    event DictionaryUpgraded(address dictionary);\n\n    constructor(address dictionary, bytes memory initData) {\n        assembly { sstore(DICTIONARY_SLOT, dictionary) }\n        emit DictionaryUpgraded(dictionary);\n        if (initData.length \u003e 0) {\n            (bool ok, ) = address(this).call(initData);\n            require(ok, \"init failed\");\n        }\n    }\n\n    fallback() external payable {\n        address dict;\n        assembly { dict := sload(DICTIONARY_SLOT) }\n        address impl = IDictionary(dict).getImplementation(msg.sig);\n        require(impl != address(0), \"no impl\");\n        assembly {\n            calldatacopy(0, 0, calldatasize())\n            let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)\n            returndatacopy(0, 0, returndatasize())\n            switch ok case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) }\n        }\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다.\n- 모든 function contract가 프록시의 스토리지를 공유하므로 레이아웃 충돌은 현실적인 위험입니다. 명세는 방법을 정하지 않지만 [ERC-7201](/eip-7201/) 같은 네임스페이스 스토리지를 제안합니다.\n- Dictionary를 통제하는 사람이 연결된 모든 프록시의 코드를 통제합니다. 신뢰할 수 없는 관리자가 운영하는 Dictionary에 프록시를 연결하지 말고, 다른 Dictionary로 전환할 수 있게 하는 것도 고려하세요.\n- Dictionary 주소를 하드코딩(immutable)하면 Dictionary 관리자가 내가 아닐 경우 변경이 영구히 막힐 수 있습니다.\n- 셀렉터는 실제로 그것을 구현한 function contract에만 등록하세요. 불일치하면 호출이 실패합니다. 프록시는 `DELEGATECALL`로 호출되도록 설계되지 않았습니다.\n"},"zh":{"lang":"zh","tldr":"一种草案代理模式，把按函数升级（类似 Diamond）与信标式共享升级结合起来，使大量克隆代理可以在一笔交易中逐函数升级。","tags":["proxy","upgradeability","clone","factory","solidity"],"related":[2535,1967,1167,7201,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7546/","markdown":"## 它解决什么问题？\n\n现有的代理标准各自覆盖了一部分场景：\n\n| 需求 | 现有方案 |\n| --- | --- |\n| 廉价克隆，无升级 | [ERC-1167](/eip-1167/) 最小代理 |\n| 升级整个合约 | UUPS / 透明代理 |\n| 一次升级许多克隆 | [ERC-1967](/eip-1967/) 的信标代理 |\n| 升级单个函数 | [ERC-2535](/eip-2535/) Diamond |\n\n缺少的是**面向克隆工厂的函数级升级**。Diamond 把选择器到 facet 的映射表存放在每个代理内部，所以升级 1,000 个克隆的 Diamond 就意味着 1,000 次更新。ERC-7546，即 *Upgradeable Clone Standard*（UCS），填补了这个空白。按函数拆分逻辑也有助于应对 24,576 字节的合约大小限制。\n\n## 它如何运作\n\n一个逻辑上的合约被拆成三部分：\n\n1. **Proxy**：保存状态（余额、存储）。它把 Dictionary 的地址存放在 ERC-1967 风格的槽位 `bytes32(uint256(keccak256('erc7546.proxy.dictionary')) - 1)` 中。每次调用时，它向 Dictionary 查询 `getImplementation(msg.sig)`，并对结果执行 delegatecall。为避免选择器冲突，它不应定义自己的 external 函数，并在 Dictionary 变更时触发 `DictionaryUpgraded`。\n2. **Dictionary**：一个共享注册表，把函数选择器映射到实现地址，提供 `getImplementation`，通常还有 `setImplementation`，并触发 `ImplementationUpgraded`。它也可以为整个集合回答 ERC-165 的 `supportsInterface`。\n3. **Function contracts**：逻辑部分，每个包含一个或多个函数。它们通过 delegatecall 在代理的存储中运行。\n\n由于许多代理可以指向同一个 Dictionary，一次 `setImplementation` 调用就能同时为**所有**代理升级一个函数，就像信标，但粒度是函数级。\n\n## 示例代码\n\n一个最小的 UCS 代理（从规范的设计简化而来）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ninterface IDictionary {\n    function getImplementation(bytes4 selector) external view returns (address);\n}\n\ncontract UCSProxy {\n    // bytes32(uint256(keccak256(\"erc7546.proxy.dictionary\")) - 1)\n    bytes32 internal constant DICTIONARY_SLOT =\n        0x267691be3525af8a813d30db0c9e2bad08f63baecf6dceb85e2cf3676cff56f4;\n\n    event DictionaryUpgraded(address dictionary);\n\n    constructor(address dictionary, bytes memory initData) {\n        assembly { sstore(DICTIONARY_SLOT, dictionary) }\n        emit DictionaryUpgraded(dictionary);\n        if (initData.length \u003e 0) {\n            (bool ok, ) = address(this).call(initData);\n            require(ok, \"init failed\");\n        }\n    }\n\n    fallback() external payable {\n        address dict;\n        assembly { dict := sload(DICTIONARY_SLOT) }\n        address impl = IDictionary(dict).getImplementation(msg.sig);\n        require(impl != address(0), \"no impl\");\n        assembly {\n            calldatacopy(0, 0, calldatasize())\n            let ok := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)\n            returndatacopy(0, 0, returndatasize())\n            switch ok case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) }\n        }\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**。\n- 所有 function contract 共享代理的存储，因此布局冲突是真实存在的风险。规范没有规定具体方法，但建议使用带命名空间的存储，例如 [ERC-7201](/eip-7201/)。\n- 谁控制 Dictionary，谁就控制所有相连代理的代码。不要把代理接到由不受信任的管理员运营的 Dictionary 上，并考虑允许切换到另一个 Dictionary。\n- 把 Dictionary 地址硬编码（immutable）可能会让你永久无法变更，如果 Dictionary 的管理员与你不是同一方。\n- 只在真正实现了某个选择器的 function contract 上注册该选择器；不匹配会导致调用失败。代理并不打算通过 `DELEGATECALL` 来调用。\n"}}}
