NFT-Mix 项目安装与使用教程
nft-mix项目地址:https://gitcode.com/gh_mirrors/nf/nft-mix
1. 项目目录结构及介绍
NFT-Mix 项目的目录结构如下:
nft-mix/
├── contracts/
│ ├── NFT.sol
│ └── ...
├── interfaces/
│ ├── INFT.sol
│ └── ...
├── scripts/
│ ├── deploy.py
│ └── ...
├── tests/
│ ├── test_nft.py
│ └── ...
├── .env
├── .gitignore
├── LICENSE
├── README.md
├── brownie-config.yaml
└── requirements.txt
目录结构介绍
- contracts/: 存放智能合约的 Solidity 文件。
- interfaces/: 存放智能合约的接口文件。
- scripts/: 存放部署和测试脚本。
- tests/: 存放测试文件。
- .env: 环境变量配置文件。
- .gitignore: Git 忽略文件配置。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文件。
- brownie-config.yaml: Brownie 配置文件。
- requirements.txt: 项目依赖文件。
2. 项目的启动文件介绍
项目的启动文件主要位于 scripts/
目录下,其中 deploy.py
是主要的启动脚本。
deploy.py
文件介绍
from brownie import NFT, accounts, config, network
def main():
account = accounts.add(config["wallets"]["from_key"])
nft = NFT.deploy({"from": account})
print(f"NFT deployed at {nft.address}")
启动步骤
-
安装 Brownie:
pip install eth-brownie
-
克隆项目:
git clone https://github.com/PatrickAlphaC/nft-mix.git cd nft-mix
-
安装依赖:
brownie compile
-
运行部署脚本:
brownie run scripts/deploy.py --network <network_name>
3. 项目的配置文件介绍
.env
文件
.env
文件用于配置环境变量,例如钱包私钥和 Infura 项目 ID。
WEB3_INFURA_PROJECT_ID=your_infura_project_id
PRIVATE_KEY=your_private_key
brownie-config.yaml
文件
brownie-config.yaml
文件用于配置 Brownie 的行为,例如网络设置和钱包配置。
wallets:
from_key: ${PRIVATE_KEY}
networks:
development:
cmd_settings:
gas_limit: 6721975
mainnet:
cmd_settings:
gas_limit: 6721975
gas_price: auto
requirements.txt
文件
requirements.txt
文件列出了项目所需的 Python 依赖包。
eth-brownie==1.17.2
web3==5.22.0
通过以上步骤,您可以成功安装并启动 NFT-Mix 项目。