`

solidity工具

 
阅读更多
1.前置准备,运行一个新项目
mkdir my-project
cd my-project
npm init --yes
npm install --save-dev hardhat@2.8.2 -g
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.部署contract
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)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics