{"eip":5008,"title":"ERC-721 Nonce Extension","description":"Add a `nonce` function to ERC-721.","authors":["Anders (@0xanders)","Lance (@LanceSnow)","Shrug \u003cshrug@emojidao.org\u003e"],"status":"Last Call","type":"Standards Track","category":"ERC","created":"2022-04-10","requires":[165,721],"discussionsTo":"https://ethereum-magicians.org/t/eip5008-eip-721-nonce-and-metadata-update-extension/8925","repo":"ERCs","label":"ERC-5008","officialUrl":"https://eips.ethereum.org/EIPS/eip-5008","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5008.md","url":"https://eips.huatuo.xyz/eip-5008/","tldr":{"en":"Adds a per-token `nonce` to ERC-721 that changes on every transfer, so marketplace orders can be bound to a nonce and stale listings cannot be reactivated after an NFT leaves and returns to a wallet.","ja":"ERC-721 にトークンごとの `nonce` を追加し、転送のたびに値が変わるようにする。これにより、マーケットプレイスの注文を nonce に紐付けられ、NFT がウォレットを離れて戻ってきても、古い出品が再び有効になることを防げる。","ko":"ERC-721에 토큰별 `nonce`를 추가해 전송할 때마다 값이 바뀌게 한다. 이렇게 하면 마켓플레이스 주문을 nonce에 묶을 수 있어, NFT가 지갑을 떠났다가 돌아와도 오래된 판매 등록이 다시 활성화되지 않는다.","zh":"为 ERC-721 增加每个代币独立的 `nonce`，每次转移时都会变化，使市场订单可以绑定某个 nonce，这样即使 NFT 离开钱包后又回来，过期的挂单也无法重新生效。"},"tags":["nft","erc-721","marketplace","orders","security"],"explainers":{"en":{"lang":"en","tldr":"Adds a per-token `nonce` to ERC-721 that changes on every transfer, so marketplace orders can be bound to a nonce and stale listings cannot be reactivated after an NFT leaves and returns to a wallet.","tags":["nft","erc-721","marketplace","orders","security"],"related":[721,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5008/","markdown":"## What problem does it solve?\n\nNFT marketplaces typically use signed off-chain orders: \"I will sell token #42 for X\". If the owner later moves the NFT to another wallet, the order fails, and they may forget about it. When the NFT comes back to the original wallet, the old order becomes valid again, possibly at a price far below the current market. Attackers have exploited such forgotten listings.\n\nA marketplace cannot easily tell from ERC-721 alone whether a token has moved since an order was signed.\n\n## How it works\n\nThe token contract exposes `nonce(tokenId)`, a number that changes whenever the token is transferred (and may change on other important updates). It emits `NonceChanged(tokenId, nonce)` when it does.\n\nA marketplace includes the current nonce in the signed order. At fill time it compares the order's nonce with `nonce(tokenId)`. If the token has moved at any point, even if it is back with the same owner, the nonce differs and the order is rejected.\n\nThe interface is discoverable through [ERC-165](/eip-165/) with ID `0xce03fdab`. The name `nonce` was chosen over `transferCount` because implementations may bump it for reasons other than transfers.\n\n## Sample code\n\nInterface and a minimal implementation on top of OpenZeppelin ERC-721 (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 IERC5008 {\n    event NonceChanged(uint256 tokenId, uint256 nonce);\n    function nonce(uint256 tokenId) external view returns (uint256);\n}\n\ncontract NoncedNFT is ERC721, IERC5008 {\n    mapping(uint256 =\u003e uint256) private _nonces;\n\n    constructor() ERC721(\"Nonced\", \"NNC\") {}\n\n    function nonce(uint256 tokenId) external view returns (uint256) {\n        _requireOwned(tokenId);\n        return _nonces[tokenId];\n    }\n\n    function _update(address to, uint256 tokenId, address auth)\n        internal override returns (address from)\n    {\n        from = super._update(to, tokenId, auth);\n        emit NonceChanged(tokenId, ++_nonces[tokenId]);\n    }\n\n    function supportsInterface(bytes4 id) public view override returns (bool) {\n        return id == type(IERC5008).interfaceId || super.supportsInterface(id);\n    }\n}\n```\n\n## Things to know\n\n- Status: **Last Call** (its last-call deadline passed in August 2023), not yet Final.\n- The nonce only helps if marketplaces actually include it in orders and check it on fill.\n- `nonce` must be a `view` function and must revert for tokens that do not exist.\n- Owners should still cancel listings they no longer want; the nonce is a safety net, not a substitute.\n"},"ja":{"lang":"ja","tldr":"ERC-721 にトークンごとの `nonce` を追加し、転送のたびに値が変わるようにする。これにより、マーケットプレイスの注文を nonce に紐付けられ、NFT がウォレットを離れて戻ってきても、古い出品が再び有効になることを防げる。","tags":["nft","erc-721","marketplace","orders","security"],"related":[721,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5008/","markdown":"## 何を解決するのか\n\nNFT マーケットプレイスは通常、オフチェーンの署名付き注文を使います。「トークン #42 を X で売ります」というものです。オーナーがその後 NFT を別のウォレットに移すと注文は失敗し、オーナーはその存在を忘れてしまうこともあります。NFT が元のウォレットに戻ってくると、古い注文が再び有効になり、現在の市場価格をはるかに下回る価格で成立する可能性があります。こうした忘れられた出品が攻撃者に悪用されてきました。\n\nERC-721 だけでは、マーケットプレイスは、注文が署名されてからトークンが移動したかどうかを簡単には判断できません。\n\n## 仕組み\n\nトークンコントラクトは `nonce(tokenId)` を公開します。これはトークンが転送されるたびに（場合によってはその他の重要な更新でも）変わる数値です。変わったときは `NonceChanged(tokenId, nonce)` を emit します。\n\nマーケットプレイスは、署名付き注文に現在の nonce を含めます。注文の成立時に、注文の nonce と `nonce(tokenId)` を比較します。途中でトークンが一度でも移動していれば、同じオーナーのもとに戻っていたとしても nonce は異なるため、注文は拒否されます。\n\nこのインターフェースは、ID `0xce03fdab` で [ERC-165](/eip-165/) により検出できます。名前を `transferCount` ではなく `nonce` にしたのは、実装が転送以外の理由でも値を増やす場合があるためです。\n\n## サンプルコード\n\nインターフェースと、OpenZeppelin ERC-721（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 IERC5008 {\n    event NonceChanged(uint256 tokenId, uint256 nonce);\n    function nonce(uint256 tokenId) external view returns (uint256);\n}\n\ncontract NoncedNFT is ERC721, IERC5008 {\n    mapping(uint256 =\u003e uint256) private _nonces;\n\n    constructor() ERC721(\"Nonced\", \"NNC\") {}\n\n    function nonce(uint256 tokenId) external view returns (uint256) {\n        _requireOwned(tokenId);\n        return _nonces[tokenId];\n    }\n\n    function _update(address to, uint256 tokenId, address auth)\n        internal override returns (address from)\n    {\n        from = super._update(to, tokenId, auth);\n        emit NonceChanged(tokenId, ++_nonces[tokenId]);\n    }\n\n    function supportsInterface(bytes4 id) public view override returns (bool) {\n        return id == type(IERC5008).interfaceId || super.supportsInterface(id);\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータス: **Last Call**（Last Call の期限は 2023 年 8 月に過ぎています）。まだ Final ではありません。\n- nonce が役に立つのは、マーケットプレイスが実際に注文に nonce を含め、成立時にそれを確認する場合に限られます。\n- `nonce` は `view` 関数でなければならず、存在しないトークンに対しては revert しなければなりません。\n- オーナーは、不要になった出品を引き続きキャンセルすべきです。nonce は安全網であり、代わりにはなりません。\n"},"ko":{"lang":"ko","tldr":"ERC-721에 토큰별 `nonce`를 추가해 전송할 때마다 값이 바뀌게 한다. 이렇게 하면 마켓플레이스 주문을 nonce에 묶을 수 있어, NFT가 지갑을 떠났다가 돌아와도 오래된 판매 등록이 다시 활성화되지 않는다.","tags":["nft","erc-721","marketplace","orders","security"],"related":[721,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5008/","markdown":"## 어떤 문제를 해결하나요?\n\nNFT 마켓플레이스는 보통 오프체인 서명 주문을 사용합니다. \"토큰 #42를 X에 판매하겠습니다\" 같은 주문입니다. 소유자가 나중에 NFT를 다른 지갑으로 옮기면 주문은 실패하고, 소유자는 이를 잊어버릴 수 있습니다. NFT가 원래 지갑으로 돌아오면 오래된 주문이 다시 유효해지며, 현재 시장 가격보다 훨씬 낮은 가격일 수도 있습니다. 공격자들은 이렇게 잊힌 판매 등록을 악용해 왔습니다.\n\nERC-721만으로는 마켓플레이스가 주문이 서명된 이후 토큰이 이동했는지 쉽게 알 수 없습니다.\n\n## 어떻게 동작하나요?\n\n토큰 컨트랙트는 `nonce(tokenId)`를 노출합니다. 토큰이 전송될 때마다(그 밖의 중요한 업데이트에서도 바뀔 수 있음) 바뀌는 숫자입니다. 바뀔 때 `NonceChanged(tokenId, nonce)`를 emit합니다.\n\n마켓플레이스는 서명된 주문에 현재 nonce를 포함합니다. 체결 시점에 주문의 nonce를 `nonce(tokenId)`와 비교합니다. 토큰이 중간에 한 번이라도 이동했다면, 같은 소유자에게 돌아왔더라도 nonce가 다르므로 주문은 거부됩니다.\n\n이 인터페이스는 [ERC-165](/eip-165/)를 통해 ID `0xce03fdab`으로 확인할 수 있습니다. 이름을 `transferCount` 대신 `nonce`로 한 것은, 구현이 전송 외의 이유로도 값을 올릴 수 있기 때문입니다.\n\n## 샘플 코드\n\n인터페이스와 OpenZeppelin ERC-721(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 IERC5008 {\n    event NonceChanged(uint256 tokenId, uint256 nonce);\n    function nonce(uint256 tokenId) external view returns (uint256);\n}\n\ncontract NoncedNFT is ERC721, IERC5008 {\n    mapping(uint256 =\u003e uint256) private _nonces;\n\n    constructor() ERC721(\"Nonced\", \"NNC\") {}\n\n    function nonce(uint256 tokenId) external view returns (uint256) {\n        _requireOwned(tokenId);\n        return _nonces[tokenId];\n    }\n\n    function _update(address to, uint256 tokenId, address auth)\n        internal override returns (address from)\n    {\n        from = super._update(to, tokenId, auth);\n        emit NonceChanged(tokenId, ++_nonces[tokenId]);\n    }\n\n    function supportsInterface(bytes4 id) public view override returns (bool) {\n        return id == type(IERC5008).interfaceId || super.supportsInterface(id);\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태: **Last Call**(Last Call 마감일은 2023년 8월에 지났습니다). 아직 Final이 아닙니다.\n- nonce는 마켓플레이스가 실제로 주문에 이를 포함하고 체결 시 확인할 때만 도움이 됩니다.\n- `nonce`는 `view` 함수여야 하며, 존재하지 않는 토큰에 대해서는 revert해야 합니다.\n- 소유자는 더 이상 원하지 않는 판매 등록을 여전히 취소해야 합니다. nonce는 안전망이지 대체 수단이 아닙니다.\n"},"zh":{"lang":"zh","tldr":"为 ERC-721 增加每个代币独立的 `nonce`，每次转移时都会变化，使市场订单可以绑定某个 nonce，这样即使 NFT 离开钱包后又回来，过期的挂单也无法重新生效。","tags":["nft","erc-721","marketplace","orders","security"],"related":[721,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5008/","markdown":"## 它解决什么问题？\n\nNFT 市场通常使用链下签名订单：\"我愿以 X 的价格出售代币 #42\"。如果所有者之后把 NFT 转到另一个钱包，该订单就会失效，而他们可能忘了这件事。当 NFT 回到原来的钱包时，旧订单又变得有效，价格可能远低于当前市价。攻击者已经利用过这类被遗忘的挂单。\n\n仅凭 ERC-721，市场很难判断代币自订单签署以来是否发生过转移。\n\n## 它如何运作\n\n代币合约公开 `nonce(tokenId)`，这个数字在代币每次转移时都会变化（在其他重要更新时也可以变化）。变化时会触发 `NonceChanged(tokenId, nonce)` 事件。\n\n市场把当前的 nonce 放进签名订单。成交时，它将订单中的 nonce 与 `nonce(tokenId)` 比较。如果代币在任何时候移动过，即使又回到了同一个所有者手中，nonce 也不同，订单就会被拒绝。\n\n该接口可通过 [ERC-165](/eip-165/) 发现，ID 为 `0xce03fdab`。之所以选用 `nonce` 而不是 `transferCount` 这个名字，是因为实现可能出于转移以外的原因递增它。\n\n## 示例代码\n\n接口，以及基于 OpenZeppelin ERC-721（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 IERC5008 {\n    event NonceChanged(uint256 tokenId, uint256 nonce);\n    function nonce(uint256 tokenId) external view returns (uint256);\n}\n\ncontract NoncedNFT is ERC721, IERC5008 {\n    mapping(uint256 =\u003e uint256) private _nonces;\n\n    constructor() ERC721(\"Nonced\", \"NNC\") {}\n\n    function nonce(uint256 tokenId) external view returns (uint256) {\n        _requireOwned(tokenId);\n        return _nonces[tokenId];\n    }\n\n    function _update(address to, uint256 tokenId, address auth)\n        internal override returns (address from)\n    {\n        from = super._update(to, tokenId, auth);\n        emit NonceChanged(tokenId, ++_nonces[tokenId]);\n    }\n\n    function supportsInterface(bytes4 id) public view override returns (bool) {\n        return id == type(IERC5008).interfaceId || super.supportsInterface(id);\n    }\n}\n```\n\n## 需要注意\n\n- 状态：**Last Call**（其 Last Call 截止日期已于 2023 年 8 月过去），尚未 Final。\n- 只有当市场真的把 nonce 放进订单并在成交时检查，它才有用。\n- `nonce` 必须是 `view` 函数，并且对不存在的代币必须 revert。\n- 所有者仍应取消不再需要的挂单；nonce 是安全网，不能替代取消操作。\n"}}}
