This README will guide you on how to run this metadata deployment code. This code provides two features: one for uploading images to IPFS using Pinata, processing them, and then uploading the associated metadata, and the second for fetching and converting metadata from a provided base URI.
Before you start, make sure Node.js and NPM are installed on your system.
This README will guide you on how to run this metadata deployment code. This code uploads images to IPFS using Pinata, processes them, and then uploads the associated metadata.
Before you start, make sure Node.js and NPM are installed on your system.
Create an account on Pinata and create your API keys.
Create a .env
file in the root directory of your project.
Set the environment variables required for the Pinata NFT upload.
Your .env
file should include your Pinata API keys as follows:
PINATA_API_KEY=<your-pinata-api-key>
PINATA_API_KEY_SECRET=<your-pinata-secret-key>
Replace <your-pinata-api-key>
and <your-pinata-secret-key>
with your actual Pinata API key and secret key, respectively.
Replace the existing images located in the ./assets/img/ directory with the ones you want to use. Ensure you replace both icon.png and banner.png. The image paths are defined in the code, and the current code assumes PNG format.
You will need to change the metadata to suit your needs. The LSP4DigitalAssetMetadata object in the code provides a template. Replace the description, links, and other fields as needed.
For example:
const metadata: LSP4DigitalAssetMetadata = {
description: 'Your description',
links: [{title: 'Your Title', url: 'Your URL'}],
icon: [
// your icon data will be populated automatically
],
images: [
// your images data will be populated automatically
],
assets: [] // add your assets if needed
};
Now you're ready to run the code. Use the following NPM command in your terminal:
npm run upload-metadata
This command will trigger the deployMetadata function. It will upload the images to IPFS via Pinata, gather image data, populate the metadata, and finally, upload the metadata.
If everything runs successfully, you will see a console log of the metadata's Content Identifier (CID) on IPFS.
If the metadata you're trying to fetch and convert is an IPFS URI, you'll need to add an IPFS gateway to the .env
with IPFS_GATEWAY
. Your .env
file should now look like this:
PINATA_API_KEY=<your-pinata-api-key>
PINATA_API_KEY_SECRET=<your-pinata-secret-key>
IPFS_GATEWAY=<your-ipfs-gateway>
Replace with your actual IPFS gateway.
In the last line of fetch-convert-metadata.ts,
change the baseURI
to the URI of the metadata you want to fetch and convert,
and amount of tokens to convert:
fetchConvertMetadata(<baseURI>, <tokensNumber>);
Run the fetchConvertMetadata
function by using the following NPM command in your terminal:
npm run fetch-convert-metadata
This command will trigger the fetchConvertMetadata
function. It will fetch and convert metadata from the provided base URI.
If everything runs successfully, you will see a progress log of the metadata fetching and converting process.
See the instructions in the previous sections.
Either run the previous script to generate metadata files, either add you custom files to the ./src/output/ folder.
npm run upload-output-folder
This feature is for creating a Merkle Tree from a list of Ethereum addresses, and then uploading this to IPFS using Pinata. This can be used for whitelisting addresses in a decentralized manner.
Create a text file containing all the Ethereum addresses that you want to whitelist. The addresses should be one per line and in the text file src/whitelist.txt.
Just like in previous features, make sure your .env
file is set up with your Pinata API keys.
To run the Merkle tree deployment script, use the following NPM command in your terminal:
npm run deploy-merkle
This command will trigger the deploy-merkle
function. It will read the addresses from the whitelist file, convert them into a Merkle Tree, and upload the Merkle Tree to IPFS via Pinata.
If everything runs successfully, you will see a console log of the Merkle Tree's Content Identifier (CID) on IPFS.
In case you encounter issues:
- Check your Pinata API keys in your .env file.
- Ensure your images are in the correct format (PNG) and in the correct directory ./assets/img/.
- Make sure your metadata is correctly structured.
- Ensure that your environment has the necessary dependencies installed (Node.js and NPM).
- Check your IPFS gateway in your .env file if you're using the fetching and converting metadata feature.
- Check your whitelist file if you're using the Merkle Tree deployment feature.
Happy coding!