Open Anas-debug opened 5 months ago
const { ethers } = require("hardhat");
async function deploy() { const [deployer] = await ethers.getSigners(); const MaliciousContract = await ethers.getContractFactory("contracts/malicious_contracts/MaliciousContract"); const maliciousContract = await MaliciousContract.deploy(); await maliciousContract.deployed(); console.log("MaliciousContract deployed to:", maliciousContract.address); }
module.exports = deploy;
I am trying to deploy a contract using Hardhat, but I am encountering an "Error HH303: Unrecognized task 'deploy'" issue. Here are the steps I have taken:
npx hardhat
.deploy.js
file in thetasks
directory with the following code:async function deploy() { const [deployer] = await ethers.getSigners(); const MaliciousContract = await ethers.getContractFactory("contracts/malicious_contracts/MaliciousContract"); const maliciousContract = await MaliciousContract.deploy(); await maliciousContract.deployed(); console.log("MaliciousContract deployed to:", maliciousContract.address); }
module.exports = deploy;
npx hardhat --network localhost deploy
to deploy the contract.Expected Result: The
MaliciousContract
contract should be deployed to the local blockchain network and its address should be logged to the console.Actual Result: I received the following error message:
I have tried specifying the full path to the
deploy.js
file in my command (npx hardhat --network localhost tasks/deploy.js
), but I received the same error message. I have also tried running Hardhat with the--debug
flag, but I did not see any additional information that would help me identify the issue.I am using Hardhat version 2.9.3 and Node.js version 14.17.3.
Please let me know if there is any additional information I can provide to help diagnose this issue. Thank you!