nftMetadataUpdates - EVM Data Stream

The nftMetadataUpdates topic sends decoded ERC-4906 events. Collections emit these to announce that a token's metadata changed, so indexers and marketplaces know to refresh tokenURI instead of polling it.

WebSocket-only topic. Subscribe with getblock_subscribe on any network endpoint.

Parameters

ParameterTypeRequiredDescription
filters.tokenContractstringNoNFT contract address.
filters.tokenIdstringNoOne token ID as a hex quantity.

Request Example

bash# WebSocket-only. Connect first:
wscat -c 'wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream' -H 'Authorization: Bearer <API-KEY>'

# Then send:
{"jsonrpc":"2.0","id":1,"method":"getblock_subscribe","params":[{"topic":"nftMetadataUpdates","filters":{"tokenContract":"0x8004a169fb4a3325136eb29fa0ceb6d2e539a432"}}]}
javascript// npm install ws
import WebSocket from 'ws';

const ws = new WebSocket('wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream', {
  headers: { Authorization: 'Bearer <API-KEY>' }
});

ws.on('open', () => {
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getblock_subscribe',
    params: [{
      topic: 'nftMetadataUpdates',
      filters: {
        tokenContract: '0x8004a169fb4a3325136eb29fa0ceb6d2e539a432'
      }
    }]
  }));
});

ws.on('message', (raw) => {
  const msg = JSON.parse(raw);

  // First reply is the subscription ID (or an error)
  if (msg.id !== undefined) {
    console.log(msg.error ?? `Subscribed: ${msg.result}`);
    return;
  }

  const { removed, data } = msg.params.result;
  if (!removed) console.log('refresh metadata', data.tokenContract, data.updateType, data.tokenId);
});
python# pip install "websockets>=14"
import asyncio, json, websockets

URL = "wss://stream.eu-central-1.getblock.io/v1/eth-mainnet/stream"
HEADERS = {"Authorization": "Bearer <API-KEY>"}

async def main():
    # ping_interval=None: the server sends its own keepalive pings (see Connection keepalive)
    async with websockets.connect(URL, additional_headers=HEADERS, ping_interval=None) as ws:
        await ws.send(json.dumps({
            "jsonrpc": "2.0",
            "id": 1,
            "method": "getblock_subscribe",
            "params": [{
                "topic": "nftMetadataUpdates",
                "filters": {
                    "tokenContract": "0x8004a169fb4a3325136eb29fa0ceb6d2e539a432"
                }
            }]
        }))

        async for message in ws:
            msg = json.loads(message)

            # First reply is the subscription ID (or an error)
            if "id" in msg:
                print(msg.get("error") or f"Subscribed: {msg['result']}")
                continue

            event = msg["params"]["result"]
            removed, data = event["removed"], event["data"]
            if not removed:
                print('refresh metadata', data['tokenContract'], data['updateType'], data.get('tokenId'))

asyncio.run(main())

Response Example

The first reply is the subscription ID:

json{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0xc37755570546333df386be6355ee736e"
}

Every later message is an event notification:

json{
  "jsonrpc": "2.0",
  "method": "getblock_subscribe",
  "params": {
    "subscription": "0xc37755570546333df386be6355ee736e",
    "result": {
      "eventId": "eth:mainnet:receipts:0x5cb2b901e6fd1e2ca3a7cef95af7a22946a4d973840…",
      "removed": false,
      "revision": 117013229,
      "data": {
        "updateType": "single",
        "tokenContract": "0x8004a169fb4a3325136eb29fa0ceb6d2e539a432",
        "tokenId": "0xc748",
        "address": "0x8004a169fb4a3325136eb29fa0ceb6d2e539a432",
        "blockNumber": "0x18d1e8e",
        "transactionHash": "0x05b874945b5f64705afea62f0063c423705c56ea35f03e565dffef95e43ddacb",
        "transactionIndex": "0x2b",
        "blockHash": "0x5cb2b901e6fd1e2ca3a7cef95af7a22946a4d973840eecbc047574245161d112",
        "blockTimestamp": "0x6ab11603",
        "logIndex": "0xe0",
        "removed": false
      }
    }
  }
}

Response Parameters

The result object contains the event envelope and the payload in data.

FieldTypeDescription
eventIdstringStable event identifier. A reorg correction reuses it.
removedbooleantrue when a reorg removed this previously delivered event.
revisionnumberEvent version. For one eventId, a greater revision is newer.
data.updateTypestringsingle for MetadataUpdate(tokenId). A BatchMetadataUpdate(fromTokenId, toTokenId) covers a range of tokens instead of one.
data.tokenContractstringNFT contract address.
data.tokenIdstringFor single updates: the token whose metadata changed, hex-encoded.
data.addressstringAddress of the contract that emitted the log.
data.blockNumberstringBlock number, hex-encoded.
data.blockHashstringHash of the block that contains the log.
data.blockTimestampstringBlock timestamp in Unix seconds, hex-encoded.
data.transactionHashstringHash of the transaction that emitted the log.
data.transactionIndexstringTransaction's position in the block, hex-encoded.
data.logIndexstringLog's position in the block, hex-encoded.
data.removedbooleanThe underlying log's removed flag. Use the envelope's removed for reorg handling.

ERC-4906 events are relatively rare: only collections that implement the standard emit them. Expect long gaps between notifications on an unfiltered subscription.

Use Cases

  • Invalidating cached NFT metadata and images
  • Tracking reveals, upgrades, and evolving or dynamic NFTs
  • Keeping marketplace listings in sync with on-chain metadata changes

Error Handling

CodeMessageCause
-32602… cannot unmarshal hex string without 0x prefix …A hex-quantity filter was sent as a decimal string. Encode it as 0x….
-32602invalid tokenContract: invalid EVM address "…"tokenContract is not a 20-byte hex address.
-32602invalid nftMetadataUpdates request: json: unknown field "…"The request has a field this topic does not accept.
-32001subscription limit exceededYou already have 15 active or pending subscriptions.