手把手使用 Hardhat 和 Truffle 进行 React 项目设置
在开发智能合约时,使用开发环境非常重要。本文将探讨Truffle和Hardhat的命令翻译,以及如何通过在React中创建一个小项目来适应它们。
什么是Truffle和Hardhat?
Truffle和Hardhat都是在以太坊区块链上编写智能合约的开发环境。这些工具允许开发者:
- 编译合约
- 测试合约
- 部署合约
- 调试合约
项目设置
第一步是在我们开始编写智能合约之前用React建立一个项目。
- 转到项目所在的文件夹
Truffle的设置方法
npx create-react-app
输出应该是这样的:
npx create-react-app truffle-example
Creating a new React app in /Examples/truffle-example.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-templa