Skip to content

Commit ee948e7

Browse files
committed
Add study notes for 2025-08-14
1 parent f2ffedb commit ee948e7

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

snaildarter.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,42 @@ timezone: UTC+8
1515
## Notes
1616

1717
<!-- Content_START -->
18+
# 2025-08-14
19+
20+
### hardhat tasks,console
21+
22+
在 hardhat 的 config.ts 文件中增加调用 task 方法。
23+
24+
```ts
25+
import { HardhatUserConfig, task } from 'hardhat/config';
26+
import '@nomicfoundation/hardhat-toolbox';
27+
28+
const config: HardhatUserConfig = {
29+
solidity: '0.8.20',
30+
};
31+
32+
task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
33+
const accounts = await hre.ethers.getSigners();
34+
35+
for (const account of accounts) {
36+
console.log(account.address, 'i');
37+
}
38+
});
39+
40+
export default config;
41+
```
42+
43+
借此可以自己定义一些方法,解决重复的功能。
44+
45+
#### 为了更好的调试
46+
47+
```BASH
48+
npx hardhat console
49+
```
50+
51+
然后可以获取一些信息,config、ethers 和 hrt 等。
52+
根据这些信息和区块交互。
53+
1854
# 2025-08-13
1955

2056
看了 hardhat 的文档,根据文档动手操作了。为开发许愿树项目做准备。

0 commit comments

Comments
 (0)