Can I modify NFT metadata on IPFS Lighthouse after the tokens are already minted?

I have an issue with my NFT collection that I minted recently. The problem is that the images are not showing up properly because of how I structured the metadata.

Currently my metadata looks like this:

{
  "name": "My Token",
  "picture": "token1.jpg"
}

But I need it to be:

{
  "name": "My Token", 
  "picture": "https://gateway.lighthouse.storage/ipfs/bafkreihqkdlpsjdvdhxfz3stpvece36luauhs3zw5dtwqwq7kuqkprqnhq/token1.jpg"
}

The NFTs are already deployed on the blockchain but the images won’t display because the metadata has the wrong image paths. I need to update all the metadata files to use the full gateway URLs instead of just the filenames.

From what I’ve read online, IPFS files are supposed to be immutable once uploaded. Is there any way around this or do I need to start over completely?

totally feel ya, that’s a bummer! ipfs is meant to be permanent, so u can’t change it. ur best bet is to reupload the metadata with correct links and see if ur contract lets u do updates. good luck!

Oh wow, that sucks! I’ve been wondering about this too since I’m launching my own collection soon.

You’re right - IPFS content can’t be changed once it’s uploaded with a hash. But here’s what I’m thinking: when you uploaded to lighthouse, did you upload individual files or a folder? Each metadata file gets its own hash if uploaded separately.

Couldn’t you just upload new metadata files with the fixed image URLs? They’d get new hashes, but then you could update your smart contract if it has functions for changing token URIs.

What’s your contract setup like? Does it have setTokenURI or similar functions? Some contracts let owners update metadata for exactly this reason.

How many tokens are we talking? If it’s a small collection, gas costs might be manageable. Thousands of tokens though… that gets pricey fast.

Have you contacted lighthouse support? They might have bulk operation tools. Also, what contract did you use - custom deploy or something like OpenZeppelin templates?

The Problem:

Your NFT images aren’t displaying correctly because your metadata uses incorrect image paths. Currently, your metadata only includes the filename, but you need the full IPFS gateway URL. IPFS files are immutable after upload, meaning you can’t directly change the existing metadata on IPFS. Therefore, you need to upload new metadata files with the correct URLs.

:thinking: Understanding the “Why” (The Root Cause):

The issue stems from how IPFS handles files. When you upload a file to IPFS, it generates a unique cryptographic hash (CID) that acts as the file’s immutable identifier. This CID is part of the URL used to access the file. Your initial metadata only pointed to the filename (token1.jpg), not the complete, addressable location of the file on the IPFS network (the URL including the CID). You can’t modify the original IPFS file or change its location.

:gear: Step-by-Step Guide:

  1. Create New Metadata Files with Correct URLs: Create new JSON files for each of your NFTs, replacing the old picture property with the correct IPFS gateway URL including the CID. For example, if your IPFS gateway is https://gateway.lighthouse.storage/ipfs/, and the CID for token1.jpg is bafkreihqkdlpsjdvdhxfz3stpvece36luauhs3zw5dtwqwq7kuqkprqnhq, then your updated metadata JSON should look like this:
{
  "name": "My Token",
  "picture": "https://gateway.lighthouse.storage/ipfs/bafkreihqkdlpsjdvdhxfz3stpvece36luauhs3zw5dtwqwq7kuqkprqnhq/token1.jpg"
}

Repeat this for all your NFT metadata files.

  1. Upload New Metadata to IPFS: Upload these updated JSON files to your IPFS gateway. You’ll get new CIDs for each file.

  2. Update Your Smart Contract (If Necessary): Many NFT smart contracts provide functions to update metadata. Depending on your specific contract, you might need to use a function like setTokenURI or a similar method to update the URI for each token with the new IPFS URLs from Step 2. Consult your contract’s documentation or explore its functions on a blockchain explorer to identify the appropriate method. Consider the gas costs associated with updating multiple NFTs.

:mag: Common Pitfalls & What to Check Next:

  • Incorrect Gateway URL: Double-check that you’re using the correct IPFS gateway URL. A typo here will lead to broken links.
  • Smart Contract Permissions: Ensure your account has the necessary permissions to call the metadata update functions on your smart contract. Many contracts require the original minter or the owner to perform this action.
  • Gas Costs: Updating metadata on-chain for a large number of NFTs can be expensive. Consider the gas fees before initiating a bulk update.
  • Bulk Uploading Tools: Investigate if your IPFS provider offers bulk uploading tools to streamline the process of uploading many files simultaneously.

:speech_balloon: Still running into issues? Share your (sanitized) config files, the exact command you ran, and any other relevant details. The community is here to help!