Generating NFT Metadata with Python

Learn how to generate NFT metadata with Python and IPFS.

What is Metadata?

Metadata by definition refers to data about data. Metadata provides additional information about existing data to provide enrichment and additional attributes that make data easier to manage, use, and find.

Prerequisites:

Read below to learn how to generate NFT metadata with Python and IPFS.

1. First, we need to create an IPFS bucket on Filebase.

To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.

2. Select ‘Buckets’ from the left side bar menu, or navigate to.

Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.

3. Enter a bucket name and choose the IPFS storage network to create the bucket.

Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.

4. Next, run the following command to clone the Github repository generative-art-nft:

git clone https://github.com/rounakbanik/generative-art-nft.git

5. Then, install the required dependencies:

pip3 install Pillow pandas progressbar2

6. Navigate into the generative-art-nft directory. Run the following command to generate your NFT collection:

python3 nft.py

When prompted provide the number of NFTs to generate and give your collection a version name.

Your generated NFTs will be in the output folder. By default, this example git repo uses 8 different attributes to generate Scrappy Squirrel NFTs.

7. Now, upload your NFTs to Filebase using the web console and selecting ‘Folder’, then selecting ‘images’ folder to be uploaded:

8. You will see your folder uploaded as a single object:

9. Copy the CID of your folder:

10. Open the file metadata.py in your generative-nft-collection directory. Edit the following values:

  • BASE_IMAGE_URL: ipfs://IPFS-CID - Replace IPFS-CID with the IPFS CID of your folder you took note of.

  • BASE_NAME: A name for each of your NFTs.

  • Description: A description of your NFT collection.

11. Next, let’s generate the metadata for these NFTs. Run the following command:

python3 metadata.py

Your metadata files will be found in the json folder.

12. Then, use the web console and select ‘Folder’, then select the ‘json’ folder to be uploaded.

13. Navigate to your IPFS Folder to see your files:

https://ipfs.filebase.io/ipfs/IPFS_CID

Replace IPFS_CID with your folder’s IPFS CID.

If you have any questions, please join our Discord server, or send us an email at hello@filebase.com

Last updated