Step 2: Generate blog metadata
Now we can generate the blog NFT.
First you need to get the NFT.Storage NFT_STORAGE_TOKEN from NFT.Storage and your PRIVATE_KEY from your metamask, and store in the.env file.
You can simple copy the .env-example and rename it into .env, then update your NFT_STORAGE_TOKEN and PRIVATE_KEY.
NFT_STORAGE_TOKEN=your-nft-storage-token
PRIVATE_KEY=your-private-key
chainKey=hyperspace
Then, run the cmd in your terminal. The demo-blog is the folder you want to generate NFT, feel free to replace to your own new created folder.
folder=demo-blog node generateNFT.js
This command will publish your blog article on to IPFS and auto generate new blog article's NFT metadataCID, then use your PRIVATE_KEY to call the createToken method in our Web3VitePress contract to create a new token for you. After done all of these will automaticly store the metadataCID and tokenId into the article's content metadata field.
---
basicPrice: 0.001
name: A clonex
description: This is the clonex NFT
image: ./assets/clonex.png
metadataCID: bafkreicde7hco6ga64o4jnqhthclk2eb4ytny7sgvmrnznb2hhhpszgn24
tokenId: '0'
---