---
eip: 7496
label: ERC-7496
title: NFT Dynamic Traits
status: Draft
type: Standards Track
category: ERC
created: 2023-07-28
requires: 165, 721, 1155
official: https://eips.ethereum.org/EIPS/eip-7496
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7496.md
canonical: https://eips.huatuo.xyz/eip-7496/
lang: en
tldr: "Adds a generic on-chain key-value trait store to ERC-721 and ERC-1155 tokens, so traits like 'redeemed' or 'points' can change over time and marketplaces can check them at sale time to stop front-running."
tags: [nft, traits, metadata, marketplace, erc721]
---

# ERC-7496: NFT Dynamic Traits

> Extension to ERC-721 and ERC-1155 for dynamic onchain traits

**TL;DR:** Adds a generic on-chain key-value trait store to ERC-721 and ERC-1155 tokens, so traits like 'redeemed' or 'points' can change over time and marketplaces can check them at sale time to stop front-running.

## What problem does it solve?

NFT traits normally live in off-chain JSON metadata. Contracts cannot read or change them, and that creates a real attack: a seller lists an NFT that still has an unused redeemable benefit, then redeems it just before the buyer's purchase executes. The buyer pays for something that is gone.

ERC-7496 puts changeable traits on-chain behind a standard interface. Other contracts, especially marketplaces, can read the current values and refuse a sale if an important trait changed after the offer was made.

## How it works

Each trait is identified by a `bytes32 traitKey` (recommended: `keccak256` of the trait name) and holds a `bytes32` value:

- `getTraitValue(tokenId, traitKey)` / `getTraitValues(tokenId, keys[])` read values. An unknown key reverts with `TraitDoesNotExist`; a known key that is unset returns `bytes32(0)`.
- `setTrait(tokenId, traitKey, newValue)` writes a value. It must be permissioned, except for traits marked `tokenOwnerCanUpdateValue`, which the token owner can set.
- Every change emits one of the `TraitUpdated*` events (single token, range, or list, with "uniform value" variants for bulk updates). Values must change only through explicit actions, never implicitly with time, so indexers can follow events.
- `getTraitMetadataURI()` returns a JSON document describing every trait: display name, data type (`string`, `decimal`, `boolean`, `epochSeconds`), optional `valueMappings` from raw `bytes32` to labels, and `validateOnSale`.

`validateOnSale` tells marketplaces how to protect buyers: `requireEq`, `requireNeq`, or numeric comparisons such as `requireUintGte` between the value at offer time and at fulfilment. If the check fails, the marketplace must not complete the sale.

Contracts advertise support via [ERC-165](/eip-165/) interface id `0xaf332f3e`. On-chain trait values override conflicting values from the ERC-721/1155 metadata URI.

## Sample code

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

interface IERC7496 {
    event TraitUpdated(bytes32 indexed traitKey, uint256 tokenId, bytes32 traitValue);
    event TraitMetadataURIUpdated();
    function getTraitValue(uint256 tokenId, bytes32 traitKey) external view returns (bytes32);
    function getTraitValues(uint256 tokenId, bytes32[] calldata traitKeys) external view returns (bytes32[] memory);
    function getTraitMetadataURI() external view returns (string memory);
    function setTrait(uint256 tokenId, bytes32 traitKey, bytes32 newValue) external;
}

// Marketplace-side check for a trait marked "validateOnSale": "requireEq"
function _checkRedeemed(IERC7496 nft, uint256 id, bytes32 valueAtOffer) view {
    bytes32 key = keccak256("redeemed");
    require(nft.getTraitValue(id, key) == valueAtOffer, "trait changed");
}
```

A trait definition in the metadata JSON:

```json
{
  "traits": {
    "redeemed": {
      "displayName": "Redeemed",
      "dataType": { "type": "boolean" },
      "validateOnSale": "requireEq"
    }
  }
}
```

## Things to know

- Status is **Draft**.
- Booleans default to `bytes32(0)` for false and `bytes32(uint256(1))` for true unless `valueMappings` says otherwise.
- The spec warns buyers and sellers not to rely solely on marketplaces: check current trait values yourself before trading.
- Use the `UniformValue` events for bulk updates so indexers do not have to query every token.


---

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