hardhat使用手册

hardhat

基本环境配置
Truffle:    v5.1.X
node:       v12.16.3
web3.js:    v1.2.9
hardhat:    v2.0.7
yarn:       v1.22.x
安装依赖:
在项目根目录下:
    yarn install                //安装相关的包,yarn工具会自动按照yarn.lock拉取相关的库文件和依赖包
    npm install --save-dev hardhat              //安装hardhat工具
    npx hardhat             //查看hardhat版本信息
    npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers              //安装其他组件
操作命令

通用命令是:npx hardhat + 全局选项+task +task选项

npx hardhat
Hardhat version 2.0.0

Usage: hardhat [GLOBAL OPTIONS] <TASK> [TASK OPTIONS]

GLOBAL OPTIONS:

  --config              A Hardhat config file.
  --emoji               Use emoji in messages.
  --help                Shows this message, or a task's help if its name is provided
  --max-memory          The maximum amount of memory that Hardhat can use.
  --network             The network to connect to.
  --show-stack-traces   Show stack traces.
  --tsconfig            Reserved hardhat argument -- Has no effect.
  --verbose             Enables Hardhat verbose logging
  --version             Shows hardhat's version.

AVAILABLE TASKS:

  check         Check whatever you need
  clean         Clears the cache and deletes all artifacts
  compile       Compiles the entire project, building all artifacts
  console       Opens a hardhat console
  flatten       Flattens and prints contracts and their dependencies
  help          Prints this message
  node          Starts a JSON-RPC server on top of Hardhat Network
  run           Runs a user-defined script after compiling the project
  test          Runs mocha tests

To get help for a specific task run: npx hardhat help [task]
常用操作:
npx hardhat compile                 //编译默认的hardhat.config.ts配置下的合约文档
npx hardhat --config  configFile compile                    //编译configFile配置下的合约文档
npx hardhat test test/SushiswapBank.test.ts                 //测试 test/SushiswapBank.test.ts 脚本

猜你喜欢

转载自blog.51cto.com/15112311/2634313