forked from ed-marquez/hedera-example-hts-nft-blog-p1-p2-p3
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uploadJsonToIpfs.js
47 lines (41 loc) · 1.36 KB
/
uploadJsonToIpfs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { PinataSDK } = require("pinata");
require("dotenv").config();
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT,
pinataGateway: process.env.PINATA_GATEWAY,
});
async function uploadJsonToIpfsFcn() {
console.log(`\n=======================================`);
console.log(`- Uploading JSON Metadata...`);
const names = ["LEAF1", "LEAF2", "LEAF3", "LEAF4", "LEAF5"];
const imageCIDs = [
"ipfs://Qmb3CMWJzxWZJ34TgJgjASvdTc4x6PEz6LGm2QTWPPpkw5",
"ipfs://QmXbV2QztazJjAiZn1tv4oEBrSnRSRaXyDtnLLBp13ixNj",
"ipfs://QmaRPNrGzbj7jpheFPujM72rr2upDS72Ca1gLFBmJKSPij",
"ipfs://Qmb5yU3bxWT5QFYnQY32P1KouU52rwoTqNjVhFm16uPR3i",
"ipfs://QmeZ86y884AfpswZW8J13BXt4K2N8LFPBLBBkfQnPNHBb9",
]; // CID of the images - you must have uploaded the images to IPFS to get the CIDs
for (let i = 0; i < names.length; i++) {
const metadata = {
name: names[i],
creator: "Mother Nature & Hashgraph",
description: "Autumn",
image: imageCIDs[i],
type: "image/jpg",
format: "[email protected]",
properties: {
city: "Boston",
season: "Fall",
decade: "20's",
license: "MIT-0",
collection: "Fall Collection",
website: "www.hashgraph.com",
},
};
const upload = await pinata.upload.json(metadata).addMetadata({
name: `${names[i]}.json`,
});
console.log(`Uploaded metadata for ${names[i]}:`, upload);
}
}
uploadJsonToIpfsFcn();