{"eip":4931,"title":"Generic Token Upgrade Standard","description":"Create a standard interface for upgrading ERC20 token contracts.","authors":["John Peterson (@John-peterson-coinbase)","Roberto Bayardo (@roberto-bayardo)","David Núñez (@cygnusv)"],"status":"Stagnant","type":"Standards Track","category":"ERC","created":"2021-11-02","requires":[20],"discussionsTo":"https://ethereum-magicians.org/t/eip-4931-generic-token-upgrade-standard/8687","repo":"ERCs","label":"ERC-4931","officialUrl":"https://eips.ethereum.org/EIPS/eip-4931","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-4931.md","url":"https://eips.huatuo.xyz/eip-4931/","tldr":{"en":"A standard interface for migrating holders from an old ERC-20 contract to a new one at a fixed ratio, so wallets and exchanges can run any token upgrade the same way.","ja":"旧 ERC-20 コントラクトから新しいコントラクトへ、固定レートで保有者を移行するための標準インターフェース。ウォレットや取引所がどのトークンアップグレードも同じ方法で実行できる。","ko":"보유자를 이전 ERC-20 컨트랙트에서 새 컨트랙트로 고정 비율에 따라 이전하기 위한 표준 인터페이스. 지갑과 거래소가 어떤 토큰 업그레이드든 같은 방식으로 처리할 수 있다.","zh":"一个标准接口，用于按固定比例把持有者从旧 ERC-20 合约迁移到新合约，让钱包和交易所能以同样的方式执行任何代币升级。"},"tags":["erc-20","migration","upgrade","token","exchanges"],"explainers":{"en":{"lang":"en","tldr":"A standard interface for migrating holders from an old ERC-20 contract to a new one at a fixed ratio, so wallets and exchanges can run any token upgrade the same way.","tags":["erc-20","migration","upgrade","token","exchanges"],"related":[20,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4931/","markdown":"## What problem does it solve?\n\nWhen a project replaces its [ERC-20](/eip-20/) contract (a bug fix, a rebrand, a token split or merge), every holder has to swap old tokens for new ones. Each project builds its own migration contract and UI, so exchanges and custodians must review and script every migration from scratch, and users have to trust a bespoke interface.\n\nERC-4931 standardizes the migration contract itself. Once an exchange or wallet supports the interface, it can process any compliant token upgrade with the same code, and auditors know what behavior to expect.\n\n## How it works\n\nA separate *upgrade contract* sits between the **source** (old) token and the **destination** (new) token:\n\n| Function | Purpose |\n| --- | --- |\n| `upgradeSource()` / `upgradeDestination()` | Addresses of the old and new tokens |\n| `ratio()` | `(numerator, denominator)`: destination tokens per source token, e.g. `(3, 1)` |\n| `isUpgradeActive()` | Whether upgrades are currently being served |\n| `computeUpgrade(sourceAmount)` | Preview: destination amount and leftover source remainder |\n| `upgrade(to, sourceAmount)` | Pull approved source tokens, send destination tokens to `to` |\n| `totalUpgraded()` | Total source tokens upgraded so far |\n\nFlow for a holder: `approve` the upgrade contract on the old token, then call `upgrade`. The source tokens are **burned or locked** in the upgrade contract. If the ratio would leave a fractional amount, only the whole convertible part is upgraded and the remainder is returned to the caller. With a `(3, 2)` ratio, `computeUpgrade(5)` returns `(6, 1)`.\n\nAn **optional downgrade extension** (`isDowngradeActive`, `computeDowngrade`, `downgrade`) lets holders convert back. If it is implemented, source tokens must be locked rather than burned so they can be released again, and `totalUpgraded` can then go down.\n\n`Upgrade` and `Downgrade` events record each conversion.\n\n## Sample code\n\nRunning an upgrade from a script (ethers v6):\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider } from \"ethers\";\n\nconst signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));\nconst upgrader = new Contract(UPGRADE_CONTRACT, [\n  \"function upgradeSource() view returns (address)\",\n  \"function isUpgradeActive() view returns (bool)\",\n  \"function computeUpgrade(uint256) view returns (uint256 destinationAmount, uint256 sourceRemainder)\",\n  \"function upgrade(address to, uint256 sourceAmount)\",\n], signer);\n\nconst oldToken = new Contract(await upgrader.upgradeSource(), [\n  \"function balanceOf(address) view returns (uint256)\",\n  \"function approve(address,uint256) returns (bool)\",\n], signer);\n\nif (!(await upgrader.isUpgradeActive())) throw new Error(\"upgrade not active\");\n\nconst amount: bigint = await oldToken.balanceOf(signer.address);\nconst [out, rest] = await upgrader.computeUpgrade(amount);\nconsole.log(`will receive ${out}, ${rest} left over`);\n\nawait (await oldToken.approve(UPGRADE_CONTRACT, amount)).wait();\nawait (await upgrader.upgrade(signer.address, amount)).wait();\n```\n\n## Things to know\n\n- Status: **Stagnant**. The interface is a reasonable template, but there is no ecosystem-wide expectation that migrations follow it.\n- The upgrade contract must hold or be able to mint enough destination tokens; the spec does not cover how the new supply is provisioned.\n- Burning versus locking is a real design choice: locking keeps the old supply recoverable (and enables downgrades), burning makes the migration one-way.\n- Always preview with `computeUpgrade` so users see the remainder before rounding surprises them.\n"},"ja":{"lang":"ja","tldr":"旧 ERC-20 コントラクトから新しいコントラクトへ、固定レートで保有者を移行するための標準インターフェース。ウォレットや取引所がどのトークンアップグレードも同じ方法で実行できる。","tags":["erc-20","migration","upgrade","token","exchanges"],"related":[20,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4931/","markdown":"## 何を解決するのか\n\nプロジェクトが [ERC-20](/eip-20/) コントラクトを置き換えるとき（バグ修正、リブランディング、トークンの分割や統合など）、保有者全員が旧トークンを新トークンと交換する必要があります。プロジェクトごとに独自の移行コントラクトと UI が作られるため、取引所やカストディアンは移行のたびにゼロからレビューしてスクリプトを書かなければならず、ユーザーも個別のインターフェースを信頼する必要があります。\n\nERC-4931 は移行コントラクトそのものを標準化します。取引所やウォレットがこのインターフェースに対応すれば、準拠するどのトークンアップグレードも同じコードで処理でき、監査人も期待される挙動を把握できます。\n\n## 仕組み\n\n**ソース**（旧）トークンと**デスティネーション**（新）トークンの間に、別個の*アップグレードコントラクト*が置かれます。\n\n| 関数 | 役割 |\n| --- | --- |\n| `upgradeSource()` / `upgradeDestination()` | 旧トークンと新トークンのアドレス |\n| `ratio()` | `(分子, 分母)`: ソーストークン 1 つあたりのデスティネーショントークン数。例: `(3, 1)` |\n| `isUpgradeActive()` | 現在アップグレードを受け付けているか |\n| `computeUpgrade(sourceAmount)` | プレビュー: デスティネーションの量と、余るソースの端数 |\n| `upgrade(to, sourceAmount)` | 承認済みのソーストークンを引き出し、デスティネーショントークンを `to` に送る |\n| `totalUpgraded()` | これまでにアップグレードされたソーストークンの合計 |\n\n保有者の流れは、旧トークンでアップグレードコントラクトを `approve` し、`upgrade` を呼ぶ、というものです。ソーストークンはアップグレードコントラクトで**バーンまたはロック**されます。レートによって端数が出る場合は、変換できる整数部分だけがアップグレードされ、残りは呼び出し元に返されます。レートが `(3, 2)` のとき、`computeUpgrade(5)` は `(6, 1)` を返します。\n\n**任意のダウングレード拡張**（`isDowngradeActive`、`computeDowngrade`、`downgrade`）を使うと、保有者は元に戻すこともできます。これを実装する場合、ソーストークンは再び解放できるようバーンではなくロックしなければならず、`totalUpgraded` は減ることがあります。\n\n`Upgrade` と `Downgrade` イベントが各変換を記録します。\n\n## サンプルコード\n\nスクリプトからアップグレードを実行する例（ethers v6）:\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider } from \"ethers\";\n\nconst signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));\nconst upgrader = new Contract(UPGRADE_CONTRACT, [\n  \"function upgradeSource() view returns (address)\",\n  \"function isUpgradeActive() view returns (bool)\",\n  \"function computeUpgrade(uint256) view returns (uint256 destinationAmount, uint256 sourceRemainder)\",\n  \"function upgrade(address to, uint256 sourceAmount)\",\n], signer);\n\nconst oldToken = new Contract(await upgrader.upgradeSource(), [\n  \"function balanceOf(address) view returns (uint256)\",\n  \"function approve(address,uint256) returns (bool)\",\n], signer);\n\nif (!(await upgrader.isUpgradeActive())) throw new Error(\"upgrade not active\");\n\nconst amount: bigint = await oldToken.balanceOf(signer.address);\nconst [out, rest] = await upgrader.computeUpgrade(amount);\nconsole.log(`will receive ${out}, ${rest} left over`);\n\nawait (await oldToken.approve(UPGRADE_CONTRACT, amount)).wait();\nawait (await upgrader.upgrade(signer.address, amount)).wait();\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。このインターフェースは妥当なテンプレートですが、移行がこれに従うべきだというエコシステム全体の期待はありません。\n- アップグレードコントラクトは、十分な量のデスティネーショントークンを保有しているか、ミントできる必要があります。新しい供給量をどう用意するかは仕様の対象外です。\n- バーンとロックのどちらにするかは実際の設計上の選択です。ロックなら旧トークンの供給量を回復でき（ダウングレードも可能）、バーンなら移行は一方通行になります。\n- 端数で思わぬ目に遭わないよう、ユーザーに余りを見せるため、必ず `computeUpgrade` でプレビューしてください。\n"},"ko":{"lang":"ko","tldr":"보유자를 이전 ERC-20 컨트랙트에서 새 컨트랙트로 고정 비율에 따라 이전하기 위한 표준 인터페이스. 지갑과 거래소가 어떤 토큰 업그레이드든 같은 방식으로 처리할 수 있다.","tags":["erc-20","migration","upgrade","token","exchanges"],"related":[20,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4931/","markdown":"## 어떤 문제를 해결하나요?\n\n프로젝트가 [ERC-20](/eip-20/) 컨트랙트를 교체할 때(버그 수정, 리브랜딩, 토큰 분할 또는 병합), 모든 보유자는 기존 토큰을 새 토큰으로 바꿔야 합니다. 프로젝트마다 자체 마이그레이션 컨트랙트와 UI를 만들기 때문에 거래소와 수탁 기관은 마이그레이션마다 처음부터 검토하고 스크립트를 작성해야 하며, 사용자도 제각각인 인터페이스를 신뢰해야 합니다.\n\nERC-4931은 마이그레이션 컨트랙트 자체를 표준화합니다. 거래소나 지갑이 이 인터페이스를 지원하면 이를 준수하는 모든 토큰 업그레이드를 같은 코드로 처리할 수 있고, 감사자도 어떤 동작을 기대해야 하는지 알 수 있습니다.\n\n## 어떻게 동작하나요?\n\n별도의 *업그레이드 컨트랙트*가 **소스**(이전) 토큰과 **데스티네이션**(새) 토큰 사이에 놓입니다.\n\n| 함수 | 역할 |\n| --- | --- |\n| `upgradeSource()` / `upgradeDestination()` | 이전 토큰과 새 토큰의 주소 |\n| `ratio()` | `(분자, 분모)`: 소스 토큰 하나당 데스티네이션 토큰 수. 예: `(3, 1)` |\n| `isUpgradeActive()` | 현재 업그레이드를 처리하고 있는지 여부 |\n| `computeUpgrade(sourceAmount)` | 미리보기: 데스티네이션 수량과 남는 소스 나머지 |\n| `upgrade(to, sourceAmount)` | 승인된 소스 토큰을 가져오고 데스티네이션 토큰을 `to`로 전송 |\n| `totalUpgraded()` | 지금까지 업그레이드된 소스 토큰 총량 |\n\n보유자의 흐름은 이전 토큰에서 업그레이드 컨트랙트를 `approve`한 뒤 `upgrade`를 호출하는 것입니다. 소스 토큰은 업그레이드 컨트랙트에서 **소각되거나 잠깁니다**. 비율 때문에 소수 부분이 생기면 정수로 변환 가능한 부분만 업그레이드되고 나머지는 호출자에게 돌려줍니다. 비율이 `(3, 2)`일 때 `computeUpgrade(5)`는 `(6, 1)`을 반환합니다.\n\n**선택적 다운그레이드 확장**(`isDowngradeActive`, `computeDowngrade`, `downgrade`)을 쓰면 보유자가 다시 되돌릴 수 있습니다. 이를 구현하는 경우 소스 토큰은 다시 풀어줄 수 있도록 소각하지 않고 잠가야 하며, 그러면 `totalUpgraded`가 줄어들 수 있습니다.\n\n`Upgrade`와 `Downgrade` 이벤트가 각 변환을 기록합니다.\n\n## 샘플 코드\n\n스크립트에서 업그레이드를 실행하는 예시입니다(ethers v6).\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider } from \"ethers\";\n\nconst signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));\nconst upgrader = new Contract(UPGRADE_CONTRACT, [\n  \"function upgradeSource() view returns (address)\",\n  \"function isUpgradeActive() view returns (bool)\",\n  \"function computeUpgrade(uint256) view returns (uint256 destinationAmount, uint256 sourceRemainder)\",\n  \"function upgrade(address to, uint256 sourceAmount)\",\n], signer);\n\nconst oldToken = new Contract(await upgrader.upgradeSource(), [\n  \"function balanceOf(address) view returns (uint256)\",\n  \"function approve(address,uint256) returns (bool)\",\n], signer);\n\nif (!(await upgrader.isUpgradeActive())) throw new Error(\"upgrade not active\");\n\nconst amount: bigint = await oldToken.balanceOf(signer.address);\nconst [out, rest] = await upgrader.computeUpgrade(amount);\nconsole.log(`will receive ${out}, ${rest} left over`);\n\nawait (await oldToken.approve(UPGRADE_CONTRACT, amount)).wait();\nawait (await upgrader.upgrade(signer.address, amount)).wait();\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 이 인터페이스는 쓸 만한 템플릿이지만, 마이그레이션이 이를 따라야 한다는 생태계 전체의 기대는 없습니다.\n- 업그레이드 컨트랙트는 충분한 데스티네이션 토큰을 보유하고 있거나 발행할 수 있어야 합니다. 새 공급량을 어떻게 마련하는지는 사양이 다루지 않습니다.\n- 소각이냐 잠금이냐는 실제 설계상의 선택입니다. 잠그면 이전 공급량을 되찾을 수 있고(다운그레이드도 가능), 소각하면 마이그레이션은 일방향이 됩니다.\n- 반올림 때문에 놀라는 일이 없도록, 사용자가 나머지를 미리 볼 수 있게 항상 `computeUpgrade`로 미리보기를 하세요.\n"},"zh":{"lang":"zh","tldr":"一个标准接口，用于按固定比例把持有者从旧 ERC-20 合约迁移到新合约，让钱包和交易所能以同样的方式执行任何代币升级。","tags":["erc-20","migration","upgrade","token","exchanges"],"related":[20,2612],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4931/","markdown":"## 它解决什么问题？\n\n当项目替换其 [ERC-20](/eip-20/) 合约时（修复漏洞、更换品牌、代币拆分或合并），每个持有者都必须把旧代币换成新代币。每个项目都自建迁移合约和界面，因此交易所和托管机构必须从头审查并为每次迁移编写脚本，用户也必须信任一个定制的接口。\n\nERC-4931 对迁移合约本身进行了标准化。一旦交易所或钱包支持该接口，就可以用同一套代码处理任何合规的代币升级，审计人员也知道应当预期怎样的行为。\n\n## 它如何运作\n\n一个独立的*升级合约*位于**源**（旧）代币和**目标**（新）代币之间：\n\n| 函数 | 用途 |\n| --- | --- |\n| `upgradeSource()` / `upgradeDestination()` | 旧代币和新代币的地址 |\n| `ratio()` | `(分子, 分母)`：每个源代币对应的目标代币数量，例如 `(3, 1)` |\n| `isUpgradeActive()` | 当前是否正在提供升级服务 |\n| `computeUpgrade(sourceAmount)` | 预览：目标代币数量以及剩余的源代币零头 |\n| `upgrade(to, sourceAmount)` | 拉取已授权的源代币，把目标代币发送给 `to` |\n| `totalUpgraded()` | 迄今已升级的源代币总量 |\n\n持有者的流程：先在旧代币上对升级合约执行 `approve`，然后调用 `upgrade`。源代币会在升级合约中被**销毁或锁定**。如果比例会产生小数部分，则只升级可整数转换的部分，余数退还给调用者。在 `(3, 2)` 的比例下，`computeUpgrade(5)` 返回 `(6, 1)`。\n\n一个**可选的降级扩展**（`isDowngradeActive`、`computeDowngrade`、`downgrade`）允许持有者换回旧代币。如果实现了它，源代币必须被锁定而不是销毁，以便再次释放，此时 `totalUpgraded` 可以减少。\n\n`Upgrade` 和 `Downgrade` 事件记录每次兑换。\n\n## 示例代码\n\n通过脚本执行升级（ethers v6）：\n\n```ts\nimport { Contract, Wallet, JsonRpcProvider } from \"ethers\";\n\nconst signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));\nconst upgrader = new Contract(UPGRADE_CONTRACT, [\n  \"function upgradeSource() view returns (address)\",\n  \"function isUpgradeActive() view returns (bool)\",\n  \"function computeUpgrade(uint256) view returns (uint256 destinationAmount, uint256 sourceRemainder)\",\n  \"function upgrade(address to, uint256 sourceAmount)\",\n], signer);\n\nconst oldToken = new Contract(await upgrader.upgradeSource(), [\n  \"function balanceOf(address) view returns (uint256)\",\n  \"function approve(address,uint256) returns (bool)\",\n], signer);\n\nif (!(await upgrader.isUpgradeActive())) throw new Error(\"upgrade not active\");\n\nconst amount: bigint = await oldToken.balanceOf(signer.address);\nconst [out, rest] = await upgrader.computeUpgrade(amount);\nconsole.log(`will receive ${out}, ${rest} left over`);\n\nawait (await oldToken.approve(UPGRADE_CONTRACT, amount)).wait();\nawait (await upgrader.upgrade(signer.address, amount)).wait();\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。该接口是一个合理的模板，但整个生态并不期望迁移都遵循它。\n- 升级合约必须持有足够的目标代币，或者能够铸造它们；规范没有涉及新供应量如何提供。\n- 销毁还是锁定是一个真实的设计取舍：锁定使旧供应量可以恢复（并支持降级），销毁则使迁移成为单向的。\n- 始终用 `computeUpgrade` 预览，让用户在被舍入问题吓到之前先看到余数。\n"}}}
