Skip to content

Commit 761cde6

Browse files
committed
[portal] add new support article (#7595)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `knowledge-base` section by adding new assets and a comprehensive guide for bulk updating NFT metadata, specifically for ERC-721A contracts. ### Detailed summary - Added multiple image assets to the `knowledge-base`. - Introduced a new guide in `page.mdx` for bulk updating NFT metadata. - Explained concepts of batch and base URI in the context of NFTs. - Provided step-by-step instructions for updating NFT metadata efficiently. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a new sidebar entry for "Bulk update NFT metadata" under the "Contracts" section in the Troubleshoot category. * Introduced a comprehensive step-by-step guide on how to update metadata for multiple NFTs in bulk, including instructions, images, and helpful resources. * **Documentation** * Expanded the knowledge base with detailed troubleshooting documentation for bulk updating NFT metadata. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 9546b92 commit 761cde6

File tree

9 files changed

+165
-0
lines changed

9 files changed

+165
-0
lines changed
14.9 KB
Loading
268 KB
Loading
99.6 KB
Loading
194 KB
Loading
171 KB
Loading
45 KB
Loading
20.5 KB
Loading

apps/portal/src/app/knowledge-base/sidebar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export const sidebar: SideBar = {
7575
href: "/knowledge-base/troubleshoot/contracts/erc20-transfer-allowance",
7676
name: "Transfer Amount Exceeds Allowance",
7777
},
78+
{
79+
href: "/knowledge-base/troubleshoot/contracts/update-nft-metadata",
80+
name: "Bulk update NFT metadata",
81+
},
7882
],
7983
name: "Contracts",
8084
},
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
import { DocImage, Step, Steps } from "@doc";
2+
import Batch from "../../../assets/update-batch.png";
3+
import Token from "../../../assets/token-uri.png";
4+
import IPFS from "../../../assets/import-ipfs.png";
5+
import DownloadIpfs from "../../../assets/download-ipfs.png";
6+
import Search from "../../../assets/search.png";
7+
import Storage from "../../../assets/storage.png";
8+
import BaseUri from "../../../assets/base-uri.png";
9+
10+
11+
12+
# How to update the metadata for multiple NFTs
13+
14+
This guide is intended for NFTDrop contracts (ERC-721A) and is meant to be a low-code solution.
15+
16+
Let’s say you have a NFTDrop collection called “Crypto Cats” which contains 10,000 items. Upon lazy-minting those 10,000 items, you realize that you have made a small typo in all their names.
17+
18+
Instead of naming them "Crypto Cats Token", you accidentally added an extra “s” like this:
19+
20+
```tsx
21+
{
22+
name: "Crypto Catss Token", // <--------- "Catss"
23+
description: "This NFT belongs to the Crypto Cats collection",
24+
image: "ipfs://Qm....",
25+
...
26+
}
27+
```
28+
29+
Now, if only you have made the typo on a few items, you can use the thirdweb Dashboard to manually update the metadata on those few. Checkout this guide: https://blog.thirdweb.com/changelog/updateable-nft-metadata-in-dashboard/
30+
31+
**So here comes the challenge: How to fix the names of all 10,000 items at once (because it would be incredibly inefficient to update it one-by-one)**
32+
33+
Fortunately, all the latest thirdweb Drop contracts come with a write method called `updateBatchBaseURI` , allowing you to update the metadata of all NFTs in a given “batch”. To learn how to use it, you would have to understand how a Drop contract “organizes” the NFTs that it holds.
34+
35+
## Understanding the “base” & “batch” terminologies
36+
37+
### Batch
38+
39+
Every time you upload a bunch of items to the contract (the action is also called “lazy minting”), you are creating a new batch containing all those items.
40+
41+
***In this example, these first 10,000 items belong to the same batch. Since this is the first batch ever uploaded to the contract, the batch ID is 0 (the next batch ID will be 1, 2 and so on).***
42+
43+
### Base URI
44+
45+
The metadata files of those items are uploaded to IPFS in the same folder. let's say you upload the first 10,000 items to an NFTDrop contract, the end result would look like this:
46+
47+
```tsx
48+
ipfs://Qm...abcxyz/0
49+
ipfs://Qm...abcxyz/1
50+
ipfs://Qm...abcxyz/2
51+
ipfs://Qm...abcxyz/3
52+
...
53+
ipfs://Qm...abcxyz/9998
54+
ipfs://Qm...abcxyz/9999
55+
```
56+
57+
***These first 10,000 items’ metadata files are uploaded in a same folder on IPFS, so the “Base” here is `ipfs://Qm...abcxyz`***
58+
59+
For every batch ID, there will be an unique associated base URI.
60+
61+
## Using `updateBatchBaseURI`
62+
63+
If you go to the contract Explorer on the thirdweb Dashboard, you can see that the function takes in 2 parameters: `_index` and `_uri`. Index here is the index of the batch (or batch ID) and ***not*** the tokenId. And URI is the ***new*** base URI that contain the corrected metadata. In this example you uploaded all 10,000 items at once, so conveniently, there will only be one batch and that batch ID will be `0`.
64+
65+
<DocImage src={Batch} />
66+
67+
The challenging part here is preparing the new content (with the corrected names) for all 10,000 items, re-uploading them, retrieving the new IPFS URI, and using as the value for the second parameter — with the least amount of effort. Below are the suggested steps:
68+
69+
## Step 1: Identifying the current base URI that you want to replace.
70+
71+
First of all we need to retrieve the base URI that you are going to replace. This is essential for step 2.
72+
73+
Here’s the trick: since all the tokens in a batch share the same batch base URI, the tokenURIs in that batch (let’s say batch #0) will share the following format:
74+
75+
```tsx
76+
ipfs://<batch-base-for-batch-id-0>/<tokenId>
77+
```
78+
79+
You can get the tokenURI of any token by calling the read method `tokenURI` which takes in a single parameter, an `uint256`, representing the targeted tokenId.
80+
81+
<DocImage src={Token} />
82+
83+
As you can see here, the tokenURI of the #0 token is: `ipfs://batch-base-uri/0`
84+
85+
Once you have the output similar to the image above, we can move to step 2.
86+
87+
## Step 2: Download the current metadata files
88+
89+
Since you only want to update part of the metadata – the name of the NFTs – you want to retain all the rest of the info. The idea of this step is to download all the current metadata files → open them in a text editor → fix the typo → re-upload the files to IPFS.
90+
91+
Once re-uploaded, you will have the new batch base URI that you can use in the `updateBatchBaseURI` method!
92+
93+
### Download the metadata files using IPFS Desktop
94+
95+
First you need to install IPFS Desktop. Once installed, the CID can be imported from IPFS and downloaded to your machine. A guide can be found here:
96+
[IPFS Desktop Tutorial | IPFS Docs](https://docs.ipfs.tech/how-to/desktop-app/#download)
97+
98+
<DocImage src={IPFS} />
99+
100+
And the downloaded files would look like this:
101+
102+
<DocImage src={DownloadIpfs} />
103+
104+
### Download using IPFS Kubo (command-line interface)
105+
106+
If you have IPFS Kubo installed on your system, you can simply do:
107+
108+
```bash
109+
ipfs get <cid>
110+
# this is example, the full command would be:
111+
# ipfs get QmVQpAEkbzbqm7fxMJ5up68CppbP5fF7bLxnrtPRMuTaYT
112+
```
113+
114+
## Step 3: Edit the content
115+
116+
At this point, you should be able to download a compressed file containing all 10,000 items from 0 to 9999 via your IPFS Client (Node). You should extract the folder and open it in a text editor. I will be using VS Code in this example.
117+
118+
Using the Global search + Replace feature, it takes seconds to fix all the names at once:
119+
120+
<DocImage src={Search} />
121+
122+
## Step 4: Re-upload the new metadata files to IPFS
123+
124+
Head over to thirdweb Storage page: https://thirdweb.com/dashboard/settings/storage
125+
126+
Here you should be able to drag and drop the folder (containing 10,000 updated metadata files) to the upload zone. Once uploaded, this is what you’ll see:
127+
128+
<DocImage src={Storage} />
129+
130+
## Step 5: Retrieve the new batch base URI
131+
132+
If you click on the Copy button of one of the uploaded items (in the image above), you will get something like this:
133+
134+
135+
```bash
136+
ipfs://QmSfoytDR19NjFxykPorqXmXJWCtSXcGt3Dcv11HtLSeSZ/0
137+
```
138+
139+
IMPORTANT: You must strip out the file name (which is `0` in this case) ***and*** the trailing slash.
140+
141+
The result will be the new batch base URI that you can use!
142+
143+
```bash
144+
# New batch base URI:
145+
ipfs://QmSfoytDR19NjFxykPorqXmXJWCtSXcGt3Dcv11HtLSeSZ
146+
```
147+
148+
## That’s it!
149+
150+
Now you have both the batch ID (zero) and the new batch base URI, you can go back to the Dashboard Explorer, enter the two parameters, and hit Execute. That new names for the NFTs should be reflected in a short while.
151+
152+
<DocImage src={BaseUri} />
153+
154+
Keep in mind that some NFT marketplaces do not show the freshest data from the blockchain. They often cache the data to save on cost and achieve better performance. If you are using OpenSea and still see the old “typo” name, try to hit the “Refresh Metadata” button.
155+
156+
157+
---
158+
159+
160+
Still stuck? [**Contact our support team**](https://thirdweb.com/support)
161+

0 commit comments

Comments
 (0)