{"id":25898157,"url":"https://github.com/coderrob/pinata-ipfs-scripts-for-nft-projects","last_synced_at":"2025-03-03T00:17:16.906Z","repository":{"id":37298925,"uuid":"424069089","full_name":"Coderrob/pinata-ipfs-scripts-for-nft-projects","owner":"Coderrob","description":"Node scripts using the Pinata SDK to upload files and download the CIDs of already uploaded files.","archived":false,"fork":false,"pushed_at":"2024-05-05T03:47:21.000Z","size":528,"stargazers_count":48,"open_issues_count":0,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-06T04:27:36.805Z","etag":null,"topics":["ipfs","nft","pfp","pinata"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Coderrob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-03T02:40:54.000Z","updated_at":"2024-05-05T03:47:18.000Z","dependencies_parsed_at":"2024-05-05T04:37:23.284Z","dependency_job_id":null,"html_url":"https://github.com/Coderrob/pinata-ipfs-scripts-for-nft-projects","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coderrob%2Fpinata-ipfs-scripts-for-nft-projects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coderrob%2Fpinata-ipfs-scripts-for-nft-projects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coderrob%2Fpinata-ipfs-scripts-for-nft-projects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coderrob%2Fpinata-ipfs-scripts-for-nft-projects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Coderrob","download_url":"https://codeload.github.com/Coderrob/pinata-ipfs-scripts-for-nft-projects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587837,"owners_count":19986628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ipfs","nft","pfp","pinata"],"created_at":"2025-03-03T00:17:16.428Z","updated_at":"2025-03-03T00:17:16.895Z","avatar_url":"https://github.com/Coderrob.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/coderrob"],"categories":[],"sub_categories":[],"readme":"# Pinata IPFS scripts for NFT projects\n\n\u003ca href=\"https://www.buymeacoffee.com/coderrob\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-white.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\n## Scripts\n\nThe scripts contained in this repository were created to help automate the import and processing of NFT profile pic projects. Each script serves a unique purpose and when combined will help import both NFT images and the associated image metadata. A brief description of the scripts is below:\n\n- `calculate-cids.js` - calculate the IPFS hash CID for every file in a specified folder\n- `calculate-hashes.js` - calculate the sha256 hash for every file in a specified folder\n- `download-cids.js` - downloads every pinned file from Pinata for an API account\n- `upload-files.js` - uploads the contents of a specified folder and pins each individual file in Pinata\n- `upload-folder.js` - uploads the contents of a specified folder and pins the folder container and its contents\n\n### Getting Started\n\nClone the repository.\n\n```bash\ngit clone https://github.com/Coderrob/pinata-ipfs-scripts-for-nft-projects.git\n```\n\nChange directory to the `pinata-ipfs-scripts-for-nft-projects` folder.\n\n```bash\ncd pinata-ipfs-scripts-for-nft-projects\n```\n\nInstall dependencies.\n\n```bash\nnpm install\n```\n\nSome scripts require environment variables to connect with the [Pinata API](https://docs.pinata.cloud/). These environment variables are needed to download pinned files, or to upload files and folders.\n\n#### Environment Variables\n\n`PINATA_API_KEY` - The Pinata API Key environment variable\n\n`PINATA_API_SECRET` - The Pinata API Secret environment variable\n\nThe repo is setup with [dotenv](https://github.com/motdotla/dotenv) and configured to allow using an `.env` file to run the scripts.\n\nIf the env file does not already exist simply create a new `.env` file at the root of the repository.\n\nThe contents of the `.env` file should look similar to this:\n\n```ini\nPINATA_API_KEY=\"a1237a8dcd87766ff4\"\nPINATA_API_SECRET=\"fb8654309ca8777asdf7558758123456asdf817166927aknnk888877\"\n```\n\nTo generate these Pinata API keys you'll need to follow the [Getting Started](https://docs.pinata.cloud/#your-api-keys) Pinata documentation\n\n### Calculate File IPFS CIDs\n\n`/src/calculate-cids.js`\n\nThe calculate file CIDs script will iterate the contents of a specified folder, and for each file will compute the IPFS hash CID mapped to the file name.\n\nOnce complete the script will output the file name and CID mappings to a file.\n\n#### Settings\n\n`var: OUTPUT_PATH` - The relative output file path. Defaulted to `./output/file-cids.json`.\n\n`var: FOLDER_PATH` - The relative folder path containing the files to be processed. Each file will have its name and CID mapped. Defaulted to the `files` folder.\n\n#### Command\n\n```bash\nnode ./src/calculate-cids.js\n```\n\n#### Output\n\n`./output/file-cids.json`\n\n#### Contents\n\n```json\n{\n  \"one.png\": \"QmZPnX4481toHABEtvKFoCWoVuzFFQRBiA5QR2Cij9pjon\",\n  \"two.png\": \"QmazpAaWf3Bb4qhSW9PnQXfj2URbQwdNbZvDr77RbwH7xb\"\n}\n```\n\n### Calculate File sha256 Hashes\n\n`/src/calculate-hashes.js`\n\nThe calculate file hashes script will iterate the contents of a specified folder, and for each file will compute the sha256 hash mapped to the file name.\n\nOnce complete the script will output the file name and sha256 hash mappings to a file.\n\n#### Settings\n\n`var: OUTPUT_PATH` - The relative output file path. Defaulted to `./output/file-hashes.json`.\n\n`var: FOLDER_PATH` - The relative folder path containing the files to be processed. Each file will have its name and CIDsha256 hash mapped. Defaulted to the `files` folder.\n\n#### Command\n\n```bash\nnode ./src/calculate-hashes.js\n```\n\n#### Output\n\n`./output/file-hashes.json`\n\n#### Contents\n\n```json\n{\n  \"one.png\": \"f8e50b5c45e6304b41f87686db539dd52138b873a3af98cc60f623d47a133df2\",\n  \"two.png\": \"76d9c6f8dc113fff71a180195077526fce3d0279034a37f23860c1f519512e94\"\n}\n```\n\n### Download Pinata Pinned CIDs\n\n`/src/download-cids.js`\n\nThe download file CIDs script will iterate all pinned files associated with the Pinata API Key. The script will map each row's file name and IPFS hash CID.\n\nOnce complete the script will output the file name and CID mappings to a file.\n\n#### Settings\n\n`var: OUTPUT_PATH` - The relative output file path. Defaulted to `./output/downloaded-cids.json`\n\n`env: PINATA_API_KEY` - The Pinata API Key environment value\n\n`evn: PINATA_API_SECRET` - The Pinata API Secret environment value\n\n#### Command\n\n```bash\nnode ./src/download-cids.js\n```\n\n#### Output\n\n`./output/downloaded-cids.json`\n\n#### Contents\n\n```json\n{\n  \"one.png\": \"QmZPnX4481toHABEtvKFoCWoVuzFFQRBiA5QR2Cij9pjon\",\n  \"two.png\": \"QmazpAaWf3Bb4qhSW9PnQXfj2URbQwdNbZvDr77RbwH7xb\"\n}\n```\n\n### Upload Files\n\n`/src/upload-files.js`\n\nThe upload files script will iterate the contents of a specified folder and will upload and pin each _individual_ file to Pinata. After a successful upload the file name will be mapped to the IPFS hash CID from the response.\n\nOnce complete the script will output the file name and CID mappings to a file.\n\n#### Settings\n\n`var: pinataCIDs` - To prevent re-uploading already pinned files in Pinata. This variable is loaded with the json contents of the `./ouput/downloaded-cids.json` file if one exists. These CID mappings will help prevent re-uploading a file that has already been pinned in Pinata.\n\n`var: OUTPUT_PATH` - The relative output file path. Defaulted to `./output/uploaded-cids.json`.\n\n`var: FOLDER_PATH` - The relative folder path to read and upload all local files to be pinned with Pinata.  Defaulted to the `files` folder.\n\n`env: PINATA_API_KEY` - The Pinata API Key environment value\n\n`env: PINATA_API_SECRET` - The Pinata API Secret environment value\n\n#### Command\n\n```bash\nnode ./src/upload-files.js\n```\n\n#### Output\n\n`./output/uploaded-cids.json`\n\n#### Contents\n\n```json\n{\n  \"one.png\": \"QmZPnX4481toHABEtvKFoCWoVuzFFQRBiA5QR2Cij9pjon\",\n  \"two.png\": \"QmazpAaWf3Bb4qhSW9PnQXfj2URbQwdNbZvDr77RbwH7xb\"\n}\n```\n\n### Upload Folder\n\n`/src/upload-folder.js`\n\nThe upload folder script will iterate the contents of a specified folder and will upload and pin each file under a folder container in Pinata. After a successful upload the folder name will be mapped to the IPFS hash CID from the response.\n\nOnce complete the script will output the folder name and CID mapping to a file.\n\n\u003e **Note** - To support `ipfs/\u003cCID\u003e/\u003cTokenId\u003e` such as `ipfs/QmR5m9zJDSmrLnYMawrySYu3wLgN5afo3yizevAaimjvmD/0` simply name the JSON files with numeric names and strip the file extensions. This will allow the files to be accessed by a numeric file name that can be easily mapped to the `TokenId`.\n\n![Pinata pinned file list](https://github.com/Coderrob/nft-pinata-bulk-upload/blob/master/img/pinned-list.PNG)\n\n![metadata folder container list](https://github.com/Coderrob/nft-pinata-bulk-upload/blob/master/img/metadata-list.PNG)\n\n![File 0 metadata json](https://github.com/Coderrob/nft-pinata-bulk-upload/blob/master/img/metadata-0.PNG)\n\n#### Settings\n\n`var: OUTPUT_PATH` - The relative output file path. Defaulted to `./output/folder-cid.json`.\n\n`var: FOLDER_NAME` - The folder name to use for the uploaded folder of json metadata. This can be changed to any name you'd like that identifies the collection of metadata files.  Defaulted to `metadata` as the folder name.\n\n`var: FOLDER_PATH` - The relative folder path to read and upload all local files to be pinned in Pinata as a folder container for the uploaded files. Defaulted to the `metadata` folder.\n\n`env: PINATA_API_KEY` - The Pinata API Key environment value\n\n`env: PINATA_API_SECRET` - The Pinata API Secret environment value\n\n#### Command\n\n```bash\nnode ./src/upload-folder.js\n```\n\n#### Output\n\n`./output/folder-cid.json`\n\n#### Contents\n\n```json\n{ \n    \"metadata\": \"QmR5m9zJDSmrLnYMawrySYu3wLgN5afo3yizevAaimjvmD\" \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderrob%2Fpinata-ipfs-scripts-for-nft-projects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderrob%2Fpinata-ipfs-scripts-for-nft-projects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderrob%2Fpinata-ipfs-scripts-for-nft-projects/lists"}