Compare commits
3 Commits
6ac5000c86
...
90ed801658
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90ed801658 | ||
|
|
f0e768d66f | ||
|
|
6a508cc8d4 |
@@ -41,6 +41,12 @@ const solidity = defineNoteConfig({
|
||||
text: "项目实例", prefix: "/basic-syntax", items: [
|
||||
{ text: "Solidity 代码实例", link: "/programming/solidity/analysis/case-analysis/" }
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "杂项", prefix: "/other", items: [
|
||||
{ text: "Hardhat 相关知识", link: "/programming/solidity/other/hardhat/" },
|
||||
{ text: "一些没分类的小知识", link: "/programming/solidity/other/miscellaneous/" }
|
||||
],
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
56
docs/notes/programming/solidity/other/hardhat.md
Normal file
56
docs/notes/programming/solidity/other/hardhat.md
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: Hardhat 相关知识
|
||||
createTime: 2025/10/14 14:57:06
|
||||
permalink: /programming/solidity/other/hardhat/
|
||||
---
|
||||
|
||||
## HardHat2 部署
|
||||
### Node.js v16 安装
|
||||
HardHat2 需要 Node.js v16 及以上的版本
|
||||
这里给出的是通过 npm 来将旧版本升级到 Node.js v16 的,如果想要直接安装的话通过 `yum install nodejs` 或者 `apt install nodejs` 来即可。
|
||||
```bash
|
||||
npm config set registry https://registry.npmmirror.com
|
||||
sudo npm install -g n
|
||||
sudo n 16
|
||||
```
|
||||
安装完成之后可以查看版本,如果没有更新可以重新刷新一下环境(直接退出重连最简单)
|
||||
```bash
|
||||
node -v
|
||||
# v16.20.2
|
||||
npm -v
|
||||
# 6.14.15
|
||||
```
|
||||
### 安装 Hardhat2
|
||||
创建一个 hardhat2-project 目录,初始化 npm 项目,注意这里不要用 hardhat 作为项目名
|
||||
```bash
|
||||
mkdir ~/hardhat2-project
|
||||
cd ~/hardhat2-project
|
||||
npm init -y
|
||||
```
|
||||
安装 Hardhat 2
|
||||
```bash
|
||||
npm install --save-dev hardhat@^2.23.0
|
||||
```
|
||||
初始化 Hardhat2 项目
|
||||
```bash
|
||||
npx hardhat --init
|
||||
```
|
||||
选择
|
||||
```bash
|
||||
✔ What do you want to do? · Create a JavaScript project
|
||||
✔ Hardhat project root: · /root/hardhat2-project
|
||||
✔ Do you want to add a .gitignore? (Y/n) · y
|
||||
✔ Help us improve Hardhat with anonymous crash reports & basic usage data? (Y/n) · y
|
||||
✔ Do you want to install this sample project's dependencies with npm (@nomicfoundation/hardhat-toolbox)? (Y/n) · y
|
||||
```
|
||||
## 使用 Hardhat2 编译测试合约
|
||||
在 hardhat2-project 目录下,执行以下命令来编译合约
|
||||
合约都会放在 `contracts` 目录下,这里我们选择了一个默认的合约,因此可以直接编译
|
||||
```bash
|
||||
# 测试编译
|
||||
npx hardhat compile
|
||||
# 运行测试
|
||||
npx hardhat test
|
||||
# 查看可用任务
|
||||
npx hardhat help
|
||||
```
|
||||
7
docs/notes/programming/solidity/other/miscellaneous.md
Normal file
7
docs/notes/programming/solidity/other/miscellaneous.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: 一些没分类的小知识
|
||||
createTime: 2025/10/12 15:34:38
|
||||
permalink: /programming/solidity/other/miscellaneous/
|
||||
---
|
||||
|
||||
## 关于 memory 和 stoage 存储类型
|
||||
Reference in New Issue
Block a user