---
eip: 5008
label: ERC-5008
title: ERC-721 Nonce Extension
status: Last Call
type: Standards Track
category: ERC
created: 2022-04-10
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-5008
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5008.md
canonical: https://eips.huatuo.xyz/eip-5008/
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]
---

# ERC-5008: ERC-721 Nonce Extension

> Add a `nonce` function to ERC-721.

**TL;DR:** 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.

## What problem does it solve?

NFT 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.

A marketplace cannot easily tell from ERC-721 alone whether a token has moved since an order was signed.

## How it works

The 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.

A 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.

The 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.

## Sample code

Interface and a minimal implementation on top of OpenZeppelin ERC-721 (v5):

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

interface IERC5008 {
    event NonceChanged(uint256 tokenId, uint256 nonce);
    function nonce(uint256 tokenId) external view returns (uint256);
}

contract NoncedNFT is ERC721, IERC5008 {
    mapping(uint256 => uint256) private _nonces;

    constructor() ERC721("Nonced", "NNC") {}

    function nonce(uint256 tokenId) external view returns (uint256) {
        _requireOwned(tokenId);
        return _nonces[tokenId];
    }

    function _update(address to, uint256 tokenId, address auth)
        internal override returns (address from)
    {
        from = super._update(to, tokenId, auth);
        emit NonceChanged(tokenId, ++_nonces[tokenId]);
    }

    function supportsInterface(bytes4 id) public view override returns (bool) {
        return id == type(IERC5008).interfaceId || super.supportsInterface(id);
    }
}
```

## Things to know

- Status: **Last Call** (its last-call deadline passed in August 2023), not yet Final.
- The nonce only helps if marketplaces actually include it in orders and check it on fill.
- `nonce` must be a `view` function and must revert for tokens that do not exist.
- Owners should still cancel listings they no longer want; the nonce is a safety net, not a substitute.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-5008
