{"eip":5007,"title":"Time NFT, ERC-721 Time Extension","description":"Add start time and end time to ERC-721 tokens.","authors":["Anders (@0xanders)","Lance (@LanceSnow)","Shrug \u003cshrug@emojidao.org\u003e"],"status":"Final","type":"Standards Track","category":"ERC","created":"2022-04-13","requires":[165,721],"discussionsTo":"https://ethereum-magicians.org/t/eip-5007-eip-721-time-extension/8924","repo":"ERCs","label":"ERC-5007","officialUrl":"https://eips.ethereum.org/EIPS/eip-5007","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5007.md","url":"https://eips.huatuo.xyz/eip-5007/","tldr":{"en":"Adds startTime and endTime to ERC-721 tokens so an NFT's validity window (a ticket, pass or rental slot) is readable onchain and takes effect automatically, with optional split and merge.","ja":"ERC-721 トークンに startTime と endTime を追加し、NFT の有効期間（チケット、パス、レンタル枠）をオンチェーンで読み取れるようにして自動的に効力を持たせます。分割とマージはオプションです。","ko":"ERC-721 토큰에 startTime과 endTime을 추가해 NFT의 유효 기간(티켓, 패스, 대여 구간)을 온체인에서 읽을 수 있고 자동으로 효력이 발생하게 합니다. 분할과 병합은 선택 사항입니다.","zh":"为 ERC-721 代币增加 startTime 和 endTime，使 NFT 的有效期窗口（门票、通行证或租赁时段）可以在链上读取并自动生效，另有可选的拆分与合并功能。"},"tags":["nft","erc721","time","tickets","rental"],"explainers":{"en":{"lang":"en","tldr":"Adds startTime and endTime to ERC-721 tokens so an NFT's validity window (a ticket, pass or rental slot) is readable onchain and takes effect automatically, with optional split and merge.","tags":["nft","erc721","time","tickets","rental"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5007/","markdown":"## What problem does it solve?\n\nMany NFTs are only meaningful for a period: a season pass, a concert ticket, a week of access to a virtual property. Without time data in the token, someone has to send a transaction to switch the token on or off at the right moment, which is cumbersome and costs gas. Projects that did add time fields each used their own interface, so marketplaces and tools could not support them generically.\n\nERC-5007 standardises two read functions so any contract or app can tell when a token is valid, with no transactions needed to \"activate\" or \"expire\" it.\n\n## How it works\n\nThe core interface (ERC-165 ID `0xf140be0d`):\n\n| Function | Returns |\n| --- | --- |\n| `startTime(tokenId)` | Start of validity as a UNIX timestamp (`uint64`) |\n| `endTime(tokenId)` | End of validity as a UNIX timestamp (`uint64`) |\n\nBoth must revert for non-existent tokens. Times are `uint64` because it is natively supported across mainstream languages and lasts for hundreds of billions of years.\n\nAn **optional composable extension** (ID `0x75cf3842`) treats time slots as divisible:\n\n- `assetId(tokenId)`: the underlying asset; only tokens with the same asset can be merged.\n- `split(oldTokenId, id1, owner1, id2, owner2, splitTime)`: cut one time slot into two at `splitTime` (which must lie within the old token's window). Both new tokens keep the same `assetId`.\n- `merge(firstId, secondId, newOwner, newId)`: join two adjacent slots, where `first.endTime + 1 == second.startTime`.\n\nThis makes it possible to, say, sell the second half of a year-long pass.\n\n## Sample code\n\nA minimal time NFT and a consumer check (OpenZeppelin v5):\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ninterface IERC5007 {\n    function startTime(uint256 tokenId) external view returns (uint64);\n    function endTime(uint256 tokenId) external view returns (uint64);\n}\n\ncontract SeasonPass is ERC721, IERC5007 {\n    struct Window { uint64 start; uint64 end; }\n    mapping(uint256 =\u003e Window) private _windows;\n\n    constructor() ERC721(\"Season Pass\", \"PASS\") {}\n\n    function _mintPass(address to, uint256 id, uint64 start, uint64 end) internal {\n        require(start \u003c end, \"bad window\");\n        _windows[id] = Window(start, end);\n        _safeMint(to, id);\n    }\n\n    function startTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].start;\n    }\n\n    function endTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].end;\n    }\n\n    function isActive(uint256 id) external view returns (bool) {\n        Window memory w = _windows[id];\n        return block.timestamp \u003e= w.start \u0026\u0026 block.timestamp \u003c= w.end;\n    }\n\n    function supportsInterface(bytes4 iid) public view override returns (bool) {\n        return iid == 0xf140be0d || super.supportsInterface(iid);\n    }\n}\n```\n\n## Things to know\n\n- **Status: Final.**\n- The token still exists and transfers normally outside its window. Expiry is a signal for apps to honour, not a burn.\n- The `merge` adjacency rule (`end + 1 == start`) implies windows are inclusive of both endpoints, as in the `isActive` check above.\n- For rentals where an owner lends usage rights for a period, [ERC-4907](/eip-4907/) (ERC-721) and [ERC-5006](/eip-5006/) (ERC-1155) define a separate `user` role with an expiry; ERC-5007 instead puts the time on the token itself.\n"},"ja":{"lang":"ja","tldr":"ERC-721 トークンに startTime と endTime を追加し、NFT の有効期間（チケット、パス、レンタル枠）をオンチェーンで読み取れるようにして自動的に効力を持たせます。分割とマージはオプションです。","tags":["nft","erc721","time","tickets","rental"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5007/","markdown":"## 何を解決するのか\n\n多くの NFT は一定期間だけ意味を持ちます。シーズンパス、コンサートチケット、バーチャル不動産の 1 週間分のアクセス権などです。トークンに時間データがないと、適切なタイミングでトークンをオン・オフするために誰かがトランザクションを送る必要があり、手間もガスもかかります。時間フィールドを追加したプロジェクトもありましたが、それぞれ独自のインターフェースだったため、マーケットプレイスやツールは汎用的に対応できませんでした。\n\nERC-5007 は 2 つの読み取り関数を標準化します。これにより、どのコントラクトやアプリもトークンがいつ有効かを判定でき、「有効化」や「失効」のためのトランザクションは不要です。\n\n## 仕組み\n\nコアインターフェース（ERC-165 ID `0xf140be0d`）:\n\n| 関数 | 戻り値 |\n| --- | --- |\n| `startTime(tokenId)` | 有効期間の開始。UNIX タイムスタンプ（`uint64`） |\n| `endTime(tokenId)` | 有効期間の終了。UNIX タイムスタンプ（`uint64`） |\n\nどちらも存在しないトークンに対してはリバートしなければなりません。時刻に `uint64` を使うのは、主要な言語でネイティブにサポートされており、数千億年もつからです。\n\n**オプションのコンポーザブル拡張**（ID `0x75cf3842`）は、時間枠を分割可能なものとして扱います。\n\n- `assetId(tokenId)`: 基になるアセット。同じアセットのトークン同士だけがマージできます。\n- `split(oldTokenId, id1, owner1, id2, owner2, splitTime)`: 1 つの時間枠を `splitTime`（古いトークンの期間内でなければならない）で 2 つに分割します。新しい 2 つのトークンは同じ `assetId` を保ちます。\n- `merge(firstId, secondId, newOwner, newId)`: 隣り合う 2 つの枠を結合します。条件は `first.endTime + 1 == second.startTime` です。\n\nこれにより、たとえば 1 年パスの後半だけを売る、といったことが可能になります。\n\n## サンプルコード\n\n最小限の時間 NFT と、consumer 側のチェックです（OpenZeppelin v5）。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ninterface IERC5007 {\n    function startTime(uint256 tokenId) external view returns (uint64);\n    function endTime(uint256 tokenId) external view returns (uint64);\n}\n\ncontract SeasonPass is ERC721, IERC5007 {\n    struct Window { uint64 start; uint64 end; }\n    mapping(uint256 =\u003e Window) private _windows;\n\n    constructor() ERC721(\"Season Pass\", \"PASS\") {}\n\n    function _mintPass(address to, uint256 id, uint64 start, uint64 end) internal {\n        require(start \u003c end, \"bad window\");\n        _windows[id] = Window(start, end);\n        _safeMint(to, id);\n    }\n\n    function startTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].start;\n    }\n\n    function endTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].end;\n    }\n\n    function isActive(uint256 id) external view returns (bool) {\n        Window memory w = _windows[id];\n        return block.timestamp \u003e= w.start \u0026\u0026 block.timestamp \u003c= w.end;\n    }\n\n    function supportsInterface(bytes4 iid) public view override returns (bool) {\n        return iid == 0xf140be0d || super.supportsInterface(iid);\n    }\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Final。**\n- トークンは期間外でも存在し、通常どおり転送できます。失効はアプリが尊重すべきシグナルであり、バーンではありません。\n- `merge` の隣接ルール（`end + 1 == start`）は、上の `isActive` のチェックのように、期間が両端を含むことを意味します。\n- 所有者がある期間だけ利用権を貸し出すレンタルについては、[ERC-4907](/eip-4907/)（ERC-721）と [ERC-5006](/eip-5006/)（ERC-1155）が、有効期限付きの別個の `user` ロールを定義しています。ERC-5007 は代わりに、時間をトークン自体に持たせます。\n"},"ko":{"lang":"ko","tldr":"ERC-721 토큰에 startTime과 endTime을 추가해 NFT의 유효 기간(티켓, 패스, 대여 구간)을 온체인에서 읽을 수 있고 자동으로 효력이 발생하게 합니다. 분할과 병합은 선택 사항입니다.","tags":["nft","erc721","time","tickets","rental"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5007/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 NFT는 일정 기간에만 의미가 있습니다. 시즌 패스, 콘서트 티켓, 가상 부동산의 일주일 이용권 같은 것들입니다. 토큰에 시간 데이터가 없으면 적절한 시점에 토큰을 켜거나 끄기 위해 누군가 트랜잭션을 보내야 하고, 이는 번거롭고 가스 비용도 듭니다. 시간 필드를 추가한 프로젝트들도 각자 자체 인터페이스를 썼기 때문에 마켓플레이스와 도구가 범용적으로 지원할 수 없었습니다.\n\nERC-5007은 읽기 함수 두 개를 표준화해, 어떤 컨트랙트나 앱이든 토큰이 언제 유효한지 알 수 있게 하며, \"활성화\"나 \"만료\"를 위한 트랜잭션은 필요하지 않습니다.\n\n## 어떻게 동작하나요?\n\n핵심 인터페이스(ERC-165 ID `0xf140be0d`):\n\n| 함수 | 반환값 |\n| --- | --- |\n| `startTime(tokenId)` | 유효 기간 시작. UNIX 타임스탬프(`uint64`) |\n| `endTime(tokenId)` | 유효 기간 종료. UNIX 타임스탬프(`uint64`) |\n\n두 함수 모두 존재하지 않는 토큰에 대해서는 리버트해야 합니다. 시간에 `uint64`를 쓰는 이유는 주요 언어에서 기본적으로 지원되고 수천억 년 동안 쓸 수 있기 때문입니다.\n\n**선택적 컴포저블 확장**(ID `0x75cf3842`)은 시간 구간을 분할 가능한 것으로 다룹니다.\n\n- `assetId(tokenId)`: 기반 자산. 같은 자산의 토큰끼리만 병합할 수 있습니다.\n- `split(oldTokenId, id1, owner1, id2, owner2, splitTime)`: 하나의 시간 구간을 `splitTime`(이전 토큰의 기간 안에 있어야 함)에서 둘로 자릅니다. 새 토큰 둘은 같은 `assetId`를 유지합니다.\n- `merge(firstId, secondId, newOwner, newId)`: 인접한 두 구간을 합칩니다. 조건은 `first.endTime + 1 == second.startTime`입니다.\n\n이를 통해 예를 들어 1년짜리 패스의 후반부만 판매할 수 있습니다.\n\n## 샘플 코드\n\n최소한의 시간 NFT와 consumer 측 확인 코드입니다(OpenZeppelin v5).\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ninterface IERC5007 {\n    function startTime(uint256 tokenId) external view returns (uint64);\n    function endTime(uint256 tokenId) external view returns (uint64);\n}\n\ncontract SeasonPass is ERC721, IERC5007 {\n    struct Window { uint64 start; uint64 end; }\n    mapping(uint256 =\u003e Window) private _windows;\n\n    constructor() ERC721(\"Season Pass\", \"PASS\") {}\n\n    function _mintPass(address to, uint256 id, uint64 start, uint64 end) internal {\n        require(start \u003c end, \"bad window\");\n        _windows[id] = Window(start, end);\n        _safeMint(to, id);\n    }\n\n    function startTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].start;\n    }\n\n    function endTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].end;\n    }\n\n    function isActive(uint256 id) external view returns (bool) {\n        Window memory w = _windows[id];\n        return block.timestamp \u003e= w.start \u0026\u0026 block.timestamp \u003c= w.end;\n    }\n\n    function supportsInterface(bytes4 iid) public view override returns (bool) {\n        return iid == 0xf140be0d || super.supportsInterface(iid);\n    }\n}\n```\n\n## 알아둘 점\n\n- **상태: Final.**\n- 토큰은 기간 밖에서도 존재하며 정상적으로 전송됩니다. 만료는 앱이 따라야 할 신호이지 소각이 아닙니다.\n- `merge`의 인접 규칙(`end + 1 == start`)은 위 `isActive` 확인처럼 기간이 양 끝점을 모두 포함함을 뜻합니다.\n- 소유자가 일정 기간 사용권을 빌려주는 대여의 경우, [ERC-4907](/eip-4907/)(ERC-721)과 [ERC-5006](/eip-5006/)(ERC-1155)이 만료 시간이 있는 별도의 `user` 역할을 정의합니다. ERC-5007은 대신 시간을 토큰 자체에 둡니다.\n"},"zh":{"lang":"zh","tldr":"为 ERC-721 代币增加 startTime 和 endTime，使 NFT 的有效期窗口（门票、通行证或租赁时段）可以在链上读取并自动生效，另有可选的拆分与合并功能。","tags":["nft","erc721","time","tickets","rental"],"related":[721,165,4907,5006],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5007/","markdown":"## 它解决什么问题？\n\n许多 NFT 只在一段时间内有意义：季票、演唱会门票、一周的虚拟地产使用权。如果代币里没有时间数据，就得有人发送一笔交易，在合适的时刻把代币打开或关闭，既麻烦又耗 gas。有些项目确实添加了时间字段，但各自使用自己的接口，因此市场和工具无法通用地支持它们。\n\nERC-5007 标准化了两个读取函数，让任何合约或应用都能判断代币何时有效，无需交易来\"激活\"或\"使其过期\"。\n\n## 它如何运作\n\n核心接口（ERC-165 ID `0xf140be0d`）：\n\n| 函数 | 返回值 |\n| --- | --- |\n| `startTime(tokenId)` | 有效期开始时间，UNIX 时间戳（`uint64`） |\n| `endTime(tokenId)` | 有效期结束时间，UNIX 时间戳（`uint64`） |\n\n对于不存在的代币，两者都必须回滚。时间使用 `uint64`，是因为它在主流语言中都得到原生支持，并且可以持续数千亿年。\n\n一个**可选的可组合扩展**（ID `0x75cf3842`）把时间段视为可分割的：\n\n- `assetId(tokenId)`：底层资产；只有资产相同的代币才能合并。\n- `split(oldTokenId, id1, owner1, id2, owner2, splitTime)`：在 `splitTime`（必须位于旧代币的时间窗口内）把一个时间段切成两个。两个新代币保持相同的 `assetId`。\n- `merge(firstId, secondId, newOwner, newId)`：合并两个相邻的时间段，要求 `first.endTime + 1 == second.startTime`。\n\n这样就可以做到，例如，出售一年期通行证的后半段。\n\n## 示例代码\n\n一个最小的时间型 NFT，以及一个 consumer 侧的检查（OpenZeppelin v5）：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ninterface IERC5007 {\n    function startTime(uint256 tokenId) external view returns (uint64);\n    function endTime(uint256 tokenId) external view returns (uint64);\n}\n\ncontract SeasonPass is ERC721, IERC5007 {\n    struct Window { uint64 start; uint64 end; }\n    mapping(uint256 =\u003e Window) private _windows;\n\n    constructor() ERC721(\"Season Pass\", \"PASS\") {}\n\n    function _mintPass(address to, uint256 id, uint64 start, uint64 end) internal {\n        require(start \u003c end, \"bad window\");\n        _windows[id] = Window(start, end);\n        _safeMint(to, id);\n    }\n\n    function startTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].start;\n    }\n\n    function endTime(uint256 id) external view returns (uint64) {\n        _requireOwned(id);\n        return _windows[id].end;\n    }\n\n    function isActive(uint256 id) external view returns (bool) {\n        Window memory w = _windows[id];\n        return block.timestamp \u003e= w.start \u0026\u0026 block.timestamp \u003c= w.end;\n    }\n\n    function supportsInterface(bytes4 iid) public view override returns (bool) {\n        return iid == 0xf140be0d || super.supportsInterface(iid);\n    }\n}\n```\n\n## 需要注意\n\n- **状态：Final。**\n- 代币在其时间窗口之外依然存在，也可以正常转移。过期是供应用遵守的信号，而不是销毁。\n- `merge` 的相邻规则（`end + 1 == start`）意味着时间窗口包含两个端点，正如上面 `isActive` 的检查所示。\n- 对于所有者在一段时间内出借使用权的租赁，[ERC-4907](/eip-4907/)（ERC-721）和 [ERC-5006](/eip-5006/)（ERC-1155）定义了一个带有效期的独立 `user` 角色；ERC-5007 则把时间放在代币本身上。\n"}}}
