Creating NFT Metadata and Uploading to IPFS (Web3.Storage)
Date: 250321
Project: NFT Collection #1 (“Aurora’s Echo” and 9 others)
painting_01.png,
painting_02.png, etc.https://ipfs.io/ipfs/<CID>/<filename>.pngCreated names and descriptions for each painting.
Format:
{
"name": "Aurora's Echo",
"description": "A feathered traveler bathed in the hues of dawn...",
"image": "ipfs://<CID>/painting_01.png"
}Wrote a Python script (generate_metadata.py) to
generate all 10 metadata JSON files. this fiile can be found in
blockchain/scripts folder.
Important correction: Replaced incorrect links like
ipfs://...ipfs.w3s.link with proper IPFS paths.
metadata/ folder to Web3.Storage.https://ipfs.io/ipfs/<metadata_CID>/metadata1.jsonimage field correctly pointed to painting
PNG.ipfs:// with
https://ipfs.io/ipfs/Write smart contract (TopSecurityNFT.sol) using
tokenURI() pattern:
function tokenURI(uint256 tokenId) public view override returns (string memory) {
return string(abi.encodePacked("ipfs://<metadata_CID>/metadata", Strings.toString(tokenId), ".json"));
}Deploy to Polygon Mumbai and test first mint!
Notes: - This process was stressful at times,
especially verifying IPFS links and getting the image references right.
- Learned that ipfs:// is preferred in metadata, and
platforms like OpenSea will resolve it via gateway.
Status: Metadata is complete and verified. Smart contract phase begins next.
Project: CLI Setup
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashAdded to .zshrc:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"Then installed and used Node:
nvm install 18
nvm use 18npm install -g web3.storageTry the following: - https://web3.storage/account
Set it in terminal:
export WEB3_STORAGE_TOKEN="your-api-key-here"Optional: add it to .zshrc:
echo 'export WEB3_STORAGE_TOKEN="your-api-key-here"' >> ~/.zshrc
source ~/.zshrccd ~/2025NFT
web3.storage upload --name "My NFT Metadata" --directory metadataCopy the returned CID and verify:
https://ipfs.io/ipfs/<your_cid_here>/metadata1.json
Update contract to use:
baseURI = "ipfs://<your_cid_here>/";