# hardhat_demo **Repository Path**: cekongsb/hardhat_demo ## Basic Information - **Project Name**: hardhat_demo - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-12 - **Last Updated**: 2026-02-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Sample Hardhat Project This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract. Try running some of the following tasks: ```shell # 参考官方文档:https://hardhat.org/tutorial/creating-a-new-hardhat-project npx hardhat help npx hardhat test REPORT_GAS=true npx hardhat test # 启动本地Hardhat网络 npx hardhat node npx hardhat ignition deploy ./ignition/modules/Lock.js # # 创建项目目录 mkdir hardhat-demo cd hardhat-demo # 初始化npm项目 npm init -y # 安装Hardhat npm install --save-dev hardhat # 安装指定版本 npm install --save-dev hardhat@2.24.0 # 验证hardhat版本号 npx hardhat --version # 初始化Hardhat项目 npx hardhat # 新版本可能需要使用 --init 命令初始化项目 npx hardhat --init # 选择 "Create a JavaScript project" # 编译合约 npx hardhat compile # 运行测试 # 通过使用fixture,可以避免代码重复,并提高测试套件的性能。fixture是一个设置函数,只在第一次调用时运行。 # 在随后的调用中,Hardhat不会重新运行它,而是会将网络状态重置为最初执行fixture时的状态。 npx hardhat test # 指定测试文件 npx hardhat test test/greeter-test.js npx hardhat test test/token-test.js # 启动本地Hardhat网络 npx hardhat node # 第一种合约部署方式 # 部署到本地网络 npx hardhat run scripts/deployToken.js --network localhost # 部署到imcnet网络 npx hardhat run scripts/deployToken.js --network imcnet # 部署到imcnet网络 npx hardhat run scripts/deployToken.js --network tok_testnet # 第二种合约部署方式 # 部署到本地网络 npx hardhat ignition deploy ./ignition/modules/Token.js --network localhost # 部署到imcnet网络 npx hardhat ignition deploy ./ignition/modules/Token.js --network imcnet # 与合约交互 npx hardhat run scripts/interact.js --network imcnet # 转账操作 npx hardhat run scripts/transfer.js --network imcnet # erc20转账操作 npx hardhat run scripts/transferErc20.js --network imcnet ```