Web3.0热门领域NFT项目实战-深度掌握Solidity合约开发,助力Web3.0工程师

发布时间 2023-10-22 16:18:26作者: 天使angl

Web3.0热门领域NFT项目实战-深度掌握Solidity合约开发,助力Web3.0工程师

免费自动批量生成NFT图片和批量部署NFT

一、环境准备

1.注意:需合理上网

2.准备素材:准备一套多个属性元素的不一样的图层素材,比如10张背景图、10张face图、10张眼睛图层、10张头发图层等,每张图特性不一样,像素大小一样 ,比如500*500,背景透明,这样就可以随机组合1万+张nft图片;

素材样例下载地址:https://pan.baidu.com/s/1l9hjeZbn0Lmwbzc5qUQqgw
提取码: f6ks

3.本教程提供2两种方式,一种是平台网站无代码方式,一种是开源项目代码方式

二、平台网站无代码方式

推荐使用mintables

1. mintables

地址:https://www.mintables.club/projects

特点:免费、用户体验较好、性能好

2. nft-generator.art

地址:https://nft-generator.art/
特点:专业、用户体验好、100张内免费但有水印

3. autominter

地址:https://www.autominter.com/projects

特点:免费、用户体验较差、性能较差

三、开源项目代码方式

推荐使用hashlips_art_engine

1. nft-art-generator

代码地址:https://github.com/NotLuksus/nft-art-generator

npm install -g nft-art-generator
 
  • 1

Usage nft-generate [–save-config] [–load-config filename]

Options

  • save-config: saves all entered values to a config.json file, which
    gets used in future runs
  • load-config: loads values from a specific json config file

文件结构需调整如下

YOUR_PROJECT/  
├─ images/  
│  ├─ trait1_name/  
│  │  ├─ file1.png  
│  │  ├─ file2.png  
│  │  ├─ file3.png  
│  │  ├─ ...  
│  ├─ trait2_name/  
│  │  ├─ file4.png  
│  │  ├─ file5.png  
│  │  ├─ ...  
│  ├─ trait3_name/  
│  │  ├─ file6.png  
│  │  ├─ ...  
│  ├─ ...
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

2. hashlips_art_engine

配置代码

代码地址:https://github.com/HashLips/hashlips_art_engine

git clone https://github.com/HashLips/hashlips_art_engine.git
cd hashlips_art_engine
yarn install
# 或者 
# npm install
 
  • 1
  • 2
  • 3
  • 4
  • 5

调整代码配置

const layerConfigurations = [
  {
    growEditionSizeTo: 100,
    layersOrder: [
      { name: "Head" },
      { name: "Mouth" },
      { name: "Eyes" },
      { name: "Eyeswear" },
      { name: "Headwear" },
    ],
  },
];
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
const layerConfigurations = [
  {
    // Creates up to 50 artworks
    growEditionSizeTo: 50,
    layersOrder: [
      { name: "Background" },
      { name: "Head" },
      { name: "Mouth" },
      { name: "Eyes" },
      { name: "Eyeswear" },
      { name: "Headwear" },
    ],
  },
  {
    // Creates an additional 100 artworks
    growEditionSizeTo: 150,
    layersOrder: [
      { name: "Background" },
      { name: "Head" },
      { name: "Eyes" },
      { name: "Mouth" },
      { name: "Eyeswear" },
      { name: "Headwear" },
      { name: "AlienHeadwear" },
    ],
  },
];
 
  • 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
执行命令自动生成nft图片
npm run build
 
  • 1

或者

node index.js
 
  • 1
批量上传到ipfs网络

使用ipfs官方提供的上传工具ipfs-desktop
https://github.com/ipfs/ipfs-desktop/releases

执行智能合约自动部署NFT

智能合约代码地址:
https://github.com/HashLips/solidity_smart_contracts/blob/main/contracts/NFT/NFT.sol

批量导入到OpenSea

用部署返回的智能合约地址,在OpenSea选导入功能

在OpenSea售卖NFT

先操作售卖一个 ,同时用工具录入操作脚本,然后用脚本自动执行重复的操作;
一键批量Sell NFT工具:Macro Recorder实现在Opensea自动销售NFT作品;