2022-10-13Web300

hardhat提供了很多我们在使用ethers.js时很难实现的工具或者快捷的方法

搭建项目

yarn hardhat

根据提示生成一个简单的框架模版 例如这样:

image.png

添加需要的依赖

{
  "name": "hardhat-simple-storage-fcc",
  "author": "maochaoying",
  "devDependencies": {
    "@nomiclabs/hardhat-ethers": "^2.0.4",
    "@nomiclabs/hardhat-etherscan": "^3.0.0",
    "@nomiclabs/hardhat-waffle": "^2.0.2",
    "chai": "^4.3.4",
    "ethereum-waffle": "^3.4.0",
    "ethers": "^5.5.3",
    "hardhat": "^2.8.3",
    "hardhat-gas-reporter": "^1.0.7",
    "solidity-coverage": "^0.7.18"
  },
  "dependencies": {
    "dotenv": "^14.2.0",
    "prettier-plugin-solidity": "^1.0.0-beta.19"
  },
  "scripts": {
    "lint": "yarn prettier --check .",
    "lint:fix": "yarn prettier --write ."
  }
}

solidity-coverage

hardhat提供了一个查看当前我们编写的测试代码的功能覆盖率的插件,叫做solidity-coverage,专门用于可靠性测试的代码覆盖率。

2022-10-11Web300

创建项目

yarn hardhat

部署

const { ethers } = require("hardhat");

async function main() {
  const contractFactory = await ethers.getContractFactory("SimpleStorage");
  const contract = await contractFactory.deploy();
  console.log(contract.address);
  await contract.deployed();
}

main()
  .then(() => {
    process.exit(0);
  })
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });
2022-10-11Web300

依赖项

package.json

{
  "dependencies": {
    "dotenv": "^16.0.3",
    "ethers": "^5.7.1",
    "fs-extra": "^10.1.0",
    "prettier": "^2.7.1",
    "prettier-plugin-solidity": "^1.0.0-beta.24",
    "solc": "0.8.7-fixed"
  },
  "scripts": {
    "compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
  }
}

搭建本地 Ethereum blockchain

官网:ganache

Quickly fire up a personal Ethereum blockchain which you can use to run tests, execute commands, and inspect state while controlling how the chain operates.

image.png

ethers.js

官网: https://learnblockchain.cn/docs/ethers.js/

ethers.js 库是为以太坊 提供的一个的小而完整的 JavaScript 库。

安装ethers

npm install --save ethers

导入ethers

const ethers = require('ethers');
2022-10-11Web300

下载vscode

官网:https://code.visualstudio.com/

安装插件

solidity + hardhat

地址:Solidity

image.png

2022-10-10大厂面经00

搜狐面经(一面二面)

地点:搜狐新媒体大厦

null和undefined的区别

js中call和apply的区别,bind的应用场景

vm.onvm.on和vm.emit

js如何判断null

css 选择器,属性和伪类和优先级

webpack中loader和plugins的区别

  • Loaders是用来告诉webpack如何转化处理某一类型的文件,并且引入到打包出的文件中
  • Plugin是用来自定义webpack打包过程的方式,一个插件是含有apply方法的一个对象,通过这个方法可以参与到整个webpack打包的各个流程(生命周期)。

路由懒加载