hardhat
程序员文章站
2022-03-24 16:49:36
...
1.前置准备,运行一个新项目
mkdir my-project
cd my-project
npm init --yes
npm install --save-dev hardhat
npm install --save-dev @nomiclabs/hardhat-truffle5 @nomiclabs/hardhat-web3 web3
2.启动本地节点
npx hardhat node
3.设置自动挖矿
await network.provider.send("evm_setAutomine", [false]);
4.启动区间挖矿
await network.provider.send("evm_setIntervalMining", [5000]);
5.console.log
适用于view,但不适用于pure,最多调用uint,string,bool,address4个参数
6.编译
npx hardhat compile
强制编译
npx hardhat compile --force
清空缓存
npx hardhat clean
7.部署合约
npx hardhat run --network localhost scripts/deploy.js
npx hardhat run --network bsc_testnet scripts/deploy.js
8.运行脚本
npx hardhat run script.js
node scripts/sample-script.js
9.运行测试用例
npx hardhat test
10.调试节点
npx hardhat test --verbose
11.当内存不足的时候
npx hardhat --max-memory 4096 compile
12.快捷键
npm i -g hardhat-shorthand
13.打印
console.logInt(int i)
console.logUint(uint i)
console.logString(string memory s)
console.logBool(bool b)
console.logAddress(address a)
console.logBytes(bytes memory b)
console.logBytes1(bytes1 b)
console.logBytes2(bytes2 b)
...
console.logBytes32(bytes32 b)
mkdir my-project
cd my-project
npm init --yes
npm install --save-dev hardhat
npm install --save-dev @nomiclabs/hardhat-truffle5 @nomiclabs/hardhat-web3 web3
2.启动本地节点
npx hardhat node
3.设置自动挖矿
await network.provider.send("evm_setAutomine", [false]);
4.启动区间挖矿
await network.provider.send("evm_setIntervalMining", [5000]);
5.console.log
适用于view,但不适用于pure,最多调用uint,string,bool,address4个参数
6.编译
npx hardhat compile
强制编译
npx hardhat compile --force
清空缓存
npx hardhat clean
7.部署合约
npx hardhat run --network localhost scripts/deploy.js
npx hardhat run --network bsc_testnet scripts/deploy.js
8.运行脚本
npx hardhat run script.js
node scripts/sample-script.js
9.运行测试用例
npx hardhat test
10.调试节点
npx hardhat test --verbose
11.当内存不足的时候
npx hardhat --max-memory 4096 compile
12.快捷键
npm i -g hardhat-shorthand
13.打印
console.logInt(int i)
console.logUint(uint i)
console.logString(string memory s)
console.logBool(bool b)
console.logAddress(address a)
console.logBytes(bytes memory b)
console.logBytes1(bytes1 b)
console.logBytes2(bytes2 b)
...
console.logBytes32(bytes32 b)
上一篇: JFreeChart 1.0.9发布
下一篇: vi编辑器中文乱码
推荐阅读