赢得文件'没有部署?(HardhatError:HH700:未找到项目)



我在这里学习本教程:https://ethereum.org/en/developers/tutorials/hello-world-smart-contract-fullstack/我被这个错误消息卡住了:HardhatError: HH700: Artifact for contract "HelloWorld" not found.

从我在论坛上发现的情况来看,这似乎是一个命名问题,但合同的名称&正在部署的是相同的:

pragma solidity >=0.7.3;

contract HelloWorld {

event UpdatedMessages(string oldStr, string newStr);
string public message;
constructor(string memory initMessage) {

message = initMessage;
}

function update(string memory newMessage) public {
string memory oldMsg = message;
message = newMessage;
emit UpdatedMessages(oldMsg, newMessage);
}
}

这是deploy.js文件:

async function main() {
const HelloWorld = await ethers.getContractFactory("HelloWorld")
// Start deployment, returning a promise that resolves to a contract object
const hello_world = await HelloWorld.deploy("Hello World!")
console.log("Contract deployed to address:", hello_world.address)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

当我编译它时,它只是说";无需编译";并运行此命令:CCD_ 2给定提到的HH700错误。有人能帮忙吗?

可能是您在测试前缺少了"npx hardhat compile"。工件是在编译时创建的。

const hello_world=wait HelloWorld.deploy("hello world!"(应该是const hello_world=等待部署("HelloWorld!"(

最新更新