# react-dapp **Repository Path**: yanwankun/react-dapp ## Basic Information - **Project Name**: react-dapp - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-07-07 - **Last Updated**: 2021-07-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # eth 合约开发测试 * [参考文档](https://learnblockchain.cn/article/2383) ## 步骤 * 安装nodejs ```shell script brew install node node -V ``` * 创建一个react应用 ```shell script npx create-react-app react-dapp ``` * 安装依赖 ```shell script npm install ethers hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ``` * 初始化eth环境 ```shell script npx hardhat ``` * 更改配置 hardhat.config.js ``` text module.exports = { solidity: "0.8.4", paths: { artifacts: './src/artifacts', }, networks: { hardhat: { chainId: 1337 } // , // ropsten: { // url: "https://ropsten.infura.io/v3/your-project-id", // accounts: [`0x`] // } } }; ``` * 查看合约并编译 ```shell script npx hardhat compile ``` * 部署一个本地eth节点 ```shell script npx hardhat node ``` * 部署自己编译的合约 ```shell script npx hardhat run scripts/deploy.js --network localhost ``` * 启动react项目 ```shell script npm start ```