hardhat编写合约、编译合约:hardhat编写合约、编译合约-CSDN博客
hardhat部署合约:hardhat部署合约-CSDN博客
hardhat测试合约、编写测试脚本:hardhat测试合约、编写测试脚本-CSDN博客
1、在已安装node.js的情况下,创建hardhat项目
2、打开一个新终端并运行以下命令 创建新文件夹:
mkdir hardhat-app
cd hardhat-app
3、初始化一个 npm 项目,如下所示
npm init
4、 安装hardhat
npm install --save-dev hardhat
5、 在安装 Hardhat 的同一目录中,运行:
npx hardhat init
6、 用键盘选择并按回车键,会出现以下内容:
$ npx hardhat init
888 888 888 888 888
888 888 888 888 888
888 888 888 888 888
8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
888 888 "88b 888P" d88" 888 888 "88b "88b 888
888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888
👷 Welcome to Hardhat v2.22.5 👷
? What do you want to do? …
Create a JavaScript project
Create a TypeScript project
Create a TypeScript project (with Viem)
❯ Create an empty hardhat.config.js
Quit
选择Create an empty hardhat.config.js
7、安装插件——@nomicfoundation/hardhat-toolbox,在项目中运行以下命令:
npm install --save-dev @nomicfoundation/hardhat-toolbox
8、在hardhat.config.js 文件中添加以下代码:
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.24",
};