---
eip: 4906
label: ERC-4906
title: EIP-721 Metadata Update Extension
status: Final
type: Standards Track
category: ERC
created: 2022-03-13
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-4906
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-4906.md
canonical: https://eips.huatuo.xyz/eip-4906/
lang: en
tldr: "Adds MetadataUpdate and BatchMetadataUpdate events to ERC-721, so marketplaces and indexers know exactly when to refresh an NFT's metadata instead of polling or guessing."
tags: [nft, erc-721, metadata, events, marketplaces]
---

# ERC-4906: EIP-721 Metadata Update Extension

> Add a MetadataUpdate event to EIP-721.

**TL;DR:** Adds MetadataUpdate and BatchMetadataUpdate events to ERC-721, so marketplaces and indexers know exactly when to refresh an NFT's metadata instead of polling or guessing.

## What problem does it solve?

Many NFTs change after mint: game items level up, reveals swap placeholder art for the real image, and dynamic NFTs react to on-chain state. Marketplaces and indexers cache each token's metadata, so they need to know when to fetch it again.

Before ERC-4906, each collection signaled changes with its own custom event, or did not signal them at all. Platforms had to write a separate integration per collection, or offer a manual "refresh metadata" button. ERC-4906 standardizes one event that everyone can listen for.

## How it works

It is an optional [ERC-721](/eip-721/) extension that adds two events and no functions:

```solidity
event MetadataUpdate(uint256 _tokenId);
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
```

- Emit `MetadataUpdate` when the JSON metadata of one token changes.
- Emit `BatchMetadataUpdate` when a **consecutive range** of token IDs changes, for example a whole-collection reveal.
- Emitting them is **not recommended** on mint or burn, or when `tokenURI` changes but the JSON behind it is the same.
- `supportsInterface(0x49064906)` must return `true` ([ERC-165](/eip-165/)).

The events deliberately carry no new metadata values. When a listener sees one, it calls `tokenURI(tokenId)` again and re-downloads the JSON. For a batch event it does this for each token in the range.

## Sample code

A reveal-style collection that emits the events (OpenZeppelin 5 ships `IERC4906`):

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

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC4906} from "@openzeppelin/contracts/interfaces/IERC4906.sol";

contract Revealable is ERC721, Ownable, IERC4906 {
    string private base;
    uint256 public minted;

    constructor() ERC721("Reveal", "RVL") Ownable(msg.sender) {}

    function reveal(string calldata newBase) external onlyOwner {
        base = newBase;
        if (minted > 0) emit BatchMetadataUpdate(0, minted - 1);
    }

    function _baseURI() internal view override returns (string memory) { return base; }

    function supportsInterface(bytes4 id) public view override(ERC721, IERC165) returns (bool) {
        return id == bytes4(0x49064906) || super.supportsInterface(id);
    }
}
```

Listening as an indexer (ethers v6):

```ts
nft.on("MetadataUpdate", async (tokenId) => refresh(await nft.tokenURI(tokenId)));
nft.on("BatchMetadataUpdate", async (from, to) => {
  for (let id = from; id <= to; id++) refresh(await nft.tokenURI(id));
});
```

## Things to know

- **Status: Final** and widely supported. OpenZeppelin's `ERC721URIStorage` emits `MetadataUpdate` from `_setTokenURI`.
- If metadata changes off-chain (for example, a mutable server URL), the contract never knows. You can add an access-controlled function that only emits the event. Make sure only authorized parties can call it, or anyone could spam refreshes.
- For very large ranges, consumers may throttle or ignore huge batches. Emit the narrowest range that actually changed.
- For on-chain, typed traits rather than whole-JSON refreshes, see [ERC-7496](/eip-7496/) (Dynamic Traits, Draft).


---

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