荒唐的NFT(一) - 上传IPFS图片

准备工作

  1. 一个装着 图片的文件夹,里面最好是这种结构
1
2
3
4
├── 1.png
├── 2.png
├── 3.png
#...
  1. 写一个 js 文件,生成这种 metadata json
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
{
"name": "Rabbit #1",
"image": "ipfs://bafybeibcjaperxogvs4jhi7huxjdkwtjw4hmq7uc5mhk75kokrhbtk3shy/1.png",
"attributes": [
{
"trait_type": "Background",
"value": "Orange"
},
{
"trait_type": "Scarf",
"value": "Red"
},
{
"trait_type": "Jersey",
"value": "Argentina"
},
{
"trait_type": "Face",
"value": "White and little pink"
},
{
"trait_type": "Eyes",
"value": "Brown eyes"
},
{
"trait_type": "Mouth",
"value": "Crevice"
}
]
}

看看分别对应的什么意思,但凡不瞎都应该能看出来…

上传你的答辩图片

方式一:
下载 ipfs 传输软件 NFT.storage 前提是你的终端可以爬梯子 🪜

方式二:

浏览器必须有梯子

1
2
git clone https://github.com/huasun47/nft.storage-browser-uploader.git
npm i

上传后的图片地址看起来是这样: ipfs://bafybeibcjaperxogvs4jhi7huxjdkwtjw4hmq7uc5mhk75kokrhbtk3shy/1.png

写入 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
48
49
50
51
52
53
54
55
56
const { join } = require("path");
const { writeFile } = require("fs");

const dir = "./放json的文件夹";

const folder = join(__dirname, dir);

let count = 400;

const baseURI = "ipfs://地址";

const wirte = () => {
const jsonTxt = `
{
"name": "Rabbit #${count}",
"image": "${baseURI}${count}.png",
"attributes": [
{
"trait_type": "Background",
"value": "Orange"
},
{
"trait_type": "Scarf",
"value": "Red"
},
{
"trait_type": "Jersey",
"value": "Argentina"
},
{
"trait_type": "Face",
"value": "White and little pink"
},
{
"trait_type": "Eyes",
"value": "Brown eyes"
},
{
"trait_type": "Mouth",
"value": "Crevice"
}
]
}
`;
const fileName = join(folder, `${count}.json`);

writeFile(fileName, jsonTxt, (err) => {
if (err) throw err;
count--;
if (count > 0) {
wirte();
}
});
};

wirte();

再上传 js 输出的 json 文件

是的,你的 NFT,就是串傻逼 JSON 文件

得到 ipfs://bafybeibcjaperxogvs4jhi7huxjdkwtjw4hmq7uc5mhk75kokrhbtk3shy/1.json 类似这种地址

作者

Huasun47

发布于

2023-03-02

更新于

2023-03-02

许可协议