Skip to main content

Mutate your NFT's metadata live on devnet

Mutate your Solana NFT’s metadata on devnet and watch each on-chain change appear in Explorer as live state, not a static artifact.
Mutate your NFT's metadata live on devnet background
Challenge

Mutate your NFT's metadata live on devnet

For the past few days you have been building. You minted a 1-of-1 token. You stamped it with the Metadata extension. You grouped it under a collection with the Group and Member extensions. Then you audited the whole thing and confirmed every byte sat exactly where you expected.

The Scenario

That is a lot of careful work. Now it is time to break the careful posture for a day and just poke at things.

In your Web2 life, this is the part where you would open a staging database, run a few UPDATE statements, and refresh the admin panel to see what happens. You would change a user’s display name. You would flip a feature flag. You would add a new column and watch how the UI reacts. The point is not to ship anything. The point is to build intuition by touching the thing.

Today you are going to do the on-chain equivalent. Your NFT has metadata sitting inside the mint account. That metadata is mutable as long as you hold the update authority, which you do. So you are going to rename it, change the image it points to, invent a custom field nobody asked for, and then delete that field a minute later. Each change is a single CLI call. Each change shows up in Solana Explorer the moment the transaction confirms.

This is the day you stop treating your NFT like a fragile artifact and start treating it like a living row of data on a public network.

The Challenge

What you’ll need

  • A terminal with the Agave tool suite installed
  • The spl-token CLI configured for the Token-2022 program
  • The mint address of the NFT you created earlier this arc
  • Your keypair file, which holds the metadata update authority you set when you initialized the metadata
  • A browser tab open to Solana Explorer on devnet

Steps

  1. Make sure your Solana CLI is pointed at devnet by running solana config set --url https://api.devnet.solana.com. Confirm with solana config get.
  2. Open your NFT in Solana Explorer. Paste the mint address into the search bar and scroll down to the Token Extensions panel. Find the Token Metadata extension. Note the current name, symbol, URI, and any additional metadata fields. Keep this tab open. You will come back to it after every change.
  3. Pick a new name for your NFT. Anything you want. "Field Notes". "Devnet Original". "Probably Worthless". Run the rename command shown in the Run it section below, substituting your mint address.
  4. Refresh the Explorer tab. The name field should reflect your change within a few seconds. If it does not, give it a beat. Devnet RPC nodes occasionally lag a slot or two behind.
  5. Now invent a custom field. The metadata extension lets you store arbitrary key/value pairs in the additional_metadata array. Add one called rarity with the value legendary. Or vibe, chaotic-good. Or edition, field-test-1. The point is the schema is open.
  6. Refresh Explorer again. Scroll down to the Token Metadata extension and look for your new key under additional metadata. There it is, on chain, on a public network, queryable by anyone with an RPC endpoint.
  7. Change your mind. Remove the custom field you just added by passing the --remove flag. Refresh Explorer. Watch it disappear.
  8. Finally, swap the image. Find any publicly hosted image you have rights to use, get its raw URL, build a new metadata JSON file that points at it, host the JSON somewhere public (a GitHub gist with the raw URL works), and update the uri field on the mint to point at the new JSON.
  9. Open a wallet like Phantom or Backpack on devnet and import or send the NFT to a wallet you control. See whether the new image shows up. Wallets cache aggressively, so this is also a lesson in how the off-chain image layer behaves differently from the on-chain metadata layer.

Run it

Update the name field:

spl-token update-metadata [MINT_ADDRESS] name "Field Notes"

Add a custom additional metadata field:

spl-token update-metadata [MINT_ADDRESS] rarity legendary

Remove that custom field:

spl-token update-metadata [MINT_ADDRESS] rarity --remove

Point the NFT at a new metadata JSON:

spl-token update-metadata [MINT_ADDRESS] uri https://gist.githubusercontent.com/janvinsha/6f8187a0b15de99c03a1b07e82db36e9/raw/83e33a3529d07df1f4d60bf7d543c5b72b5314e2/metadata.json

What Just Happened

Every command you ran was a single transaction sent to the Token-2022 program. The program checked that the signer holds the update authority recorded inside the metadata extension on the mint account, and then it rewrote the relevant field in place. No new accounts. No migrations. No off-chain database. Just a few bytes of state shifting on a public ledger, paid for in fractions of a cent.

The piece worth sitting with is the separation between the on-chain layer and the off-chain layer. The name, symbol, and URI all live on chain inside the mint account. They moved instantly. The image those bytes point at lives off chain, on whatever HTTP host you chose. Wallets and marketplaces fetch that image when they index your NFT, and they tend to cache it for hours or days. That asymmetry is why a freshly updated NFT can show the new name and the old picture for a while. It is also why a lot of NFT projects eventually move their image hosting onto Arweave or IPFS: the on-chain pointer is permanent, so the thing it points at should be permanent too.

The other thing worth noticing is that you just performed an action a senior on-chain engineer performs every week. Patching live state on a deployed program. You did it in one line, against a real network, with real signatures. That is the muscle.

Resources

Submission

Take a screenshot of your NFT in Solana Explorer showing at least one field you mutated today (the new name, the new URI, or a custom additional metadata key) and submit it below!

Submit your project