{"eip":8255,"title":"Expiring Token Approvals","description":"Token approvals expire after a bounded duration by default.","authors":["Moody Salem (@moodysalem) \u003cmoody.salem@gmail.com\u003e"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2026-05-06","requires":[20,2612],"discussionsTo":"https://ethereum-magicians.org/t/eip-8255-expiring-token-approvals/28456","repo":"ERCs","label":"ERC-8255","officialUrl":"https://eips.ethereum.org/EIPS/eip-8255","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8255.md","url":"https://eips.huatuo.xyz/eip-8255/","tldr":{"en":"An ERC-20 extension where every approval, including plain approve() and permit, automatically expires after a token-defined maximum duration, limiting the damage from forgotten or exploited allowances.","ja":"素の approve() や permit を含むすべての承認が、トークンが定める最大期間の経過後に自動的に失効する ERC-20 拡張。忘れられた、あるいは悪用された allowance による被害を抑える。","ko":"단순 approve()와 permit을 포함한 모든 승인이 토큰이 정한 최대 기간이 지나면 자동으로 만료되는 ERC-20 확장. 잊혀졌거나 악용된 allowance로 인한 피해를 줄인다.","zh":"一种 ERC-20 扩展，其中每一次授权（包括普通的 approve() 和 permit）都会在代币定义的最长期限后自动过期，从而限制被遗忘或被利用的授权额度所造成的损失。"},"tags":["token","erc20","approvals","security","allowance"],"explainers":{"en":{"lang":"en","tldr":"An ERC-20 extension where every approval, including plain approve() and permit, automatically expires after a token-defined maximum duration, limiting the damage from forgotten or exploited allowances.","tags":["token","erc20","approvals","security","allowance"],"related":[20,2612,7758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-8255/","markdown":"## What problem does it solve?\n\n[ERC-20](/eip-20/) allowances last forever. Users routinely grant huge or unlimited approvals to a protocol for a single swap, then forget about them. If that spender contract is later exploited, maliciously upgraded, or its front end is compromised, the attacker can drain every wallet that still has a live approval. Revocation tools exist, but they depend on users remembering to use them.\n\nERC-8255 makes approvals expire by default while keeping the existing `approve` / `transferFrom` ABI, so old wallets and apps keep working.\n\n## How it works\n\nThe token defines a constant `maxApprovalDuration()` in seconds.\n\n- `approve(spender, amount)` sets the allowance and an expiration of `block.timestamp + maxApprovalDuration()`.\n- New `approveForDuration(spender, amount, duration)` lets you choose a shorter lifetime (`duration` must be ≤ the max). `duration = 0` creates an approval valid only within the current block, which is handy for approve-and-spend bundles.\n- If the token also supports [ERC-2612](/eip-2612/), `permit` uses the default duration. Its signature format is unchanged, and the permit `deadline` still only limits when the signature can be *submitted*, not how long the approval lasts.\n- An approval is expired when `expiration \u003c block.timestamp`. After that, `allowance()` returns 0 and `transferFrom` treats it as zero.\n- `allowanceAndExpiration(owner, spender)` returns `(expiration, storedAllowance)` even when expired, so UIs can show what happened.\n- `transferFrom` reduces the amount but never extends the expiration.\n\n**Legacy spenders.** Old contracts that assume \"approve once, use forever\" would break. Tokens MAY keep a list of legacy-compatible spenders (set by an admin, by the spender itself, or both) that keep classic behaviour. The list must be empty by default and holders can always revoke.\n\n**Optional packing.** Expiration (64 bits) and amount (192 bits) can share one storage slot, so the extension costs no extra storage per allowance; `type(uint256).max` can still be used as an \"unlimited\" sentinel.\n\n## Sample code\n\nRequesting a short-lived approval and reading its status (ethers v6):\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst abi = [\n  \"function maxApprovalDuration() view returns (uint32)\",\n  \"function approveForDuration(address spender, uint256 amount, uint32 duration) returns (bool)\",\n  \"function allowanceAndExpiration(address owner, address spender) view returns (uint64 expiration, uint256 allowance)\",\n];\nconst token = new Contract(tokenAddress, abi, signer);\n\nconst max = await token.maxApprovalDuration();\nconst duration = Math.min(600, Number(max));             // 10 minutes, capped by the token\nawait (await token.approveForDuration(router, amount, duration)).wait();\n\nconst [expiration, stored] = await token.allowanceAndExpiration(await signer.getAddress(), router);\nconsole.log(`allowance ${stored} valid until ${new Date(Number(expiration) * 1000).toISOString()}`);\n```\n\nThe packing used by the reference implementation:\n\n```solidity\nuint256 packed = (uint256(expiration) \u003c\u003c 192) | allowance; // 64-bit expiry | 192-bit amount\n```\n\n## Things to know\n\n- **Status: Draft.**\n- Integrations that rely on a long-lived allowance must refresh it, check `allowanceAndExpiration`, or ask to be treated as legacy-compatible. Patterns that approve exactly what is needed right before use already work.\n- Pick durations with slack for mempool delays and small `block.timestamp` variation, or transactions may fail because an approval expired in transit.\n- Expiry shortens the risk window but does not fix the classic ERC-20 change-allowance race.\n- Wallets should show the permit deadline and the resulting approval expiry as two different things.\n- Upgrading an existing token can make old single-slot allowances read as expired (expiration 0) under the packed layout; the spec describes migration options.\n"},"ja":{"lang":"ja","tldr":"素の approve() や permit を含むすべての承認が、トークンが定める最大期間の経過後に自動的に失効する ERC-20 拡張。忘れられた、あるいは悪用された allowance による被害を抑える。","tags":["token","erc20","approvals","security","allowance"],"related":[20,2612,7758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-8255/","markdown":"## 何を解決するのか\n\n[ERC-20](/eip-20/) の allowance は永遠に残ります。ユーザーは、1 回のスワップのために巨額または無制限の承認をプロトコルに与え、そのまま忘れてしまうことがよくあります。その spender コントラクトが後で悪用されたり、悪意のあるアップグレードを受けたり、フロントエンドが侵害されたりすると、攻撃者は有効な承認が残っているすべてのウォレットから資金を抜き取れます。取り消しツールはありますが、ユーザーが使うことを覚えていることに依存します。\n\nERC-8255 は、既存の `approve` / `transferFrom` の ABI を維持したまま、承認がデフォルトで失効するようにします。そのため、古いウォレットやアプリも動き続けます。\n\n## 仕組み\n\nトークンは、秒単位の定数 `maxApprovalDuration()` を定義します。\n\n- `approve(spender, amount)` は allowance と、`block.timestamp + maxApprovalDuration()` の有効期限を設定します。\n- 新しい `approveForDuration(spender, amount, duration)` では、より短い有効期間を選べます（`duration` は最大値以下でなければなりません）。`duration = 0` は現在のブロック内でのみ有効な承認を作り、承認と使用をまとめたバンドルに便利です。\n- トークンが [ERC-2612](/eip-2612/) にも対応している場合、`permit` はデフォルトの期間を使います。署名フォーマットは変わらず、permit の `deadline` は引き続き署名を*提出できる*期限を制限するだけで、承認がどれだけ続くかは制限しません。\n- 承認は `expiration \u003c block.timestamp` のときに失効します。その後、`allowance()` は 0 を返し、`transferFrom` はそれをゼロとして扱います。\n- `allowanceAndExpiration(owner, spender)` は、失効していても `(expiration, storedAllowance)` を返すため、UI は何が起きたかを表示できます。\n- `transferFrom` は額を減らしますが、有効期限を延ばすことはありません。\n\n**レガシーな spender。** 「一度承認すれば永遠に使える」と想定している古いコントラクトは動かなくなります。トークンは、従来の挙動を維持するレガシー互換の spender のリストを保持してもかまいません（MAY）（管理者、spender 自身、またはその両方が設定します）。このリストはデフォルトで空でなければならず、ホルダーはいつでも取り消せます。\n\n**任意のパッキング。** 有効期限（64 ビット）と額（192 ビット）は 1 つのストレージスロットを共有できるため、この拡張は allowance ごとの追加ストレージを必要としません。`type(uint256).max` も「無制限」を示す番兵値として引き続き使えます。\n\n## サンプルコード\n\n短期間の承認をリクエストしてそのステータスを読み取る例（ethers v6）:\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst abi = [\n  \"function maxApprovalDuration() view returns (uint32)\",\n  \"function approveForDuration(address spender, uint256 amount, uint32 duration) returns (bool)\",\n  \"function allowanceAndExpiration(address owner, address spender) view returns (uint64 expiration, uint256 allowance)\",\n];\nconst token = new Contract(tokenAddress, abi, signer);\n\nconst max = await token.maxApprovalDuration();\nconst duration = Math.min(600, Number(max));             // 10 minutes, capped by the token\nawait (await token.approveForDuration(router, amount, duration)).wait();\n\nconst [expiration, stored] = await token.allowanceAndExpiration(await signer.getAddress(), router);\nconsole.log(`allowance ${stored} valid until ${new Date(Number(expiration) * 1000).toISOString()}`);\n```\n\nリファレンス実装で使われているパッキング:\n\n```solidity\nuint256 packed = (uint256(expiration) \u003c\u003c 192) | allowance; // 64-bit expiry | 192-bit amount\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。**\n- 長期間有効な allowance に頼る連携は、それを更新するか、`allowanceAndExpiration` を確認するか、レガシー互換として扱うよう求める必要があります。使用の直前に必要な額だけを承認するパターンは、すでに動作します。\n- mempool の遅延や `block.timestamp` の小さなばらつきを見込んだ余裕のある期間を選んでください。そうしないと、承認が送信中に失効してトランザクションが失敗する可能性があります。\n- 失効はリスクの期間を短くしますが、従来の ERC-20 の allowance 変更の競合状態は解決しません。\n- ウォレットは、permit の deadline と、その結果としての承認の有効期限を、別々のものとして表示すべきです。\n- 既存のトークンをアップグレードすると、古い単一スロットの allowance がパッキングされたレイアウトでは失効したもの（expiration が 0）として読まれる可能性があります。仕様は移行の選択肢を説明しています。\n"},"ko":{"lang":"ko","tldr":"단순 approve()와 permit을 포함한 모든 승인이 토큰이 정한 최대 기간이 지나면 자동으로 만료되는 ERC-20 확장. 잊혀졌거나 악용된 allowance로 인한 피해를 줄인다.","tags":["token","erc20","approvals","security","allowance"],"related":[20,2612,7758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-8255/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-20](/eip-20/) allowance는 영원히 유지됩니다. 사용자는 한 번의 스왑을 위해 프로토콜에 거액이나 무제한 승인을 주고는 그대로 잊어버리곤 합니다. 그 spender 컨트랙트가 나중에 공격당하거나 악의적으로 업그레이드되거나 프런트엔드가 침해되면, 공격자는 유효한 승인이 남아 있는 모든 지갑을 털 수 있습니다. 취소 도구가 있지만 사용자가 사용하기를 기억해야만 합니다.\n\nERC-8255는 기존 `approve` / `transferFrom` ABI를 유지하면서 승인이 기본적으로 만료되게 하므로, 오래된 지갑과 앱도 계속 동작합니다.\n\n## 어떻게 동작하나요?\n\n토큰은 초 단위의 상수 `maxApprovalDuration()`을 정의합니다.\n\n- `approve(spender, amount)`는 allowance와 `block.timestamp + maxApprovalDuration()`의 만료 시각을 설정합니다.\n- 새로운 `approveForDuration(spender, amount, duration)`으로 더 짧은 유효 기간을 고를 수 있습니다(`duration`은 최대값 이하여야 합니다). `duration = 0`은 현재 블록 안에서만 유효한 승인을 만들며, 승인과 사용을 묶은 번들에 유용합니다.\n- 토큰이 [ERC-2612](/eip-2612/)도 지원한다면 `permit`은 기본 기간을 사용합니다. 서명 형식은 바뀌지 않으며, permit의 `deadline`은 여전히 서명을 *제출할 수 있는* 시점만 제한할 뿐 승인이 얼마나 지속되는지는 제한하지 않습니다.\n- 승인은 `expiration \u003c block.timestamp`일 때 만료됩니다. 그 후 `allowance()`는 0을 반환하고 `transferFrom`은 이를 0으로 취급합니다.\n- `allowanceAndExpiration(owner, spender)`는 만료된 경우에도 `(expiration, storedAllowance)`를 반환하므로 UI가 무슨 일이 있었는지 보여 줄 수 있습니다.\n- `transferFrom`은 금액을 줄이지만 만료 시각을 연장하지는 않습니다.\n\n**레거시 spender.** \"한 번 승인하면 영원히 사용\"을 가정하는 오래된 컨트랙트는 깨집니다. 토큰은 기존 동작을 유지하는 레거시 호환 spender 목록을 둘 수 있습니다(MAY)(관리자, spender 자신, 또는 둘 다 설정). 이 목록은 기본적으로 비어 있어야 하며 홀더는 언제든 취소할 수 있습니다.\n\n**선택적 패킹.** 만료 시각(64비트)과 금액(192비트)이 하나의 스토리지 슬롯을 공유할 수 있으므로 이 확장은 allowance당 추가 스토리지를 요구하지 않습니다. `type(uint256).max`도 여전히 \"무제한\" 표시값으로 쓸 수 있습니다.\n\n## 샘플 코드\n\n단기 승인을 요청하고 그 상태를 읽는 예시(ethers v6):\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst abi = [\n  \"function maxApprovalDuration() view returns (uint32)\",\n  \"function approveForDuration(address spender, uint256 amount, uint32 duration) returns (bool)\",\n  \"function allowanceAndExpiration(address owner, address spender) view returns (uint64 expiration, uint256 allowance)\",\n];\nconst token = new Contract(tokenAddress, abi, signer);\n\nconst max = await token.maxApprovalDuration();\nconst duration = Math.min(600, Number(max));             // 10 minutes, capped by the token\nawait (await token.approveForDuration(router, amount, duration)).wait();\n\nconst [expiration, stored] = await token.allowanceAndExpiration(await signer.getAddress(), router);\nconsole.log(`allowance ${stored} valid until ${new Date(Number(expiration) * 1000).toISOString()}`);\n```\n\n레퍼런스 구현에서 쓰는 패킹:\n\n```solidity\nuint256 packed = (uint256(expiration) \u003c\u003c 192) | allowance; // 64-bit expiry | 192-bit amount\n```\n\n## 알아둘 점\n\n- **상태: Draft.**\n- 오래 유지되는 allowance에 의존하는 연동은 이를 갱신하거나, `allowanceAndExpiration`을 확인하거나, 레거시 호환으로 취급해 달라고 요청해야 합니다. 사용 직전에 필요한 만큼만 승인하는 패턴은 이미 동작합니다.\n- 멤풀 지연과 `block.timestamp`의 작은 변동을 감안해 여유 있는 기간을 고르세요. 그렇지 않으면 승인이 전송 중에 만료되어 트랜잭션이 실패할 수 있습니다.\n- 만료는 위험 구간을 줄여 줄 뿐, 고전적인 ERC-20 allowance 변경 경쟁 상태를 해결하지는 않습니다.\n- 지갑은 permit deadline과 그 결과로 생기는 승인 만료 시각을 서로 다른 것으로 보여 줘야 합니다.\n- 기존 토큰을 업그레이드하면 오래된 단일 슬롯 allowance가 패킹된 레이아웃에서 만료된 것(expiration 0)으로 읽힐 수 있습니다. 스펙은 마이그레이션 방안을 설명합니다.\n"},"zh":{"lang":"zh","tldr":"一种 ERC-20 扩展，其中每一次授权（包括普通的 approve() 和 permit）都会在代币定义的最长期限后自动过期，从而限制被遗忘或被利用的授权额度所造成的损失。","tags":["token","erc20","approvals","security","allowance"],"related":[20,2612,7758],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-8255/","markdown":"## 它解决什么问题？\n\n[ERC-20](/eip-20/) 的授权额度（allowance）永远有效。用户经常为了一次兑换就向某个协议授予巨额甚至无限的授权，然后就把它忘了。如果该 spender 合约后来被攻击、被恶意升级，或其前端被攻陷，攻击者就可以掏空所有仍然持有有效授权的钱包。虽然有撤销工具，但它们依赖用户记得去使用。\n\nERC-8255 在保留现有 `approve` / `transferFrom` ABI 的同时，让授权默认会过期，因此旧钱包和旧应用仍能继续工作。\n\n## 它如何运作\n\n代币定义一个以秒为单位的常量 `maxApprovalDuration()`。\n\n- `approve(spender, amount)` 设置授权额度，以及 `block.timestamp + maxApprovalDuration()` 的过期时间。\n- 新增的 `approveForDuration(spender, amount, duration)` 允许你选择更短的有效期（`duration` 必须 ≤ 最大值）。`duration = 0` 会创建一个仅在当前区块内有效的授权，适合\"授权并使用\"的打包交易。\n- 如果代币还支持 [ERC-2612](/eip-2612/)，`permit` 使用默认期限。其签名格式不变，permit 的 `deadline` 仍然只限制签名可以在什么时候被*提交*，而不是授权持续多久。\n- 当 `expiration \u003c block.timestamp` 时，授权即已过期。此后 `allowance()` 返回 0，`transferFrom` 将其视为零。\n- `allowanceAndExpiration(owner, spender)` 即使在授权过期后也会返回 `(expiration, storedAllowance)`，这样 UI 可以展示发生了什么。\n- `transferFrom` 会减少额度，但绝不会延长过期时间。\n\n**遗留 spender。** 假设\"授权一次、永远可用\"的旧合约会失效。代币可以（MAY）维护一份遗留兼容 spender 的列表（由管理员、spender 自己或两者共同设置），这些 spender 保持经典行为。该列表默认必须为空，持有者始终可以撤销。\n\n**可选的打包。** 过期时间（64 位）和额度（192 位）可以共用一个存储槽，因此该扩展不会为每个授权额度增加额外存储；`type(uint256).max` 仍可作为\"无限\"的哨兵值。\n\n## 示例代码\n\n请求一个短期授权并读取其状态（ethers v6）：\n\n```ts\nimport { Contract } from \"ethers\";\n\nconst abi = [\n  \"function maxApprovalDuration() view returns (uint32)\",\n  \"function approveForDuration(address spender, uint256 amount, uint32 duration) returns (bool)\",\n  \"function allowanceAndExpiration(address owner, address spender) view returns (uint64 expiration, uint256 allowance)\",\n];\nconst token = new Contract(tokenAddress, abi, signer);\n\nconst max = await token.maxApprovalDuration();\nconst duration = Math.min(600, Number(max));             // 10 minutes, capped by the token\nawait (await token.approveForDuration(router, amount, duration)).wait();\n\nconst [expiration, stored] = await token.allowanceAndExpiration(await signer.getAddress(), router);\nconsole.log(`allowance ${stored} valid until ${new Date(Number(expiration) * 1000).toISOString()}`);\n```\n\n参考实现所用的打包方式：\n\n```solidity\nuint256 packed = (uint256(expiration) \u003c\u003c 192) | allowance; // 64-bit expiry | 192-bit amount\n```\n\n## 需要注意\n\n- **状态：Draft。**\n- 依赖长期有效授权额度的集成必须刷新它、检查 `allowanceAndExpiration`，或要求被视为遗留兼容。在使用前才授权恰好所需额度的模式已经可以正常工作。\n- 选择期限时要为 mempool 延迟和 `block.timestamp` 的小幅波动留出余量，否则交易可能因授权在传输途中过期而失败。\n- 过期缩短了风险窗口，但并不能解决经典的 ERC-20 修改授权额度的竞态问题。\n- 钱包应把 permit 的 deadline 和由此产生的授权过期时间作为两件不同的事展示。\n- 升级现有代币可能会使旧的单槽授权额度在打包布局下被读作已过期（expiration 为 0）；规范描述了迁移方案。\n"}}}
