refreshNftMetadata -SDK

Refreshes the cached metadata for a provided NFT contract address and token id. Returns a boolean value indicating whether the metadata was refreshed.

Don’t have an API key?

Start using this method in your app today.

Description

Refreshes the cached metadata for a provided NFT contract address and token id. Returns a boolean value indicating whether the metadata was refreshed.

This method is useful when you want to refresh the metadata for an NFT that has been updated since the last time it was fetched.

📘

NOTE

Note that the backend only allows one refresh per token every 15 minutes, globally for all users. The last refresh time for an NFT can be accessed on the Nft.timeLastUpdated field.

To trigger a refresh for all NFTs in a contract, use refreshContract instead.

Parameters

NameTypeDescription
contractAddressstringThe contract address of the NFT.
tokenIdstringToken id of the NFT.

Response

PropertyTypeDescription
Promise<boolean>booleanspecifies true or false.

Example Request and Response

Prerequisite: You will need to install the Alchemy SDK before making requests with it.

The commands for installing it using npm or yarn are given below:

npm install alchemy-sdk
yarn add alchemy-sdk

Request

// Imports the Alchemy SDK
const { Alchemy, Network } = require("alchemy-sdk");

// Configures the Alchemy SDK
const config = {
    apiKey: "alchemy-replit", // Replace with your API key
    network: Network.ETH_MAINNET, // Replace with your network
};

// Creates an Alchemy object instance with the config to use for making requests
const alchemy = new Alchemy(config);

const main = async () => {
    const contractAddress = "0x06012c8cf97bead5deae237070f9587f8e7a266d";
    const tokenId = "1";
    //Call the method
    let response = await alchemy.nft.refreshNftMetadata(contractAddress, tokenId)

    //Logging the response to the console
    console.log(response)
};

main();

Response

false

Code Sandbox

You can test out the refreshNftMetadata method using the code sandbox below:

Use Cases

Here are some potential use cases for the refreshNftMetadata method:

  • Updating NFT information: NFT owners can use the refreshNftMetadata method to update the metadata associated with their NFT. For example, they can update the name, description, image, or other attributes.

  • Correcting errors: Sometimes errors can occur in the metadata associated with an NFT. For example, the wrong image may have been uploaded or the description may contain a typo. The refreshNftMetadata method can be used to correct these errors.

  • Improving NFT marketability: The metadata associated with an NFT can have a significant impact on its marketability. By updating the metadata, NFT owners can improve the chances of their NFTs being sold or traded.

Related Methods

Here are some methods that are similar to the refreshNftMetadata method:

  • refreshContract - Triggers a metadata refresh of all NFTs in the provided contract address.
ReadMe